You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Line of a breakable block is lost when a float is deferred to the next page #8890
A line of text disappears when a breakable block splits onto a page whose space is reduced by a deferred float.
#setpage(width: 60pt, height: 100pt)
#v(30pt)
#figure(rect(height: 60pt), placement: auto)
#block[A \ B \ C \ D \ E]
Page 1 shows A, B, C. Page 2 shows the float and E. D is missing in PNG, SVG and PDF output.
If the lost line contains the start of a link, PDF export fails instead:
error: internal error: expected link ancestor in logical tree (occurred at crates/typst-pdf/src/link.rs:107:10)
That's how I ran into it in a larger document. The error is the same as in #7777 and #8608, but the cause is different, and it still happens on main after #8778.
The cause seems to be that a breakable block is laid out again for every page it spills onto, and the earlier pages don't always come out the same way (the comment in MultiSpill::layout in flow/collect.rs mentions this). Here widow prevention (distribute.rs:350-360) moves D to the next page only if D and E fit there. On page 1 the next page is assumed to be empty, so D moves. Once page 2 is laid out with the float, D and E no longer fit, so D stays on page 1 in that layout. Page 1 uses the first layout and page 2 uses the second, and D ends up on neither.
I have a local patch that detects when the new layout changes an already emitted frame and skips the region instead. Happy to open a PR if that approach sounds acceptable.
Same underlying issue as #8487, but I've closed the other one since it has more irrelevant tangents and is less to the point.
I was aware of the potential for this issue when writing the original code but misjudged the likelihood of it practically happening. The fix proposed by AI is interesting. It is an extremely hacky band-aid, but at least feasible without rewriting large swaths of the layout engine. I will think about what to do here.
Activity
ManuelLerchner commentedon Sep 24, 2026
A proof-of-concept patch is on my fork, written with AI help. Not a PR, just in case it helps with the diagnosis: ManuelLerchner/typst@main...fix-lost-line-breakable-block
internal error: parent groupwhen usingplacement: autoinfigurefor some large content #8487 as a duplicate of this issuelaurmaedje commentedon Sep 28, 2026
Same underlying issue as #8487, but I've closed the other one since it has more irrelevant tangents and is less to the point.
I was aware of the potential for this issue when writing the original code but misjudged the likelihood of it practically happening. The fix proposed by AI is interesting. It is an extremely hacky band-aid, but at least feasible without rewriting large swaths of the layout engine. I will think about what to do here.