Wrong numbering for the equation

I don’t know whether it’s a bug or if I did something wrong, but the equation numbers aren’t displaying correctly.

A minimal code:

#set page(paper: "a7")
#set heading(numbering: "1.1")
#set math.equation(numbering: "(1.1)" )
= Heading One 
$ y = x^2 + 1 $
$ y = x^2 + 2 $
= Heading Two
$ y = x^2 + 3 $

it gives

The expectation is (1.1), (1.2), (2.1). The same issue also happens to figures.

By just setting the equation numbering to "(1.1)", Typst cannot infer that you wish to have the current heading number there. You need to specify that separately, via a numbering function:

#set math.equation(numbering: (..nums) => {
  let section = counter(heading).get().first()
  numbering("(1.1)", section, ..nums)
})

Doing this will give you the numbers (1.1), (1.2) and (2.3). You see that the equation number also needs to be reset at the start of each section. To achieve that, you can update the heading counter in a show rule for level-1 headings:

#show heading.where(level: 1): it => {
  counter(math.equation).update(0)
  it
}

These two pieces together will then give your expected numbers. To do the same for figures, just copy the first piece (to set the numbering) for figures, and include the counter updates for the various figure kinds in the show rule:

counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
counter(figure.where(kind: raw)).update(0)
// + any custom figure kinds you use in your document

One side effect of this is that if you now reference equations, you no longer get something like “Equation 1”. Instead, the parentheses of the equation numbering is included, resulting in something like “Equation (1.1)”.

Thank you! It works now, and the current citation style is exactly what I wanted.