3

We use XeLaTeX to produce Large Print and have come across an issue when trying to produce a book with quite a few Parts where we only want to show the parts in the ToC. I have reduced it down to a minimal example:

\documentclass{book}

\usepackage[english]{babel}
\begin{document}
\tableofcontents
\part[{1}]{1}
\part[{2}]{2}
\part[{3}]{3}
\part[{4}]{4}
\part[{5}]{5}
\part[{6}]{6}
\part[{7}]{7}
\part[{8}]{8}
\part[{9}]{9}
\part[{10}]{10}
\part[{11}]{11}
\part[{12}]{12}
\part[{13}]{13}
\part[{14}]{14}
\part[{15}]{15}
\part[{16}]{16}
\part[{17}]{17}
\part[{18}]{18}

\end{document}

This produces a Contents page which starts on page 2 as it can't fit on page 1 and doesn't want to split. In reality I'm using memoir and 25pt with 7 parts, but this example produces the same result. I've tried it in texlive 2014. Is there a work around that doesn't involve manually inserting a ToC break where it needs to be. This is part of an automated system and the user doesn't have access to the TeX code, so I need a way to allow the page to split automatically.

Werner
  • 603,163
Paul Wood
  • 31
  • 3

1 Answers1

1

You could update \l@part - the macro responsible for setting each \part-related entry in the ToC - to insert a zero \penalty after each regular entry:

enter image description here

\documentclass{book}

\makeatletter
\let\old@l@part\l@part
\renewcommand{\l@part}[2]{%
  \old@l@part{#1}{#2}% Regular setting of \part in ToC
  \pagebreak[0]}% Add a zero penalty (for possible page break)
\makeatother

\begin{document}

\tableofcontents

\part[{1}]{1}
\part[{2}]{2}
\part[{3}]{3}
\part[{4}]{4}
\part[{5}]{5}
\part[{6}]{6}
\part[{7}]{7}
\part[{8}]{8}
\part[{9}]{9}
\part[{10}]{10}
\part[{11}]{11}
\part[{12}]{12}
\part[{13}]{13}
\part[{14}]{14}
\part[{15}]{15}
\part[{16}]{16}
\part[{17}]{17}
\part[{18}]{18}

\end{document}
Werner
  • 603,163