如何强制某一行不出现在页面顶部

如何强制某一行不出现在页面顶部

我有一行文本,它不应该通过分页符与它之前的内容分开。(如果这很重要,那么它之前的内容就是文本环境)。IE 如何强制一行文本永远不成为页面的第一行?

这是我的最小示例:

\documentclass{article}

\begin{document}

\begin{quotation}
Very long quote about honour and fate, having to do with family and children, torture and death, with rending of garments and gnashing of teeth thrown in for good measure.
\end{quotation}
\raggedleft{---Last speech to the Doomed Squadron, 57 Years Before The Fall}

\end{document}

在我的例子中,我希望里面的文本\raggedleft仍然附加到引用环境。

更新1:我不能使用,vbox因为我可以有一个很长的多段引文,应该跨页折行。

更新2:我打算实现一个具有这些特征的环境,因此解决方案必须能够实现,而不管上下文如何。IEneedspace将无法工作,因为我必须知道是否/何时需要空间。

答案1

TeX 遵循盒子惩罚粘合原理。如果你\penalty10000在粘合之前插入,则粘合是牢不可破的。宏\nobreak是 的快捷方式\penalty10000

在 之前插入以下内容\end{quotation}

\par\nobreak \countdef\penalty=0

\par返回垂直模式,\nobreak插入惩罚 10000 并\countdef\penalty=0进行\penalty混淆,因为 LaTeX 环境会在该环境的末尾插入另一个惩罚,但我们不希望出现这样的第二个惩罚。该设置是局部的,因此在\penaltyLaTeX 环境打开的组末尾恢复了图元的原始含义quotation

答案2

您可以使用该包并在引文末尾needspace添加一个关闭,以强制将部分文本打印在右对齐文本之前的下一页上。\Needspace{}

引文中的最后一句话“还有一句话。”\Needspace{5cm}被注释掉时会出现在第一页,而添加该句子后,该句子会移到下一页。

\documentclass{article}

\usepackage{lipsum, needspace}

\begin{document}

\begin{quotation}
Very long quote about honour and fate, having to do with family and children, torture and death, with rending of garments and gnashing of teeth thrown in for good measure.

\lipsum[1-4]

\Needspace{5cm}
And one more sentence.
\end{quotation}
\raggedleft{---Last speech to the Doomed Squadron, 57 Years Before The Fall}

\end{document}

在此处输入图片描述

相关内容