[luatex] \latelua
David Carlisle
d.p.carlisle at gmail.com
Sun Jul 13 11:21:36 CEST 2014
On 13 July 2014 10:10, Hans Hagen <pragma at wxs.nl> wrote:
> On 7/13/2014 10:01 AM, Joseph Wright wrote:
>>
>> Hello all,
>>
>> I'm trying to understand exactly what \latelua does. I was mainly trying
>> to follow the expansion behaviour, cf. \directlua, but that at least
>> seems clear. However, I'm not really sure where the code gets executed.
>> With the example
>>
>> First
>> \directlua{tex.print("direct")}%
>> \latelua{tex.print("late")}%
>> \par\vfill\penalty-10000 %
>> Second
>> \directlua{tex.print("direct")}%
>> \bye
>>
>> the text "late" is inserted into the second page after "Second" but
>> before "direct", while if I omit the \directlua call on page two "late"
>> vanishes entirely. The manual does not give a lot away: is there a good
>> explanation/set of demos somewhere?
>
>
> think of it as \special ... delayed code till shipout (so the latelua gets
> executes as part of the conversion to pdf or dvi) ... where \directlua
> happens in the input (no node created unless the lua code does it) a
> \latelua creates a node
>
> in your case, you print, during shipout, something to the input which is why
> it ends up on the next page (and as there can be left over stuff, it ends up
> after there)
>
> Hans
Hans, that explains why in Joseph's case the "late" appears after
"Second" (it's like tokens a that are inserted \aftergroup out of the
output routine and appear at the point where "Tex exercises the page
breaker") but it doesn't explain why "late" doesn't appear at all in
\directlua{tex.print("direct")}%
\latelua{tex.print("late")}%
\par\vfill\penalty-10000 %
Second
% \directlua{tex.print("direct")}%
\bye
why isn't it inserted into the stream as the first page is shipped
out, and then appear after "Second"
More information about the luatex
mailing list