6

I am currently writing a manuscript using \documentclass{book}. I would like to devote one of the chapters in the manuscript to a proof of an earlier result. I have named the Chapter:

\chapter{Proof of Theorem \ref{Theorem1}}

and the actual chapter itself (including the chapter name in the table of contents and the chapter title) looks fine. I have include an image below.

enter image description here

However, in the even numbered pages of the chapter at the top right-hand side of the page is an all-capitalized version of the chapter title, and the reference there does not seem to go through:

enter image description here

I have compiled the code multiple times, so I am sure it is not a compiling error. Is there any way I can keep the Theorem reference in the title and have it properly show up at the top of the even pages of the chapter?

  • It seems like you're using hyperref, correct? If so, is it necessary for the links to be hyperlinked? – Werner Apr 16 '14 at 16:42
  • @Werner: I am indeed using hyperref. It is not necessary to have hyperlinks, although I much prefer it. – JavaMan Apr 16 '14 at 16:48
6

i believe (but am unable to check) that when the chapter title is upper cased for the running head, the name specified with \ref is also uppercased. this will not match the original label.

make this label "THEOREM1" instead of "Theorem1" and all should be resolved.

  • That worked perfectly. Thanks for the simple fix. – JavaMan Apr 17 '14 at 1:12
3

The following option uses refcount to extract the reference number, but you lose hyperlinking:

enter image description here

\documentclass{book}
\usepackage[paper=a6paper]{geometry}% Just for this example
\usepackage{hyperref,refcount}
\newtheorem{theorem}{Theorem}
\renewcommand{\thetheorem}{\thechapter.\arabic{theorem}}
\begin{document}
\chapter{Proofs of Theorem~\getrefnumber{Theorem1}}
\begin{theorem}\label{Theorem1}
An important theorem.
\end{theorem}
\newpage
Some text.
\end{document}

So, instead of using \ref{Theorem1}, you would use \getrefnumber{Theorem1}.

2

The problem is partly caused by what I believe is a major flaw in the standard classes, that is applying \MakeUppercase to the titles as part of the definition of \chaptermark and \sectionmark, whereas it should be, if desired, applied when typesetting the headers.

However, changing this is not sufficient because \MakeUppercase would capitalize also the label before computing the reference. The package textcase could come to the rescue, but, alas, hyperref redefines \ref with \DeclareRobustCommand so what's seen by \MakeTextUppercase is not \ref (which the macro knows how to handle), but \ref• (where the bullet represents a space in the name): the first level expansion of \foo after

\DeclareRobustCommand{\foo}{...}

is indeed \protect\foo•. This first level expansion happens because the title is passed through \protected@edef.

Here's a possible solution, which

  1. modifies the headings page style definition in order to exchange the place where the uppercasing is performed;

  2. uses textcase for the uppercasing macros

  3. modifies the definition of \ref with the help of etoolbox so that it becomes a \protected macro which survives \protected@edef unchanged.

\documentclass{book}
\usepackage[paper=a6paper]{geometry}% Just for this example

\usepackage{textcase}
\usepackage{etoolbox}
\usepackage{hyperref}

\makeatletter
% modify \ps@headings so the uppercasing is done at the right place
\def\ps@headings{%
  \let\@oddfoot\@empty\let\@evenfoot\@empty
  \def\@evenhead{\thepage\hfil\slshape\MakeTextUppercase{\leftmark}}%
  \def\@oddhead{{\slshape\MakeTextUppercase{\rightmark}}\hfil\thepage}%
  \let\@mkboth\markboth
  \def\chaptermark##1{%
    \markboth{%
      \ifnum \c@secnumdepth >\m@ne
        \if@mainmatter
          \@chapapp\ \thechapter. \ %
        \fi
      \fi
      ##1}{}%
   }%
 \def\sectionmark##1{%
   \markright{%
     \ifnum \c@secnumdepth >\z@
       \thesection. \ %
     \fi
     ##1}%
  }%
}
% issue again the style declaration to renew it
\pagestyle{headings}
\makeatother
% modify \ref to become \protected; it needs to be done
% \AtBeginDocument because hyperref delays its redefinitions
\AtBeginDocument{\robustify{\ref}}

\newtheorem{theorem}{Theorem}

\begin{document}

\chapter{Proof of Theorem \ref{theorem1}}

\begin{theorem}\label{theorem1}
An important theorem.
\end{theorem}

\newpage

Some text.

\end{document}
  • can you please upgrade this to avoid uppercasing math? it's impossible to persuade authors that they shouldn't put math in titles, so that's the only possible fallback for some of us. – barbara beeton Sep 16 '15 at 13:10
  • @barbarabeeton Doesn't \MakeTextUppercase take care of it? – egreg Sep 16 '15 at 13:12
  • oh, yes it does. (i'm still not awake enough to see the difference between the text at the top and the code.) – barbara beeton Sep 16 '15 at 13:21
1

This is merely a demonstration of barbara beeton's answer. It does not break hyperlinking.

\documentclass{book}
\usepackage[paper=a6paper]{geometry}% Just for this example
\usepackage{hyperref}
\newtheorem{theorem}{Theorem}
\begin{document}
\chapter{Proof of Theorem \ref{THEOREM1}}
\begin{theorem}\label{THEOREM1}
An important theorem.
\end{theorem}
\newpage
Some text.
\end{document}

Linked header

  • thanks. (i would have been quite happy for you to edit my answer. this is a nice concise demonstration, anyhow, +1) – barbara beeton Sep 16 '15 at 13:07
  • @barbarabeeton I wouldn't like to do that ;). I wouldn't know whether to use capitals or not ;). – cfr Sep 16 '15 at 20:10

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.