I am trying to troubleshoot what happens in the code in Wrong placement (and/or size) of picture / plot with groupplot of table (... and discontinuity)?. So I added \usepackage{lua-visual-debug}
to that example, and built it with lualatex test.tex
; and this is what comes out:
As far as I can tell (by consulting lvdebug-doc.pdf
documentation of lua-visual-debug
), those gray horizontal lines "pushing away" the plot from the left are glues. The problem is - I have no idea how to tell which glues those are; even worse, at end of run, lualatex notes:
...
9093 words of node memory still in use:
123 hlist, 1 vlist, 1 rule, 32 math, 638 glue, 33 glyph, 69 glue_spec, 1 wri
te, 1561 pdf_literal, 18 pdf_colorstack nodes
avail lists: 1:1,2:44,3:2341,4:710,6:41,7:1,9:130
...
... so even if I had a list of glue names of sorts, it would be difficult to trawl manually through 638 glues.
Ideally, what I'd want is to typeset the name of the LaTex glue, right by its rendered lua-visual-debug
line; e.g. I can see that the code responsible for it in lua-visual-debug.lua
is:
elseif head.id == 10 then -- glue
print "Got glue" -- added for debug
local wd = head.spec.width
local color = "0.5 G"
if parent.glue_sign == 1 and parent.glue_order == head.spec.stretch_order then
wd = wd + parent.glue_set * head.spec.stretch
color = "0 0 1 RG"
elseif parent.glue_sign == 2 and parent.glue_order == head.spec.shrink_order then
wd = wd - parent.glue_set * head.spec.shrink
color = "1 0 1 RG"
end
local pdfstring = node.new("whatsit","pdf_literal")
local wd_bp = math.round(wd / number_sp_in_a_pdf_point,2)
if parent.id == 0 then --hlist
pdfstring.data = string.format("q %s [0.2] 0 d 0.5 w 0 0 m %g 0 l s Q",color,wd_bp)
else -- vlist
pdfstring.data = string.format("q 0.1 G 0.1 w -0.5 0 m 0.5 0 l -0.5 %g m 0.5 %g l s [0.2] 0 d 0.5 w 0.25 0 m 0.25 %g l s Q",-wd_bp,-wd_bp,-wd_bp)
end
parent.list = node.insert_before(parent.list,head,pdfstring)
-- print("Got glue; wd " .. tostring(wd))
So, basically, if I'd want to typeset those names, I'd have to insert PDF primitives; I tried adding (Hello world) Tj
to the pdfstring.data
, but nothing comes out.
Considering typesetting the 638 names will be a bit crowded, I'd also settle for typesetting a numeric index in the PDF, and then printing to stdout a list with the index, the LaTex name of command/length/glue, and possibly its width/length value; that should allow somewhat easier inspection.
What I really cannot tell is this - so these are my questions:
- At this point in the
lua-visual-debug
code, are originating Tex command names even available? (I can see LuaTex reference hastoken.command_name
, but at this point I have "nodes" [what nodes?], not "tokens") - If I enable the last
print
there, I can print the widths; it turns out, most of those are 0, however, some are like "Got glue; wd 27571199" -- is this 27571199 inbp
units? How could I print it out, say, in centimeters or in inches? - Is it even possible to insert text PDF primitives at this point in the lua code?
\showoutput
and looking at what is written in thelog
. There you will boxes and glues specified.\showoutput
command, will check it out. Cheers!