From what I can tell, the goal of the show rule on ref
is to change the appearance of a reference from Equation 2.1 to just (2.1). The unfortunate thing is that you have to explicitly call numbering(..)
in the show rule, so the numbering function set in the rule for equations is always called with the context of the reference (instead of the context of the equation itself). The only possible workaround I could think of right now, is using a regex show rule to remove the supplement like this:
#show ref: it => {
let el = it.element
if (el != none and el.func() == math.equation) {
// May need to adjust this when using letters in numbering
show regex("\p{letter}+\s+"): none
it
} else {
it
}
}
Other than that, there are some potentially related issues you could follow:
- Ergonomic numbering-by-section · Issue #1896 · typst/typst · GitHub
- Providing different `context`s · Issue #3930 · typst/typst · GitHub
- Numbering contexts do not include styles · Issue #4646 · typst/typst · GitHub
- `numbering` function does not get local counter for sub-equations · Issue #3 · EpicEricEE/typst-equate · GitHub (for the same issue in the equate package)