[luatex] Bug in tex.linebreak ?

Hans Hagen pragma at wxs.nl
Thu Mar 10 11:57:08 CET 2016


On 3/10/2016 11:01 AM, Frank Mittelbach wrote:
> you are proving my point aren't you?
>
>> \setbox0\hbox{\input tufte }
>> \directlua{
>>      local n,t,head
>>      head = tex.box[0].head
>>      n, t = tex.linebreak(node.copy_list(head), {looseness=1})
>>      print("1.1",t.looseness)
>>      n, t = tex.linebreak(node.copy_list(head), {looseness=0})
>>      print("1.2",t.looseness)
>> }
>> \directlua{
>>      local n,t,head
>>      head = tex.box[0].head
>>      n, t = tex.linebreak(node.copy_list(head), {looseness=1,
>> tolerance=4500, pretolerance=100, emergencystretch=655360 })
>>      print("2.1",t.looseness)
>>      n, t = tex.linebreak(node.copy_list(head), {looseness=0,
>> tolerance=4500, pretolerance=100, emergencystretch=655360 })
>>      print("2.2",t.looseness)
>> }
>> \tolerance4500 \pretolerance100 \emergencystretch10pt
>> \directlua{
>>      local n,t,head
>>      head = tex.box[0].head
>>      n, t = tex.linebreak(node.copy_list(head), {looseness=1})
>>      print("3.1",t.looseness)
>>      n, t = tex.linebreak(node.copy_list(head), {looseness=0})
>>      print("3.2",t.looseness)
>> }
>>
>> 1.1    0
>> 1.2    0
>> 2.1    1
>> 2.2    1
>> 3.1    1
>> 3.2    1
>
> 1.2   2.2  and 3.2  should show "0"  given that we run the linebreaking
> with looseness zero but 2.1 and 3.1 still show "1"
>
> and if you add t.prevgraf  you can see that it actually does do
> looseness correctly:
>
> 1.1    0    7
> 1.2    0    7
> 2.1    1    8
> 2.2    1    7
> 3.1    1    8
> 3.2    1    7
>
> am I missing something? the first column reports wrong values

[used looseness]

the normal line break function is called with a set if parameters that 
get either values from the given table or the values set at the tex end
so if you set looseness in the table then that value is passed and if 
you don't set it the \looseness value is used

now, the \looseness is normally reset when tex sees a new paragraph but 
here we don't are in that situation so if that one is used we need to 
reset it ourselves

i'll add tex.resetparagraph that resets looseness, hangindent, 
hangafter, parshape and interlinepenalties in one go, something:

         function tex.resetparagraph()
             tex.looseness = 0
             ...
         end

[reported looseness]

the reported looseness (and demerits) are currently variables that 
reflect the state set when actually a possible looseness come in play 
but i'll reset them always now (hopefully not introducing some side 
effects in current usage)

(the prev values are actually taken from the state lists so these are 
less local; that will be left untouched)

[so]

in a next release we will have (1) a resetter in order to simulate par 
behaviour, and (2) an reset of two variables also when not used

hopefully that helps

Hans



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
       tel: 038 477 53 69 | www.pragma-ade.com | www.pragma-pod.nl
-----------------------------------------------------------------


More information about the luatex mailing list