Can you access the physical page count?

Hi,
is there a way to retrieve the physical number of pages from within Typst, even if the logical number might have changed, e.g. due to a reset of the respective page counter?
I’d like to use different pagenumbers starting with a new count for the annex, which prevents me from simply doing

#context counter(page).get().last() 

to get the total amount.

One possibility would be to add an empty element at the end of the document, which you can query and get the location from.

Total Pages: #context query(<end>).first().location().page()

... // All your content, including appendix

#[] <end>

You can of course also put that empty element in a show-all rule, so you don’t need to add additional boilerplate at the end of the document, when the rest of the document setup is somewhere else:

#show: it => it + [#[] <end>]

Thanks, i was unaware that the page returned by location() is the physical page. This is exactly what I need, albeit it feels somewhat hacky.

By the way #context locate(<end>).page() is short, sweet and does the same :slight_smile:

2 Likes