How do I add sub-numbers to grouped equations?

395 Views Asked by At

I want something like this:
enter image description here

Notice that each equation is aligned at the equals sign, and each has its own letter. (presumably they're in the same align environment)

1

There are 1 best solutions below

0
On

An, albeit a bit hacky, solution would be this:

#let c = counter(math.equation)
#set math.equation(numbering: (.._n) => [])
#show math.equation: set text(weight: "bold")

#let sub() = {
  $&&$
  c.step(level: 2)
  h(2cm)
  c.display("(1a)")
}

$
m^+ &= m^- + K[z - h(m^-)] #sub() \
P^+ &= P^- - K H(m^-) P^- #sub() \
K   &= P^- H^T (m^-) W^(-1) #sub() \
W   &= H(m^-) P^- H^T (m^-) + R #sub()
$

We need to manually use the equation counter for this example to work. In this example, we first retrieve the counter to access it easily. Then, we set an empty closure as the numbering argument of equation. When this parameter is not none, the equation counter is incremented for all block-level equations with a number. We do not want to print the default number, so we assign a closure that always returns an empty content block.

The math in the example is bold, so we force bold text for the whole formula with line three.

Then, we define the sub function. It adds two alignment points (for left-alignment), steps the counter, prints a bit of space, and then displays the counter's value for the given numbering pattern. We specify level 2 for the counter increment to obtain the letters in the number, this sublevel is reset to zero by the next equation block. This is also why we needed to collect variadic arguments in line 2. The amount of arguments passed to a numbering function depends on the deepest non-zero level of the counter.

Finally, in the equation, we need to call sub for each line.