Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do you create numbered sections for PDF and Word exports from Confluence?

Debbi Sedlak February 22, 2018

We are using Confluence as our documents with a space template to create numbered sections, but that formatting does not export to Word or PDF.  How do I get the section numbers to export?

To further clarify:

I use a space stylesheet (CSS) to create numbered headings.  However, while the effects of those styles show on the page in Confluence, when you export, the numbering does not display in the exports.  I tried cutting and pasting that stylesheet into the PDF stylesheet but it does not work.  Headings are like this:

1. Heading 1

1.1 Heading 2

1.1.1 Heading 3

1.1.1.1 Heading 4

etc. 

I know the TOC macro shows the heading numbers, but I need the heading numbers shown in the body of the document, not just in the table of contents.  We are using Confluence pages as documents.  We need the exports to share with people outside of Confluence to comment on the documents. 

4 answers

0 votes
Ferdinand Fürstenau
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 13, 2023

For everyone looking, Chatgpt gave the correct answer. 


body { counter-reset: heading1_counter; }

h1 { counter-reset: heading2_counter; }

h2 { counter-reset: heading3_counter; }

h1:before { content: counter(heading1_counter) ". ";

counter-increment: heading1_counter; }

h2:before { content: counter(heading1_counter) "." counter(heading2_counter) ". ";

counter-increment: heading2_counter; }

h3:before { content: counter(heading1_counter) "." counter(heading2_counter) "." counter(heading3_counter) ". ";

counter-increment: heading3_counter; }

0 votes
Chee T
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 6, 2018

Hi Debbi,

 

Based on your code, I put my code as below and it works for chapter. I did same way in h2/h3 but it doesn't work as expected. 

 

----------------------------------------

body {
counter-reset: heading1_counter;
}

 

h1:before {
content: counter(heading1_counter) ". ";
counter-increment: heading1_counter;
}

0 votes
Nils Bier _K15t_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 22, 2018

Hi Debbi,

How are those numbered sections created? Are you using the numbered heading macro for that?

Can you share the storage format of an example page?

Best,
Nils

Debbi Sedlak February 23, 2018

No, cannot use that macro.  we cannot buy anything right now, although I wish I knew how to create that.  Even free plug-ins that are not from Atlassian have to go through rigorous review.  I am using a space style sheet.  Is there a way to embed a style sheet in a document that would export, rather than by space?  I may want to post that as a separate question.

Debbi Sedlak February 23, 2018

See update to my question above

Nils Bier _K15t_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2018

Hi Debbi,

Thanks for the update - using stylesheets you're changing the way the content is displayed, but this information is not stored in the storage format which is used for the export.

You'd need to find a way to get the numbers inserted in the storage format (e.g. using a macro), or change the PDF stylesheet.

An easier way (allowing you to have multiple templates per space or globally and giving you more enhanced customization options) would be to have a look at our Scroll PDF Exporter - but if you can't get any apps right now, you might need to check the PDF stylesheet options.

Debbi Sedlak February 26, 2018

I copied the css stylesheet used for Confluence to the PDF stylesheet, but it is not working. 

This is what I have:

body {
  counter-reset: h1-counter;
  font-style: normal;
  font-variant: normal;
  font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
}
#main-content h1:before {
  content: counter(h1-counter) " ";
  counter-increment: h1-counter;
}
#main-content h1 {
  font-size: 24px;
  font-weight: 500;
  line-height: 26.4px;
  counter-reset: h2-counter;
}
#main-content h2:before {
  content: counter(h1-counter) "." counter(h2-counter) " ";
  counter-increment: h2-counter;
}
#main-content h2 {
  font-size: 22px;
  font-weight: 500;
  line-height: 24px;
  counter-reset: h3-counter;
}
#main-content h3:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) " ";
  counter-increment: h3-counter;
}
#main-content h3 {
  font-size: 20px;
  font-weight: 500;
  line-height: 22px;
  counter-reset: h4-counter;
}
#main-content h4:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) "." counter(h4-counter) " ";
  counter-increment: h4-counter;
}
#main-content h4 {
  font-size: 18px;
  font-weight: 500;
  line-height: 20px;
  counter-reset: h5-counter;
}
#main-content h5:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) "." counter(h4-counter) "." counter(h5-counter) " ";
  counter-increment: h5-counter;
}
#main-content h5 {
  font-size: 16px;
  font-weight: 400;
  line-height: 18px;
  counter-reset: h6-counter;
}
#main-content h6:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) "." counter(h4-counter) "." counter(h5-counter) "." counter(h6-counter) " ";
  counter-increment: h6-counter;
}
#main-content h6 {
  font-size: 14px;
  font-weight: 300;
  line-height: 16px;
}
#main-content p {
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
}
#main-content blockquote {
  font-size: 21px;
  font-weight: 400;
  line-height: 30px;
}
#main-content pre {
  font-size: 13px;
  font-weight: 400;
  line-height: 18.5714px;
}
.mceContentBody h1:before {
  content: counter(h1-counter) " ";
  counter-increment: h1-counter;
}
.mceContentBody h1 {
  font-size: 24px;
  font-weight: 500;
  line-height: 26.4px;
  counter-reset: h2-counter;
}
.mceContentBody h2:before {
  content: counter(h1-counter) "." counter(h2-counter) " ";
  counter-increment: h2-counter;
}
.mceContentBody h2 {
  font-size: 20px;
  font-weight: 500;
  line-height: 20px;
  counter-reset: h3-counter;
}
.mceContentBody h3:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) " ";
  counter-increment: h3-counter;
}
.mceContentBody h3 {
  font-size: 14px;
  font-weight: 500;
  line-height: 15.4px;
  counter-reset: h4-counter;
}
.mceContentBody h4:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) "." counter(h4-counter) " ";
  counter-increment: h4-counter;
}
.mceContentBody h4 {
  font-size: 12px;
  font-weight: 500;
  line-height: 12px;
  counter-reset: h5-counter;
}
.mceContentBody h5:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) "." counter(h4-counter) "." counter(h5-counter) " ";
  counter-increment: h5-counter;
}
.mceContentBody h5 {
  font-size: 12px;
  font-weight: 400;
  line-height: 12px;
  counter-reset: h6-counter;
}
.mceContentBody h6:before {
  content: counter(h1-counter) "." counter(h2-counter) "." counter(h3-counter) "." counter(h4-counter) "." counter(h5-counter) "." counter(h6-counter) " ";
  counter-increment: h6-counter;
}
.mceContentBody h6 {
  font-size: 10px;
  font-weight: 300;
  line-height: 12px;
}

0 votes
Dave Theodore [Coyote Creek Consulting]
Community Champion
February 22, 2018

Will the Table of Contents macro work for you? It provides clickable links and anchors in exported PDFs.

Debbi Sedlak February 23, 2018

No, need numbered sections 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events