防止枚举项跨两页的“简单方法”

防止枚举项跨两页的“简单方法”

考虑以下示例,

\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}

如您所见,第六项跨越两页:

在此处输入图片描述

我宁愿这种事不发生。

我认为,也许一个简单的解决方案可能是\raggedbottom在之后的某个地方添加命令\begin{document},但我无法让它发挥作用。

我的实际文档有数百个项目,分布在数百页以上,如果可能的话,我会喜欢 Latex (Pdflatex) 来防止项目被分成两页。 (我希望尝试处理这可能导致的以后增加的空白。)

问题:是否有一种简单的方法可以修改上述代码,使文档的任何页面都不会包含跨两页拆分的项目?我在这个网站上遇到过类似的拆分问题,但它们要么没有答案,要么(我记得)答案相当复杂。

有没有简单的方法可以实现这一点?

谢谢。

答案1

避免行间分页,并允许项目之间的空间伸展

在此处输入图片描述

\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}

答案2

这使用了牢不可破的盒子。

\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}

相关内容