jbezos / enumitem

Customize enumerate, itemize and description
MIT License
45 stars 5 forks source link

\begin{itemize}[beginpenalty=\lastpenalty] => to avoid a page break !! #6

Open jbezos opened 5 years ago

jbezos commented 5 years ago

Reported by CHERVET Florent.

At the entry inside the environment, enumitem executes :

  \addpenalty \@beginparpenalty

As a result, an unwanted page break may occur : % --------------------------------- Some text \par \nobreak \begin{itemize}% < A page break may occur here ! > \item ... \end{itemize} % ---------------------------------

As a turnaround, I usually say in this case : % --------------------------------- Some text \par \nobreak \begin{itemize}[beginpenalty=\lastpenalty] \item ... \end{itemize} % ---------------------------------

It would be usefull to test, at the entry in the environment, if \lastpenalty is 10000 or higher, and avoid to add an unwanted \@beginpenalty if this is the case.

FrankMittelbach commented 5 years ago

If there is some enhancement happening here then probably checking the @nobreak switch should be done too ie to account for the case when a list is the first element in a headed section.