Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

So I am writing a programming book and I decided to include \sections in the ToC as well (see picture below). The problem I am having is that I have ugliness where \chapter is the last item on the page and only on the next page I have the \sections for that chapter (see the very end of picture).

How can I fix ToC to move this 3 Text Conversion and Substitution to a new page rather than leaving it hanging on the current page?

I am using memoir class, btw.

wrong2

share|improve this question
add comment

3 Answers

up vote 16 down vote accepted

insert before the third chapter:

\addtocontents{toc}{\protect\newpage}
share|improve this answer
    
Awesome, it worked! –  Peteris Krumins May 1 '11 at 6:55
    
Martin's answers normally do. (:-) –  Brent.Longborough May 1 '11 at 11:22
1  
@Brent Herbert's do too. :-) –  Alan Munn May 1 '11 at 11:44
1  
@Alan: Oops, Senior Moment Alert! @Herbert: Terribly sorry. –  Brent.Longborough May 1 '11 at 12:29
add comment

Another aolution is to introduce stretchability to the space above chapters in the toc, something like

\setlength{\cftbeforechapterskip}{1.0em plus 0.3em minus 0.1em}

that is what I normally do

share|improve this answer
    
Shouldn't that be \cftbeforechapskip? –  Tom Aug 27 '12 at 20:51
    
if you are using tocloft yes, I usually use memoir, where it is renamed \cftbeforechapterskip –  daleif Aug 28 '12 at 21:24
add comment

I found this question because I had the same issue. The response by @daleif didn't fix it for me, but I found this to work instead:

\renewcommand{\cftchapterbreak}{\addpenalty{-4000}}

The number you choose in place of 4000 determines how likely the new page will be before a chapter in the ToC. Out of curiosity, I set it to 10000 and all of my ToC chapters disappeared. High values (but under 10000) will prevent any chapter from crossing the page in the ToC. The might be problematic if you have numerous entries below a chapter that require a page break - I have not tested that yet.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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