# Looking for ways to auto-number sections.

#### pum

21 Aug, 2017 07:13 PM

I'm looking for a way to number section headings automatically, so

# Chapter A

## Section B

## Section C

looks like
1. Chapter A
1.1 Section B
1.2 Section C

I found this on StackOverflow. Adding the following to css works in preview but in the generated PDF all counters are 0 or 1. Suggestions?
(After posting this I saw a tip which is similar to the css below. That tip shows the same behaviour for me: all counters are 0 or 1 only)

body {
counter-reset: h1
}

h1 {
counter-reset: h2
}

h2 {
counter-reset: h3
}

h3 {
counter-reset: h4
}

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

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

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

h4:before {
counter-increment: h4;
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) ". "
}

1. Support Staff Posted by Brett on 21 Aug, 2017 07:34 PM

What you have should work. If you could show me a sample document and
the resulting PDF output, I'd be happy to test it out.

-Brett

2. Posted by pum on 22 Aug, 2017 05:45 AM

Attached a zip with md, css and pdf

3. Support Staff Posted by Brett on 22 Aug, 2017 02:04 PM

I've tried a few different settings and my PDF always comes out like the
attached (with 1.2 properly numbered). If you want to test further, I'd
need the output of Help->Report an Issue so I can see if there's a
particular setting that might be throwing it off for you.

-Brett

4. Posted by pum on 22 Aug, 2017 02:15 PM

// Please enter a detailed description of the issue // Description of the issue:

All numbers using auto numbering are 1 or 0 (e.g. level two numbers are 1.1, 1.1, 1.1, …)

// Please enter a list of steps required to reproduce the issue // Steps to reproduce:

1. Zipfile sent above
2. output to pdf

// If applicable please attach a sample document that causes the issue for you.

// Configuration (do not edit) Marked 2 930 (Mac App Store)

## OS X Version: 10.12.6

additionalMathJaxConfig:
allowPageBreakInCode: 1
bookTxtIsLeanpub: 0
summaryMdIsGitBook: 0
codeIsPoetry: 0
collapsibleHeadlines: 1
convertGithubCheckboxes: 1
convertYAMLToMMD: 0
defaultMathJaxConfig: TeX-AMS-MML_HTMLorMML
defaultPreviewStyle: 102
defaultProcessor: MultiMarkdown
enableMiniMap: 1
excludeBlockQuotesFromCounts: 0
excludeFootnotesFromCounts: 0
excludeVerbatimFromCounts: 0
excludeCaptionsFromCounts: 0
folderPreviewExtensionsArray: md, markdown, txt, mdown, html, opml
githubNewlines: 1
h1IsPageBreak: 0
h2IsPageBreak: 0
hrIsPageBreak: 0
includeMathJax: 0
limitTextWidth: 0
minimalJavaScript: 0
outlineModeExtensions:
permissionGranted: 0
printHeaderBottomLeft: %title
printHeaderBottomRight: %page / %total
printHeaderFooterFirstPage: 0
printHeaderTopLeft:
printHeaderTopRight:
processHTMLFiles: 1
removeMetadataForPreview: 0
removeYAMLHeaders: 0
scrollToEdit: 1
shouldDetectCritic: 1
shouldHighlightMarkupErrors: 0
shouldLoadCritic: 0
syntaxHighlight: 1

5. Support Staff Posted by Brett on 23 Aug, 2017 04:59 PM

Are you loading the CSS file in your archive as a custom style, or
adding it to Additional CSS in Style preferences?

-Brett

6. Support Staff Posted by Brett on 23 Aug, 2017 05:08 PM

Forget that question, it works for me either way. I'm really uncertain why you're running into this. One thing I'd have you try is going to the gear menu and turning outline mode on to Decimal format. Then use a default style and try exporting and see if counters work at that point.

Also, if you export HTML (and be sure to check the box to include the stylesheet in the save panel), then open in a browser and print to PDF, does the resulting PDF maintain the count properly?

7. Posted by pum on 23 Aug, 2017 05:12 PM

Hi Brett,

I will look into this as soon as I have some time, and I will let you know if I find anything.

Thanks so far,

Pum

8. Posted by Mazhar on 08 Oct, 2017 06:50 PM

I am facing the same problem. The Preview and html show progressive numbers to sections correctly. But pdf export gives the number 1 to every occurence.

9. Support Staff Posted by Brett on 11 Oct, 2017 03:57 PM

Could you attach a sample document that causes the issue, the configuration display from Help->Report an Issue, and let me know whether you're outputting to paginated or continuous PDF?

Thanks,
Brett

## Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

### »

#### Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

# Keyboard shortcuts

### Generic

? Show this help Blurs the current field

### Comment Form

r Focus the comment reply box Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

## Recent Discussions

 19 Sep, 2018 01:31 AM Blank lines before html table with row/col-span 18 Sep, 2018 04:42 PM Error Invalid Font when printing 18 Sep, 2018 12:48 PM Marked as a Command Line Processor 17 Sep, 2018 08:48 PM UI Typo 15 Sep, 2018 09:28 PM relative image paths in Streaming Preview

## Recent Articles

 Highlight sentences longer than a certain number of words In-app purchase issues (Error Domain=Paddle Code=0 "(null)") License code has already been utilized How do I retrieve a lost license (direct version) Custom CSS: Writing custom CSS for Marked