[Dev-luatex] tex.print and \inputlineno

Jonathan Sauer Jonathan.Sauer at silverstroke.com
Tue Sep 25 11:15:18 CEST 2007


Hello,

while testing, I stumbled on a (then) strange phenomenon concerning
line numbers in tex.print. It seems that \inputlineno is not equal
to the number of the line of the tex.print statement (or the macro
expanding to it), but of the virtual file tex.print uses internally.

Example (PlainTeX):

--------------------------------------------------------------------

% Output is `1' instead of `3':
\directlua0{\unexpanded{tex.print('\\message{\\the\\inputlineno}')}}

% Output is `1' instead of `6':
\scantokens{\message{\the\inputlineno}}


\bye

--------------------------------------------------------------------

Results in:

This is luaTeX, Version 3.141592-beta-0.11.2-2007091918 (Web2C 7.5.6)
(format=luatex 2007.9.20)  24 SEP 2007 15:25
**LineNumberTest.tex
(LineNumberTest.tex 1 1 )
No pages of output.


As you can see, eTeX's \scantokens exhibits the same behaviour (most
likely because it also uses a virtual file). But I think that tex.print
will be used more often than \scantokens, since it is the only way to
pass arbitrary tokens from Lua to TeX. This means that when TeX
executes these tokens, log messages will use not the line number of
the TeX macro that expanded to the Lua code that created new TeX tokens,
but the "virtual line number" (as seen in the example above). These
log messages (and most likely \errmessage-s as well) are not very
useful.


Jonathan



More information about the dev-luatex mailing list