在下面的程式碼中
\documentclass{article}
\usepackage{amsthm}
\newcounter{number}
\begin{document}
\begin{proof}ccc\[aaa\]\end{proof}
\label{\thenumber}
\begin{proof}ee\end{proof}
\end{document}
\label 指令會產生額外的垂直空間,如果我省略此指令,則不會產生額外的垂直空間。我怎樣才能避免這個空間?這可能與\refstepcounter 的額外空間,但這裡不涉及 'hyperref' 套件。
答案1
通常,如果一個顯示環境(或節標題等)跟隨另一個,則由一個的末尾和下一個的開頭指定的任何垂直間距都會被合併,因此您只能獲得兩個長度的最大值,而不是總和。
然而,\write
生成的節點\label
(需要延遲寫入 aux 文件,因此\pageref
有效)意味著這裡第二個證明環境無法「看到」第一個證明添加的垂直空間,因此您得到
結束證明空間,寫入節點,開始證明空間
代替
max(結束證明空間,開始證明空間)
解決方案是將其放在\label
更安全的地方(如果可以避免的話,幾乎總是最好不要在 vmode 中執行此操作),例如,這是可行的
\documentclass{article}
\usepackage{amsthm}
\newcounter{number}
\begin{document}
\begin{proof}ccc\[aaa\label{\thenumber}\]\end{proof}
\begin{proof}ee\end{proof}
\end{document}
與空間問題無關(因為這與 相同\label{zzz}
),但\label
與計數器產生的標籤鍵一起使用是一個相當奇怪的構造。