"1 / 1" numbering: How to get correct max page number?

I am currently working on a template that has some template content after the users content. This leads to the max page number to be “wrong” in the content section when using “1 / 1” or similar as numbering format.

// content
#set page(numbering: "1 / 1")
#counter(page).update(1)


#lorem(9999)

// appendix
#set page(numbering: "i")
#counter(page).update(1)

#lorem(999)

This is a minimal version showing this problem: lorem(999) produces two pages, leading to the footer in the content section showing “x / 2”, even though the content section has 15 pages.

The easy solution would probably to use a label selector to find the last page of the content section and built the “1 / 1” numbering with a custom function. This is not viable in my situation, as the numbering should be customizable by the user. The user should be able to set the numbering to their liking with a single parameter (numbering-content).

How do I fix the wrong max page in “1 / 1” numbering styles, without receiving additional information from a template user?

The user should be able to set numbering-content to “1 / 1”, “I”, or whatever they want.

Hi @Marvin_Fuchs.

This has been resolved before (duplicate).

Multiple sections

Please have a look at the solution from How to reset the page counter after every section? - #10 by laurmaedje

Only one section - To switch from arabic to roman

You can also use a shorter solution from How can I switch from Roman to Arabic page numbers without breaking the total page count? - #2 by janekfleper

#let arabic-numbering(..n) = context {
  numbering("1 / 1", n.at(0), ..counter(page).at(<last-arabic-page>))
}
// content
#set page(numbering: arabic-numbering)
#counter(page).update(1)

#lorem(9999)
#metadata("last-arabic-page") <last-arabic-page>

// appendix
#set page(numbering: "i")
#counter(page).update(1)

#lorem(999)

2 Likes