Pandoc - 你能同时改变边距和字体大小吗?

Pandoc - Can you change margins and fontsize simultaneously?

Sample Markdown used as a Reproducible Example (GitHub hyperlink)

我将上述超链接中的 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: does not exist (No such file or directory)

你还要写两次-V,直接写在你要设置的变量选项前面:

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

http://pandoc.org/getting-started.html and http://pandoc.org/MANUAL.html

试试这个:

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

Pandoc 的 FAQs 状态:

How do I change the margins in PDF output?

The option

-V geometry:margin=1in

will set the margins to one inch on each side.

请注意,geometry:margin=1in-V 标志的值。但是,您在标志及其值之间有文件名 documentation.md。因此,您导致标志的值为 documentation.md 并且 geometry:margin=1in 被假定为文件名。毕竟,任何前面没有标志的文本字符串都应该是一个文件名(这解释了 "No such file or directory" 错误)。

作为解释,-V 标志的 documentation 给出了这种格式:

-V KEY[:VAL]

请注意,[:VAL] 中的括号表示该部分是可选的。所以 -V KEY 是完全有效的,没有值,这意味着 -V documentation.md 导致 documentation.md 成为 -V 标志的 KEY(默认为 VAL true 根据文档)。

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

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

最后,-s 标志不接受值,所以我移动它以便清楚。