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

3 Answers 3

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

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
    
Worked for me. I did need to add an extra \\ to the end of the paragraph before the itemize to get the spacing I wanted. –  jhclark Sep 1 at 18:28

I do not understand why a new paragraph should be lauched before the list. Actually, it seems that you need to take into account the effects of \par to get what you want.

There is only one situation where I do not like page breaks before lists. Furthermore, I do not like list tags not being aligned. This has led to the following.

\makeatletter
\newcommand{\nolisttopbreak}{\vspace{\topsep}\nobreak\@afterheading}
\makeatother

\newenvironment{listproof}[1][\proofname]{\begin{proof}[#1]\mbox{}\nolisttopbreak}{\end{proof}}

As you can see, there is no paragraph break anywhere.

\@afterheading is probably just what a \begin{proof} generates, so that the first list item is started right after the \proofname command without any linebreak or vertical space in between.

share|improve this answer
    
Oops, this is an answer for another question, namely the question where the questioner refers to. Sorry. –  brac37 Nov 5 at 20:18
    
Welcome to TeX.SX! If this is 'wrong' in the sense of the real question, you should either edit or delete it –  Christian Hupfer Nov 5 at 20:19
    
It has already been accepted and edited, so I cannot delete it any more. I copied the edited version to the right location. Any moderator may delete this answer, as far as I am concerned. –  brac37 Nov 5 at 20:34

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.