How to correctly customize equation numbering & referencing simultaneously?

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:

1 Like