Short version of a heading inside the header?

Hello @jlb, this is possible using a combination of queries in the page header. You will find below a full example that also supports numbering, which is trickier in the header as it is right before the heading.

Queries are very powerful indeed, don’t hesitate to play with them. You can also inspect the content of queries directly by hovering over the variable. See

#set heading(numbering: "1.1")
#show heading.where(level: 1): set heading(supplement: "Chapter")
#set page(header: context {
  let h = query(selector(heading.where(level: 1)).before(here()))
  if h.len() == 0 {
    h = query(selector(heading.where(level: 1)).after(here())).first()
  } else {
    h = h.last()
  }
  let s = query(selector(metadata).after(h.location())).filter(it => it.value.children.first().text  == "h:").first()
  let short = s.value.children.slice(1).first()
  align(center, {
    h.supplement
    " "
    if h.numbering != none { numbering(h.numbering, ..counter(heading).at(s.location())) }
    [ -- ]
    short
  })
})
#let chapter(long, short) = {
  heading(long) 
  metadata("h:" + short)
}

#chapter[This is a very long title][Short 1]

#pagebreak()

#chapter[Long][Short 2]