PDF presentation from Markdown

January 27, 2023 - Reading time: 3 minutes

I use Markdown format to write my notes and documents. You can use Markdown to create presentations in PDF format.

Tools used

For this to work you will need a text editor (I use helix), to create your presentation. Then we will use tool that can convert Markdown to many formats called pandoc. We will use slide show functionality of this tool.

Pandoc needs an extra dependency to be able to work with PDFs called texlive. It uses a module called beamer that is included in texlive.

On Void Linux thees can be installed with:

xi pandoc texlive

Writing presentation

The Markdown document need to contain a header:

aspectratio: 1610
title: "My Presentation"
subtitle: "Super interesting stuff"
author: "HxD"
date: 2023

Next you can use first level headings ("#") for section slides (slide with just the title in the middle). These must not be followed by any other content, only by second level headings ("##"). These in turn will become separate slides with content. Any extra level of heading will will be included in same slide.

You can also add {.shrink} to the end second level heading name to make the slide content smaller to fit on the slide. There are more options to be found in documentation.

Generating the presentation PDF

Run the flowing command:

pandoc <markdown_file>.md -t beamer -o <output_file>.pdf -V theme:Madrid

You can use different theme by replacing Madrid with one of built in themes:

AnnArbor Antibes Bergen Berkeley Berlin Boadilla CambridgeUS Copenhagen Darmstadt Dresden EastLansing Frankfurt Goettingen Hannover Ilmenau JuanLesPins Luebeck Madrid Malmoe Marburg Montpellier PaloAlto Pittsburgh Rochester Singapore Szeged Warsaw bars boxes classic compatibility default lined plain shadow sidebar split tree

Now you can open it with your browser or tool like okular.