How can I make blank pages not step the page counter?

Hi everyone, I am developing my own template in Typst and I want to leave a blank page each time a new 1st level heading is created.
Now, I have managed to do so with the following code:

#let blankpage() =  context {
  set page(numbering: none, header: none)
  pagebreak()
  align(center + horizon, [
    #set text(weight: "regular", fill: colors.darkgray, size: sizes.subsection)
    #emph([This page has been intentionally left blank.])
  ])
  // counter(page).update(counter(page).at(here()).at(0) - 1)
}

I also want the blankpages to not update the page counter. For instance, If I have a chapter/section end at page 2, the new chapter must be start on page 3 with a blankpage in between. If I uncomment the last line in the function I get a layout did not converge within 5 attempts warning and my page numbers become all messed up.

What do you think?

Hi!

You can replace the offending line with

counter(page).update(i => i - 1)

See Counter Type – Typst Documentation


I updated your title to keep with the guidelines from How to post in the Questions category — Feel free to update it if it isn’t what you meant

3 Likes

The underlying problem, “layout did not converge”, is explained in a bit more detail in my blog; may be interesting for you: Typst's dreaded "Layout did not converge" warning (particularly starting at the “The usual suspect: chained state updates” part)

2 Likes

Thank you! I will give it a read

This works perfectly, thank you!