2

I have a single sentence paragraph that introduces a list, and LaTeX is trying to insert a page break between the paragraph and its list, which I find unacceptable. I can prevent that page break with \@nobreaktrue, but then I lose the vertical space between the paragraph and its list. How can I prevent a page break between the paragraph and its list without losing the normal vertical space I'd expect there?

MWE:

\documentclass{article}

\makeatletter
\newcommand{\reallynopagebreak}{\par\@nobreaktrue\nopagebreak}
\makeatother

\begin{document}

Paragraph introducing list:\reallynopagebreak{}

\begin{itemize}
\item list
\end{itemize}

\end{document}

Unwanted result, no space between paragraph and list:

enter image description here

For now I've just done \vspace{\baselineskip} at the end of the paragraph, but surely that's not the best way?

  • Would a conditional be the best way you want? – Jesse Aug 31 '13 at 14:57
  • I'm not opposed to employing a conditional to fix this, or better a macro which uses a conditional, if that's what you're asking Jesse? Sorry if I misunderstood you. – dsedivec Aug 31 '13 at 19:13
  • Use \@afterheading. – Ulrike Fischer Aug 31 '13 at 20:04
  • Sorry Ulrike, I did some searching but I don't understand what you mean by "use \@afterheading". I tried putting that in my document in various places to no avail. Google wasn't much help, either. Could you provide a bigger hint? Thanks! – dsedivec Sep 1 '13 at 5:13
2

I think the answer I'd prefer today is lockstep's answer for preventing page break before itemize. Here's my MWE above adapted to demonstrate this:

\documentclass{article}

\usepackage{lipsum}

\begin{document}

% Provide enough content such that LaTeX would normally break between
% "Paragraph introducing list:" and the actual list.  Please forgive
% my imperial units.
\vspace*{1.1in}
\lipsum[1-4]

Paragraph introducing list:

\begingroup
\makeatletter
% Strongly encourage LaTeX not to break before this list.
% http://tex.stackexchange.com/a/46795/1680
\@beginparpenalty=10000
\makeatother
\begin{itemize}
\item list
\end{itemize}
\endgroup

\end{document}
1

Taking a different tack, I introduce \ListIntro macro, which will automatically check for enough space to get the list going, or else page break.

To test the alternative, with no intervention, uncomment the line redefining the \ListIntro macro to {#1}, which merely passes on the argument unaltered.

\documentclass{article}
\usepackage{needspace}
\usepackage{calc}
\usepackage{lipsum}
\newcommand\ListIntro[1]{%
  \def\intpar{\parbox{\textwidth}{#1}}%
  \needspace{\heightof{\intpar}+3\baselineskip}%
  #1%
}
\begin{document}
\lipsum[1-4]

%\def\ListIntro#1{#1}

\ListIntro{\lipsum[5]}

\begin{itemize}
\item list
\end{itemize}

\end{document}
  • Thanks much! I'm liking your use of \heightof plus \needspace there. I'm not crazy about having to wrap the introductory paragraph to every list in this document with \ListIntro, but it may come to pass that this is really the best solution. I'm going to let this sit a little while longer and see if any more suggestions pop up. – dsedivec Sep 7 '13 at 22:18

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.