I am writing a reference book in which every section heading is followed by an itemized list. I often get page breaks after the section heading and just one or two of the list items. In such cases I would like the heading to move to the next page. I tried all the solutions mentioned at Avoiding page breaks shortly after section/subsection headings, but none of them had any effect. It seems like these methods apply only when a paragraph follows the heading. What can I do in my case?
-
Your title suggests that you were getting a page break between the heading and the list. That should never happen. The text seems to imply that the break was after an item, which can happen and jfbu's answer is the answer for that case– David CarlisleCommented Oct 26, 2018 at 13:06
-
Sorry - text is right; please parse the title as "Avoiding page breaks after (section headings followed by lists)".– KeithBCommented Oct 26, 2018 at 13:46
Add a comment
|
1 Answer
I would use the needspace
package.
\documentclass[a4paper]{article}
\usepackage{geometry}
\usepackage{needspace}
\begin{document}
\vspace*{17.25cm}% try 17.26cm and see the whole section moving to next page
\needspace{7\baselineskip}
\section{Foo}
\begin{itemize}
\item A
\item B
\item C
\item D
\end{itemize}
\end{document}
-
-
After writing this up I discovered that old answers to tex.stackexchange.com/questions/2347/… already provided this answer, see Ulrike's answer tex.stackexchange.com/a/2353/4686 and others– user4686Commented Oct 26, 2018 at 13:06