
align
我正在編輯一篇相當長的文本,其中包含許多方程式和浮點數,並且遇到了和環境問題gather
。
微量元素:
\documentclass[preview]{standalone}
\usepackage{amsmath}
\begin{document}
Paragraph one. Lorem ipsum dolor sit amet, consecuteur adipiscing elit.
\begin{gather*}
\boxed{\sum_{x=1}^{N} A_x} \\
\boxed{\sum_{x=1}^{N} A_x}
\end{gather*}
Paragraph two. Lorem ipsum dolor sit amet, consecuteur adipiscing elit.
\end{document}
結果:
第一段和方程式之間的垂直空間太多,就像插入了一個額外的空段落一樣。如果我刪除第一段和數學環境之間的空行,則不會有多餘的空間,但此時頁面無法被破壞,並且我經常會得到孤兒。當我使用equation
環境或時,不存在額外的空間\[ \]
:
\documentclass[preview]{standalone}
\usepackage{amsmath}
\begin{document}
Paragraph one. Lorem ipsum dolor sit amet, consecuteur adipiscing elit.
\[ \boxed{\sum_{x=1}^{N} A_x} \]
\[ \boxed{\sum_{x=1}^{N} A_x} \]
Paragraph two. Lorem ipsum dolor sit amet, consecuteur adipiscing elit.
\end{document}
結果:
如何擺脫不需要的垂直空間,但同時允許在環境之前分頁?
答案1
頁面不應以不是上一頁顯示的延續的顯示方程式開始(這種情況應該是最後的手段)。
您可以透過發出以下命令自動允許多行對齊顯示內的分頁符
\allowdisplaybreaks
(一個amsmath
命令)在文檔序言中,但是 TeX 永遠不會在顯示之前中斷頁面,除非你自己玩一些骯髒的把戲。
切勿在顯示前留下空白行。
答案2
我找到了一個解決方案,並且沒有真正的理由在給出顯示的方程式之前禁止分頁,所以我給可能看到這個問題的其他人留下了一條註釋。
若要允許在特定顯示的方程式之前中斷,但要消除多餘的垂直空間,請放置\pagebreak[0]
第一個空白行:
\documentclass[preview]{standalone}
\usepackage{amsmath}
\begin{document}
Paragraph one. Lorem ipsum dolor sit amet, consecuteur adipiscing elit.
\pagebreak[0]
\begin{gather*}
\boxed{\sum_{x=1}^{N} A_x} \\
\boxed{\sum_{x=1}^{N} A_x}
\end{gather*}
Paragraph two. Lorem ipsum dolor sit amet, consecuteur adipiscing elit.
\end{document}
若要允許到處中斷,請\predisplaypenalty
在序言中重新定義:
\makeatletter
\predisplaypenalty=\@medpenalty
\makeatother
這兩種方式都允許發生分頁。