How to change the header for a single page?

I´ve been using the following piece of code to create chapter titles for my document. However, I´d like to make it so the first header looks like it, the second one like the original first, the third one like the original second and so on. Specially for the website´s index navigator to work just fine. How could I do it?

#let chapter(title: "No title", body) = {
  counter(heading).update(0)
  show figure: set place(center+horizon)
  show figure.caption: strong
  show figure.caption: set text(40pt)
  set figure.caption(position: top)
  pagebreak(weak: true)
  place(center+horizon)[#figure(
    kind: "chapter",
    numbering: "I",
    supplement: "Chapter",
    outlined: true,
    placement: bottom,
    gap: 150pt,
    caption: [\ #title],
    [#body]
  )]
  pagebreak(weak: true)
}

I didn’t quite understand. Do you need a different header for odd and even pages?

If that’s the case:

#set page(
  numbering: "1", // be sure to add page numbering
  header: {
    context {
      let num = counter(page).display().first() // thanks to @PgBiel
      if calc.odd(num) {
        // odd page header
      } else {
        // even page header
      }
    }
  }
)

Hey @Alberto , welcome to the forum! I’ve updated your post title in accordance with our question post guidelines: How to post in the Questions category

Make sure your title is a question you’d ask to a friend about Typst. :wink:


I think they meant that the header should only be changed for the first (or a single) page.

By the way, please don’t use int(counter(...).display()), write counter(...).get().first() instead! :wink:

They have clarified their question in a new thread: Define a new highest header while keeping the others the same