## LaTeX: more csname…endcsname

Third in our survey of Insights into TEX Macro Writing Techniques (1990), this post defines an offshoot of \uppercase that transforms, say, \foo into \Foo. The lessons learned in the previous two posts are applied here.

Input

\def\cmdUppercaseHelper#1#2#3*{
%strips backslash
\uppercase{\def\first{#2}}
\def\rest{#3}
}
\def\cmdUppercase[#1]{
\expandafter\cmdUppercaseHelper\string#1*
\csname \first\rest \endcsname
}
\def\foo{bar}
\def\Foo{Bar}
\noindent
\cmdUppercase[\foo]

Output

$\text{Bar}$

Remarks

• See Getting rid of backslashes from the reference stated in the beginning.