The numbering function is called both in equations and their references. Therefore, mine.step() is executed even in references.
Solution:
#show: body => {
set heading(numbering: "1.1")
set math.equation(
numbering: n => {
// Add the chapter number
let chap = counter(heading).get().first()
[(#chap.#n)]
},
number-align: top,
)
show heading.where(level: 1): it => {
// Reset the equation counter at chapters
counter(math.equation).update((0,))
it
}
body
}
= Heading
$ F(x) $ <f>
See @f
$ G(x) $
= The next chapter
@f also works