LuaLaTeX 会影响 pagetotal 吗?

LuaLaTeX 会影响 pagetotal 吗?

梅威瑟:

%%%! LuaLaTeX

\def\doSmth{\the\pagetotal\message{XXXXX::\the\pagetotal::XXXXX}}

\documentclass[a4paper]{article}
\begin{document}
Some text

Some text

Some text

\doSmth
\end{document}
% \bye

此示例中的宏将寄存器\doSmth的值写入\pagetotal页面和日志中。当我使用 LaTeX、纯 TeX 或 luaTeX(后两者经过修改以适应纯 TeX)编译此示例时,页面上和日志中的值都相等,即34.0pt。但是,当使用 luaLaTeX 运行时,页面上的值保持不变,34.0pt但在日志中我得到的是34.22pt

这种差异似乎很小而且微不足道(而且谁会在乎一些日志呢,对吧?),但它只能说明有些地方出了问题。真正的问题是,在另一个(更复杂得多的)情况下,luaLaTeX 将其视为具有\pagetotal零值(\ifnum \pagetotal > 0因此失败),同时将其值正确打印在页面上(我临时放入了一个宏,就在失败之前\ifnum,与上面的宏相同的命令\doSmth,并在页面上得到了一些,231.8pt在日志中得到了零)。

在 Linux 上使用LuaTeX, Version 1.0.4 (TeX Live 2017) (format=lualatex 2017.9.20)。如有任何帮助,不胜感激。

编辑:经过更多的实验和测试,结果发现问题其实并不严重,或者更准确地说,这里描述的这个不同值的问题和我零值的问题没有关系。我的问题实际上是我自己\dimen0在本地环境中玩得太随意而导致的 bug。

答案1

我没有看出 luatex 和 pdftex 有什么太大区别。

%% https://www.tug.org/utilities/plain/cseq.html
%%
%% everypar: holds tokens added at the beginning of every paragraph.
%%
%% pagetotal: is the accumulated height of the current page.
%%
\loggingall
\tracingpages=1000
\def\doSmth{\immediate\write12{>>before:t=\the\pagetotal .}\the\pagetotal\immediate\write12{>>after:t=\the\pagetotal .}}%
\everypar{\noindent\immediate\write12{>>everypar:t=\the\pagetotal}}%
\def\TESTCHAR{S}%
\def\TESTCHAR{m}%
\def\TESTCHAR{e}%
\def\TESTCHAR{\strut}%
\TESTCHAR%
\par%
\doSmth%
\def\TESTCHAR{S}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{o}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{m}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{e}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{\ }\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{t}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{e}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{x}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{t}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\def\TESTCHAR{\strut}\setbox0\hbox{\TESTCHAR}\immediate\write12{>>\TESTCHAR: wd=\the\wd0, ht=\the\ht0, dp=\the\dp0 .}%
\bye

luatex 与 luatex-plain:

$>mtxrun --script plain test.tex|grep '>>' ;pdftotext test.pdf -;pdffonts test.pdf;

给出

>>before:t=10.0pt.
>>everypar:t=13.5pt
>>after:t=13.5pt.
>>S: wd=5.56pt, ht=7.05pt, dp=0.22pt.
>>o: wd=5.0pt, ht=4.48pt, dp=0.11pt.
>>m: wd=8.33pt, ht=4.42pt, dp=0.0pt.
>>e: wd=4.44pt, ht=4.48pt, dp=0.11pt.
>>\ : wd=3.33pt, ht=0.0pt, dp=0.0pt.
>>t: wd=3.89pt, ht=6.15pt, dp=0.11pt.
>>e: wd=4.44pt, ht=4.48pt, dp=0.11pt.
>>x: wd=5.28pt, ht=4.31pt, dp=0.0pt.
>>t: wd=3.89pt, ht=6.15pt, dp=0.11pt.
>>\relax \unhcopy \strutbox : wd=0.0pt, ht=8.5pt, dp=3.5pt.
10.0pt

1


name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
JOCVHR+LMRoman10-Regular             CID Type 0C       Identity-H       yes yes yes      4  0

luatex 带有平原:

$> luatex test.tex|grep '>>';pdftotext test.pdf -;pdffonts test.pdf; 

给出

