Skip to content

Fix pagebreak to check - #2475

Merged
laurmaedje merged 3 commits into
typst:mainfrom
Zheoni:fix-pagebreak-to
Oct 25, 2023
Merged

laurmaedje merged 3 commits into
typst:mainfrom
Zheoni:fix-pagebreak-to

Conversation

@Zheoni

@Zheoni Zheoni commented Oct 23, 2023

Copy link
Copy Markdown
Contributor

After #2182 the parity check was inverted because the empty frame was added to the end of the old styles (I think). This introduced the problem where the page counter was being checked with the current number of pages and not taking into account the pages that were about to be appended. This problem was not noticeable when between pagebreaks the content didn't introduce more than one page. This PR fixes the parity check and adds a new entry to the existing test. Also, fixes #2473.

This is my first time fiddling with typst source code and although it's a small PR, please be careful when reviewing it. Sorry in advance if I broke anything 😓.

@Zheoni

Zheoni commented Oct 24, 2023

Copy link
Copy Markdown
Contributor Author

There's still (at least) one problem this does not fix: a pagebreak(to: "even", weak: true) at the beginning of the document, when the first page is empty, will not work and won't add an empty page:

#set page(paper: "a8", numbering: "1")

#pagebreak(to: "even", weak: true)

Second

Renders (also since #2182):
image

And it should render (as it does in 0.8.0):
image

I have been trying to understand the layout/resolution code and I think it's because weak pagebreaks are removed before the empty pages are added to match parity. That removes the page with the clear_to style and therefore it's never added? Maybe my reasoning is wrong, but the issue is there.

However, this PR still solves the original issue. I now don't know if the correct path is to continue working in solving this new thing in this PR or open a new issue.

@PgBiel PgBiel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fair to merge this PR first and then make a separate issue/PR pair for the other problem.

Comment thread tests/typ/layout/pagebreak-parity.typ Resolved
@PgBiel

PgBiel commented Oct 24, 2023

Copy link
Copy Markdown
Contributor

In principle (from a brief analysis including the surrounding code), LGTM.

cc @laurmaedje for further opinions

@laurmaedje

Copy link
Copy Markdown
Member

I will take a closer look later, but this does make sense.

@laurmaedje
laurmaedje merged commit c29a31b into typst:main Oct 25, 2023
@laurmaedje

Copy link
Copy Markdown
Member

Thanks!

Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pagebreak to does not behave correctly (again)

3 participants