#Counter display problem in headings

12 messages · Page 1 of 1 (latest)

lapis sedge
#

Hello,
I use some counter to keep the appendix number and display it directly in the heading
It works very well except in the table of contents where it is always zero
Can someone figure out why and has a solution ?
Thanks in advance

#

If it can help I use some function defined like this ```typst
#let calculateAnnexeTitle(title, count) = {
"Annexe " +count + ": " + title
}

And I use it like this : 
```typst
==  #calculateAnnexeTitle("Capture d'écran de la vue principale de l'application", context annexes.display("1"))
twin parrot
#

try this:

#context [==  #calculateAnnexeTitle("Capture d'écran de la vue principale de l'application", annexes.display("1"))]```
#

that is, using the context around the heading, not using the context where the information is displayed

#

otherwise it tries to display the counter value at the outline, before you update the counter at all, which is zero

lapis sedge
#

Ok it works well, thank you

marble star
#

For this kind of things, I create a function appendix and use a show rule to activate the environment.

#let appendix = {
counter(heading).update(0)
set heading(numbering: "A")
}
lapis sedge
#

Ok I'll try this too, thank you for the advice

ruby stirrup
marble star
#

Of course. Once you define your function. You can put the following code in your main file, when you want to activate the appendix environment.

#show: appendix
lapis sedge
marble star
#

Yes, it is what I did for a book template. You also have this example in elsearticle template I shared on Typst Universe