Page numbering: How to use characters as-is and not as counting symbols? (Page x of y)

Hi,
I basically want this page numbering format:

#set page(numbering: "Page 1 of 1")

It catches the a as a counting symbol and changes it to Pbge, Pcge, … . This is obviously not my intended behavior.

On the one hand I want to ask: What is the correct way to do that in typst?

And as the solution will probably not be that simple (?): I think there should be a simple way to either escape characters. Or a syntax like f"Page {num} of {total}" in Python.

My current Workaround is using a cyrillic а instead of a latin one. Looks close enough for me.

#set page(numbering: "Pаge 1 of 1")

Anyways, thanks so much for creating such a great LaTeX alternative! I really enjoy working with typst!

Best,
Thomas

Hi @Thomas4934, welcome to the forum,

You have correctly identified the problem (and the solution). To achieve this, you can use a numbering function:

#set page(numbering: (page, total) => [Page #page of #total])
3 Likes

Thank you very much! Works perfectly! Could we maybe put this example into the documentation? Ideally in Page Setup – Typst Documentation as well as Numbering Function – Typst Documentation .

Which parameters the function passed to the numbering function needs (the (page, total) part) is not well documented in my opinion.

1 Like

There are more ways of doing it, like this way using Counter Type – Typst Documentation, which gives more control over the footer:

#set page(footer: context [Page #counter(page).display("1 of 1", both: true)])

or even

#let nb = (page, total) => [Page #page de #total]
#set page(footer: context { counter(page).display(nb, both: true) })

EDIT: I have updated the code example.

Valid point. Most of it comes from: Page Function – Typst Documentation

Accepts a numbering pattern or function taking one or two numbers:

  1. The first number is the current page number.
  2. The second number is the total number of pages. In a numbering pattern, the second number can be omitted. If a function is passed, it will receive one argument in the context of links or references, and two arguments when producing the visible page numbers.

Your input is relevant as this is not likely to be easy to find for everyone looking at the current documentation. Some relevant posts about Typst documentation suggestions, where you are welcome to participate and share your opinion:

That being said, a lot can be found on the forum (and our Discord) and we are always happy to help.

I’ve moved your post to the Questions category and added the numbering tag.

If your question has been answered, please consider marking :white_check_mark: the reply you found most helpful so others can easily find the solution.

1 Like