[luatex] rounding errors with node.dimensions?
frank.mittelbach at latex-project.org
Wed Apr 13 09:52:03 CEST 2016
I'm looking for a simple way to determine if a paragraph breaking (by
tex.linebreak) has some overfull boxes inside.
My simple idea was to traverse the resulting list from tex.linebreak and
use node.dimensions to compare for each hbox
- n.width width of the box
- node.dimensions( n.glue_set, n.glue_sign, n.glue_order, n.head )
which should give me the internal width of all nodes inside with the
glue setting applied (at least that's the way I understand the manual).
So if the latter is larger than n.width we should have an overfull box.
To my surprise I ended up with many more overfulls than reported by TeX
itself and those extras all showed a differences of only a few sp, eg 1
or 2, so I guess what I'm seeing is some sort of rounding error or
miscalculation by node.dimensions.
It is probably possible for me to work around that simply by only
looking at cases with n.glue_set == 1 but regardless of that I think it
is a bug in node.dimensions because the value should be "exact" not "close"
Below is an MWE that reports 2 possible overfulls only one of which
function get_hlist_content (hlist)
local text, n
text = ""
for n in node.traverse (hlist.head) do
if n.id == 37 then
text = text .. string.char(n.char)
elseif n.id == 10 then
text = text .. " "
function postlinebreak (head, groupcode)
for n in node.traverse_id(0, head) do
base=node.dimensions( n.glue_set, n.glue_sign, n.glue_order, n.head )
if n.glue_sign == 2 and n.glue_order == 0 then
print("Glue set:", n.glue_set)
if n.width < base then
print("Node dimensions:", n.width, base, base - n.width,
print("Node dimensions: --- " .. get_hlist_content (n) )
print("Node dimensions:", n.width, base, "ok")
luatexbase.add_to_callback("post_linebreak_filter", postlinebreak, "new
\parindent=10.00002pt % strange latex value
At that moment they were met from another walk by Mrs. Hurst and
"I did not know that you intended to walk," said Miss Bingley, in some
confusion, lest they had been overheard.
"You used us abominably ill," answered Mrs. Hurst, "running away without
telling us that you were coming out."
Then taking the disengaged arm of Mr. Darcy, she left Elizabeth to walk
by herself. The path just admitted three. Mr. Darcy felt their rudeness,
and immediately said:
More information about the luatex