我如何让 pandoc 生成书籍部分?

How do I get pandoc to generate book parts?

我正在使用 markdown 写一本带有 pandoc 的书。 Pandoc 可以使用 ### 等生成标题,但我还想要书籍部分(相当于 LaTeX 中的 \part)。我尝试使用 #-(Leanpub 等网站使用的标记),但它不起作用。那么,如何生成书籍部件?

如果你使用the raw_tex extension,你可以简单地添加\part在任何你想要的地方,例如:

\part{Part I}
# Heading
Blah

当你 运行 Pandoc 启用它时,将 +raw_tex 添加到输入格式:

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

预期的方法是对部分使用 # 标题并使用选项 --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.

你的 Markdown 应该是这样的:

# Part heading

## Chapter heading

### Section heading

#### Subsection heading

等等。