#How do I reset the figure numbering after a header using Quarto

1 messages · Page 1 of 1 (latest)

analog locust
#

I am using a Typst template in Quarto for a report and I want to number my images and tables. I want them to be numbered as Figure 1.1, Figure 1.2 in chapter 1 and as Figure 2.1, Figure 2.2 in chapter 2. Currently, the figures in chapter 2 are numbered as Figure 2.3, Figure 2.4. The first number is correct, but I want the second number to be resetted at the start of each chapter.

I import my typst template in the yaml. In the typst template I use the following pieces of code:

show heading.where(level: 1): hdr => {
      counter(figure.where(kind:image)).update(0)
      counter(figure.where(kind:table)).update(0)
      hdr
  } 

set figure(numbering: n => {
                  let hdr = counter(heading).get().first()
                  let num = query(selector(heading).before(here())).last().numbering
                  numbering(num, hdr, n)
  })

To my understanding, the first piece of code should reset the second number in the figure and table numbering when a new chapter is made by placing a new header.

Other people using typst directly (so no Quarto) do use the same code, and for them the counter resets correctly (see for example: https://forum.typst.app/t/do-i-need-different-code-for-numbering-equations-and-figures/3068/2 or https://forum.typst.app/t/how-to-change-numbering-in-appendix/1716/6). If this a bug between Quarto and typst?

Typst Forum

You need to also reset the figure/equation counters manually with each first-level heading. You can do so with a show rule #show heading.where(level: 1): it => { counter(figure.where(kind: image)).update(0) counter(figure.where(kind: table)).update(0) counter(figure.where(kind: raw)).update(0) // ..repeat with whatever figure kinds you ...

twin blaze
#

Like I said on GitHub, you'll have to take this to the quarto forum. This discord is for typst specifically

brisk sinew
#

Quarto outputs a custom kind. Instead of kind: table use kind: “quarto-float-tbl” and likewise “quarto-float-fig” for image