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:

\documentclass{book}
\usepackage[pdfpagemode={UseOutlines},bookmarks=true,bookmarksopen=true,
bookmarksopenlevel=0,bookmarksnumbered=true,hypertexnames=true, plainpages=false,

\makeatletter
\let\hyperchapter\chapter
\def\chapter{\@ifstar\starchapter\mychapter}
\def\starchapter{\hyperchapter*}
\newcommand{\mychapter}[2][\@empty]% #1=optional (toc and top of page), #2=title
\fi}
\let\hypersection\section
\def\section{\@ifstar\starsection\mysection}
\def\starsection{\hypersection*}
\newcommand{\mysection}[2][\@empty]% #1=optional (toc), #2=title
\fi}
\let\hypersubsection\subsection
\def\subsection{\@ifstar\starsubsection\mysubsection}
\def\starsubsection{\hypersubsection*}
\newcommand{\mysubsection}[2][\@empty]% #1=optional (toc), #2=title
\fi}
\let\hypersubsubsection\subsubsection
\def\subsubsection{\@ifstar\starsubsubsection\mysubsubsection}
\def\starsubsubsection{\hypersubsubsection*}
\newcommand{\mysubsubsection}[2][\@empty]% #1=optional (toc), #2=title
\fi}
% close out
\makeatother

\begin{document}

\let\hypercontentsline=\contentsline
\renewcommand{\contentsline}[4]{\hypertarget{toc.#4}{}\hypercontentsline{#1}{#2}{#3}{#4}}
%%%---End set up clickable section headers----------

\tableofcontents

\chapter{The First}
\section{ant}
\subsection{bee}
\subsubsection{cow}
\section{dog}
\subsection{eel}
\subsubsection{fly}
\chapter{The Second}
\section{ant1}
\subsection{bee1}
\subsubsection{cow1}
\section{dog1}
\subsection{eel1}
\subsubsection{fly1}
\section{ant2}
\subsection{bee2}
\subsubsection{cow2}
\section{dog2}
\subsection{eel2}
\subsubsection{fly2}
\section{ant3}
\subsection{bee3}
\subsubsection{cow3}
\section{dog3}
\subsection{eel3}
\subsubsection{fly3}
\section{ant4}
\subsection{bee4}
\subsubsection{cow4}
\section{dog4}
\subsection{eel4}
\subsubsection{fly4}
\section{ant41}
\subsection{bee41}
\subsubsection{cow41}
\section{dog41}
\subsection{eel41}
\subsubsection{fly41}
\section{ant42}
\subsection{bee42}
\subsubsection{cow42}
\section{dog42}
\subsection{eel42}
\subsubsection{fly42}
\section{ant43}
\subsection{bee43}
\subsubsection{cow43}
\section{dog43}
\subsection{eel43}
\subsubsection{fly43}
\chapter{The Third}
\section{ant5}
\subsection{bee5}
\subsubsection{cow5}
\section{dog5}
\subsection{eel5}
\subsubsection{fly5}
\section{ant6}
\subsection{bee6}
\subsubsection{cow6}
\section{dog6}
\subsection{eel6}
\subsubsection{fly6}
\section{ant7}
\subsection{bee7}
\subsubsection{cow7}
\section{dog7}
\subsection{eel7}
\subsubsection{fly7}
\section{ant8}
\subsection{bee8}
\subsubsection{cow8}
\section{dog8}
\subsection{eel8}
\subsubsection{fly8}

\end{document}

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

[...]