Styling the table of contents isn't quite as trivial as the chapter page, as there are several more things to consider. Before we embark on this, however, let us take a look at how the table of contents are usually set up in a typical LaTeX book.

Standard table of contents style

While this seems to be a fairly tradition-bound way to set up the table of contents, it may feel rather out of pace with the rest of the styling of the document. Or it may just be that you feel more avant-garde than the default LaTeX styles lead people to believe. Either way, restyling the table of contents is just as fascinating as the chapter page!

Something that's important to keep in mind is that the table of contents, list of figures and other front matter lists are not typeset using the chapter styles we saw in the last post, but using their own setup. The TOC (for instance) is set up as follows in memoir:

\tocheadstart \printtoctitle{\contentsname} \tocmark \thispagestyle{chapter} \aftertoctitle

And thus, to restyle these front matter lists, you have to also override these commands. For the other lists, replace toc with the appropriate list.

This is, however, not the primary focus of this post, so let's get on with the show. If we look above at the standard layout of the table of contents we see a couple of recurring items: a page number, a chapter/part/section number, a chapter/part/section title, and a separation between each of these items, which may or may not contain a series of dots. Now, in my personal opinion, the dots are absolutely terrible and ruin the overall aesthetic flow of the page, but that might just be me.

The control over the entries is extremely fine-grained and you can thus define stylings for the following things: part, chapter, section, subsection, subsubsection, paragraph, subparagraph, figure, subfigure, table, and subtable.

To start out we will try something fairly straightforward. We will remove page numbers from the \part entries and typeset them in colour, and we will also move the page numbers for the remaining entries closer to the actual text. This is a bit more involved than just changing the chapter style:

\usepackage{xcolor} \renewcommand{\cftdotsep}{\cftnodots} \cftpagenumbersoff{part} \renewcommand{\cftpartpresnum}{\sffamily\large\bfseries\color{blue}\partname\ } \renewcommand{\cftpartaftersnumb}{\\} \cftsetindents{part}{0em}{0em} \renewcommand{\cftchapterleader}{\hskip1cm} \renewcommand{\cftchapterafterpnum}{\cftparfillskip} \renewcommand{\cftsectionleader}{\hskip1cm} \renewcommand{\cftsectionafterpnum}{\cftparfillskip}

This requires a bit of explanation. The \cftdotsep sets the separator spacing, and \cftnodots is a ‘big enough’ value that we will never see any dots. \cftpartpresnum specifies what goes before the part section number (I, II, etc.). Here we make the font sans-serif, blue and we print \partname (which in English amounts to ‘Part’) and a space after it. \cftpartaftersnumb specifies what happens after the section number block (that's what the last b is for), and here we print a newline so the part title is displayed below the part name and number. There is also a \cftpartaftersnum where you can, for instance, place a colon so you'll get something like ‘Part I:’. Lastly we set the indentation for the part lines to 0em leading space to the section number, and 0em subsequential space to the beginning of the title (since we're printing the title on the following line). The \cftchapterleader contains the code for what happens after the section title and the page number (the default is for it to print the dots or blank space to right-align the page number). We make this empty. If this is all we do we'll get the title spaced out over the line (like in a bad case of justified paragraphs in Microsoft Word), so we will have to specify that after the page number is printed we want to fill the rest of the line with blank space, we do this using \cftchapterafterpnum and the \cftparfillskip command.

Whew, that was a lot of text. What all this gives us is a table of contents page that looks like this:

Custom table of contents style

While the balance of the page seems a bit more skewed, I actually find this kind of table of contents easier to use as you don't have to trace across the page to find the right page number, and the dots across the page look even more ugly than this.

As a last practice, let us try another way to setup tables of contents, namely without part, chapter and section numbers. The section number is printed inside a \numberline command for all list types, except for part and chapter, which have their own \partnumberline and \chapternumberline. Thus to create a table of contents that doesn't contain any of these numbers, we need to override all these commands. Furthermore we'll keep the page numbers close to the titles like in the previous example, and no page number for the part. This amounts to the following:

\renewcommand{\cftdotsep}{\cftnodots} \cftpagenumbersoff{part} \renewcommand{\partnumberline}[1]{} \renewcommand{\chapternumberline}[1]{} \renewcommand{\cftchapterleader}{\hskip1cm} \renewcommand{\cftchapterafterpnum}{\cftparfillskip} \renewcommand{\numberline}[1]{} \renewcommand{\cftsectionleader}{\hskip1cm} \renewcommand{\cftsectionafterpnum}{\cftparfillskip}

This gives us the following output:

Section number-less list style

Depending on your need the section number-less style can be preferable while retaining part, chapter and section numbers inside the actual document. If none of these are needed you can use the \setsecnumdepth macro instead and just turn off the numbers everywhere. That's a lot more easy.

As a rule of thumb, it is important to remember to keep fonts consistent between section numbers, section titles and page numbers. Mixing and matching makes for a very jumbled expression and is (for the most part) not what you're interested in.

Again, for more technical details, consult the memoir manual or class file.