I have a section that is devoted to the proof of a theorem, and hence I used

\section{Proof of Theorem~\ref{thm}}

Of course, because of the headers that are capitalized, it asks for \ref{THM} when producing the header, and I get an obvious error. What is the proper way to handle such a case? Below is a MWE:

\chapter{First Chapter}
\section{The Theorem}
\begin{thm}[Lipsum Theorem]
\section{Proof of Theorem~\ref{thm}}

When compiling I get:

LaTeX Warning: Reference `THM' on page 3 undefined on input line 14.

(each time it produces a header), and the header shows


  • 2
    I would say, it's a bug in amsbook. Mar 19 '11 at 16:06
  • Sorry -- I was looking for a literal error message. I can see the problem now.
    – lockstep
    Mar 19 '11 at 16:08
  • if the textcase package is loaded, amsmath uses its \MakeTextUppercase. This could be used to work out a solution, since textcase respects \ref, and it further provides a \NoCaseChange macro.
    – Stefan Kottwitz
    Mar 19 '11 at 16:45

If you don't feel like hacking around and don't mind just circumventing your problem: a theorem can have multiple labels, so give it \label{THM} as well.

  • Just an idea: would it be possible to re-define \label such that it defines a label both in the given form and additionally in uppercase form? Once the bug is fixed one could get rid of this hack. Mar 19 '11 at 17:17
  • 1
    @Christian Lindig -- creating a "double label" will most likely fail in hyperref; at least, if two explicit instances of \label are attached to a single node, hyperref will report that one of them is being ignored. using an uppercase value for the label will always work. Mar 19 '11 at 20:29
  • @barbara beeton: what about having \label (and \ref) uppercase their argument before using it, going for a fully uppercase version (the user can still type in lowercase). Mar 20 '11 at 1:31

A workaround is to define a new macro that contains the expanded reference and use this macro in the section title:

\section{Proof of Theorem~\mythmref}
  • Thanks for your answer. That's what I'm actually already using as a temporary work around, but I'm not entirely satisfied to have some random \edef's in my document. So there doesn't seem to be a native amsbook way to do this? need for a patch? Mar 19 '11 at 16:16
  • @gniourf-gniourf As I said, I think it's a bug. I guess Barbara Beeton can say more on this. Mar 19 '11 at 16:18
  • 3
    @gniourf-gniourf: If this is really a bug and you don't like the \edef-ing, would using uppercase labels from the beginning be an acceptable workaround? Mar 19 '11 at 16:29
  • 3
    @gniourf-gniourf -- the uppercasing of labels in running heads in ams document classes is certainly a weakness; we are aware of it, and the workaround we suggest is indeed to use all-uppercase labels in situations when a label is in a section heading or other text that will go into a running head. so using uppercase labels from the start is acceptable. we will look into the problem during the next review and upgrade, but there are many other problems that are more important, in the sense that there is no simple workaround. Mar 19 '11 at 20:23

Since amsbook uses a macro \uppercasenonmath, which doesn't capitalize math expressions, you could use the trick to enter math mode for the reference:

\section{Proof of Theorem~$\text{\ref{thm}}$}

Works fine for me: in the body text, in the table of contents and in the page header.

  • @Stephan: Thanks for your answer. It's a cool trick, but as I also use the hyperref package, this method would force me to also wrap this with a `\texorpdfstring command... which seems a bit too clumsy! Mar 19 '11 at 16:13
  • @Stefan, sorry I mispelled your name! Mar 19 '11 at 16:20
  • @gniourf_gniourf: comments can be edited. ;-)
    – Stefan Kottwitz
    Mar 19 '11 at 16:24
  • @Stefan: But only by mods!
    – Caramdir
    Mar 19 '11 at 16:38
  • 1
    Would be it sufficient to change it to \lowercase{\ref{thm}}? However, this still doesn't allow for arbitrary reference labels.
    – Martin Scharrer
    Mar 19 '11 at 22:56

You could define \label and \ref to lowercase their argument before using it, as follows:


Then, label names become case insensitive.

  • this can work just fine for one user, but it's a non-starter for repairing the document class. too many authors use "camel case" labels with variations on the same underlying spelling. until authors learn to be more sensible, there's no hope in this direction. Sep 30 '12 at 21:15
  • @barbarabeeton You are right. One thing that could be done is to check that label names which appear in are fully uppercase when using them in headers. So \section would set \@inheadertrue while processing the text, and \ref would check that \if@inheader, its argument should be entirely uppercase, lest there be a warning explaining to the user what to do. Oct 6 '12 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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