jgm / jgm/typst-hs

counter isn't resetting properly for figures

Open
#75 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
76
Forks
11
Avg merge
9h 5m
Merged PRs (30d)
1

Description

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](https://typst.app/docs/reference/model/figure/#parameters-kind)" have a separate counter so that should be considered.

Sample typst file `figure.typ`:
```typst
#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 👍

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the issue with figure.typ using the typst-to-PDF and typst-to-DOCX Pandoc paths, comparing both outputs with the expected Typst output. Trace figure counters for tables and other kinds, and consider the work complete when resetting a counter preserves the expected numbering in both formats.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.