# [luatex] \latelua

Hans Hagen pragma at wxs.nl
Sun Jul 13 11:10:51 CEST 2014

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

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