Let pandoc number sections without h1
Asked Answered
B

2

7

When I am writing a documentation with markdown (in order to process it to HTML with pandoc), I always have one heading of first order (# Heading), which is the document title, and multiple headings of second order (## Heading).

But when I switch on --number-sections in pandoc, all headings have a leading number for the document title.

How can I prevent that? Is there a parameter that h1-like headings should not be numbered, or should I specify the title in another way?

Biggers answered 19/4, 2017 at 12:55 Comment(0)
A
4

The manual states that

Headers with the class unnumbered will not be numbered, even if --number-sections is specified.

For that, you just need to append {-} at the end of the header line

Edit: it might also be better if you specify the title within the YAML metadata (at least that's how I do it with jekyll and similar tools)

Ardehs answered 19/4, 2017 at 14:25 Comment(2)
Using the {-} makes all lower-range headings carry a 0. in front of their number. I did it with the YAML title now and pulled all headings one level up.Biggers
I compile markdown to pdf via latex and with this {-} at the end of the first header, I also get all the other header-numbers starting with 0 now. Is there a way to fix this automtically, e.g., with a flag when compling, without any detours over intermediate output, or so? I just want one quick command...Raggletaggle
B
1

--shift-heading-level-by=-1 works for me.

Bobsledding answered 17/3, 2022 at 7:3 Comment(1)
See "Explaining entirely code-based answers". While this might be technically correct, it doesn't explain why it solves the problem or should be the selected answer. We should educate along with helping solve the problem.Sedimentary

© 2022 - 2024 — McMap. All rights reserved.