Specifying papersize for md to pdf conversion
Asked Answered
U

5

20

I've read you can specify papersize by pandoc -V papersize:"a4paper" .... This doesn't seem to work anymore. I've managed to specify B5 using

pandoc -V papersize:b5 -o out.pdf in.md

But this fails for e.g. b6. The following -V arguments also all appear to have no effect:

-V papersize:b5paper
-V papersize:"b5paper"
-V "papersize:b5paper"

What is the proper way to format this, or am I missing something more fundamental? In my opinion the documentation is far from clear, lacking e.g. any examples.

Unconsidered answered 19/7, 2016 at 9:51 Comment(0)
U
22
pandoc -s -V papersize:a4

Pandoc's LaTeX template will append paper to a4...

Ultra answered 20/7, 2016 at 7:47 Comment(6)
Well the default is I think a4. But pandoc -V papersize:b6 ... doesn't work despite being a legitimate Latex size..Unconsidered
it should work... try -s -o out.tex instead of -o out.pdf to see the LaTeX pandoc generates...Ultra
Is there a way to have the width of the paper match A4 but the page to have infinite length (Namely don't cut the MD file into pages, just long page as it looks in HTML)?Jorie
@Jorie make your own pandoc latex template (or use header-includes) and see tex.stackexchange.com/questions/19237/…Ultra
What if I'm OK with setting the length myself? Does PanDoc supports that?Jorie
@Jorie pandoc just calls LaTeX for the PDF so it supports everything LaTeX does. see pandoc.org/MANUAL.html#creating-a-pdf and if necessary ask a new question on tex.stackexchange.comUltra
M
9

You can use either -V papersize:a4 per the manual or -V geometry:a4paper. The latter has a side-effect of giving smaller margins than the default template.

Magenta answered 11/5, 2017 at 8:53 Comment(1)
Is there a way to have the width of the paper match A4 but the page to have infinite length (Namely don't cut the MD file into pages, just long page as it looks in HTML)?Jorie
B
5

In order to control papersize and margins you could run something along the lines of:

pandoc -V geometry:a4paper,margin=2cm in.md -o out.pdf

(you may try other options of the geometry.sty latex package)

Bourbon answered 20/1, 2021 at 19:54 Comment(1)
Combining paper geometry with margins is just fantastic!Caldera
T
3
pandoc -V geometry:b5paper infile -o outfile.pdf

Using 'geometry' worked for me.

I presume the options here under 'Reference guide' would work (but I haven't tested).

Thruster answered 25/10, 2016 at 23:18 Comment(0)
S
0

Another option is to add a YAML metadata block to your markdown:

---
geometry: a4paper,margin=2cm
---
Splashy answered 2/7 at 8:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.