8

I have a string stored in a variable \word, and I want to store its upper case counterpart in another variable \WORD. If I try

 \def\WORD{\MakeUppercase{\word}}
 \show\WORD

then the message generated by \show is \MakeUppercase {abc}. Presumably I need to adjust the order of expansion in the first line. How do I do this?

Ian Thompson
  • 43,767

1 Answers1

7

In fact, \MakeUppercase expands its argument before uppercasing it, so we can do the following.

\def\word{abcd}
\MakeUppercase{\gdef\noexpand\WORD{\word}}

\noexpand prevents the expansion of \WORD, but \word is expanded. Then \MakeUppercase uppercases the whole definition. The definition must be made global because \MakeUppercase works inside a group.