Changing margin and paper size
Yesterday I learned how to change the margin of the PDF file Pandoc generates. But I forgot about the paper size. I live in the Netherlands and A4 is the common format here. First, I wanted to know how to check the current paper size. This can be done on the command line as follows:
mdls freecodecamp.pdf |
grep -i page
This reports the number of pages, the height (792 for US letter) and width (612 for US letter). The values are in PostScript points; 1" equals 72 points or 8.5" × 11" for US letter.
How to change this? Well, it turns out that with one Pandoc variable one can control both the margin and the paper size:
-V geometry="margin=1in,a4paper"
So the command for generating the PDF via Pandoc in a Docker container and viewing the output in the Preview application on macOS becomes:
docker run --rm \
-v "$(pwd):/data" \
-u $(id -u):$(id -g) \
pandoc/latex freecodecamp.md \
-V geometry="margin=1in,a4paper"\
-o freecodecamp.pdf &&
open freecodecamp.pdf
Checking the dimensions with mdls reports 841.89 points ×
595.2760009765625 points which matches the dimensions of an A4 page.