After reading a post here about this topic for equations where the first number of the numbering should be from the level 1 heading I found this solution:
#set heading(numbering: "1.")
#show heading.where(level:1): it => {
counter(math.equation).update(0)
it
}
#set math.equation(
numbering: it => {
let count = counter(heading.where(level: 1)).at(here()).first()
if count >0 {
numbering("(1.1)", count, it)
} else {
numbering("(1)",it)
}
}
)
How I can implement it also for this custom figure (theorem):
What will be the most correct way to implement a thing like this? Any tips on making this numbering function to be more generic or to define the theorem better would help a lot!
If I’m understanding your initial code correctly, you want to make all theorems before the first header just have a theorem counter number (e.g., (1)), and all theorems after a header to have that header’s number and the theorem counter number (e.g., (1.1)), yes? If that’s the case, inside your show rule for thm figures, you will want to:
save current header count in a variable (e.g., let header_count = ...)
save current theorem count in a variable (e.g., let thm_count = ...)
use an if statement to use one of the two numbering uses based on header_count, and save its result to a variable (e.g., let num = if header_count > 0 {...} else {...})