8

For a few toc-entries with long titles getting wrapped I am getting Overfull \hboxes, which are not visible, if I don't use the draft-option of memoir. I wonder where they come from, and how to turn them off, as I don't want to just ignore them:

\documentclass[draft,11pt,a4paper]{memoir}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\begin{document}
\tableofcontents*
\subsection{Places: River Banks, Charnel Grounds and Other Shared Locations}
\end{document}

producing the following output (black box for Overfull \hbox):

Sample Output

2
  • Looks like a bug to me. Commented Sep 3, 2015 at 20:43
  • 1
    You get an even worse overfull if you switch to book. The main error here might be that the items in the toc are not raggedright, try adding \setrmarg{3.55em plus 1fil}
    – daleif
    Commented Sep 4, 2015 at 8:18

3 Answers 3

6

The lines before the last line of an entry in the table of contents are indented at the right by \@tocrmarg, default in class memoir and article is 2.55em. The last line ends with a right aligned page number in a box, whose width is \pnumwidth, default in class memoir and article is 1.55em. Thus the text part of the line is 1em shorter than the text in the last line, as illustrated by the following example using rules:

\documentclass[draft,11pt,a4paper]{memoir}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\DeclareRobustCommand*{\HRuleFilll}{%
  \null
  \leaders\hrule\hskip 0pt plus 1filll\relax
  \kern0pt\relax
}

\begin{document}
\tableofcontents*
\subsection{Places: River Banks, Charnel Grounds and Other Shared Locations}
\subsection{\HRuleFilll\protect\newline\HRuleFilll\protect\newline\HRuleFilll}
\end{document}

Result

I assume the rationale behind this, is to make the line with the page number easier detectable from the right.

Thus, Fran's list can be extended by another option:

Option 7: Making \@tocrmarg a little smaller. (It could be set to \@pnumwidth, but I have some doubts, that this looks better.)

8

Option 1: Abbreviated version for the ToC:

\subsection[Short title]{Very Long Title}

Option 2: Force a linebreak in the ToC

\subsection[Very long\newline title]{Very Long Title}

Option 3: Allow hyphenation in "Shared"

\hyphenation{Sha-red} 

Option 4: As above, but using a soft hyphen

\subsection{Places: River Banks, Charnel Grounds and Other Sha\-red Locations}

Option 5: Rewrite the header

\subsection{River banks, charnel grounds and other locations} % (for example)

Option 6:

% Reminder: At the end of the day, just ignore a overfull \hbox 
% unnoticeable in the final version it is not such a bad idea.

Option 7: Settled by Heiko Oberdiek's answer

Option 8: Be tolerant (note that I'm not ;))*

\tolerance9999     % or \sloppy
\tableofcontents*
\tolerance200     % or \fuzzy

Option 9: For onepage ToC, a minipage:

\begin{document}
\noindent\begin{minipage}{\textwidth}   
\tableofcontents*
\end{minipage}

or even a \parbox:

\noindent\parbox{\textwidth}{\tableofcontents*}
1
3

Similarly to Option 8 by Fran, but possibly more "elegant", one can enclose the \tableofcontents command as such:

\begin{sloppypar}
\tableofcontents
\end{sloppypar}

This will produce a TOC possibly with more blank spaces than normal, but everything should be nicely aligned and without \hbox Overfull warnings.

The same works also for \listoffigures and \listoftables, for which it may be more difficult to manually apply most of the other options.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .