如何避免使用 lettrine 时出现糟糕的分页符?

如何避免使用 lettrine 时出现糟糕的分页符?

我使用该lettrine软件包将某些段落开头的首字母降低。但有时它恰好是页面的最后一行,结果很糟糕。有没有办法自动将其移动到下一页?

这是一个展示该问题的小示例文件。

\documentclass{article}
\usepackage{lettrine}

\usepackage[paperwidth=200pt,paperheight=300pt, offset=0pt, hmargin=40pt, tmargin=50pt, bmargin=80pt,
noheadfoot]{geometry}

\newcommand{\TestLettrine}[2]{\lettrine[lines=2, loversize=1.0]{#1}{ #2}}

\begin{document}

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex
emulsion consisting of proteins, alkaloids, starches, sugars, oils, tannins, resins, and gums that coagulates on
exposure to air. It is usually exuded after tissue injury. In most plants, latex is white, but some have yellow, orange,

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex

\end{document}

答案1

使用needspace包裹。它提供\needspace{<length>}(或)如果页面上没有可用,则\Needspace{<length>}发出中断,否则不执行任何操作:<length>

\documentclass{article}
\usepackage{lettrine}% http://ctan.org/pkg/lettrine
\usepackage{needspace}% http://ctan.org/pkg/needspace

\usepackage[paperwidth=200pt,paperheight=300pt, offset=0pt, hmargin=40pt, tmargin=50pt, bmargin=80pt,
noheadfoot]{geometry}

\newcommand{\TestLettrine}[2]{\lettrine[lines=2, loversize=1.0]{#1}{ #2}}

\begin{document}

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex
emulsion consisting of proteins, alkaloids, starches, sugars, oils, tannins, resins, and gums that coagulates on
exposure to air. It is usually exuded after tissue injury. In most plants, latex is white, but some have yellow, orange,

\needspace{2\baselineskip}% Break if needed.

\TestLettrine{L}{atex} as found in nature is a milky fluid found in 10\% of all flowering plants (angiosperms). It is a complex

\end{document}

在此处输入图片描述

\needspace将该命令包含在您的定义中可能会更好\TestLettrine

\newcommand{\TestLettrine}[2]{%
  \needspace{2\baselineskip}% Need at least 2 lines of text available on page, or else...
  \lettrine[lines=2, loversize=1.0]{#1}{ #2}%
}

“相对”长度2\baselineskip确保至少有 2 行文本需要适合页面底部,否则会\break发出。

当然,您也可以直接在段落前使用\newpage\pagebreak自己。但是,这有点太手动了,无法适应文档的变化。

相关内容