Numbering of Headings does not work after export to PDF

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. 

3 answers

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

Like this:

 

h2 { counter-reset: h3counter; }


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;
<h1>H1</h1>
<h2>H2</h2>
<h2>H2</h2>
<h1>H1</h1>
<h4>H4</h4>
<h2>H2</h2>
<h3>H3</h3><h3>H3</h3><h3>H3</h3>
<h4>H4</h4><h4>H4</h4><h4>H4</h4>
<h1>H1</h1>
<h2>H2</h2>

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

The CSS code looks correct. And yes, if headings are missing, the numbering will be mixed up as well.

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? 

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. 

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Kesha Thillainayagam
Posted Friday in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

287 views 11 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you