[luatex] accessing attribute registers (and other register types)

David Carlisle d.p.carlisle at gmail.com
Tue Jun 16 22:26:52 CEST 2015

If you have an attributedef token defined via


(or some allocation macro that does that internally)

then you can access the value (53 here) from lua as tex.attribute.qqq

but to use in node callbacks with such as

 node.has_attribute(n, attr_number)

then you need access to the underlying register number (301).

Does luatex have a documented way to get from the csname "qqq"
to the register number?

The latex luatexbase package achieves this by wrapping the \attributedef
in a call to \directlua that stores the "qqq"->53 association in its
own lua table.

It seemed to me that luatex must have this information and it ought to be
possible to simplify this just to do a bare \attributedef.

The following code appears to work producing

qqq is attribute: 301 value: 53

hhhz is attribute: 444 value: 99

zzz is count: 200 value: 2

that is the register number and value in each case, but poking into
tex.hashtokens seems like it probably is not the correct thing to do
and I'm not sure I'm supposed to assume that all the countdef tokens
get consecutive identifying integers?





v=tex.hashtokens()["qqq"][2] - tex.hashtokens()["attrzero"][2]
texio.write_nl("qqq is attribute: "  .. v .. " value: " .. tex.attribute["qqq"])

v=tex.hashtokens()["hhhz"][2] -tex.hashtokens()["attrzero"][2]
texio.write_nl("hhhz is attribute: "  .. v .. " value: " ..

v=tex.hashtokens()["zzz"][2] -tex.hashtokens()["pageno"][2]
texio.write_nl("zzz is count: "  .. v.. " value: " .. tex.count["zzz"])



More information about the luatex mailing list