# [texhax] Contents line reformatting

Konstantin Karapetyan kotya at photonica.ru
Mon Mar 20 13:29:36 CET 2006

> 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

Thanks very much! I've tried this, and it works all right in a
separate file. Unfortunately, it looks like tocloft conflicts with
some of other packages I use in my class. At least, after adding the
above lines and \renewcommand{\cftsecfont}{\MakeUppercase}, I get very
strange result: during the first compilation, I get numerous errors
and no output file, after the second one no errors at all, but the
contents section is empty, the third again gives errors and empty
file, and so on.

I will try to find out which part of my class conflicts with tocloft.

Thank you!

Regards,
Konstantin.