# How to avoid page breaks before enumerate/itemize by default?

Basically the same as this question, except I don't want to have to remember to write \mynobreakpar (or anything else) everywhere.

How do I set this as the default option for all itemize/enumerate/etc. environments?

-

## 2 Answers

I don't know if this is overkill but one workaround is by using etoolbox package. I took the liberty of copying Ulrike Fischer's macro from your link.

\documentclass{article}
\makeatletter
\newcommand\mynobreakpar{\par\nobreak\@afterheading}
\makeatother

\usepackage{etoolbox}
\BeforeBeginEnvironment{itemize}{
\mynobreakpar
}
\usepackage{lipsum}
\begin{document}
Some text
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\lipsum[1-4]
Here is an intervening paragraph. Does this answer your needs? Because the quick brown fox jumps over the head of the lazy dog. And the quick brown fox jumps over the head of the lazy dog.
\begin{itemize}
\item Item 1
\item Item 2
\item Item 3
\end{itemize}
\end{document}

-
Oh interesting, I hadn't seen etoolbox before, +1 thanks. –  Mehrdad Dec 8 '12 at 4:29

Here's an alternative solution. I would create my own version of the environments for which you want this feature to apply:

\makeatletter
\newcommand\mynobreakpar{\par\nobreak\@afterheading}
\makeatother
\newenvironment{myitemize}{\mynobreakpar\begin{itemize}}{\end{itemize}}

-
I just tried it with you MWE. It seems to work. –  A.Ellett Dec 8 '12 at 15:35
Hmmm... Strange. It does now as well it should. I wonder what happened to my compilation earlier. I would upvote this but I am out of votes for now. –  hpesoj626 Dec 8 '12 at 15:40