Lua-widow-control begins processing the page after it has already been broken, but before the output routine¹. This is after the inserts for the page have already been processed². If the last line has a footnote, the "footnote mark" will be moved, but the "footnote text" will remain on the previous page.
To fix this, we need to traverse through the last line and find the class and index of any ins nodes. Then we can iterate through tex.getbox(<insert class>), pull any boxes with a matching index, and put them back into tex.lists.page_ins_head.
The problem here is that so much of this information is removed after the page is broken. I'm pretty sure that all of the ins nodes are already gone, and the contents of \box<insert class> aren't labeled with the insert index. I might need to hook into build_page_insert to mark some boxes with a lua-widow-control attribute. This is a tricky one.
Reported in #26 by @hpvd.
¹ Lua callback: pre_output_filter
² TeXbook p. 123
Todo
[ ] Tag inserts with an attribute at build_page_insert
[ ] Detect when an insert is in the moved line (last_line)
[ ] Pull the correct box out of tex.getbox(<insert class>)
[ ] Push this box back into tex.lists.page_ins_head
Lua-widow-control begins processing the page after it has already been broken, but before the output routine¹. This is after the inserts for the page have already been processed². If the last line has a footnote, the "footnote mark" will be moved, but the "footnote text" will remain on the previous page.
To fix this, we need to traverse through the last line and find the class and index of any
ins
nodes. Then we can iterate throughtex.getbox(<insert class>)
, pull any boxes with a matching index, and put them back intotex.lists.page_ins_head
.The problem here is that so much of this information is removed after the page is broken. I'm pretty sure that all of the
ins
nodes are already gone, and the contents of\box<insert class>
aren't labeled with the insert index. I might need to hook intobuild_page_insert
to mark some boxes with a lua-widow-control attribute. This is a tricky one.Reported in #26 by @hpvd.
¹ Lua callback:
pre_output_filter
² TeXbook p. 123Todo
build_page_insert
last_line
)tex.getbox(<insert class>)
tex.lists.page_ins_head