Pandoc - 可以同时更改边距和字体大小吗?

sta*_*tor 1 markdown latex pdflatex pandoc

用作可重现示例的 Markdown 示例(GitHub 超链接)

我将上面超链接中的 markdown 粘贴到 Atom 文本编辑器中,并将其另存为 Documentation.md 文件。我可以运行以下两个单独的 Pandoc 命令,每个命令都可以减少 pdf 的边距,并将输出 pdf 的字体大小增加到 12。

pandoc -s -V documentation.md geometry:margin=1in -o documentation.pdf

pandoc -s -V documentation.md fontsize=12 -o documentation.pdf

当我将这两个命令组合到下面时,出现如下错误。我的 Pandoc 语法有问题吗?

pandoc -s -V documentation.md geometry:margin=1in fontsize=12 -o documentation.pdf

pandoc Geometry:margin=1in openBinaryFile: 不存在(没有这样的文件或目录)

Way*_*lan 7

尝试这个:

pandoc documentation.md -V geometry:margin=1in -V fontsize:12pt -s -o documentation.pdf
Run Code Online (Sandbox Code Playgroud)

Pandoc 的常见问题解答指出:

如何更改 PDF 输出中的边距?

选项

-V geometry:margin=1in
Run Code Online (Sandbox Code Playgroud)

将每边的边距设置为一英寸。

请注意,这geometry:margin=1in是标志的值-V。但是,文件名documentation.md位于标志及其值之间。因此,您将导致标志的值成为documentation.md并被geometry:margin=1in假定为文件名。毕竟,任何前面没有标志的文本字符串都应该是文件名(这解释了“没有这样的文件或目录”错误)。

作为解释,该标志的文档-V给出了以下格式:

-V KEY[:VAL]
Run Code Online (Sandbox Code Playgroud)

请注意,中的括号[:VAL]表示该部分是可选的。因此-V KEY完全有效,没有任何值,这意味着-V documentation.md结果documentation.mdKEY标志的-V(默认VALtrue按照文档)。

诚然,-V geometry:margin=1in这是一个特别奇怪的情况,很容易看出人们可能会对此感到困惑。然而,在本例中,-V是标志,geometry是“KEY”,margin=1in是“VAL”。我意识到它margin=1in看起来像一个KEY=VAL,但在这种情况下它本身就是一个“VAL”。据推测,Pandoc 稍后会对它进行一些进一步的处理,以将“VAL”分解为多个部分。

当然,fontsize是另一个变量,因此您需要第二个-V标志来定义该变量:-V fontsize:12pt

最后,该-s标志不接受值,因此我将其移动以使其清楚。