如何在Pandoc的前面部分指定编号部分?

tln*_*agy 20 yaml pandoc

我想通过Pandoc对YAML前端问题的支持来指定编号部分.我知道命令行用法的标志是--number-sections,但是类似于

---
title: Test
number-sections: true
---
Run Code Online (Sandbox Code Playgroud)

不会产生预期的结果.我知道我很接近,因为你可以用几何包(例如geometry: margin=2cm)来做到这一点.我希望有关于Pandoc YAML前端处理方式的明确指南.例如,以下内容非常有用(避免模板),但其可发现性很低:

 header-includes: 
 - \usepackage{some latex package}
Run Code Online (Sandbox Code Playgroud)

dfc*_*dfc 18

要在乳胶输出中打开编号部分,您需要numbersections在YAML块中使用.如果你想用pandoc"发现"这样的东西,只需戳一下模板:

 $ grep -i number default.latex
 $if(numbersections)$
 $ grep -i number default.html*
 $
Run Code Online (Sandbox Code Playgroud)

如您所见,此选项不适用于html.

Markdown和YAML我测试过:

 ---
 title: Test
 numbersections: true
 ---


 # blah

 Text is here.

 ## Double Blah

 Twice the text is here
Run Code Online (Sandbox Code Playgroud)

如果你需要它不仅仅使用beamer,latex,context,opendoc,你需要在github上提交一个bug.

  • @Sridhar-Sarnobat,尝试`pandoc -f markdown -S -s --standalone --toc -numbersections -Vsecnumdepth=4 -t latex` (3认同)

jdh*_*hao 8

为了在生成的输出 pdf 中显示节号,有两种选择。

在 YAML 前端

将以下设置添加到 markdown 文件的开头

---
numbersections: true
---
Run Code Online (Sandbox Code Playgroud)

在命令行中

我们还可以使用命令选项生成带有编号部分的 pdf。根据Pandoc 文档,正确的选项是--number-sections或简单地-N

pandoc test.md -o test.pdf --number-sections
# pandoc test.md -o test.pdf -N
Run Code Online (Sandbox Code Playgroud)