TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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


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?

share|improve this question
up vote 7 down vote accepted

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


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

share|improve this answer
@Bruno - this doesn't seem to work. I get the error ! Undefined control sequence. <argument> \def \WORD {abc} – Ian Thompson Mar 10 '11 at 9:52
@Ian: right. I get where the problem is: \MakeUppercase tries to expand everything. Let me think a bit. A short solution is to replace \MakeUppercase by \uppercase, but it's not optimal. – Bruno Le Floch Mar 10 '11 at 10:19
@Ian: that's fixed, and we now don't need all those expandafters. – Bruno Le Floch Mar 10 '11 at 10:54
Very nice. I taught myself a lot about \expandafter trying to figure out my own solution, only to find out that \MakeUppercase expands its own argument. Putting the \gdef inside the \MakeUppercase had eluded me. – Matthew Leingang Mar 10 '11 at 13:27
@Matthew: my first (wrong) answer involved some expandafters as well. I'm still wondering why the authors of \MakeUppercase enclosed the whole definition in {...}, rather than using the standard \begingroup...\uppercase{\endgroup...}. – Bruno Le Floch Mar 10 '11 at 14:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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