I’m using the scrbook class but removing the pagebreaks that precede each chapter using a patchcmd I copy-and-pasted from here without understanding it.
When this leads to a chapter heading being exactly at the beginning of a page, the table of contents lists the chapter as being at (the end of) the previous page.
The following MWE demonstrates this: The ToC lists Second Chapter as being on page 1.
\documentclass[]{scrbook}
% remove pre-chapter pagebreak as per https://tex.stackexchange.com/a/24067
\usepackage{etoolbox}
\makeatletter
\patchcmd{\scr@startchapter}{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\makeatother
\begin{document}
\tableofcontents
\chapter{First Chapter}
Lorem ipsum
\vspace{11cm}
This page is pretty full.
\chapter{Second Chapter}
More lorem ipsum
\end{document}
How do I fix the page number in the ToC? I don’t mind if the solution is hacky.
Extra questions: Is it a terrible abuse of scrbook to use it this way? Is there a better way to remove the pagebreaks?
