Looking for ways to auto-number sections.
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) ". "
}
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Brett on Aug 21, 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 Aug 22, 2017 @ 05:45 AM
Attached a zip with md, css and pdf
Support Staff 3 Posted by Brett on Aug 22, 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 Aug 22, 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:
// 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
Support Staff 5 Posted by Brett on Aug 23, 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
Support Staff 6 Posted by Brett on Aug 23, 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 Aug 23, 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 Oct 08, 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.
Support Staff 9 Posted by Brett on Oct 11, 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