I'm trying to modify the way that page breaks are handled within the Table of Contents in my class file. In particular, I'd like to make it impossible for a page break to occur between two lines when the indentation/sectioning level of the second line is greater than that on the first and for it to be far more favorable for a page break to occur when the indentation/sectioning level on the second line is less than that on the first.
I.e. If I were writing out the toc manually, I'd do something like this:
Code: Select all
Chapter 1
\nopagebreak
Section 1.1
Section 1.2
\nopagebreak
Subsection 1.2.1
Subsection 1.2.2
\pagebreak[3]
Section 1.3
Section 1.4
\pagebreak[4]
Chapter 2
Does anyone have suggestions for the most efficient way of doing this? My current thoughts are to create a counter which tracks the level of the most recent sectioning command to add to the TOC and then put some \if statements in either the various sectioning commands or the \@sect command (my class file already redefines this command for other reasons, so making further modifications isn't a huge deal) which checks to see if that counter should be incremented or decremented by the command being called and adding the appropriate page break command to the TOC when it is.