How to get rid of "Layout did not converge" warning when pagebreaking on odd pages?

I always want an even number of pages for my document. To do that, I add a pagebreak when the last page number is odd. The problem is that, since I change the page parity in a context block where I check the page parity, I get a warning.

#lorem(100)

#context if calc.odd(here().page()) { pagebreak() }

Layout did not converge within 5 attempts (warning)

How to get rid of that?

I think that pagebreak(to: "even") cannot help in this case, since I don’t want any pagebreak when the page ends on an even page.

I think the issue is that the function call of calc.odd(here().page()) is evaluated again after the new page is added. And since the result will always stay the same the compiler should just continue to add pages, which will obviously not converge.

Thankfully the function pagebreak() directly supports your use case of making sure that the number of pages in the document is even.

#lorem(100)

#pagebreak(to: "odd", weak: true)
1 Like