我想将两段文本(问题陈述和解决方案)排版在一起,但我不想让问题成为页面上的最后一项,而解决方案成为下一页的第一项。如果它们出现在页面边界,有没有办法让 LaTeX 尝试将它们保持在一起 — 例如,将问题的几行推到解决方案页面上,反之亦然?(每个段落/部分都可以单独拆分,但我希望边界在同一页上。)
答案1
还有samepage
环境。我会尝试以下方法:
Random sentence of the problem. Random sentence of the problem. Random
sentence of the problem.
\begin{samepage}
One of the last sentences of the problem. The last sentences of the
problem.
The first sentence of the solution. Another sentence of the solution.
\end{samepage}
Random sentence of the solution. Random sentence of the solution. Random
sentence of the solution.
也许这对于你来说就足够了。
答案2
我个人喜欢\filbreak
因为它可以追溯到 Knuth(并且它的嵌套性比其他一些方法更好)。请参阅常问问题:
如果您有一连串的小文本块需要单独保存在自己的页面上,Knuth 的另一个技巧就很有用。
\filbreak
在每个小文本块前插入命令,即可实现效果。
以下如果出现分页符,则它们往往发生在\filbreak
s 处。
\filbreak
Here is the problem statement that goes on and on and on. And even more.
Here is the solution statement that goes on and on. And even more
\filbreak
Here is the problem statement that goes on and on and on. And even more.
Here is the solution statement that goes on and on. And even more
\filbreak
Here is the problem statement that goes on and on and on. And even more.
Here is the solution statement that goes on and on. And even more
答案3
我的解决方案是将这两段文字都保存在小页面环境中。
我首先有:
They were the first Hamkens on the Hamkenshof. In the distance we see more
upright sandstones, to the right and left of the door to a mausoleum. Here
lie the Gonnens, including the parents of Mrs. Ponke. North of the church we
find the gravestone of
\bigskip
\centerline{Councilor \personname{Peter Hamkens} (B 16)}
我想将文字说明与墓碑上的“议员彼得·哈姆肯斯”铭文放在同一页上,但它们经常分开。
无论\nopagebreak
是哪个环境都不samepage
适合我。
我只是将文本和题词放在一个小页面中,LaTeX 将其视为一行:
\noindent
\begin{minipage}{1\textwidth}
They were the first Hamkens on the Hamkenshof. In the distance we see more
upright sandstones, to the right and left of the door to a mausoleum. Here
lie the Gonnens, including the parents of Mrs. Ponke. North of the church we
find the gravestone of
\bigskip
\centerline{Councilor \personname{Peter Hamkens} (B 16)}
\end{minipage}
它运行良好,不需要使用任何新包。