I have a document with several lists within which I don't want a page break. In the following document:
\documentclass{article}
\usepackage[totalheight=2in]{geometry}
\begin{document}
\begin{itemize}
\item A top level item
\begin{itemize}
\item A second level item
\item A second level item
\item A second level item
\item A second level item
\item A second level item
\end{itemize}
%\newpage
\item Another top level item
\begin{itemize}
\item A second level item
\item A second level item
\item A second level item
\item A second level item
\item A second level item
\end{itemize}
\end{itemize}
\end{document}
a break occurs in the middle of the second list. I would like to break automatically at the location of the \newpage, even if it means a less optimal break. Is there a way to prefer breaks between items instead of within an item?
I tried \usepackage{enumitem} \setlist{midpenalty=5000}, but this moves the break to just after "Another top level item". I can get what I'm looking for by enclosing Another top level item...\end{itemize} within a \parbox[t]{\textwidth}, but that seems heavy handed. Is there a better way?
It appears that https://tex.stackexchange.com/a/76495/107497 would provide a (complicated) way to automatically wrap all items within a minipage, but I was hoping for something simpler. This does appear to be the same idea as ConTeXt: Page break preference between nested itemize environments, but that is using ConTeXt.
\pagebreak[3]is the recomended solution, but it doesn.t work very often.\vfil\pagebreak[3]works, but might leave a large gap. – John Kormylo Jan 25 '24 at 22:31\needspace{3cm}(needspace package). The length needed is determined by trial and error. – John Kormylo Jan 25 '24 at 22:51