8

MWE:

%%%! 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

The macro \doSmth in this example writes the value of the \pagetotal register both onto the page and into the log. When I compile this example with LaTeX, plain TeX or luaTeX (last two with modifications for plain), both values — on the page and in the log — are equal, namely 34.0pt. However when run with luaLaTeX the value on the page remains 34.0pt but in the log I get 34.22pt.

This difference seems small and insignificant (and who cares about some log anyway, right?), but it only demonstrates that something is wrong. The real problem is that in another (way more complex) case luaLaTeX treats \pagetotal as having zero value (and \ifnum \pagetotal > 0 consequently fails), whilst at the same time printing its value on the page correctly (I temporarily put in a macro, right before that failing \ifnum, the same commands as in the \doSmth macro above and got on the page some 231.8pt and zero in the log).

Using LuaTeX, Version 1.0.4 (TeX Live 2017) (format=lualatex 2017.9.20) on Linux. Any help appreciated, thanks.

EDIT: After some more experimenting and testing it turns out that the problem is not that serious after all, or—to be precise—that this thing described here with different values and my problem with zero value were not related. Mine was actually my own bug caused by playing too freely with \dimen0 in local contexts.

  • That's ... interesting, worth asking on luatex list I think (more chance of getting an authoritative answer there than here) – David Carlisle Sep 20 '17 at 11:55
  • 2
    It looks like a timing problem. Try e.g. \def\doSmth{\the\pagetotal\message{XXXXX::\the\pagetotal::XXXXX}\the\pagetotal} and \def\doSmth{\noindent\the\pagetotal\message{XXXXX::\the\pagetotal::XXXXX}} – Ulrike Fischer Sep 20 '17 at 11:56
  • I can confirm both the behaviour described in the question as well as @UlrikeFischer's observation. Note that XeLaTeX has the same behaviour, printing 34.0pt but logging 34.21999pt. – diabonas Sep 20 '17 at 11:59
  • Thank you all, I've found some more “interesting” stuff in the meantime so I'll just follow David's advice and write directly to luatex list. – Marcel S. Sep 20 '17 at 12:27
4

I don't see much difference from luatex and 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 with luatex-plain:

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

gives

>>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 with plain:

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

gives

>>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

and pdftex

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

gives

>>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

The log have more info, but practically when we typeset something several things happen not all in sync. Of course, all depends on the font used: the 'S' of LMRoman10-Regular looks similar to the 'S' of CMR10, but width, height an depth are not the same --- and the depth influences the \pagetotal. In this case using \strut gives the same result because \strut has the same dimensions in LMRoman10-Regular and CMR10; but already in LMRoman10-Regular the 'S' and the 'o' have different depths, and in CMR10 the depth of both is 0pt.

If we see the log, when TeX has to typeset the value of \pagetotal which is '10.0pt' one consequence is the update of \pagetotal by the page builder with the depth of \strut, which is 3.5pt in this case for both the fonts (\parskip is 0.0pt plus 1.0pt). This is the new value of \pagetotal seen by \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.

With \def\TESTCHAR{S} instead of \def\TESTCHAR{\strut} we have another value of depth, and in this case the fonts differ by 0.22pt; and with \def\TESTCHAR{m} both the fonts agree between them as also with the value in the pdf (10pt).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.