How to conditionally enable equation numbering for labeled equations?

#set math.equation(numbering: "(1)")
#show math.equation: it => {
  if not it.has("label") {
    let fields = it.fields()
    fields.remove("body")
    fields.numbering = none
    return [#counter(math.equation).update(v => v - 1)#math.equation(..fields, it.body)<math-equation-without-label>]
  }
  return it
}

$ x + y $

$ x + y + z $ <with-label>

82ae3879ab4cb384318bc01a3e883fc6

2 Likes