How to allow pagebreak only at section headers?

My document consists of many short (sub)sections. A section's content can consist of multiple paragraphs. I want to allow page breaks only at (sub)section titles.

I tried inserting a \pagebreak[3] before each subsection, as suggested in this question, but it doesn't help much. Now, sometimes subsection titles get separated from their section title and I still get page breaks between paragraphs and in itemize lists. What else can I try?

(I also found many questions on how to force page breaks at section titles, this is not what I want.)

1 Answer

This will never break a subsection, obviously you can customise the spacing and hide the markup in a \newenvironment definition.

\section{zzzz}

\noindent\begin{minipage}{\textwidth}
\subsection{zz aa}

zzzzzzzzz   zzzz

zzz
zz
\end{minipage}

\bigskip

\noindent\begin{minipage}{\textwidth}
\subsection{zz aa}

zzzzzzzzz   zzzz

zzz
zz
\end{minipage}

\section{fff fff}