[Tex/LaTex] How to avoid page break after \part entry in ToC with memoir

memoirpage-breakingtable of contents

I am using the memoir class for a document with many chapters and parts.
In the ToC sometimes there is a page break between the name of \part and the name of the next chapter.

Table of Contents

Part I
1. Chapter ........... 5
2. Chapter ........... 10
3. Chapter ........... 15

Part II 
1. Chapter ........... 20
2. Chapter ........... 25
3. Chapter ........... 30

Part III
‹page breaks here›

I tried to find out in the memoir documentation, but as a beginner I did not understand how to avoid the page breaking after a new part.

As Steven explained to me here (look there for an example), I certainly have to use needspace, but I don't now how.

Best Answer

One of the (IMO) best ways to fix something like this is to make the space above \part and \chapter entries flexible, that usually solves the problem. Otherwise use the

\addtocontents{toc}{\protect\newpage}
\part{title}

Not sure what you mean by "but I would prefer a solution, that avoid such a page break in the header"

\setlength{\cftbeforepartskip}{2.25em plus 0.5em minus 0.5em}
% default is 1em plus 0pt
\setlength{\cftbeforechapterskip}{1.0em plus 0.5em minus 0.25em}
% default is 1em plus 0pt
Related Question