Trying to use tocloft
package to customize a table of contents, but I am running into errors using \MakeUppercase
or \uppercase
with certain commands, namely \cftsecfont
.
When I run the following code I get errors suggesting there are missing or extra }
s. Similar errors when I replace \MakeUppercase
with \uppercase
. If I delete that command entirely it runs with no errors.
\documentclass{article}
\usepackage{tocloft}
\begin{document}
\renewcommand{\cftsecfont}{\bfseries\MakeUppercase}
\tableofcontents
\section{Section One}
\subsection{Subsection}
\section{Section Two}
\end{document}
Similar errors using \cftsubsecfont
, etc. What am I doing wrong?
Best Answer
You can patch the
\l@section
(and friends) macros - they are responsible for setting the section/subsection titles in the ToC - to\MakeUppercase
the first argument it receives (which includes the number and title):The above patch is suggested based on the construction of
\l@section
(and friends) (fromtocloft.dtx
):After the patch,
\l@section
resembleswhich forces an UPPERCASE title to be set.