Some Useful LaTeX Table of Contents Hacks

LaTeX

Adding unnumbered part to the ToC

Sometimes, it is desirable to add section headings to a modular ToC. There are packages that help in customizing the ToC and even in creating multiple ToCs, but I have always found it useful to simply insert an unnumbered part into the ToC using,

\addtocontents{toc}{\protect\contentsline{part}{\protect\numberline{}Part Title}{}}

Reducing space between entries

Closing up space between entries in the table of contents when using the memoir class,

\renewcommand\cftbeforechapterskip{0pt plus 1pt}

replace chapter with section, subsection etc. as necessary.

Changing the heading font

To change the heading of the table of contents (in this example, flushright the heading),

\renewcommand\contentsname{\hfill\LARGE Contents}

Change the font of chapter entries

To change the properties of the chapter entries in the table of contents,

\renewcommand\cftchapterfont{\normalsize}

Section entries can be changed with \cftsectionfont etc.

To change the font for the page numbers, 

\renewcommand\cftchapterpagefont{\normalsize}

Remove dotted fill from ToC entries

The dotted leaders can be removed from table of contents entries with,

\renewcommand*{\cftsectiondotsep}{\cftnodots}

Prevent hyphenation for longer ToC entries

Sometimes longer entries in the table of contents are hyphenated. I don’t see this as a major issue, but some prefer to prevent it. Use the following to prevent it,

\begingroup\raggedright\pretolerance=10000
\tableofcontents*
\endgroup

Remove bold font from ToC entries using memoir class

Memoir has useful features to change the appearance of the text in the ToC:

\renewcommand*{\cftchapterfont}{\normalfont}
\renewcommand*{\cftchapterpagefont}{\normalfont}

Remove leading numbers from ToC entries using memoir class

To remove the leftmost chapter number digits from ToC entries:

\renewcommand{\chapternumberline}[1]{}

Inserting space between entries in the ToC

To insert some vertical space directly into the ToC file:

\addtocontents{toc}{\vspace{.5\baselineskip}}

Be the first to comment

Leave a Reply

Your email address will not be published.


*