# Preventing \MakeUppercase from affecting mathematics

Is there a way to prevent \MakeUppercase from affecting in-text equations? In this example, abc should change to ABC, but n should be left as it is.

\documentclass{article}
\begin{document}
\MakeUppercase{abc $n$}
\end{document}


The following works for individual characters, but I would like something more general.

\documentclass{article}
\begin{document}
\newcount\mycount
\mycount\mathcoden
\MakeUppercase{abc $\mathchar\mycount$}
\end{document}

-
try the textcase package, AFAIK it has a \MakeUppercaseText macro –  daleif Mar 2 '12 at 16:35
Unfortunately that's not an option. This problem arises from a journal document class applying \MakeUppercase to section headings. I need to prevent the existing command from affecting mathematics. –  Ian Thompson Mar 2 '12 at 16:44
So you want to modify \MakeUppercase then? –  Werner Mar 2 '12 at 16:47
@Werner --- I thought there might be some way to prevent \MakeUppercase from changing mathematics, similar to the use of braces to prevent BIBTeX from changing the case of letters. Failing that, your suggestion of \let\MakeUppercas\MakeTextUppercase looks like a good alternative. –  Ian Thompson Mar 2 '12 at 17:04

The textcase package was already mentioned. But if you are forced to stay with an unchanged \MakeUppercasefor some reason then you still have the poor man's choice of "hiding" the math:

\newcommand\hidemath{$n$}
\MakeUppercase{abc \protect\hidemath}


The \protect is needed as \MakeUppercase in LaTeX is essentially an \edef that only stops expanding at \protect.

Or the alternative with eTeX which has protection at the macro definition level:

\protected\def\hiddenmath{$n$}
\MakeUppercase{abc \hiddenmath}

-
I think the 'poor man's' choice is the best option here. I need this for a journal article, and the publishers may view redefining \MakeUppercase as hacking their class file. –  Ian Thompson Mar 3 '12 at 10:48

textcase provides \MakeTextUppercase:

\documentclass{article}
\usepackage{textcase}% http://ctan.org/pkg/textcase
\begin{document}
\MakeUppercase{abc $n$} \par
\MakeTextUppercase{abc $n$}
\end{document}


For easy modification across the entire document, I suggest issuing

\usepackage[overload]{textcase}% http://ctan.org/pkg/textcase


which "overloads" both \MakeUppercase and \MakeLowercase with \MakeTextUppercase and \MakeTextLowercase, respectively. Similar to

\let\MakeUppercase\MakeTextUppercase
\let\MakeLowercase\MakeTextLowercase


Apparently the AMS document classes also provide this functionality - a math-aware \MakeUppercase using \uppercasenonmath. See @barbarabeeton's answer to Stop memoir from making mathmode section names uppercase in header.

-
\usepackage[overload]{textcase} does the \let` for you –  Frank Mittelbach Mar 2 '12 at 16:55
@FrankMittelbach: Thanks, modified answer to reflect that. –  Werner Mar 2 '12 at 16:58