Fix incorrect total page count

Without this fix, the total page count shows the value of the very last page (which has its number shown in Roman numbers).

Fixes bug introduced in commit `4cba67d`
This commit is contained in:
Laurenz 2024-08-07 15:15:06 +02:00
parent 4cba67d231
commit 94453b731c
Signed by: C0ffeeCode
SSH key fingerprint: SHA256:jnEltBNftC3wUZESLSMvM9zVPOkkevGRzqqoW2k2ORI
2 changed files with 20 additions and 5 deletions

Binary file not shown.

View file

@ -429,7 +429,17 @@
<roman_counter_preliminary_end> <roman_counter_preliminary_end>
// update heading and page numberings to begin the main part of the document // update heading and page numberings to begin the main part of the document
#set heading(numbering: "1.1") #set heading(numbering: "1.1")
#set page(numbering: "1 / 1") #set page(
numbering: "1 / 1",
// manipulate the footer to display the correct total page count
// otherwise it would show the value of the very last, Roman-numbered page
footer: align(center, context numbering(
"1 / 1",
..counter(page).get(),
// get the last page counted with Arabic numbers
..counter(page).at(<arabic_counter_end>).map(i => i - 1))
)
)
#counter(page).update(1) #counter(page).update(1)
#pagebreak(weak: true) #pagebreak(weak: true)
@ -449,11 +459,16 @@
// the actual chapters // the actual chapters
#body #body
#set page(numbering: "I") // reset footer to how it looked before
// reset the page numberings to the value of the last page counted in Roman numerals #set page(numbering: "I", footer:
#context counter(page).update( align(center, context numbering("I", ..counter(page).get()))
counter(page).at(<roman_counter_preliminary_end>).first()
) )
// reset the page numberings to the following value of the last page counted in Roman numerals
#context counter(page).update(
counter(page).at(<roman_counter_preliminary_end>).first() + 1
)
// used to obtain the total page count of Arabic numbered pages
<arabic_counter_end> // Placing this above does not work
// finally, include the bibliography chapter at the end of the document // finally, include the bibliography chapter at the end of the document
#pagebreak() #pagebreak()