[luatex] Dimensions of subboxes
Eduardo Ochs
eduardoochs at gmail.com
Mon Apr 25 08:52:53 CEST 2022
On Mon, 25 Apr 2022 at 03:26, Patrick Gundlach <patrick at gundla.ch> wrote:
> (...)
Hi Patrick!
The trick with coroutines looked like overkill, but there were some
very useful comments... I followed some links, and got the solution
below. If I send these lines to a shell,
cd /tmp/emlua/tex/
cat > a.tex <<'---'
\setbox0\hbox{\hbox{$a$}\hbox{$b$}\hbox{$p$}\hbox{$q$}}
\directlua{dofile "edrxlib.lua"}
\directlua{dofile "Repl1.lua"}
\directlua{REPL = EdrxRepl.new(); print(); REPL:repl()}
\bye
---
luatex a.tex
adj = 2^16
print(tex.box[0])
print(tex.box[0].width)
print(tex.box[0].width / adj)
for hlist in node.traverse_id(node.id"hlist", tex.box[0].list) do
local wd = hlist.width / adj
local ht = hlist.height / adj
local dp = hlist.depth / adj
print(format("wd: %.3f ht: %.3f dp: %.3f", wd, ht, dp))
end
Then the log of my interaction with luatex is this:
This is LuaTeX, Version 1.12.0 (TeX Live 2020)
restricted system commands enabled.
(./a.tex
>>> adj = 2^16
>>> print(tex.box[0])
<node nil < 387 > nil : hlist 2>
>>> print(tex.box[0].width)
1273476
>>> print(tex.box[0].width / adj)
19.431701660156
>>> for hlist in node.traverse_id(node.id"hlist", tex.box[0].list) do
... local wd = hlist.width / adj
... local ht = hlist.height / adj
... local dp = hlist.depth / adj
... print(format("wd: %.3f ht: %.3f dp: %.3f", wd, ht, dp))
... end
wd: 5.286 ht: 4.306 dp: 0.000
wd: 4.292 ht: 6.944 dp: 0.000
wd: 5.031 ht: 4.306 dp: 1.944
wd: 4.823 ht: 4.306 dp: 1.944
>>>
So: problem solved! Thanks! =)
Eduardo Ochs
http://angg.twu.net/
More information about the luatex
mailing list.