#Custom page numbering in ToC

4 messages · Page 1 of 1 (latest)

arctic vale
#

Hi guys I am working on unofficial template for final theses for our uni and I have last thing to make work but I am struggling with it. Can someone somewhat experienced look at the issue and help me fix it please ?

This is the whole repo and the issues is about the page numbering in ToC regarding appendices which does not correspond with the page numbering on the actual pages.

Any help that would lead to fixing the last thing would be greatly appreciated.

The file containing the logic is the thesis-template/lib.typ file.

Thanks in advance, and I hope this is the place where to ask.

GitHub

Unofficial FIIT STU thesis template for writing in Typst - MeheheCedy22/unofficial-fiit-stu-thesis

wintry mesa
#

is this the problem?

Appendix A should not start with page A-16 and so on

#

I would guess the problem is here

// Reset page counter at each new appendix section
  show heading.where(level: 1): it => {
    // Force a page break first
    pagebreak(weak: true)

    // Reset page counter to 1 for each new appendix
    counter(page).update(1)

    // Render the heading
    set text(size: 23pt)
    show: block.with(above: 15pt, below: 2em, sticky: true)
    if it.numbering != none {
      numbering("A", counter(heading).get().at(0, default: 0))
      h(7pt, weak: true)
    }
    it.body
  }

If we read the logic it says that

  • There is an appendix header
  • We add a pagebreak
  • Then reset the page counter.

This means that there is a page before the pagebreak that contains the appendix header and where the page counter is still the old value. So the order of operations needs to be changed

#

You may need to use this logic:

#show heading.where(level: 1): it => {
  pagebreak(weak: true)
  counter(page).update(1)
  pagebreak(weak: true)
  it.body
}

That seems a bit wonky to me but it looks like it has the right behaviour

See also here https://forum.typst.app/t/how-to-reset-the-page-counter-after-every-section/1924/10?u=bluss

Typst Forum

The counter is resolved based on the logical order of things: The header is logically before the page content, which is followed by the footer. Thus, if you have a counter update within a page, it will be reflected in the footer, but not in the header. However, there is an escape hatch: Typically, what you truly want is to reset the page counte...