[luatex] Strange cost in pagebreaking.

Paul Isambert zappathustra at free.fr
Wed Oct 16 17:18:25 CEST 2013


Thank you Luigi (still trying to make me read C code :) ),
Thank you Taco (though I believed you could reverse-engineer
a .tex source from a .log file),
and thank you Ulrike (who set me on the right track),

Indeed the problem came from insertions (it was so obvious that they
might be involved that I somehow refused to see it, nor did I mention
it): when you split an insertion at penalty X, then X is added to the
cost of the pagebreak calculation (in \insertpenalties). Now if an
insertion must be split, a penalty of -10000 is added at the end of
its box so TeX is sure to find a feasible breakpoint. My insertions
were split at the end (I’d designed them hastily and forgotten to
define the associated \dimen, plus they were fully unbreakable boxes),
and I had two classes of insertion, hence twice -10000.

So \insertpenalties was -20000, and the strange thing is that the
cost of a breakpoint is (generally) calculated as badness + penalty +
insertpenalties, unless the penalty is < -10000, in which case the
cost is that penalty (which forces pagebreak); but if that penalty is
less than \insertpenalties (as was the case for me), the best
breakpoint is before it, in my log at line 17:

16. % t=197.27 plus 2.0fil g=498.47559 b=0 p=150 c=-19850     < c = b+p+\insertpenalties
17. % t=209.27 plus 2.0fil g=498.47559 b=0 p=0 c=-20000#      < c = b+p+\insertpenalties
18. % t=209.27 plus 3.0fil g=498.47559 b=0 p=-11000 c=-11000  < c = p, and forces break

That behavior is slightly surprising, but it is so in legacy TeX. So
I’ll try to find the rationale behind it, and if I find none, I’ll
declare it a bug in TeX (ha ha).

Thanks to all, and sorry for the noise,
Paul

Ulrike Fischer <luatex at nililand.de> a écrit:
> Am Tue, 15 Oct 2013 22:08:58 +0200 schrieb Paul Isambert:
> 
> > Hello all,
> > 
> > I¢ve encountered a problem which I definitely can¢t solve. It looks
> > like a TeX problem, but since I really can¢t see what¢s going on I
> > suspect a LuaTeX bug. Unfortunately the problem is extremely sensitive
> > to simple changes, and so I can¢t even compare with a PDFTeX
> > compilation. (And since there is a lot of my own code involved, I
> > cannot do a minimal example either.)
> > 
> > Here¢s what \tracingpages returns in my log file (until the current
> > page is deemed good):
> > 
> > 1.  %% goal height=569.05511, max depth=4.0
> > 2.  % split251 to 0.0,38.12 p=-10000
> > 3.  % split252 to 0.0,103.05 p=-10000
> > 4.  % t=0.0 g=498.47559 b=10000 p=0 c=100000#
> > 5.  % t=22.0 g=498.47559 b=10000 p=150 c=100000#
> > 6.  % t=45.22 g=498.47559 b=10000 p=0 c=100000#
> > 7.  % t=70.16 g=498.47559 b=10000 p=0 c=100000#
> > 8.  % t=93.27 g=498.47559 b=10000 p=150 c=100000#
> > 9.  % t=105.27 g=498.47559 b=10000 p=0 c=100000#
> > 10. % t=121.27 plus 1.0fil g=498.47559 b=0 p=150 c=-19850#
> > 11. % t=133.27 plus 1.0fil g=498.47559 b=0 p=0 c=-20000#
> > 12. % t=145.27 plus 1.0fil g=498.47559 b=0 p=0 c=-20000#
> > 13. % t=157.27 plus 1.0fil g=498.47559 b=0 p=150 c=-19850
> > 14. % t=169.27 plus 1.0fil g=498.47559 b=0 p=0 c=-20000#
> > 15. % t=185.27 plus 2.0fil g=498.47559 b=0 p=150 c=-19850
> > 16. % t=197.27 plus 2.0fil g=498.47559 b=0 p=150 c=-19850
> > 17. % t=209.27 plus 2.0fil g=498.47559 b=0 p=0 c=-20000#
> > 18. % t=209.27 plus 3.0fil g=498.47559 b=0 p=-11000 c=-11000
> > 
> > What bothers me is line 10 and following: where does the cost of
> > -20000 comes from? There is no penalty of that value for each of those
> > line, so I really can¢t see how it can be computed (since, basically,
> > the cost of a breakpoint is badness + penalty).
> 
> The cost are badness+penalty+\insertpenalties where \insertpenalties
> is more or less (see page 122-126 of the texbook) the sum of the
> split penalties. But the costs are only calculated when the badness
> is <10000.
> 
> You have two splits:
> 
> > 2.  % split251 to 0.0,38.12 p=-10000
> > 3.  % split252 to 0.0,103.05 p=-10000
> 
> with penalties of -10000 and so  in line 10 when the badness is 0
> their penalties are added to the costs. 
> 
> So the main question is where is the source of the split penalties. 
> 
> With 
> \interfootnotelinepenalty=-10000
> \lipsum[1]\footnote{\lipsum[1]}
> \lipsum[1]\footnote{\lipsum[1]}
> \lipsum[1]\footnote{\lipsum[1]}
> \lipsum[1]\footnote{\lipsum[1]}
> \lipsum[1]\footnote{\lipsum[1]}
>  
> I get 
> 
> % split253 to 42.00006,31.45 p=-10000
> % t=323.80014 plus 7.0 minus 2.0 g=334.3502 b=341 p=0 c=-9659#
> 
> But that is not the default value, and I don't know how to get two
> splits.
> 
> -- 
> Ulrike Fischer 
> http://www.troubleshooting-tex.de/
> 



More information about the luatex mailing list