Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

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}
share|improve this answer
    
Oh interesting, I hadn't seen etoolbox before, +1 thanks. –  Mehrdad Dec 8 '12 at 4:29
add comment

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}}
share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.