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

! Undefined control sequence.
{#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}

-
This compiles fine for me with TeXLive 2010 –  Peter Grill Aug 14 '11 at 18:48
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

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}


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


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

-
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

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

\documentclass{memoir}
\usepackage{etoolbox}
\makeatletter
\ifpatchable*{\@chapter}{\typeout{Chapter can be patched}}{\typeout{Chapter cannot be patched}}
\patchcmd{\@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}}%
{\let\f@rtocold\f@rtoc%
\def\f@rtoc{\texorpdfstring{\uppercase\expandafter{\f@rtocold}}{\f@rtocold}}%