I can’t reproduce this bug on typst 0.11.1 by provided code. Is your typst updated or is the page number was affected by other parts of your document?
To expand on @ParaN3xus, can you add a MWE (minimal working example) which demonstrates the problem? That is, a stand-alone minimal Typst document that compiles and shows the incorrect page numbering.
In addition, for the benefit of other co-Typstists please consider tagging your question (e.g. counter) and rephrasing the title so it is clearer what you ask from by just reading the title. This post might be helpful.
From my experience, this kind of numbering issues arise from multiple contextual scripting that conflict with each other or are too large in scope. My advice is to disable every contextual bits and find the culprit. Do your best to reduce the amount of context usage.
I assume you want the title page to not count? I.e. ToC to start on page 2, with page counter 1? You have two issues:
the #counter(page).update(1) appears on page 2, so by that time, the header (EDIT: or in OP’s case, the background) of page 2 was already written, with page counter also 2.
the page counter is incremented at page start. For example the counter start out as 0 and is then immediately incremented to 1 on the first page.
What does this mean?
page 1 starts, the page counter becomes 1 (but there’s no header to show it)
page 2 starts, the page counter becomes 2
still on page 2, the page counter is set back to 1
page 3 starts, the page counter becomes 2
etc.
Which is why you get (no page number), II, II, III, …
The fix is to set the page counter to 0 on page 1, not to 1 on page 2:
So why does it work for the example in the page counter docs? Well, that example shows page numbers in the footer, so setting the counter on the same page is early enough to affect it. I think for now, you have to be aware of where you’re showing the page number when setting the counter: somewhere on the previous page for header, on the new page for footer. A real “set the counter between pages” does not seem to be possible for now.
hmm, interesting problem… maybe pagebreak(to: "even", weak: true) before you reset the page counter?
(I don’t think the problem is that the pagebreak is part of the heading; I think Typst ignores whitespace here correctly. It’s sometimes an edge case though, so maybe it is actually that. What I think is that since the pagebreak may go over two pages, it incremented from 0 to 2 when the first header is produced.)
I didn’t follow the whole conversation, but it might be worth testing the results on the development version because various bugs with respect to interactions of show rules, pagebreaks, and counters were fixed.
To be clear, tinymist is a multi-tool, but the initial and probably mostly used feature is an LSP server, which can be configured with different IDE/text editors.
Hi @enxinjie, I have updated your post’s title to what I thought was a good title according to the response you selected as an answer. If I got it wrong and the new title does not fit your original issue, feel free to change it, but make sure you follow the question guidelines:
Good titles are questions you would ask your friend about Typst.