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.

4
  • 1
    The whole point of lists is to allow page breaks anywhere (that and nesting). It's actually easier to use \parboxes. Sep 7, 2021 at 22:00
  • I added a possible duplicate, e. g. have a look at the samepage environment;. Sep 7, 2021 at 22:25
  • @Dr.ManuelKuehner I'm not sure that's a duplicate really, the OP doesn't need to mark each item separately just mark the entire list as something that may break between items but not in an item. None of the answers there address this. Sep 8, 2021 at 6:50
  • @DavidCarlisle I see, my mistake. Sep 8, 2021 at 13:07

2 Answers 2

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}
3
  • 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? Sep 7, 2021 at 22:06
  • it puts a \nobreak (10000) penalty between every line of a pargagraph and applies til the end of the group @mlchristians Sep 7, 2021 at 22:31
  • Once again, many thanks for a very helpful answer. Sep 7, 2021 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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .