Markdown to PDF conversion in Pandoc: making pages landscape?

10,196

Solution 1

Not sure how exactly it works if you convert from a markdown file, but for converting html to pdf using latex, I could make the pdf be landscape by adding this flag to the command:

-V geometry:landscape

So the complete command in your case could then be:

pandoc test.MD -V geometry:landscape -f markdown -o test.pdf

Note, as I said I used latex to convert, so I only can confirm that this one here will work:

pandoc test.html -V geometry:landscape -t latex -o test.pdf

Hope this is useful.

Solution 2

You can create a header file .sty. Insert all packages and settings you need in header file.

e.g. Into header file header.sty type:

    \usepackage{scrextend}
    \usepackage[brazil, brazilian]{babel} 
    \usepackage[utf8]{inputenc} 
    \usepackage[a4paper, landscape,top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry} 

Running pandoc add option -H:

    pandoc test.md -H header.sty -o test.pdf

I hope it works!

Solution 3

You can use the -V geometry:.... parameter to your pandoc command line in order to force landscape and also any arbitrary paper size and the margin widths. Landscape is automatically the result if you define paperwidth larger than paperheight. For example:

pandoc test.MD  \
    -f markdown \
    -o test.pdf \
    -V geometry:"paperwidth=32mm, paperheight=19mm, margin=24pt"

(You can use pt, cm, mm and in as well as any mix of them to describe the distances -- whatever is most convenient to you...)

Share:
10,196

Related videos on Youtube

patrick
Author by

patrick

Updated on September 18, 2022

Comments

  • patrick
    patrick over 1 year

    I am converting a document from Pandoc markdown to .pdf. I run the conversion like this, and everything works fine:

    pandoc test.MD -f markdown -o test.pdf
    

    However, I would like pandoc to output my PDF pages in landscape, rather than portrait, format. Is there a way to do this?

    In the documentation, I could not find the right command (checking under Variables for LaTex). Adding the command \setuppapersize[letter,landscape], which is mentioned there, seems to work only if you use the Context engine which I have no experience with / not installed. I also wanted to note that I am using the \newpage command to break the file up into pages, just in case that makes a difference.

    I'd be grateful for any pointers!

  • userE
    userE over 6 years
    btw: see the documentation of the geometry package for more info and more options