[lltx] linebreak_filter problems

Frank Mittelbach frank.mittelbach at latex-project.org
Sun Jun 10 20:49:27 CEST 2012

Am 10.06.2012 16:50, schrieb Frank Mittelbach:
> Hi folks,
> can somebody help me to identify if I do something wrong or if there is
> a bug with linebreak_filter.
> Th problem is documented at length in
> http://tex.stackexchange.com/questions/59176/lastnodetype-not-working-as-expected-in-luatex
> In a nutshell I try to replace (at certain times) TeX's linebreaking
> algorithm and replace it with a simple version that just packs up the
> hlist into an hbox and returns that.
> If I do that the resulting box appears on the current vertical list (ie
> is seen via \showlists) but at the same time
> \lastnotetype returns -1
> \lastbox picks up a void box
> ie to some parts of TeX the list appears to be empty.


I'm not sure I fully understand the implementation yet, but it seams to 
me that the reason for the problem is that the tail pointer for the 
current list is not updated if the linebreak_filter acts, i.e., there is 
code to set up just_box, but in the end cur_list.tail_field remains 
pointing to the last node before the newly appended list rather than to 
its tail.

In other words somewhere around here

         if (callback_id > 0) {
             /* find the correct value for the |just_box| */
	    halfword box_search = cur_list.tail_field;
             just_box  = null;
	    if (box_search != null) {
                 do {
	            if (type(box_search) == hlist_node) {
                        just_box = box_search;
/* perhaps simply like this */
                     cur_list.tail_field = box_search
/* end mod */
                     box_search = vlink(box_search);
                 } while (box_search != null);

one could update the tail position.


More information about the lualatex-dev mailing list