To customize the appearance of our Table of contents we use the tocloft package. One point we would like to implement is to underline the chapter entries in the ToC.

However, if we use the \cftchapaftersnum command to specify a horizontal line we always get a weird overfull hbox warning. (Weird, because if I shorten the line, the overfull hbox is shown in the middle of the page.

Small example compiled with MikTeX and pdfLaTeX:

\documentclass[draft]{book} % use draft to show overfull hboxes

% underline chapter entries:



Antelope is a term referring to many even-toed ungulate 
species found all over the world.

This \verb|\rule| does not generate a warning!

An impala is a medium-sized African antelope.

\emph{fin \dots}


Note that I've placed 0.5\textwidth as ruler width in the example above. This way, my draft PDF shows the black rectangle for the overfull box in the middle of the page (just at the end of the \rule)

What's going on here?


The documentation for tocloft makes this clear.

Normally the section number is typeset within a box of width \cftXnumwidth. Within the box the macro \cftXpresnum is first called, then the number is typeset, and next the \cftXaftersnum macro is called after the number is typeset. The last command within the box is \hfil to make the box contents flushleft.

What this means is that the box is constructed like

\hbox to\cftchapnumwidth{\cftchappresnum 1\cftchapaftersnum\hfil}

Your box is wider than \cftchapnumwidth.

If you change




then the infinite shrinkability causes the warning to go away.

Edit: You should probably not be using spacing of 4mm and instead using something proportional to the size of the font. Better still would be to use \cftchapaftersnumb (note the b at the end):


Using -0.5mm is also probably a bad idea.

  • Wow. \renewcommand{\cftchapaftersnumb}{\rlap{\rule[-0.5mm]{0.5\textwidth}{.4pt}}} does the trick. (For all those as blind as me: Note the trailing "b" which makes the command only refer to the section text) – Martin Sep 8 '10 at 10:32
  • Sorry, I should have made that more explicit. I'll edit the answer. – TH. Sep 8 '10 at 10:36
  • Separate question for the 0.5mm problem: tex.stackexchange.com/q/2891/1012 – Martin Sep 8 '10 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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