How to show Roman and Arabic page numbers correctly in the table of contents?

Hi everyone,

I’m working on a document in Typst where I want to use different page numbering styles:

  • The front matter (e.g. table of contents) should use Roman numerals (I, II, III, …).
  • The main content should use Arabic numerals (1, 2, 3, …).
  • In the footer, this works fine with:
#set page(footer: context [
  #set text(size: 10pt)
  #align(center)[#counter(page).display("I")]
])

However, the problem is that in the table of contents (#outline()), the page numbers are still displayed in Arabic numerals, even if they are shown in Roman numerals in the footer.

Important notes:
I can’t use #set page(numbering: "I") because I need the page numbers to be displayed in 10pt font, and this setting doesn’t allow me to control the text size of the numbers in the footer.

Is there a way to make #outline() reflect the actual display format of the page numbers – Roman or Arabic – depending on the section? In other words: Can I make the page numbers in the TOC match what is shown in the footer?

And if this isn’t directly supported, is there a workaround (e.g. with #show outline.entry or counter(page).at(...)) to conditionally change the format shown in the TOC based on section or page number?

Thanks in advance for your help! :pray:

Yes you can and have to use this for the outline to know about it. However, you can combine this with your custom footer, where you can just display the counter with the currently set page numbering instead of hard-coding it to "I":

#set page(numbering: "I", footer: context {
  set text(size: 10pt)
  align(center, counter(page).display()) // Automatically uses page.numbering
})

/* Front matter with roman numbering */

#set page(numbering: "1")

/* Main content with arabic numbering */
2 Likes