7

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?

5

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}}
3
  • 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 '14 at 18:28
4

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}
1
  • Oh interesting, I hadn't seen etoolbox before, +1 thanks.
    – user541686
    Dec 8 '12 at 4:29
0

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.

3
  • Oops, this is an answer for another question, namely the question where the questioner refers to. Sorry.
    – brac37
    Nov 5 '14 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
    – user31729
    Nov 5 '14 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 '14 at 20:34
0

Using my own answer in question referenced by asker, you can redefine item macro to let it work for lists environments. It's absolutely transparent, you don't event have to using own environment.

\let\nativeitem\item
\renewcommand{\item}{
    \begin{samepage} % prevent page-break before list enviroment
    \nativeitem\ % character needed after \item
    \end{samepage}\pagebreak[2] % page-break opportunity after (and only after) every item
}
1
  • Instead of the control space (character needed after \item), you could use \mbox{}.
    – Werner
    Mar 28 '17 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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