# [texhax] Contents line reformatting

Philip G. Ratcliffe philipratcliffe at tiscali.it
Wed Mar 15 18:04:45 CET 2006

> > Did you try this?  (I don't actually know if it works here.)
> > \renewcommand{\cftsecfont}{\uppercase}
> > Cheers,  Phil Ratcliffe
>
> Yes, I had tried this. It results in numerous errors like this:
>
> ! Missing { inserted.
>                    \hbox
> l.3 ...e {section}{\numberline {1}Introduction}{4}
>
> A left brace was mandatory here, so I've put one in.
> [snip]

Yes, this would appear to be a shortcoming of the 'tocloft' package - I sort of guessed this might happen.  The way the font changing is implemented only allows for commands such as \bf, \sc, em etc. and not \emph, \uppercase etc.  The quickest work around is to put the following in your preamble:

\makeatletter
\renewcommand*{\l at section}[2]{%
\ifnum \c at tocdepth >\z@
\if at cfthaschapter
\vskip \cftbeforesecskip
\else
\fi
{\leftskip \cftsecindent\relax
\rightskip \@tocrmarg
\parfillskip -\rightskip
\parindent \cftsecindent\relax\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima \cftsecnumwidth\relax
\let\@cftbsnum \cftsecpresnum
\let\@cftasnum \cftsecaftersnum
\let\@cftasnumb \cftsecaftersnumb
{\cftsecfont{#1}}\nobreak
\cftsecfillnum{#2}}
\fi}
\makeatother

Or do as I do in such cases: put this in say toclofthack.sty (the \makeat... pair are then not needed), which can then be put in your localtexmf tree, and load it immediately after tocloft itself:

\usepackage{tocloft,toclofthack}

The only modification made is the extra brace pair around #1.  This works (I tried it).

You might want to hack the whole style file by doing a global substitution "font #1" -> "font{#1}", but you'll have to call the file something different, e.g., toclofthacked.sty and load that instead of tocloft.

More permanently and sensibly, if you have the time (I don't), you might want to make a suggestion to the package author.