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.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s