Why is my footer `((..) => ..,)` instead of the page number?

I have the following template, which used to work fine. However, when the new typst version came, it places

((..) => ..,)

at the bottom of the page, instead of the page number.

Could you please help me? Thanks!

#let conf(lang: "en",
  title: none,
  author: [My full name],
  date: datetime.today().display(),
  doc,) = {

  set page(
    paper: "a4",
    numbering: "1",
    footer: context(
      loc => {
        let page-number = counter(page).at(loc).first()
        let match-list = query(selector(<turn-on-page-numbering>).before(loc), loc)
        if match-list == () { return none }
        align(center, str(page-number))
      },
    ),
  )

  set par(justify: true)
  set text(
    font: "Libertinus Serif",
    size: 12pt,
    lang: lang,
  )

  set heading(numbering: "1.")
  show: rest => {
    for i in (5,6) {
      rest = {
        show heading.where(level: i): it => strong(it.body)
        rest
      }
    }
    rest
  }

  show heading: it => {
    it
    v(0.5em)
  }

  set enum(indent: 1em)
  set list(indent: 1em)

  set align(center)
  text(17pt, weight: "bold", title)
  v(2em)
  text(15pt, author)
  v(1.5em)

  text(15pt, date)
  pagebreak()
  set align(left)
  set par(justify: true)

  set enum(full: true, numbering: (..n) => {
      let format = if n.pos().len() > 1 {"a)"} else {"1."}
      numbering(format, n.pos().last())})

  doc
}

Hello @PaulS! The ((..) => ..,) you see comes from your footer.

You can read the topic Why is the value I receive from context always content? to understand context expressions.

This topic β€œHow to use context instead of a callback function in locate function calls? - #2 by quachpas” adresses your issue directly.

Without looking any further, I can suggest the following:

#set page(
    paper: "a4",
    numbering: "1",
    footer: context {
      let page-number = counter(page).at(here()).first()
      let match-list = query(selector(<turn-on-page-numbering>).before(here()))
      if match-list == () { return none }
      align(center, str(page-number))
    },
  )

I also took the opportunity to rename your topic to β€œWhy is my footer ((..) => ..,) instead of the page number?”, if that’s wrong please modify it!
Good titles are questions you would ask your friend about Typst.

2 Likes

Thank you very much indeed, @quachpas! That fixed the issue!

1 Like