How can I have a temporary local counter for equations?

If you wrap everything in a context, you can write

#context [
  #let c = counter(math.equation).get()
  #counter(math.equation).update(0)
  #set math.equation(numbering: "(i)", number-align:left+horizon)
  $ b = 1 $
  $ b = 2 $
  $ b = 3 $
  #counter(math.equation).update(c)
]

With a small function definition, you can write

#let eq(body) = context {
  let c = counter(math.equation).get()
  counter(math.equation).update(0)
  body
  counter(math.equation).update(c)
}

$ a = 1 $<label>

#eq[
  #set math.equation(numbering: "(i)", number-align:left+horizon)
  $ b = 1 $
  $ b = 2 $
  $ b = 3 $
]

$ a = 2 $

See Why is the value I receive from context always content?

4 Likes