Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm typesetting a document with more than 100 chapters in it (don't ask, I didn't write it!). The table of contents comes out ugly, because it seems the distance between the chapter number and the chapter title is intended for two-digit chapters only. Once we hit a three digit chapter number, the last digit of the number overwrites the chapter title. How can this be modified? What variables control the width of the chapter number? Any fixes?

share|improve this question
add comment

4 Answers

up vote 6 down vote accepted

You could use the titletoc package (which is a companion for titlesec).

From the titlesec/titletoc manual page 18:

\titlecontents{<section>}[<left>]{<above>}
              {<before with label>}{<before without label>}
              {<filler and page>}[<after>]

Example:

\documentclass[a4paper]{book}
\usepackage[english]{babel}
\usepackage{titletoc}
\usepackage{blindtext}
\titlecontents{chapter}[1.5em]{\addvspace{1pc}\bfseries}{\contentslabel{5em}}{}
    {\titlerule*[0.3pc]{.}\contentspage}
\begin{document}
\tableofcontents
\blinddocument
\end{document}
share|improve this answer
add comment

The tocstyle package (included in KOMA-script) by default automatically calculates the needed indentation for chapter and other sectioning numbers in the ToC. (It needs several LaTeX runs to do so.)

\documentclass{report}

\usepackage{tocstyle}
\usetocstyle{standard}

\begin{document}

\tableofcontents

\setcounter{chapter}{5000}

\chapter{foo}

\end{document}
share|improve this answer
add comment

If you are satisfied with the normal typesetting of the book class, you can do with "minimal" effort:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\l@chapter}{1.5em}{2em}{}{}
\makeatother

You may also have a look at the memoir class, which must be considered for a 100+ chapter project; it has tools for customizing every aspect of a book, for example

\setlength{\cftchapternumwidth}{2em}

would suffice.

share|improve this answer
add comment

It depends on which class you are using and can be found in the class source file (or in LaTeX's base source files).

However, you could use the extensive tocloft package for designing the layout of the table of contents or titletoc, which is a companion to titlesec.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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