Skip to content

Read a page's numbering by physical page number #9077

Open

Description

@veralvx

Description

A script can read a page's numbering only through location.page-numbering(), so it needs a locatable element on that page. Pages with nothing locatable on them can't be read: a page a paragraph only runs on to, the blank left by pagebreak(to: "odd"), a page of a shape alone, or text set in a block, grid or place without a paragraph break. Typst's own folio isn't locatable either. A script therefore can't tell a numbered page from an unnumbered one, although the introspector already stores every page's numbering.

#set page(width: 6cm, height: 4cm, numbering: "1")
Text
#pagebreak()
#lorem(30)                       // runs on to page 3
#page(numbering: none)[#rect()]  // page 4, unnumbered
#set page(numbering: "i")
#counter(page).update(1)
Index

Pages 3 (numbered 3) and 4 (unnumbered) both have nothing locatable, so they look the same to a script. The only workaround is a context in every page's header, footer or background, which a package can't add without overriding the user's page settings, and which a page can turn off with header: none.

Possible API

  • A function giving a page's numbering (and supplement) by physical page number, or
  • a way to get a location for a page, on which page-numbering() already works.

Related: #1321 (page properties on locations), #2722 (empty pages), #8387 (PDF page labels missing for numbering functions).

Use Case

A package that builds a book's catalogue record needs its page sequences (xii, 310 p., [3] p. of plates).

Activity

  1. added
    feature request
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions