Sample Markdown used as a Reproducible Example (GitHub hyperlink)
I pasted the markdown from the hyperlink above into the Atom text editor and saved it as a documentation.md file. I can run the following two seperate Pandoc commands and each of them works to reduce the margins on my pdf -and- increase the font size to 12 on the output pdf.
pandoc -s -V documentation.md geometry:margin=1in -o documentation.pdf
pandoc -s -V documentation.md fontsize=12 -o documentation.pdf
When I combine the two commands into the following I get the error shown below. Is there a problem in my Pandoc syntax?
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)
Try this:
pandoc documentation.md -V geometry:margin=1in -V fontsize:12pt -s -o documentation.pdf
Pandoc's FAQs state:
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.
Note that geometry:margin=1in
is the value of the -V
flag. However, you have the filename documentation.md
between the flag and its value. Therefore, you are causing the value of the flag to be documentation.md
and geometry:margin=1in
is assumed to be a filename. After all, any string of text no preceded by a flag should be a filename (which explains the "No such file or directory" error).
By way of explanation, the documentation for the -V
flag gives this format:
-V KEY[:VAL]
Note that the brackets in [:VAL]
indicate that that part is optional. So -V KEY
is completely valid with no value, which means that -V documentation.md
resulted in documentation.md
being the KEY
of the -V
flag (with a default VAL
of true
as per the docs).
Admittedly, -V geometry:margin=1in
is an especially weird case and its easy to see how one might be confused by it. In this case however, -V
is the flag, geometry
is the "KEY" and margin=1in
is the "VAL". I realize that margin=1in
looks like a KEY=VAL
, but in this instance it is all a "VAL" on its own. Presumably, Pandoc does some further processing on it later to break the "VAL" up into its parts.
Of course, fontsize is another variable, so you need a second -V
flag to define that variable: -V fontsize:12pt
.
Finally, the -s
flag does not accept a value, so I moved it so that that is clear.