(define sixhat (λ (dave) (display 'ideas)))

Beamer slides with markdown and pandoc

When it comes to producing quality prints nothing compares to Latex and I use it extensively throughout my working needs. In recent years I've moved from the full Latex syntax to the quick and dirty markdown for my source files. At least for my initial drafts. Then I convert either to TEX or directly to the final PDF format with pandoc1.

Pandoc is a swiss-army knife for the conversion between different document formats. It is capable of handling more formats than those one can imagine (or need). Also, it has very sensible defaults in terms of templates. It gives you full control over them if you need so. There are a ton of advanced features. Usually converting something is just a matter of issuing the command.

pandoc -o output.html intupt.txt

For producing slides I have used marp2 for most of my markdown to pdf conversions in the past, but its dependency on node makes it a bit brittle and forces me into repair mode every now and then.

Therefore, I have a pandoc pipeline that produces great slides and usually doesn't require much maintenance. Also, pandoc allows for extra functionality that you don't get with marp, like automatic tocs, sectioning and bibliographies.

I usually use something like this command to produce my slides.

pandoc -t beamer -f markdown -o output.pdf --pdf-engine xelatex --highlight-style tango input.md

Note that I usually use xelatex (or sometimes luatex) mainly to support UTF8 in input files directly.

I usually have this command in a script file that makes it quicker to run on any markdown file I need.

#!/bin/bash
set -e
for fich; do :; done
set -x
pandoc -t beamer -f markdown+implicit_figures -o "$fich".pdf --pdf-engine xelatex --highlight-style tango $* 
open "$fich".pdf

Note that this uses a loop to get the last element of a input string into the variable $fich and then passes the list of inputs to the pandoc command with $*. This allows me to pass additional pandoc settings for a particular rendering, for example changing paper size, or styling.

Finally one last thing usually want when editing my slides is to rerun this script everytime I press save. For this I use entr3 with the following command (md2beamer.sh is the script name):

ls input.md | entr -r md2beamer.sh input.md

That's it. Simple MD to Beamer slides without complications. Sytling and colorthemes (among other things like titles, authors and institution) can be controlled by the options in the markdown yaml header.

References

1

Pandoc https://pandoc.org/

2

Marp https://github.com/marp-team/marp-cli

3

Entr https://github.com/eradman/entr