Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I get the following error when trying to use \MakeTextUppercase to customize the table of contents:

! Undefined control sequence.
\find@pdflink ...ode \protected@edef \Hy@testname 
                                              {#2}\ifx \Hy@testname \@em... 
l.2 ...entsline {chapter}{Contents}{1}{section*.1}

Any idea of what's going on? I've included a minimum example below for testing.

\documentclass[a4paper, 10pt, english]{memoir}

\usepackage{babel}
\usepackage{csquotes}
\usepackage{textcase}
\usepackage{lipsum}
\usepackage{hyperref}

\renewcommand{\cftchapterfont}{\MakeTextUppercase}



\begin{document}

\tableofcontents

\chapter{Test}
\lipsum

\end{document}
share|improve this question
    
This compiles fine for me with TeXLive 2010 –  Peter Grill Aug 14 '11 at 18:48
1  
Try compiling it twice. –  Alan Munn Aug 14 '11 at 18:50
    
Possible duplicate: typeset cftchapfont as uppercase –  Peter Grill Aug 14 '11 at 19:01
    
Although related, this is a separate question, since the error here is generated by hyperref, and the problem is related to how memoir and hyperref interact. See this thread on comp.text.tex for related discussion. –  Alan Munn Aug 14 '11 at 19:07
add comment

2 Answers

up vote 4 down vote accepted

I remember \MakeUppercase and \MakeTextUppercase can easily break, also with hyperref.

Before you try to fix that, I suggest considering using small caps shape instead. That's much better than all caps, from a typographic view. This declaration works:

\renewcommand{\cftchapterfont}{\scshape}

table of contents with small caps

If it's really required, it can be solved by redefining memoir's \l@chapter, which is responsible for printing the chapter TOC entry, using \uppercase (\MakeTextUppercase and \Makeuppercase would break here as well):

\makeatletter
\renewcommand*{\l@chapter}[2]{%
  \l@chapapp{\uppercase{#1}}{#2}{\cftchaptername}}
\makeatother

all caps in TOC chapter entry

(This time with hyperref link border, which can be removed by options.)

share|improve this answer
    
While this is good stylistic advice, what if the formatting specifications require uppercase? –  Alan Munn Aug 14 '11 at 18:52
    
@Alan: in that case I would redefine \l@chapter I'll show it –  Stefan Kottwitz Aug 14 '11 at 19:41
    
Actually, at the moment it is formatted as small caps. And as there apparently is no elegant fix I think I'll stick to it. And as you said, it is good style to use small caps rather than upper case. Thanks. –  gablin Aug 14 '11 at 20:42
add comment

Here's what I ended up with on this question from April (might want close this as a duplicate, or not). In my particular case, I needed to only make the chapter titles uppercase, and leave the appendix titles alone. I didn't want to keep a full copy of the \@chapter or related commands around, but there's the potential for long-term breakage either way if your code lives for many years (either the patch I use will fail, or your old copy of the \@chapter or related commands won't work the same way as the newer versions expect):

enter image description here

\documentclass{memoir}
\usepackage{etoolbox}
\makeatletter
\ifpatchable*{\@chapter}{\typeout{Chapter can be patched}}{\typeout{Chapter cannot be patched}}
\patchcmd{\@chapter}%
{\addcontentsline{toc}{chapter}}%
{\let\f@rtocold\f@rtoc \def\f@rtoc{\uppercase\expandafter{\f@rtocold}} \addcontentsline{toc}{chapter}}%
{\typeout{Succeeded}}%
{\typeout{Failed}}
\makeatother
\usepackage{hyperref}

\begin{document}
\tableofcontents*
\chapter{One}
\chapter{Two}
\appendix \appendixpage
\chapter{Alpha}
\end{document}

Since I still have some number of users with PC-TeX who don't get e-TeX support by default, I also have this option using the ted package.

\documentclass{memoir}
\usepackage{ted}
\makeatletter
\Substitute*[{\gdef\@chapter[##1]##2}]{\@chapter[#1]{#2}}%
{\addcontentsline{toc}{chapter}}%
{\let\f@rtocold\f@rtoc%
 \def\f@rtoc{\texorpdfstring{\uppercase\expandafter{\f@rtocold}}{\f@rtocold}}%
 \addcontentsline{toc}{chapter}}
\makeatother
\usepackage{hyperref}

\begin{document}
\tableofcontents*
\chapter{One}
\chapter{Two}
\appendix \appendixpage
\chapter{Alpha}
\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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