# Getting error using \MakeUppercase with tocloft

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?

• Welcome to TeX.SX! \MakeUppercase is a command with an argument, not a font changing command. Oct 23, 2013 at 23:41

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

\documentclass{article}
\usepackage{tocloft,etoolbox}% http://ctan.org/pkg/{tocloft,etoolbox}
\makeatletter
% \patchcmd{<cmd>}{<search>}{<replace>}{<success>}{<failure>}
\patchcmd{\l@section}{#1}{\MakeUppercase{#1}}{}{}% Sections use UPPERCASE in ToC
\patchcmd{\l@subsection}{#1}{\MakeUppercase{#1}}{}{}% Subsections use UPPERCASE in ToC
\makeatother
\begin{document}
\tableofcontents
\section{Section One}
\subsection{Subsection}
\section{Section Two}
\end{document}


The above patch is suggested based on the construction of \l@section (and friends) (from tocloft.dtx):

\renewcommand*{\l@section}[2]{%
\ifnum \c@tocdepth >\z@
% <snip>
{\cftsecfont #1}\nobreak
\cftsecfillnum{#2}}%
\fi}


After the patch, \l@section resembles

\renewcommand*{\l@section}[2]{%
\ifnum \c@tocdepth >\z@
% <snip>
{\cftsecfont \MakeUppercase{#1}}\nobreak
\cftsecfillnum{#2}}%
\fi}


which forces an UPPERCASE title to be set.

• Thank you very much for your response. That fixed my uppercase issue, but apparently broke my bibliography. Probably easier for me to just type my section titles in all caps. Oct 28, 2013 at 15:33