stackinator stackinator - 3 months ago 67
LaTeX Question

Pandoc - Can you change margins and fontsize simultaneously?

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 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 geometry:margin=1in -o documentation.pdf

pandoc -s -V 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 geometry:margin=1in fontsize=12 -o documentation.pdf

pandoc geometry:margin=1in openBinaryFile: does not exist (No such file or

Answer Source

Try this:

pandoc -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 between the flag and its value. Therefore, you are causing the value of the flag to be 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:


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 resulted in 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download