Am 10.03.16 um 09:51 schrieb Hans Hagen:
On 3/9/2016 8:48 PM, Frank Mittelbach wrote:
I think I found a bug in tex.linebreak.
Consider the following code
function prelinebreak (head, groupnode) --- for pre_linebreak_filter
--- for example
local n,t
n, t = tex.linebreak(node.copy_list(head), {looseness = -1})
print("looseness=" .. t.looseness)
n, t = tex.linebreak(node.copy_list(head), {looseness = 0})
print("looseness=" .. t.looseness)
return true
end
and pass it in head a long enough hlist so that looseness -1 actually
works. The second line breaking with looseness=0 reports the previous
looseness ... same happens if you have looseness=+2 or +1 or so
it seems that tex.linebreak always reports the looseness of the previous
linebreak action in case you pass it a "0"
it helps if you also set some more (either explicit or at the tex
level), like:
looseness=1,
tolerance=4500,
pretolerance=100,
emergencystretch=655360
not sure I understand Hans, on the TeX they are set (once) -- are you
saying one needs to set them as part of the params table for
tex.linebreak as in
{ looseness = 0, tolerance = tex.tolerance ....
just re-providing to tex.linebreak what is already set on the TeX level?
my thoughts without having seen the internal code of tex.linebreak is
that if looseness = 0 the value that is reported at the end is actually
never set so retains whatever the last time was put there (which is not
making a problem while it is always 0 but shows the wrong value once you
ever set it to non-zero and later back
frank