Generate PDF from markdown via pandoc

One option to generate PDF from a markdown file like README.md, is to use pandoc.


Installation


You need to install both:

- [Pandoc](https://pandoc.org/installing.html)

- [MiKTeX](https://miktex.org/download)

Then, restart any terminal windows where you will run the command to generate PDF.

Execution - basic command

pandoc -o ./README.pdf ./README.md

Execution - command with margins and figures

pandoc -V geometry:"top=2cm, bottom=1.5cm, left=2cm, right=2cm" -f markdown-implicit_figures -o ./README.pdf ./README.md

Execution - command with margins and figures and colored links

pandoc -V linkcolor:blue -V urlcolor:blue -V geometry:"top=2cm, bottom=1.5cm, left=2cm, right=2cm" -f markdown-implicit_figures+autolink_bare_uris -o ./README.pdf ./README.md

  • note: "autolink_bare_uris" is needed to color in the links (at least with pandoc 3.1.11.1 on Windows).

For more details and examples, see this excellent Medium article at https://pavolkutaj.medium.com/markdown-to-pdf-with-pandoc-and-miktex-58b578cedf4b

Comments