[Tex/LaTex] Protecting references in section headings from capitalization

acmcapitalizationcross-referencingsectioning

I am using the ACM SIG alternate style, which automatically converts all section titles to upper case. I would like to include a reference in one of the section titles (Proof of Lemma X). The obvious way (shown in the MWE below) results in the following warning:

LaTeX Warning: Reference `SEC:INTRODUCTION' on page \thepage  undefined on input line 9.

Apparantly the argument of \ref is converted to upper case before the reference is generated. Is there a way to fix this without changing the label to upper case?

\documentclass{sig-alternate}
\begin{document}

\section{Introduction}
\label{sec:introduction}
The introduction.

\section{The section after Section~\ref{sec:introduction}}

\end{document}

Best Answer

Another option, sig-alternate.cls uses \uppercase in \@sect to format sectional unit titles; you can patch \@sect to use \MakeTextUppercase (from the textcase package) instead; in this way, the case of any math expressions in the titles won't be changed and the arguments of \cite, \label and \ref will also be prevented from being uppercased:

\documentclass{sig-alternate}
\usepackage{xpatch}
\usepackage{textcase}
\makeatletter
\xpatchcmd{\@sect}{\uppercase}{\MakeTextUppercase}{}{}
\xpatchcmd{\@sect}{\uppercase}{\MakeTextUppercase}{}{}
\makeatother
\begin{document}

\section{Introduction}
\label{sec:introduction}
The introduction.

\section{The section after Section~\ref{sec:introduction}}

\end{document}

In case xpatch is not available, one can do the patching using etoolbox, in this case, the lines

\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@sect}{\uppercase}{\MakeTextUppercase}{}{}
\xpatchcmd{\@sect}{\uppercase}{\MakeTextUppercase}{}{}
\makeatother

must be replaced with

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@sect}{\uppercase}{\MakeTextUppercase}{}{}
\patchcmd{\@sect}{\uppercase}{\MakeTextUppercase}{}{}
\makeatother

(notice that now there's no "x" in the name of the patching command).