How to show roman page numbers in the header within the outline and arabic elsewhere?

I’m showing the current page number in the header as follows:

set page(
    ...
    header:  ...
       text(font: heading-font, size: 9pt, number-type: "lining",
          context counter(page).display()),

That works basically fine. But I would like

  • to show roman numbers (“i”, “ii”, …) on the pages of the outline
  • then reset the page counter to 1
  • and to show arabic numbers within the header of the rest of the document

How can this be achieved?

Resetting the page number by counter(page).update(1) when starting “the rest of the document” doesn’t affect the number displayed in the header of the first page. There it shows the next page number after the outline (e.g. if the outline has numbers 1 and 2, then it shows 3).

And I have the problem when changing the number style (roman/arabic), that it doesn’t affect the display of the number in the header.

I could solve the problem with the (in-)correct numbering as follows:

I don’t do counter(page).update(1) on the first page, but counter(page).update(0) on the page before (before the page break of the preceding page).

Is this the “correct” way to do it?

There is a neat trick that should work since v0-12, which is to put page counter updates between pages:

#pagebreak()
#counter(page).update(0)
#pagebreak(weak: true)

whether the first or the second pagebreak is weak shouldn’t matter, but one must be weak. This will make sure that the counter is updated after any footer on the old page, but before any header on the new page.

Even then, I have updated the counter to 0, since it is incremented at the beginning of each page: setting it to 1 would lead to the first shown page number being 2, which is intended behavior.

Unless you have both header and footer with line numbers, updating to zero is sufficient and the correct solution. If you have both, doing the between-page-trick is additionally necessary.

1 Like

Thanks @SillyFreak for that really neat trick!

So, together with How to put different page numbering in outline? - #6 by Roland_Schatzle, my questions are (almost) completely answered :blush:.