[NTG-context] Accessing inserts from Lua in LuaMetaTeX

Hans Hagen j.hagen at freedom.nl
Mon Aug 15 16:24:20 CEST 2022

On 8/15/2022 8:18 AM, Max Chernoff via ntg-context wrote:
> Hi all,
> I'm trying to manipulate some inserts from Lua in LuaMetaTeX, and I'm
> having some problems that I'm not having with LuaTeX.
> First, how do I get an insert's class/type from the "insert" nodes on
> the page? With LuaTeX, the insert's class/type is the same as the
> subtype of the "ins" nodes, but the subtype of the "insert" nodes is
> always zero in LuaMetaTeX, so I'm not sure how to get the class/type.

Indeed, we don't use these boxes and registers because we run in 
\insertmode=2. This gives us more state info (i kept the old method 
around for now).

> Second, how do I get the head of the insert box from Lua? With LuaTeX,
> from TeX you would use "\box<class>" and from Lua you can use
> "tex.box[<class>]". With LuaMetaTeX, you use "\insertbox<class>" from
> TeX, but I'm not sure how to get at the insert box from Lua.


> The context for both of these is that my module lua-widow-control
> sometimes moves a line containing footnotes to the next page, so I need
> to do some surgery to make sure that the "footnote marks" stay with the
> "footnote text". This is tricky but doable with LuaTeX, but I can't seem
> to get it to work with the new inserts in LuaMetaTeX, hence the above
> questions.
The insert (etc) handler is more clever and flexible. So, for instance 
we can bubble up inserts. I think you do a preroll so in that case you 
can set the migrations related parameter to not bubble up.



\setbox0\hbox{test \footnote{test} test}








But I have no clue how all that will work out with (lua) code that 
manipulates these things. In list nodes you can consult the pre and post 
fields to what got migrated.


                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl

More information about the ntg-context mailing list