Numbering of Headings does not work after export to PDF
Asked by Petr:

```
Hello, I am trying to get numberings for some headings, but for some reason it does not work. I am using this css code:
```

```
body {        counter-reset: h2counter;    }    h1 {        counter-reset: h2counter;    }    h2:before {        content: counter(h2counter) ".\0000a0\0000a0";        counter-increment: h2counter;        counter-reset: h3counter;    }    h3:before {        content: counter(h2counter) "." counter(h3counter) ".\0000a0\0000a0";        counter-increment: h3counter;    }
```

Unfortunately, it works only on first level, then it looses ability to count properly.

So the results looks like:

T 1.

T 2.

T 2.1

T 2.1.

T 2.0.1

T 3.

It simply reset counters too early. Anyway I was trying the code somewhere else, and code is OK, the problem might be in proper CSS selectors? Could anyone give me a hand? Thanks.


Answers:
author: Petr
body: Any idea someone? I was trying to find the solution on this website, but it seems that I am not the first one nor last one. My though was that the whole Confluence documentation is a tree structure which is converted to \<Hx\> tags. Unfortunately it seems, that only few first headings are taken in consideration. Next ones are not numbered validly. The numbering usually starts from 0 again - because there is some kind of inconsistency in generating process.


author: Petr
body: Thanks for the reply. I checked it, and I think that I found the problem somewhere else.

```
body {counter-reset: h1counter;}  h1 {counter-reset: h2counter;}  h2 { counter-reset: h3counter; }  h3 { counter-reset: h4counter;}h1:		before { content: counter(h1counter) '. ';		counter-increment: h1counter;}  h2:before {      content: counter(h1counter) '.'counter(h2counter) ".\0000a0\0000a0";      counter-increment: h2counter;  }  h3:before {      content: counter(h1counter) '.'counter(h2counter) "." counter(h3counter) ".\0000a0\0000a0";      counter-increment: h3counter;  }h4:before {      content:counter(h1counter) '.' counter(h2counter) "." counter(h3counter) "." counter(h4counter) ".\0000a0\0000a0";      counter-increment: h4counter;
```

```
&lt;h1&gt;H1&lt;/h1&gt;&lt;h2&gt;H2&lt;/h2&gt;&lt;h2&gt;H2&lt;/h2&gt;&lt;h1&gt;H1&lt;/h1&gt;&lt;h4&gt;H4&lt;/h4&gt;&lt;h2&gt;H2&lt;/h2&gt;&lt;h3&gt;H3&lt;/h3&gt;&lt;h3&gt;H3&lt;/h3&gt;&lt;h3&gt;H3&lt;/h3&gt;&lt;h4&gt;H4&lt;/h4&gt;&lt;h4&gt;H4&lt;/h4&gt;&lt;h4&gt;H4&lt;/h4&gt;&lt;h1&gt;H1&lt;/h1&gt;&lt;h2&gt;H2&lt;/h2&gt;
```

So, this example works just fine. The problem in the example is \<h4\>. And I think that this is exactly happening in my Confluence. For some reason, There are missing headings, and therefore It is not able to generate headings properly. Although there is clear tree structure - with approx. 7 levels of headings. Do you have any idea where could be a problem regarding generated structure? I think that problem is definitively in the structure itself, css is not the problem

comments: author: Steffen Heller
body: The CSS code looks correct. And yes, if headings are missing, the numbering will be mixed up as well.


author: Petr
body: Yeah, and do you have any idea how to fix the problem with missing headings? I thought, the tree hierarchy of whole Confluence is converted into \<Hx\> tags depends on the depth in the structure. But it seems it is not generating headings at all. Do you have any clue how to fix it?


author: Marcel Woschek
body: I think your **counter-reset: h3counter;** needs to be in the h2 clause, not in the h2:before clause.

Like this:

```css
h2 { counter-reset: h3counter; }
```

<br />