我一直在尝试使用\vsplit
分页来确定行高。我几乎将与分页相关的所有惩罚都设置为 0。如果不能分页,那也不是世界末日,但我想知道为什么。
\documentclass{article}
\usepackage{amsmath}
\newcounter{count}
\newlength{\size}
\newlength{\total}
\newlength{\prev}
\begin{document}
\setbox0=\vbox{This is the first line of a paragraph, so there is a penalty for
splitting here. This is the line before a display, so ditto.
\begin{equation}
x=a
\end{equation}
Everything should return to normal now.}
\noindent\usebox0
\bigskip
\total=\ht0
\advance\total by \dp0
total height = \the\total
\clubpenalty=0
\widowpenalty=0
\displaywidowpenalty=0
\predisplaypenalty=0
\postdisplaypenalty=0
\interlinepenalty=0
\total=0pt
\loop\prev=\dimexpr \ht0+\dp0\relax
\setbox1=\vsplit0 to \baselineskip
\stepcounter{count}%
\size=\dimexpr \prev-\ht0-\dp0\relax
\advance\total by \size
\thecount{ = }\the\size\par
\ifdim\ht0>0pt\repeat
total height = \the\total
\end{document}
答案1
惩罚是框结构的一部分,因此在框设置后进行的更改不会产生任何效果,而提前设置则会产生四行而不是三行。
\documentclass{article}
\usepackage{amsmath}
\newcounter{count}
\newlength{\size}
\newlength{\total}
\newlength{\prev}
\begin{document}
\clubpenalty=0
\widowpenalty=0
\displaywidowpenalty=0
\predisplaypenalty=0
\postdisplaypenalty=0
\interlinepenalty=0
\setbox0=\vbox{This is the first line of a paragraph, so there is a penalty for
splitting here. This is the line before a display, so ditto.
\begin{equation}
x=a
\end{equation}
Everything should return to normal now.}
\usebox0
\bigskip
\total=\ht0
\advance\total by \dp0
total height = \the\total
\total=0pt
\loop\prev=\dimexpr \ht0+\dp0\relax
\setbox1=\vsplit0 to \baselineskip
\stepcounter{count}%
\size=\dimexpr \prev-\ht0-\dp0\relax
\advance\total by \size
\thecount{ = }\the\size\par
\ifdim\ht0>0pt\repeat
total height = \the\total
\end{document}