10

I was being lazy and had a lot of commands of the form

\def\foo{...Foo...}

So I was thinking about taking an approach like

\def\bar#1{\expandafter\gdef\expandafter\csname\lowercase{#1}\endcsname{...#1...}

or something along the lines of

\def\bar#1{\edef\tmp{\lowercase #1}\expandafter\gdef\expandafter\csname\tmp\endcsname{...#1...}}

wanting to use it like \bar{Foo}} and followed by \foo, but this obviously won't work because \lowercase can't be expanded further. How do I do this properly?

10
\def\bar#1{\lowercase{\expandafter\gdef\csname#1\endcsname}{...#1...}

does something perhaps related to what you want.

  • It works, thank you. It feels sufficiently magic enough, that I wouldn't have come up with it myself. – Max Sep 29 '13 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.