# Keep chapter headings and related subheadings in the same page in ToC

I'm trying to finish my master's thesis and all I have left are some formatting issues. I'm trying to prevent LaTeX from breaking a chapter and its subheadings in between pages in my table of contents.

My problem is the following:

Table of Contents

... some stuff here ....

CHAPTER W
...
...

CHAPTER X
----------- Latex inserts page break here -------
<end of page>

<next page>

And this is what I want to happen:

... some stuff here ....

CHAPTER W
...
...

<end of page>
<next page>

CHAPTER X


Basically, I want to make sure that the Chapter heading is not left "orphaned" in one page, while its subheadings are in another page.

What would be the simplest enforce this in LaTeX? It's only one chapter heading that's being orphaned in my ToC. I've considered using the package to adjust the title spaces, but this might be overkill. Perhaps someone may have an elegant solution. :D

• Although a minimal example might be hard to provide in this case, some general description (at least) of the documentclass and any potentially ToC-influencing packages might help someone provide a solution. – jon Apr 1 '13 at 7:26
• the simplest method of adjusting the toc, unfortunately, may be manual -- to put a line \addtocontents{toc}{\newpage} just before the \chapter command that causes the "orphaned" line. (it has to be in the same file as the \chapter line, not in a driver file that calls in the chapter.) – barbara beeton Apr 1 '13 at 13:09
• Yes, that's just what I needed. Problem solved. Thanks barbara! – user2230542 Apr 1 '13 at 18:32

barbara beeton has already hinted a manual solution, namely, "put a line \addtocontents{toc}{\newpage} just before the\chapter command that causes the "orphaned" line". I'll add that while LaTeX's "core" ToC mechanism doesn't prevent "orphaned" ToC entries, there are at least two ToC-related packages that deal with this problem in an automatic way: tocloft and tocstyle (alpha version, part of KOMA-Script). The following example includes both alternatives -- uncomment the respective code lines to see the effect.

\documentclass{book}

% Alternatve A
% \usepackage{tocloft}% Moves "gnu" ToC entry to first page

% Alternative B
% \usepackage{tocstyle}\usetocstyle{standard}% Moves "bar" ToC entry to second page

\begin{document}

\tableofcontents

\chapter{foo}