[Tex/LaTex] Lower case first character

fontsmacros

How do you make a macro that takes 1 argument and forces the very first character to low?

So you could write the following:

\firstToLow{SOME TEXT INPUT OF VARIATING LENGTH}

And then get this output:

sOME TEXT INPUT OF VARIATING LENGTH

It should be supporting hyperref sou I will be able to write this:

\firstToLow{\textit{\nameref{label}}}

Best Answer

This is the reverse of \makefirstuc provided by mfirstuc, which converts the first letter to uppercase. You can adapt it to lowercase by redefining \mfirstucMakeUppercase. This behaves similarly to Bernard's comment, but can deal with any text-block font changing command applied to the text, provided the text to be changed is the first argument of the text-block command, as in the example below:

\documentclass{article}

\usepackage{mfirstuc}

\renewcommand{\mfirstucMakeUppercase}{\MakeLowercase}

\begin{document}

\makefirstuc{SOME TEXT INPUT OF VARIATING LENGTH}

\makefirstuc{\emph{SOME TEXT INPUT OF VARIATING LENGTH}}

\end{document}

Alternatively, wrapping it up in a command so that it doesn't interfere with any other use of \makefirstuc:

\documentclass{article}

\usepackage{mfirstuc}

\newcommand\firstToLow[1]{%
 {%
   \renewcommand{\mfirstucMakeUppercase}{\MakeLowercase}%
   \makefirstuc{#1}%
 }%
}

\begin{document}

\firstToLow{SOME TEXT INPUT OF VARIATING LENGTH}

\firstToLow{\emph{SOME TEXT INPUT OF VARIATING LENGTH}}

\end{document}

In both cases the result is:

First letter has been converted to lowercase

Related Question