>>everypar:t=0.0pt
>>before:t=10.0pt.
>>everypar:t=13.5pt
>>after:t=13.5pt.
>>S: wd=5.55557pt, ht=6.83331pt, dp=0.0pt.
>>o: wd=5.00002pt, ht=4.30554pt, dp=0.0pt.
>>m: wd=8.33336pt, ht=4.30554pt, dp=0.0pt.
>>e: wd=4.44444pt, ht=4.30554pt, dp=0.0pt.
>>\ : wd=3.33333pt, ht=0.0pt, dp=0.0pt.
>>t: wd=3.8889pt, ht=6.15079pt, dp=0.0pt.
>>e: wd=4.44444pt, ht=4.30554pt, dp=0.0pt.
>>x: wd=5.2778pt, ht=4.30554pt, dp=0.0pt.
>>t: wd=3.8889pt, ht=6.15079pt, dp=0.0pt.
>>\relax \unhcopy \strutbox : wd=0.0pt, ht=8.5pt, dp=3.5pt.
10.0pt

1


name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
DLDTEG+CMR10                         Type 1            Builtin          yes yes no       4  0

和 pdftex

$>pdftex test.tex|grep '>>';pdftotext test.pdf -;pdffonts test.pdf

给出

>>everypar:t=0.0pt
>>before:t=10.0pt.
>>everypar:t=13.5pt
>>after:t=13.5pt.
>>S: wd=5.55557pt, ht=6.83331pt, dp=0.0pt.
>>o: wd=5.00002pt, ht=4.30554pt, dp=0.0pt.
>>m: wd=8.33336pt, ht=4.30554pt, dp=0.0pt.
>>e: wd=4.44444pt, ht=4.30554pt, dp=0.0pt.
>>\ : wd=3.33333pt, ht=0.0pt, dp=0.0pt.
>>t: wd=3.8889pt, ht=6.15079pt, dp=0.0pt.
>>e: wd=4.44444pt, ht=4.30554pt, dp=0.0pt.
>>x: wd=5.2778pt, ht=4.30554pt, dp=0.0pt.
>>t: wd=3.8889pt, ht=6.15079pt, dp=0.0pt.
>>\relax \unhcopy \strutbox : wd=0.0pt, ht=8.5pt, dp=3.5pt.
10.0pt

1


name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
DLDTEG+CMR10                         Type 1            Builtin          yes yes no       4  0

日志中有更多信息,但实际上当我们排版时,会发生一些不同步的事情。当然,这一切都取决于使用的字体:'S'LMRoman10-Regular 的 看起来与'S'CMR10 的 相似,但宽度、高度和深度并不相同 --- 并且深度会影响\pagetotal。在这种情况下,使用\strut会产生相同的结果,因为\strut在 LMRoman10-Regular 和 CMR10 中具有相同的尺寸;但在 LMRoman10-Regular 中'S''o'具有不同的深度,而在 CMR10 中,两者的深度都是 0pt

如果我们看到日志,当 TeX 必须排版 的值时,\pagetotal 其结果之一是 页面构建器使用 的深度'10.0pt'更新,在本例中对于两种字体都是 (是)。这是看到的新值:\pagetotal\strut3.5pt\parskip0.0pt plus 1.0pt\pagetotal\message

\doSmth ->\immediate \write 12{>>before:t=\the \pagetotal .}\the \pagetotal \im
mediate \write 12{>>after:t=\the \pagetotal .}
{vertical mode: \immediate}
\write->>>before:t=\the \pagetotal .
>>before:t=10.0pt.
{\the}
{the character 1}
\everypar->\noindent \immediate \write 12{>>everypar:t=\the \pagetotal }
% t=10.0 g=643.20255 b=10000 p=0 c=100000#
{horizontal mode: \noindent}
{\immediate}
\write->>>everypar:t=\the \pagetotal 
>>everypar:t=13.5pt
{the character 1}
{the character 0}
{the character .}
{the character 0}
{the character p}
{the character t}
{\immediate}
\write->>>after:t=\the \pagetotal .
>>after:t=13.5pt.

\def\TESTCHAR{S}代替,\def\TESTCHAR{\strut}我们有另一个深度值,在这种情况下,字体不同 0.22pt;并且\def\TESTCHAR{m}两种字体之间以及 pdf 中的值都一致(10pt)。

相关内容