Home General LaTeX tips and tricks → Customise Table of Contents [Previous Page] [Question index] [Next Page]

21. How can you change the font and formatting of the table of contents?


Answer

Use the tocloft package by Peter Wilson.


Example usage

In the preamble:


%% Control the fonts and formatting used in the table of contents.

\usepackage[titles]{tocloft}

%% Aesthetic spacing redefines that look nicer to me than the defaults.

\setlength{\cftbeforechapskip}{2ex}
\setlength{\cftbeforesecskip}{0.5ex}

%% Use Helvetica-Narrow Bold for Chapter entries

\renewcommand{\cftchapfont}{%
  \fontsize{11}{13}\usefont{OT1}{phv}{bc}{n}\selectfont
}


Result, before

'Before' screenshot

Result, after

'After' screenshot

Things to watch out for

The font change causes a very subtle formatting problem in the Table of Contents page numbers:


%% Because of the font change, the page number becomes too large for the
%% horizontal space LaTeX reserves for it by default. Without the following
%% redefines to fix it, this would cause the Chapter entry page numbers
%% to extend a few points into the right margin. The horror!

\makeatletter
\renewcommand{\@pnumwidth}{1.75em}
\renewcommand{\@tocrmarg}{2.75em}
\makeatother


Result, before

'Before' screenshot

Result, after

'After' screenshot

[Previous page] [Question index] [Next page]

Leo Breebaart (leo@lspace.org)
Last updated: 27 June 2016