@eq displays inconsistent numbering with the label #2280
-
I use a personal template to display equation numbering based on heading levels (numbering restarts at every heading 2), however, I got inconsistent numbering. So how should I modify the following template section. #let conf(
eqnumstyle: "1",
eqnumsep: ".",
eqnumlevel: 1,
doc,
) = {
set math.equation(numbering: equation => locate(loc => {
let chapter = counter(heading).at(loc).at(0)
if eqnumlevel == 2 and counter(heading).at(loc).len() > 1 [
#let subchapter = counter(heading).at(loc).at(1)
(#numbering("1", chapter)#eqnumsep#numbering("1", subchapter)#eqnumsep#numbering(eqnumstyle, equation))]
else [
(#numbering("1", chapter)#eqnumsep#numbering(eqnumstyle, equation))]
}
), supplement: none
)
} I labeled a Eq. (1.1), but @eq shows Eq. (2.1) when I use it in a section 2 paragraph, that is to say @eq display numbering where I use Please help, many thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, If I understand you correctly, your custom equation numbering is working correctly for equations, but not when referenced. The reason for this is that you have to customize the reference function so that it can use the right location (target element, not reference itself) for querying It makes sense to define a custom equation numbering function which is then used in equation and ref rules. This way, you don't have to define the numbering format twice. Like so: Custom equation numbering function
Math set rule
Equation show rule
Reproduction URL: https://typst.app/project/ryRkf6wzlBYQXU6d4qbBfL I hope this helps, even if probably late. |
Beta Was this translation helpful? Give feedback.
Hi,
If I understand you correctly, your custom equation numbering is working correctly for equations, but not when referenced. The reason for this is that you have to customize the reference function so that it can use the right location (target element, not reference itself) for querying
counter(heading)
.It makes sense to define a custom equation numbering function which is then used in equation and ref rules. This way, you don't have to define the numbering format twice. Like so:
Custom equation numbering function