[texhax] Re: Read and process single characters

Martin Heller mr_heller at yahoo.dk
Fri Jun 24 18:58:49 CEST 2005


Torsten Wagner wrote:
> Hello TeX-Friends,
> 
> does somebody know how to read single characters and process them one by 
> one.
> 
> e.g. I like to make the first letter of a word capital, independent of 
> what the user typed in.
> so that
> 
> \mycommand{my text}
> \mycommand{My text}
> 
> results both in
> 
> My text
> 
> For sure, furthermore it would be nice if
> 
> \mycommand{MY TEXT}
> 
> results as shown above too.
> I found /uppercase and /lowercase to handle whole tokens. But how can I 
> split a token into single characters?

\documentclass{article}

\def\makefirstuppercase#1{\expandafter\MakeFirst#1\MakeFirst}
\def\MakeFirst#1#2\MakeFirst{\uppercase{#1}\lowercase{#2}}

\begin{document}
\makefirstuppercase{My text}\par
\makefirstuppercase{my text}\par
\makefirstuppercase{MY TEXT}
\end{document}



More information about the texhax mailing list