Are there any ways to get heading's numbering results in `show` setting function?

#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()
1 Like

I fogot this method before, thank you so much!!:smile:

But please get rid of all the contexts:

  1. 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 for show rules you don’t need even need to provide context, because they bring it automatically. So show heading: heading-setting is still fine even if you remove the context in the definition of heading-setting.

  2. Since you already have context within heading-setting, you also don’t need the context when you call counter(heading).display().

I didn’t know this before, but I learned it now. Thank you for your reminder :smiley: