That’s the correct behavior, the heading counter at that location (the header) has not yet advanced, it advances at the next heading (below the header), this means it will display the last heading’s number.
If you wish to show the number of the heading on this page you need to provide the location for this heading to the counter through the use of query/locate.
You may be interested in hydra – Typst Universe (full disclosure, I’m the author), which would take care of the logic for selecting the correct heading and displaying it.
If you prefer a more manual approach you can take a peek at the source code and write it yourself, but it boils down to query(heading) and filtering out candidates that don’t fit (pages after the current one etc.).
PS: Something I’ve also noticed is that you’re using here().page() in the footer, this will give you the actual page number, not the logical page number of the page counter. You probably meant to use counter(page).display()
Hi @wulfheart, thanks for your question! If you feel the response you got has sufficiently answered your question, be sure to give it a checkmark. This will help others find the solution in the future. Thanks!
@Tinger thanks for your reply. I started using hydra because it was the easiest way. However, I would have thought that it would be simpler with typst. Thanks nevertheless!