5

The page numbers in the ToC appear in different styles. For sections and subsections in normalsize and for the chapter in bold and slightly larger (I think). How can one change the fontsize/fonttype for the page number of a chapter entry in the ToC?

document style: book

live-tex LaTeX, from Ubuntu 11.4 pdfTeX 3.1415926-1.40.10-2.2 (TeX Live 2009/Debian)

11

The tocloft package offers you a series of commands to customize the ToC, LoF, and LoT. In your case, you can redefine \cftchappagefont to use \normalfont (and possibly a font size switch):

\documentclass{book}
\usepackage{tocloft}

\renewcommand\cftchappagefont{\normalfont}

\begin{document}

\tableofcontents
\chapter{Test chapter}
\section{Test section}
\subsection{Test subsection}

\end{document}

Another option would be to redefine the command \l@chapter (as implemented in book.cls) which actually typesets the chapter entries in the ToC; in this case, the redefinition would imply using \normalfont just before the page number is typeset. Here's such a redefinition:

\makeatletter
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss\normalfont #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}
\makeatother

Of course, the etoolbox package makes this a lot shorter:

\makeatletter
\patchcmd{\l@chapter}{\hss}{\hss\normalfont}{}{}
\makeatother

enter image description here

  • Is is the only answer? – Igor Kotelnikov Sep 27 '11 at 12:44
  • @Igor: no, it's not. I've added two more solutions. – Gonzalo Medina Sep 27 '11 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.