1

I have a chapter with many sections, but they are of varying lengths. I want a new section to appear right after the previous one finishes (which happens normally) -unless- two sections end up on the same page. Right now, I'm manually adding \newpage if two sections appear on the same page. Is there a global way to do this? I'm working in the book class.

\documentclass[12pt]{book}
\begin{document}
\chapter{thefirstchapter}
\section{long section}
\section{long section}
\section{short section}
\newpage
\section{long section}
\section{short section}
\newpage
\section{long section}
\end{document}
0

Based on this entry, I started to use \clearpage{} instruction instead of \newpage{}. Because the former not only starts a new page, but ensures (still floating) objects like tables, and figures of the old section to come up before entering a new section. (Otherwise it may be distracting the reader if for example an experimental section contains tables from the theoretical section because LaTeX's floating algorithm assumes «and now here is enough space for it».)

By this the new section starts on top of a new page.

Or, you split your document -- each section its own file, eventually brought together into a main document with the \include{file} pattern.

3
  • I read the link but don't understand what they mean by float. Anyway, \newpage works fine for what I am doing. But I don't want to have to manually add it in. See, I have 200 sections. Is there some way to say "if two section titles appear on one page, insert \newpage between them"? – R. B. Jawad Mar 16 '20 at 21:52
  • I start to see. Conceptualy, one could address the problem about LaTeX's counter; one of the default counters is about page(s), to reset this counter per each section's start to zero, and to read-out the page count at the end of each section. If the value were less than 1, then probably a \newpage instruction should follow to separate this from the next section to follow. While there are if-loops in TeX (tex.stackexchange.com/questions/286902/latex-if-condition), I do not know if this approach equally breaks the page counting in the bottom of the page as well. – Buttonwood Mar 16 '20 at 22:35
  • 1
    I don't think this answers the question – David Carlisle Mar 17 '20 at 0:58

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.