该页面给出错误号码

该页面给出错误号码

在此文档中\thepage给我错误的数字(在每页的第一段)

\documentclass{article}
\textheight5\baselineskip
\begin{document}
test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-

test -\thepage-\\
test -\thepage-\\
test -\thepage-\\
test -\thepage-\\
test -\thepage-\\
test -\thepage-

test -\thepage-

\end{document}

答案1

在您的示例中,您有一个六行的段落,而页面上最多只能容纳五行。

段落完全排版后,各行(作为水平框)被发送到“最近贡献列表”并“运行页面构建器”,也就是说,最近贡献中的材料被移动到主垂直列表,TeX 进行内部计算以查看是否必须发出分页符,以及在哪里。

这种情况下,显然要分页,所以刚排版的段落的一部分会留在第n,而其他部分将位于第n+1。但是所有\thepage命令都已经完全扩展到值n没有什么可以再改变这一点,因为该段落已经排版了。

如果您使用\pageref,则页码将从以前的LaTeX 运行,因此除非分页符在此期间发生变化,否则它们将是正确的。再次运行 LaTeX 将修复该情况。

您可以信赖\thepage 仅有的紧接着一个\newpage命令,因为这样的命令会结束可能正在构建的段落并使 TeX 运行页面构建器。

好吧,人们可以想到即使在这样的点上也不\thepage可靠的边界情况(例如大浮点)。

相关内容