How to convert a Markdown file to PDF

I have a Markdown file that I wish to convert to PDF so that I can upload it on Speakerdeck. I am using Pandoc to convert from markdown to PDF.

My problem is I can't specify what content should go on what page of the PDF, because Markdown doesn't provide any feature like that.

E.g., Markdown:

###Hello
* abc
* def

###Bye
* ghi
* jkl

Now I want Hello to be one slide and Bye to be on another slide on Speakerdeck. So, I will need them to be on different pages in the PDF that I generate using Pandoc.

But both Hello and Bye gets on the same page in the PDF.

How can I accomplish this?


Solution 1:

Via the terminal (tested in 2020)

Download dependencies

sudo apt-get install pandoc texlive-latex-base texlive-fonts-recommended texlive-extra-utils texlive-latex-extra

Try to use

pandoc MANUAL.txt -o example13.pdf
pandoc MANUAL.md -o example13.pdf

Via a Visual Studio Code extension (tested in 2020)

  • Download the Yzane Markdown PDF extension
  • Right click inside a Markdown file (md)
  • The content below will appear
  • Select the Markdown PDF: Export (pdf) option

Note: Emojis are better in Windows than Linux (I don't know why)

Visual Studio Code Markdown PDF

Solution 2:

2016 update:

NPM module: https://github.com/alanshaw/markdown-pdf

Has a command line interface: https://github.com/alanshaw/markdown-pdf#usage

npm install -g markdown-pdf
markdown-pdf <markdown-file-path>

Or, an online service: http://markdown2pdf.com

Solution 3:

As SpeakerDeck only accepts PDF files, the easiest option is to use the Latex Beamer backend for pandoc:

pandoc -t beamer -o output.pdf yourInput.mkd

Note that you should have LaTeX Beamer installed for that.

In Ubuntu, you can do sudo apt-get install texlive-latex-recommended to install it. If you use Windows, you may try this answer.

You may also want to try the HTML/CSS output from Slidy:

pandoc --self-contained -t slidy -o output-slidy.html yourInput.mkd

It has a decent printing output, as you can check out trying to print the original.

Read more about slideshows with pandoc here.

Solution 4:

Adding to elias' answer, if you want to separate text in slides, just put *** between the text you want to separate. For your example to be in several pages, write it like this:

### Hello
- abc
- def

***

### Bye
- ghi
- jkl

And then use elias' answer, pandoc -t beamer -o output.pdf yourInput.md.

I have Ubuntu 18.10 (Cosmic Cuttlefish) and installed the full package from texlive. It works for me.