How to use page numbering in both header and footer at once?

Without doing this manually

#set align(right+bottom)
Continue Page - 2
#pagebreak()
#set align(center+top)
Page - 2
#set align(right+bottom)
Continue Page - 3
#pagebreak()
#set align(center+top)
Page - 3

You can either set header and footer manually with set page(..) or use numbering and number-align too for the current page count.

#set page(
  numbering: (x, ..) => [Page -- #x],
  number-align: center + top,
  footer: context [
    #set align(right) // Could also use #{ int(counter(page).display()) + 1}.
    Continue Page -- #numbering("1", ..counter(page).at(here()).map(x => x + 1))
  ],
  height: auto
)

#lorem(20)

#pagebreak()

#lorem(20)

How can i adjust the gap between the header and the paragraph? The header had to be tightly spaced inside the margin.
as if
#align(center, [Page – 1 ])
#lorem(500)

Well, the header is part of the top margin so increasing the top margin will also increase the space the header lives in. Furthermore, you can play around with the header-ascent parameter on page which by default is configured at 30%, meaning the header is raised into the top margin.

1 Like

Hey @jfdsap, welcome to the forum! I’ve updated your question post title to better suit our question post guidelines: How to post in the Questions category

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