I have a book I’d like to convert from Markdown to epub via Pandoc. The book is all plain text and does not contain any figures, formulas, or code. I need it to consist of several unnumbered parts with each part divided into chapters; the chapter numbering does not renew with each new part. So something like:
Book Title
- First Part
- 1. First chapter title
- 2. Second chapter title
- Second Part
- 3. Third chapter title
- 4. Fourth chapter title
- 5. Fifth chapter title
- Third Part
- 6. Sixth chapter title
With all chapters in separate files, I have something like this for part 1:
# First Part {-}
for the first file in which just the part heading is specified, and then
## First chapter title
Lorem ipsum dolor etc etc
for all the chapters (that’s a setup for one directory in which the part is contained, and I have several of these directories). And I also have a title file in the root.
The command pandoc -o draft.epub title.txt part1/*.md --table-of-contents --number-sections --top-level-division=part
outputs a table of contents that looks like this:
Book Title
- First Part
- 0.1 First chapter title
- 0.2 Second chapter title
Which is not what I need, it has these weird zeroes. But if I try to shift the heading level with --shift-heading-level-by=-1
, then the part entry First Part
takes over the place of the title, so it’s now like
First Part
- 1. First chapter title
- 2. Second chapter title
That’s not what I need either.
How can I achieve the desired effect? Top-level headers (#
) as parts, second-level headers (##
) as chapter titles, parts are unnumbered but present in the ToC, and chapters are numbered like 1, 2, etc and not 0.1, 0.2, so on.