How can I set numbering for sub-equations as follows?
Hello @shhuang!
You can take a look at the equate package.
The discussion about this feature is at Fine grained equation numbering control · Issue #380 · typst/typst · GitHub
Thanks!
I tried equate package and it worked. However, when I tried to use cross-reference it would override the format I set before.
The codes are:
show: equate.with(breakable: true, sub-numbering: true)
set math.equation(numbering: "(R1a)")
show ref: it => {
let eq = math.equation
let el = it.element
if el != none and el.func() == eq {
// Override equation references.
numbering(
el.numbering,
..counter(eq).at(el.location()),
)
} else {
// Other references as usual.
it
}
}
It looks great in the equation block:
But in the reference:
How can I change “Equation 5a” to “(R5a)”?
Hi,
the above show rule only handles build in equations you have to add a case for equations from the package:
#import "@preview/equate:0.2.1": *
#show: equate.with(breakable: true, sub-numbering: true)
#set math.equation(numbering: "(R1a)")
#show ref: it => {
let eq = math.equation
let el = it.element
if el != none and el.func() == eq {
// Normal equations
numbering(el.numbering, ..counter(eq).at(el.location()),
)
} else if el.func() == figure and el.kind == eq {
// Equate equations
numbering(el.numbering, ..el.body.value)
} else {
// Rest
it
}
}
$
a = b #<a>\
b = c #<b>
$ <1>
See @1, @a and @b
Another option would be to use a function instead of a numbering pattern string. It is more compact but less flexible.
#import "@preview/equate:0.2.1": *
#show: equate.with(breakable: true, sub-numbering: true)
#set math.equation(supplement: none)
#set math.equation(numbering: (..n) => numbering("(R1a)", ..n))
$
a = b #<a>\
b = c #<b>
$ <1>
See @1, @a and @b
Result
2 Likes