#set math.equation(numbering: none)
#show: body => context {
let labels = query(math.equation.where(block: true))
.filter(eq => eq.has("label"))
.map(eq => eq.label)
.dedup()
if labels.len() > 0 {
show selector.or(..labels): set math.equation(numbering: "(1)")
body
} else {
body
}
}
$ A $<l1>
$ a + b $<l2>
$ c + d $
Which is based on something that @Eric has shared before I think. Idea: find all relevant labels, then let the style system apply numbering to just them. It’s a better workaround because creating new math.equation elements has various unwanted side effects, including causing problems for references.
The team prioritises issues with more likes, so if this is something that you feel is missing from the language I’d encourage you to upvote the issue
To add to @bluss’s answer, I personally find it nicer if the numbering is enabled only if the equation is referenced in the document. You can acheive this by slightly tweaking the conditional:
if labels.len() == 0 {
return body
}
let referenced-labels = query(
selector.or(..labels.map(
label => ref.where(target: label)
))
).map(it => it.target)
if referenced-labels.len() == 0 {
return body
}
show selector.or(..referenced-labels): set math.equation(numbering: "(1.1)")
body