DannySeidel / typst-dhbw-template

Unofficial Typst DHBW Template
MIT License
12 stars 11 forks source link

Customize Page Numbering Format #18

Open christian-leingang opened 2 days ago

christian-leingang commented 2 days ago

Problem

The Page Numbering Format is currently hard-coded: lib.typ ll. 400.

Solution

Introduce a new option for the page numbering format, such as numbering: "1" or numbering: "1/1", to make the template more adaptable. (See Typst page setup guide for reference)

Current Workaround

Add the following snippet below the main configuration and before the content:

#set page(footer: context [
  #h(1fr)
  #counter(page).display("1")
])

However, this workaround overrides the entire footer.

DannySeidel commented 22 hours ago

Hi there 👋🏻

This was previously possible, but I omitted it because I couldn't get it working with the three different numbering styles.

The problem is that in order to get the total page count at the end of the main section with the Latin numbering, I have to create a custom footer passing ..counter(page).get() for the current page and ..counter(page).at(<some-label>) to get the total number of pages.

Like this:

  set page(
    numbering: "1",
    footer: context align(
      numbering-alignment,
      numbering(
        "1 / 1",
        ..counter(page).get(),
        ..counter(page).at(<end>),
      ),
    ),
  )

If you now provide "1" as numbering, the footer still displays the numbering like this "11", so current-page total-pages without a space in between. This means I have to remove ..counter(page).at(<end>), but if I remove it and you provide a style that shows the total number of pages, the total number of pages will always be 1 as the data is missing.

I will take a look again and see if I can find a solution 🤞🏻