# Allow page breaks in the ToC after parts

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.

• Welcome to TeX.SX! The problem essentially disappears when you include \chapters in each \part. Is \part really the correct subdivision for your purposes? – Andrew Swann Nov 11 '14 at 13:21
• @AndrewSwann's comment gives the reason for no page break. what you can do about it is covered in How to force a Table of Contents to start new page. – barbara beeton Nov 11 '14 at 13:32
• Thanks Andrew, I do have \chapters but then I have \maxtocdepth{part} so it gets the same result. – Paul Wood Nov 12 '14 at 11:22
• As I said in the question I am trying to find an automated way of doing it, Thanks. – Paul Wood Nov 12 '14 at 11:24
• If you have only parts and not chapters, maybe you could write the ToC entries as chapter level entries. Not the most elegant solution, though. – cfr Jan 12 '17 at 2:04

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:

\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}