Dmitri Nesteruk
Dmitri Nesteruk

Reputation: 23798

How do I get pandoc to generate book parts?

I'm using markdown to write a book with pandoc. Pandoc can generate headings using #, ## and so on, but I also want book parts (equivalent to \part in LaTeX). I tried using #- (a markup that some sites such as Leanpub use) but it doesn't work. So, how can I generate book parts?

Upvotes: 3

Views: 692

Answers (2)

Chris
Chris

Reputation: 137268

If you use the raw_tex extension, you can simply add \part wherever you want it, e.g.:

\part{Part I}
# Heading
Blah

Add +raw_tex to the input format when you run Pandoc to enable it:

pandoc --from markdown+raw_tex --to pdf -o book.pdf *.md

Upvotes: 4

tarleb
tarleb

Reputation: 22709

The intended way is to use # headings for parts and to use the option --top-level-division=part:

Treat top-level headings as the given division type in LaTeX, ConTeXt, DocBook, and TEI output. The hierarchy order is part, chapter, then section; all headings are shifted such that the top-level heading becomes the specified type.

Your Markdown should look like this:

# Part heading

## Chapter heading

### Section heading

#### Subsection heading

and so on.

Upvotes: 4

Related Questions