Actions: | Security

AllGoodBits.org

Navigation: Home | Services | Tools | Articles | Other

Making presentations with Pandoc

I find Pandoc is a useful tool for content work. It is able to convert between various structured document types, but I don't use it quite often enough to remember my preferred approaches; so here are some examples. This is more or less lifted from the docs, but taking just the bits that I like to use to speed me along. Here is what the user guide says about slide shows, for more information.

Basic example

Basic Source

% My Presentation Title
% Duncan Hutty
% November 27, 2012

# First Slide, Section1

## First Slide, Section1, Subsection1

- first point
- second point

## First Slide, Section1, Subsection2

- first point in subsection2
- second point in subsection2

# First Slide, Section2

## First Slide, Section2, Subsection1

- first point
- second point

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

## Second Slide, Section1

- first point
- second point

Incantation for S5

pandoc -f markdown -t slidy -i -s --self-contained -o mypresentation.html mypresentation_source.md

-i,--incremental makes list items display incrementally

-s,--standalone ensures a complete html document not just a fragment.

--self-contained includes the necessary css/javascript to ensure that the Slidy slideshow functionality works. (This used to be --offline if you have an older version of pandoc).

Styling the Slidy presentation

Modify the CSS files in $DATADIR/slidy/default where $DATADIR is $HOME/.pandoc or $CABALDIR/pandoc-VERSION/s5/default.

Incantation for Beamer

pandoc -f markdown -t beamer -o mypresentation.pdf mypresentation_source.md

Then use a pdf viewer that supports slideshows.

Styling the Beamer presentation

Pass an additional option, depending on the themes present in your LaTeX installation.

pandoc -f markdown -t beamer -V theme:Warsaw -o mypresentation.pdf mypresentation_source.md

Options I probably want to consider

-5,--html5        Only for the html writer.
--normalize       Normalize  the  document  after reading: merge adjacent Str or Emph elements, for example, and remove repeated Spaces.
-S,--smart        Convert straight quotes -> curly quotes, `--` -> dash, `...` -> ellipse, default for latex output.
-i,--incremental  Make list items in S5 display incrementally (one by one). The default is for lists to be displayed all at once
-N,--number-sections Number section headings in LaTeX or HTML output.
--listings        Use listings package for LaTeX code blocks
--toc             Table of contents
--base-header-level=N
--css=URL         URL for CSS
--section-divs   Wrap sections in <div> tags (or <section> tags in HTML5), and attach identifiers to the enclosing <div> (or <section>) rather than the header itself.

Multiple Sources

Here is a pattern for larger works that should be split across multiple files.

title.txt:

% My Grand Presentation
% Duncan Hutty

01-intro.txt:

# Introduction to the Grand Presentation

## Scope

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

## Assumptions/Limitations

* Point1
* Point2
* Point3
* Point4
* Point5

02-in-advance.txt:

# Prerequisites

# Advance Planning

03-installation.txt:

# From packages

## Linux distros like RedHat

## Linux distros like Debian

# From source

## OSX

## Windows

Note how the intro chapter is split across multiple slides using a horizontal rule.

Incantation for multiple sources

pandoc -f markdown -t beamer -i -o Grand.pdf title.txt \
  01-intro.txt \
  02-in-advance.txt \
  03-installation.txt

There is no problem if you need to add chapters/sections afterwards, because we're including an ordering explicitly in the filename. This also lends itself to using make(1) as a shortcut. Reordering could be tedious, but not difficult.

This works for making a presentation in S5 as well:

pandoc -f markdown -t s5 -i -s -N -o Grand.html \
  title.txt \
  01-intro.txt \
  02-in-advance.txt \
  03-installation.txt