#Only number an equation if it has a label
16 messages ยท Page 1 of 1 (latest)
if you want just one label you can make counter(<some-label>)
@rich walrus what do you mean?
?render
#show math.equation:it => {
if it.fields().keys().contains("label"){
math.equation(block:true, numbering: "(1)", it)
// change your numbering style in `numbering`
} else {
it
}
}
$ sum_x^2 $
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-2>
$ sum_x^2 $
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-3>
I actually got the inspiration from https://discord.com/channels/1054443721975922748/1106309466510590082
@grand swift thank you so much!
Oh no! This seems to break references to equations ๐ฆ
?render
#show math.equation:it => {
if it.fields().keys().contains("label"){
math.equation(block:true, numbering: "(1)", it)
// change your numbering style in `numbering`
} else {
it
}
}
$ sum_x^2 $
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-2>
$ sum_x^2 $
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-3>
In @ep-2 and @ep-3 we see equations
An error occurred:
Error: cannot reference equation without numbering
โญโ[/main.typ:21:4]
โ
21 โ In @ep-2 and @ep-3 we see equations
โ โโโโโ
โ
โ
โ Help: you can enable equation numbering with `#set math.equation(numbering: "1.")`
โโโโโฏ
Error: cannot reference equation without numbering
โญโ[/main.typ:21:14]
โ
21 โ In @ep-2 and @ep-3 we see equations
โ โโโโโ
โ
โ
โ Help: you can enable equation numbering with `#set math.equation(numbering: "1.")`
โโโโโฏ
Okay so this works and keeps the clickable links, but the counter has a off-by-one error in the snippet render....
I think there is a PR on this topic by @final pasture
That first if is equivalent to it.has("label") btw
?render
#let eqnumbering = "(1)"
#show math.equation:it => {
if it.has("label"){
math.equation(block:true, numbering: eqnumbering , it)
} else {
it
}
}
#show ref: it => {
let el = it.element
if el != none and el.func() == math.equation {
link(el.location(),numbering(
eqnumbering,
counter(math.equation).at(el.location()).at(0)+1
))
} else {
it
}
}
$ sum_x^2 $
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-2>
$ sum_x^2 $
$ dif/(dif x)(A(t)+B(x))=dif/(dif x)A(t)+dif/(dif x)B(t) $ <ep-3>
In @ep-2 and @ep-3 we see equations