1

Consider the example,

\documentclass{book}
\textheight=8in
\usepackage{xcolor}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}

\begin{document} \LARGE \thispagestyle{empty}

\begin{center} \textbf{\textcolor{blue}{How to Prevent an Item from Splitting Across Two Pages?}} \end{center}

\vskip 35pt

\Large \begin{enumerate} \setlength\itemsep{1em}

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item Enough. \end{enumerate} \end{document}

which as you can see, has the sixth item splitting across two pages:

enter image description here

I would rather this wouldn't happen.

I thought, perhaps, that a simple solution might be adding the \raggedbottom command somewhere after \begin{document}, but I have not been able to get that to work.

My actual document has hundreds of items spread out over more than a couple of hundred pages and I would, if possible, like Latex (Pdflatex) to prevent items from being split across two pages. (I expect to try to deal with the increased white-space that this might cause later.)

QUESTION: Is there a simple way to modify the above code to that no page of a document will contain an item split across two pages? I have come across similar-type splitting questions on this site, but they either have no answer or, as I recall, a rather complex answer.

Is there a simple way to accomplish this?

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36

2 Answers2

2

Prevent page breaks between lines and allow the space between items to stretch

enter image description here

\documentclass{book}
\textheight=8in
\usepackage{xcolor}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}

\begin{document} \LARGE \thispagestyle{empty}

\begin{center} \textbf{\textcolor{blue}{How to Prevent an Item from Splitting Across Two Pages?}} \end{center}

\vspace{35pt}

\Large \begin{enumerate} \setlength\itemsep{1em plus 1fil} \interlinepenalty=10000

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.

\item Enough. \end{enumerate} \end{document}

David Carlisle
  • 757,742
  • Many thanks for posting this nice answer. May I ask what \interlinepenalty=10000 does; and will it be sufficient to cover 200+ pages of enumerate items in a similar fashion? – DDS Sep 07 '21 at 22:06
  • it puts a \nobreak (10000) penalty between every line of a pargagraph and applies til the end of the group @mlchristians – David Carlisle Sep 07 '21 at 22:31
  • Once again, many thanks for a very helpful answer. – DDS Sep 07 '21 at 22:46
0

This uses unbreakable boxes.

\documentclass{book}
\textheight=8in
\usepackage{xcolor}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}

\newcommand{\myitem}[1]{\par\vskip\itemsep\stepcounter{enumi}% \noindent\makebox[\labelwidth][r]{\theenumi.}\hspace{\labelsep}% \parbox[t]{\dimexpr \textwidth-\labelwidth-\labelsep}{#1}\par}

\begin{document} \LARGE \thispagestyle{empty}

\begin{center} \textbf{\textcolor{blue}{How to Prevent an Item from Splitting Across Two Pages?}} \end{center}

\vskip 35pt

\Large \begin{enumerate} \setlength\itemsep{1em} \item \parbox[t]{\linewidth}{I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.}

\item \parbox[t]{\linewidth}{I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.} \end{enumerate}

\myitem{I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum. I would rather specify no more than a few sentences from Lorem Ipsum.}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120