Producing slide shows with Pandoc

You can use Pandoc to produce an HTML + javascript slide presentation that can be viewed via a web browser. There are four ways to do this, using S5, DZSlides, Slidy, or Slideous. You can also produce a PDF slide show using LaTeX beamer.

Here’s the markdown source for a simple slide show, habits.txt:

% Habits
% John Doe
% March 22, 2005

# In the morning

## Getting up

- Turn off alarm
- Get out of bed

## Breakfast

- Eat eggs
- Drink coffee

# In the evening

## Dinner

- Eat spaghetti
- Drink wine

------------------

![picture of spaghetti](images/spaghetti.jpg)

## Going to sleep

- Get in bed
- Count sheep

To produce the slide show, simply type

pandoc -t s5 -s habits.txt -o habits.html

for S5,

pandoc -t slidy -s habits.txt -o habits.html

for Slidy,

pandoc -t slideous -s habits.txt -o habits.html

for Slideous,

pandoc -t dzslides -s habits.txt -o habits.html

for DZSlides, or

pandoc -t beamer habits.txt -o habits.pdf

for beamer.

With all HTML slide formats, the --self-contained option can be used to produce a single file that contains all of the data necessary to display the slide show, including linked scripts, stylesheets, images, and videos.

Structuring the slide show

By default, the slide level is the highest header level in the hierarchy that is followed immediately by content, and not another header, somewhere in the document. In the example above, level 1 headers are always followed by level 2 headers, which are followed by content, so 2 is the slide level. This default can be overridden using the --slide-level option.

The document is carved up into slides according to the following rules:

  • A horizontal rule always starts a new slide.

  • A header at the slide level always starts a new slide.

  • Headers below the slide level in the hierarchy create headers within a slide.

  • Headers above the slide level in the hierarchy create title slides, which just contain the section title and help to break the slide show into sections.

  • A title page is constructed automatically from the document’s title block, if present. (In the case of beamer, this can be disabled by commenting out some lines in the default template.)

These rules are designed to support many different styles of slide show. If you don’t care about structuring your slides into sections and subsections, you can just use level 1 headers for all each slide. (In that case, level 1 will be the slide level.) But you can also structure the slide show into sections, as in the example above.

For Slidy, Slideous and S5, the file produced by pandoc with the -s/--standalone option embeds a link to javascripts and CSS files, which are assumed to be available at the relative path s5/default (for S5) or slideous (for Slideous), or at the Slidy website at w3.org (for Slidy). (These paths can be changed by setting the slidy-url, slideous-url or s5-url variables; see --variable, above.) For DZSlides, the (relatively short) javascript and css are included in the file by default.

Incremental lists

By default, these writers produces lists that display all at once. If you want your lists to display incrementally (one item at a time), use the -i option. If you want a particular list to depart from the default (that is, to display incrementally without the -i option and all at once with the -i option), put it in a block quote:

> - Eat spaghetti
> - Drink wine

In this way incremental and nonincremental lists can be mixed in a single document.

Styling the slides

You can change the style of HTML slides by putting customized CSS files in $DATADIR/s5/default (for S5), $DATADIR/slidy (for Slidy), or $DATADIR/slideous (for Slideous), where $DATADIR is the user data directory (see --data-dir, above). The originals may be found in pandoc’s system data directory (generally $CABALDIR/pandoc-VERSION/s5/default). Pandoc will look there for any files it does not find in the user data directory.

For dzslides, the CSS is included in the HTML file itself, and may be modified there.

To style beamer slides, you can specify a beamer theme or colortheme using the -V option:

pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf