Beamer presentation with a markdown file

Prerequisites

In order for this method to work, you need:

  • pandoc
  • texlive
  • pandoc-citeproc (if you want to use a bibliography)

To install those dependencies on ubuntu, you can use the following commands:

apt install texlive-latex-recommended \
    texlive-fonts-recommended \
    texlive-latex-extra \
    texlive-fonts-extra \
    texlive-xetex \
    texlive-bibtex-extra
apt install pandoc \
    pandoc-citeproc

Write your markdown file

First, you need to add at the top of your file some informations that will be parsed by pandoc:

---
title:
    \textbf{Title of the presentation}
subtitle:
    Subtitle\newline
    2nd subtitle
author: Author(s)
institute: Institut(s)
date: Date and place
section-titles: false
bibliography: a_bib_file.bib
filter: pandoc-citeproc
lang: en-US
beamer: true
theme: Antibes
outertheme: tree
innertheme: rounder
colortheme: crane
urlcolor: red
aspectratio: 169
---

I disable section-titles that creates slides for each new section. You can enable it back by setting it to true.

You can add many options in this sections:

  • logo: to add a logo on slides,
  • fonttheme: to change the font theme,
  • themeoptions: options for LaTeX beamer themes,
  • titlegraphic: image for title slide,
  • aspectratio: to change the ratio, for example 169 for $16:10$, default is $4:3$
  • navigation: if you want to add navigation symbols.

We start by a Plan slide, it will setup the slide-level. Otherwise, you can also use a command line argument of pandoc (--slide-level=3). It specifies which level of header will create a new slide. By default, it is the highest heading level in the hierarchy that is followed immediately by content.

### Plan
\tableofcontents

Following this section, you can use the following headers:

# Section
## Subsection
### Title appearing in the header
#### Block header
Block content

You can put blocks side by side using:

### Allow columns in slide {.columns}
#### Block 1 title {.column width=45%}
Content of block 1

#### Block 2 title {.column width=45%}
Content of block 2

You can setup automatic slide split using:

### Another one {.allowframebreaks}

- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.
- It will allow framebreak.

You can use alerts and examples block:

### Specific syles
#### Alert {.alert}
An alert style block.

#### Example {.example}
An example style block.

And you can use syntax coloring:

### Syntax
```python
def myfunc(x):
    """
    Returns the square of x.
    """
    return x**2
```

You can use also the standard markdown:

### Style text
#### Markdown {.example}
A list:

- _italic_
- __bold__
- [link](url)
- ~~striked~~
- inline math: $x^2+x+1=0$
- equations:
$$\sum_{k=1}^n \dfrac{1}{k^2}$$

Citations are done the same way it is done for latex:

### Citations

\cite{myref} for example of \citep{myref2}.

You need to add --biblatex to your command line, and convert to a .tex and compile it (for example with latexmk -pdf).

Test the compilation

To compile the code, you can use the following command line:

pandoc -st beamer beamer.md -o beamer.pdf

The sample code and result are available here:

Customize

The first thing is to get the template file used to generate your latex (which can be found usually in /usr/share/haskell-pandoc/data/templates/default.latex).

pandoc --print-default-template latex > default.latex

Afterward, you can modify it according to your needs and use it with the command line argument --template=default.latex.

You can also use other templates, for example eisvogel.

Source

Go further: