11

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}
3

3 Answers 3

8

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

6
  • I'm having trouble with the xpatch package, so I can't verify whether this works. It looks like a better solution.
    – Mangara
    Feb 25, 2014 at 19:28
  • 1
    @Mangara I added to my answer an alternative using etoolbox instead of xpatch; if also etoolbox is not available in your system, let me know and I can give you an alternative with no packages for the patch (the code will be longer, though). Feb 25, 2014 at 20:16
  • The etoolbox version worked for me. Thanks!
    – Mangara
    Feb 25, 2014 at 20:23
  • 1
    You should do the patch twice, because \uppercase appears twice in \@sect
    – egreg
    Feb 25, 2014 at 20:24
  • @egreg Yes, you're right. I've added the missing patch. Thanks. Feb 25, 2014 at 20:39
4

If this isn't too much of a nuisance...

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

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

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

\end{document}
2
  • Thanks! That works. I only need it in a few places, so it's not too much trouble. I'll accept this if no nicer solutions show up.
    – Mangara
    Feb 25, 2014 at 18:56
  • @Mangara Gonzalo's solution is better, though it does require a package load. Feb 25, 2014 at 19:18
0

After perusing the FAQ some more, I came across this answer, which gives another solution:

  • Download and incorporate the package lcsect.sty into your source .tex file.
  • Use the \lcsection command for sections, but convert the text to upper case by hand to stay consistent with the other titles.
\documentclass{sig-alternate}
\usepackage{lcsect}
\begin{document}

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

The introduction.

\lcsection{THE SECTION AFTER SECTION~\ref{sec:introduction}}

\end{document}

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .