I am using this solution to divide my list of figures and tables into chapters, however, I have a section heading on its own at the bottom of a page and then the table captions are on the next page. What I want to do is force a new page when this happens (i.e when less than 2 figures are in the list say). The original thread is here - https://tex.stackexchange.com/a/68340/51337
I am sure the same could be down with the Table of contents to ensure that it doesn't look strange either, but I've no idea how. I know you can force a new page in the table of contents by adding \addtocontents{toc}{\protect\newpage} before the \chapter{} command, but this isn't really what I am after
\documentclass{book}
\usepackage{etoolbox}
\makeatletter
\def\thischaptertitle{}
\apptocmd{\@chapter}{\gdef\thischaptertitle{#1}}{}{}
\newcommand{\DeclareDividedList}[1]%
{\newcounter{#1@chapter}\setcounter{#1@chapter}{0}}
\pretocmd{\addcontentsline}%
{\ifltxcounter{#1@chapter}%
{%
\ifnumgreater{\thechapter}{\value{#1@chapter}}{%
\setcounter{#1@chapter}{\thechapter}%
\addtocontents{#1}{\protect\contentsline{chapter}%
{\protect\numberline {\thechapter} {\thischaptertitle}}{}{} }
}{}%
}{}%
}{}{}
\makeatother
\DeclareDividedList{lof}
\DeclareDividedList{lot}
\begin{document}
\tableofcontents
\listoffigures
\listoftables
\mainmatter
\chapter{Introduction with no Figures}
\chapter{Test Chapter with Figures but no Tables}
\begin{figure}
\caption{caption text}
\end{figure}
\begin{figure}
\caption{caption text}
\end{figure}
\chapter{Test Chapter with Tables but no Figures}
\begin{table}
\caption{caption text}
\end{table}
\begin{table}
\caption{caption text}
\end{table}
\chapter{Test Chapter with Figures and Tables}
\begin{figure}
\caption{caption text}
\end{figure}
\begin{table}
\caption{caption text}
\end{table}
\begin{figure}
\caption{caption text}
\end{figure}
\begin{table}
\caption{caption text}
\end{table}
\begin{figure}
\caption{caption text}
\end{figure}
\end{document}