【问题标题】:Make an unbreakable block in TeX [closed]在 TeX 中制作一个牢不可破的块 [关闭]
【发布时间】:2023-12-15 13:56:01
【问题描述】:

我想在 TeX 中执行以下操作:

\begin{nobreak}  

Text here will not split over pages, it will remain
as one continuous chunk. If there isn't enough room
for it on the current page a pagebreak will happen
before it and the whole chunk will start on the next
page.  

\end{nobreak}

这可能吗?

【问题讨论】:

标签: latex tex page-break


【解决方案1】:

你可以试试:

\begin{samepage}
 This is the first paragraph. This is the first paragraph. 
 This is the first paragraph. This is the first paragraph. 

 \nopagebreak
 This the second. This the second. This the second. 
 This the second. This the second. This the second. 
 This the second. This the second. 
\end{samepage}

samepage 防止 LaTeX 在一个段落内分页,即在 samepage 环境中,分页仅在段落之间。因此,您还需要nopagebreak,以防止 LaTeX 在两个段落之间分页。

【讨论】:

  • 这行得通,除了 \nopagebreak 之前或之后应该有一个空行。段落之间需要一个空行,否则在制作 PDF 时它们会合并在一起。
【解决方案2】:

快速测试表明minipage 也有这种行为。

\begin{minipage}{3in}
One contiguous chunk.
\end{minipage}

\begin{minipage}{3in}
Another contiguous chunk.
\end{minipage}

【讨论】:

  • 如果您想保持与文档其余部分相同的宽度,也可以使用 \textwidth 作为 minipage 的必需参数:\begin{minipage}{\textwidth}
  • 另请注意,如果 minipage 中有浮动,这将不起作用。浮动显然不会受到它的限制。
最近更新 更多