#let heading-setting(it) = context {
// Can I get numbering results here? Not the numbering function.
// For example, if the numbering value of current heading is "1.1" here,
// can I get the value somehow?
let numbering-results = ??
do-something-else(numbering-results)
it
}
#show heading: heading-setting
hello,
you can take a look at Counter Type – Typst Documentation.
#context counter(heading).display()
I fogot this method before, thank you so much!!
But please get rid of all the context
s:
-
When you define a function (like
heading-setting
), never put a context in front. Instead, the user of the function should provide the context to the function, i.e. should call it like#context heading-setting(...)
Also note that forshow
rules you don’t need even need to provide context, because they bring it automatically. Soshow heading: heading-setting
is still fine even if you remove thecontext
in the definition ofheading-setting
. -
Since you already have context within
heading-setting
, you also don’t need thecontext
when you callcounter(heading).display()
.
I didn’t know this before, but I learned it now. Thank you for your reminder