typst-hs icon indicating copy to clipboard operation
typst-hs copied to clipboard

counter isn't resetting properly for figures

Open RayBB opened this issue 2 months ago • 1 comments

The kind counter isn't resetting properly (issue visible in pdf, in docx number isn't shown at all).

This is a pretty big problem for me because the project I'm working on is a collection of essays and each has their own counters for figures and tables. So ideally I'd be able to reset it and have the numbers still match in the version generated with pandoc. That being said, I could manually fix it but hopefully it can be fixed here for everyone!

PS: Below is the minimum example but tables, images, and each "kind" have a separate counter so that should be considered.

Sample typst file figure.typ:

#figure(
  table(
    columns: (1fr, 1fr),
    table.header([A], [B]),
    table.hline(),
    [Content],
    [Content],
  ),
  caption: [A nice caption for my figure],
)


#counter(figure.where(kind: table)).update(0)

#figure(
  table(
    columns: (1fr, 1fr),
    table.header([C], [D]),
    table.hline(),
    [Content],
    [Content],
  ),
  caption: [A second caption],
)

Expected output (when compiled with typst):

Image

Actual output (using pandoc from typst to pdf):

Image

Actual output (using pandoc from typst to docx):

Image

Related typst documentation: https://typst.app/docs/reference/model/figure/

Mostly copied from: https://github.com/jgm/pandoc/issues/11102

Thanks again for maintaining this 👍

RayBB avatar Sep 14 '25 05:09 RayBB