Why do Headings without numbering not increase the Heading Counter

Hello,

I am helping a friend of mine to setup a template for her Rechtswissenschaften Homework.
In the faculty they have some weird and unusual requirements for the numberings of Headings, which make more sense from a Handwritten Homework perspective than a modern digital one.

Each Subheading level has a different numbering format.
Each subheading must not reference its Parent so a Heading of level 2 for the numbering “A.1.” must not contain the “A.” of its Parent.

I have found a solution for this, which I think is a reasonably good one.

#show heading.where(level: 2 ): set heading(numbering: (..nums)=> {
  numbering("A.", nums.at(1))
})
#show heading.where(level: 3 ): set heading(numbering: (..nums)=> {
  numbering("I.", nums.at(2))
})

These Start at level 2 since there needs to be an uncounted Heading of level 1, that splits the outline into different broader Questions.

Now when starting a second question the Heading at level 2 follows after the Heading for the first question. For exmaple:

= Question 1
== Should be A.
=== Should be I.
== Shoud be B.
=== Should be I.
=== Should be II.

= Question 2
== Should be A. Is C. instead
=== Should be I.
...

This can be remidied by using

#counter(heading).update(1)

My Question is then: Why does the Heading Counter not update. Shouldn’t the numbering, which is just the function that displays the number of the heading, not influence how and if a Heading is counted?

If you hover over nums in your second show-set rule, you can see how the heading counter works for multiple levels with and without numbering. The counter value for the level 1 headings is always zero since you have the numbering disabled for this level. Only the values for the levels 2 and 3 change.

The default heading counter behavior is to reset all levels below the level that is currently updated. This is why the level 3 counter is reset to 1 when the level 2 counter goes from 1 → 2 or from 2 → 3. Since the level 1 counter is not updated, the level 2 counter is just incremented with every heading.

As you already mentioned, you can fix this behavior by manually resetting the heading counter with every level 1 heading.

#show heading.where(level: 1): it => counter(heading).update(0) + it
1 Like