Category Archives: LaTeX

Problem with chapter number alignment in ToC in LaTeX

This post is about a very very specific problem in LaTex. I had hard time to figure out a way to solve this issue.

This problem is for people using the Memoir class.

When generating my PDF I noticed that by default when the number of chapter has more than 3 digits then, in the table of content, the place which should contain the chapter number is too small for the three digits. And this results in an ugly intersection with the chapter name.

This is the solution I found to correct the display. Put in the preamble of the document, the following code:

\makeatletter
\let\oldchapternumberline\chapternumberline
\renewcommand\chapternumberline[1]{#1\hspace*{1em}}
\renewcommand\cftchaptername{\chaptername~}
\addtolength\cftchapternumwidth{3em}
\makeatother

This basically redefines how a line in the ToC is done. But this code has a problem: after the chapter number, it put a fixed space and then the chapter name. The chapter name will therefore not be aligned across the ToC (at least we have the problem when the chapter number increases its number of digits).

For me, this is indeed fair enough. I did not find a better solution which works so if you do find one, I would be glad to hear it: please leave a comment!