Repository navigation
Page-dependent layout does not converge (current algorithm seems linear) #4530
Replies: 2 comments
|
Using the However the case when a song must spread over multiple pages still seems to be linear (so adding more songs make the |
|
The diagnostics proposed in #7364 helped me tweak my autobreak feature, by noticing that the first run indicates This was quite surprising at first sight, because I insert a page-break before the first Since my "algorithm" inserted page break on odd pages (like The actual bug is not resolved, but at least I can much better understand how Typst works! 🎉 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Related to #4528 and #993: I am trying to implement an
autobreakfeature, so that songs of a songbook are (when possible) not split on multiple pages.The logic I implemented checks the length of the given content, when calling
#autobreak[some content]:However with my current implementation, Typst converges in linear time, so when too many songs are present, it fails with
layout did not converge within 5 attempts(8 songs in this example: https://typst.app/project/r9GASqmDOYasvWLDv5x4cI).I recompiled Typst with slight code change, to see the intermediary steps crates/typst/src/lib.rs#L153:⚠️ use only for debugging ⚠️ )
MAX_ITER=3 cargo run -- compile ...(Left: 1st iteration, middle: 2, right: 3rd iteration

(one can see the pagebreak are being added one-by-one, at each iteration)
From what I understand, in a given iteration, the
layoutis not built one page after the other, but laid out at once and then put on pages (at which point the scripting has already been executed). On the next iteration, the page number available via scripting is the one from the second part of the previous step.So in my case, this seems to result in needed about as many iteration as pages (hence "linear").
Question: is there a way to implement the
autobreakfeature without requiring linear iterations, with the current state of Typst?Or what change would be needed to Typst in order to support such a usecase? (Since #993 got more than 30 👍 it seems that people are interested in such a feature)
@zinifier seems to have a similar issue for booklets generation (can you share your code? If you only add pages once at the end, it should converge)
All reactions