如何在不使用 raggedbottom 的情况下避免出现孤儿寡母现象

如何在不使用 raggedbottom 的情况下避免出现孤儿寡母现象

我知道我可以将\clubpenalty和设置\widowpenalty为 10 000 来使它们“非常糟糕”,但是当没有垂直拉伸(即\parskip=0pt)时,TeX 会认为缩短页面同样糟糕,所以我经常会留下未满的页面。

问题是:在这些情况下,是否有可能以某种方式指示 TeX 重新制作整个页面,例如,尝试使其缩短或延长一行?(不是页面\vsize,而是排版文本的空间要求)

也许 LuaTeX 可以实现这个功能?或者一些巧妙的输出程序?

更新

好的,现在,根据评论,我已经玩过 eTeX \club-/ \widowpenalties。但我要么不明白它们是如何工作的,要么它们对解决问题没有帮助:

\font\bodyfont=cmr10 at 11bp \bodyfont

\frenchspacing
\parskip=0pt
\baselineskip=15bp
\topskip=15bp
\parindent=1em
\hsize=27pc
\vsize=525bp % 525 / 15 = 35, the number of lines

\clubpenalties=2 10000 0
\widowpenalties=2 10000 0
\looseness=1

\input a_novel
\bye

当出现寡妇/孤儿时,页面就会缩短。

参考

乔纳森·费恩斯换行和分页”暗示可以通过多次传递实现全局优化。

David Salomon 在他的书《高级 TeXbook》中写道:“全局分页算法”,但我找不到参考文献(参考文献37)。

答案1

下列所有条件肯定不可能同时存在:

  1. 无俱乐部/寡妇
  2. TeX 不得更改段落
  3. 行数必须固定

由于 TeX 在查看页面之前会先拆分段落,因此它没有机会重做 2)。使用 LuaTeX,您可能可以制作自己的自动解决方案,但这与“简单”完全相反。

在 PDFTeX 中,您必须手动告诉 TeX 重新排列段落。参数\looseness告诉 TeX 放大或缩小段落,但前提是它可以这样做(\tolerance等等)。

以下代码是一个没有寡妇/俱乐部的示例文档,但段落不再漂亮:

\font\bodyfont=cmr10 at 11bp \bodyfont

\frenchspacing
\parskip=0pt
\baselineskip=15bp
\topskip=15bp
\parindent=1em
\hsize=27pc
\vsize=525bp % 525 / 15 = 35, the number of lines

\clubpenalties=2 10000 0
\widowpenalties=2 10000 0

\def\a{A wonderful serenity has taken possession of my entire soul, like these sweet
mornings of spring which I enjoy with my whole heart. I am alone, and feel the
charm of existence in this spot, which was created for the bliss of souls like
mine. I am so happy, my dear friend, so absorbed in the exquisite sense of
mere tranquil existence, that I neglect my talents. I should be incapable of
drawing a single stroke at the present moment; and yet I feel that I never was
a greater artist than now. When, while the lovely valley teems with vapour
around me, and the meridian sun strikes the upper surface of the impenetrable
foliage of my trees, and but a few stray gleams steal into the inner
sanctuary, I throw myself down among the tall grass by the trickling stream;
and, as I lie close to the earth, a thousand unknown plants are noticed by me:
when I hear the buzz of the little world among the stalks, and grow familiar
with the countless indescribable forms of the insects and flies, then I feel
the presence of the Almighty, who formed us in his own image, and the breath
of that universal love which bears and sustains us, as it floats around us in
an \par}
\a
\looseness=-1\a
\tolerance300\looseness=2\a
\looseness=2\a

\bye

答案2

切换到 lualatex 后,我也遇到了同样的问题。显然,\club-/\widowpenaltiespdflatex 比 lualatex 效果更好。但是,在前言中添加以下内容解决了我所有的问题:

\usepackage[defaultlines=4,all]{nowidow}

查看 nowidow 包手册以了解更多选项:http://mirrors.ctan.org/macros/latex/contrib/nowidow/nowidow.pdf

相关内容