I notice my ToC is breaking in odd places. It breaks immediately after a Chapter head unless the whole chapter can fit on the current page. Also if a Chapter has too many items the list runs off the bottom on the page instead of breaking. How do I fix this?

In MWE as posted, the first page of the TOC is only part-filled and page breaks after the Chapter 2 chapter heading item, and the second page is more tightly packed. If you alter the number of sections in Chapter 2 the page split varies in position. So, some sort of 'balancing' of the amount of content is happening - though not in a good way.

This doesn't occur without the back-link code - but I want that feature!

I think the code solution here might be what I need to add, but I don't know where/how: Allow page breaks in the ToC after parts

MWE below:

bookmarksopenlevel=0,bookmarksnumbered=true,hypertexnames=true, plainpages=false,

% back-link code from https://tex.stackexchange.com/questions/251904/hyperlinks-from-chapter-and-section-headings-back-to-the-table-of-contents/

% configure chapter back-links
\newcommand{\mychapter}[2][\@empty]% #1=optional (toc and top of page), #2=title
{\ifx#1\@empty \hyperchapter[#2]{\hyperlink{toc.chapter.\thechapter}{#2}}
    \else \hyperchapter[#1]{\hyperlink{toc.chapter.\thechapter}{#2}}
% configure section back-links
\newcommand{\mysection}[2][\@empty]% #1=optional (toc), #2=title
{\ifx#1\@empty \hypersection[#2]{\hyperlink{toc.section.\thesection}{#2}}
    \else \hypersection[#1]{\hyperlink{toc.section.\thesection}{#2}}
% configure subsection back-links
\newcommand{\mysubsection}[2][\@empty]% #1=optional (toc), #2=title
{\ifx#1\@empty \hypersubsection[#2]{\hyperlink{toc.subsection.\thesubsection}{#2}}
    \else \hypersubsection[#1]{\hyperlink{toc.subsection.\thesubsection}{#2}}
% configure subsubsection back-links
\newcommand{\mysubsubsection}[2][\@empty]% #1=optional (toc), #2=title
{\ifx#1\@empty \hypersubsubsection[#2]{\hyperlink{toc.subsubsection.\thesubsubsection}{#2}}
    \else \hypersubsubsection[#1]{\hyperlink{toc.subsubsection.\thesubsubsection}{#2}}
% close out


%%%---Set up clickable section headers----------
%%%---End set up clickable section headers----------


\chapter{The First}
\chapter{The Second}
\chapter{The Third}

  • Please post a MWE of your requirement... – MadyYuvi Sep 5 '19 at 5:15

\chapter{The Second}
| improve this answer | |
  • 1
    Got it inserted but now have a different problem, CH1 items only on TOC page 1, plus it seems I have to add this manually for each chapter? In my real doc the content is split across lots of included docs so hard to know where to put code. Basically, I just want the TOC to paginate like norrmal text as it does without the back-link code. – mwra Sep 5 '19 at 7:34
  • It should be done at the very end of your document when you are finished. Then you can insert it. – user187802 Sep 5 '19 at 7:38
  • Sorry, I don't understand - end in position or when fished writing. Plus doesn't the above only affect Chapter "The Second". I think what's needed is a similar applied to all items at all 4 levels of TOC item. True? – mwra Sep 5 '19 at 7:53
  • Ah, added the extra code line to MWE just before \end{document} and now each chapter starts on a new TOC page. Then added more items to Ch2 and now Ch2 head only is back onToC page 1. Odd! – mwra Sep 5 '19 at 8:17
  • No, at "the end" means: finish your document, then look into the TOC if it needs some manual modifications. – user187802 Sep 5 '19 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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