# How do you prevent a page break between a list and the following text?

How do you prevent a page break between a list and the following text?

\documentclass{report}

\usepackage{lipsum}

\begin{document}

\begin{itemize}
\item \lipsum[1-3]
\item \lipsum[5]
\nopagebreak
\end{itemize}

\nopagebreak
\vspace{3\baselineskip}
\nopagebreak

\begin{center}
\nopagebreak
The end
\end{center}

\end{document}


I would like to prevent the "The end" closing from ever appearing on a page of its own, even at the cost of breaking up the list across two separate pages.

This process needs to be automated over a number of different documents, and so, can't be adjusted manually on a case by case basis, like adding \pagebreak before the last item on the list.

At the end of a list (itemize and enumerate included), LaTeX issues a number of vertical adjustments that are not scrutinized by your \nopagebreak requirement. So, instead of patching \enditemize, include your The end as part of the list where you have more control over the page breaking restrictions:

\documentclass{report}

\usepackage{lipsum}

\begin{document}

\begin{itemize}
\item \lipsum[1-3]
\item \lipsum[5]
\nopagebreak
\vspace{3\baselineskip}
\makeatletter
{\centering The end\hspace*{\@totalleftmargin}\par}
\makeatother
\end{itemize}

\begin{center}
The end
\end{center}

\end{document}


Note that the center environment itself is a list. As such, to avoid further influences that might not be captured, setting it using {\centering ... \par} suffices. However, sine we're in an itemize, some spacing corrections are required.

The final center environment is merely included to show the horizontal displacement is as required.