2
votes

I would like to write beamer slides in Pandoc markdown and generate matching lecture notes with longer, explanatory text. But I can't figure out the logic.

If I were to do this in LaTeX, then I would use the beamerarticle package in the article class version or the ignorenonframetext option in the beamer class version. With this setup I can add notes between frames and quickly generate slides for the screen and lecture notes for the desks. Here is an example. Toggling the comments on the first three lines should illustrate this.

% \documentclass{article}
% \usepackage{beamerarticle}
\documentclass[ignorenonframetext]{beamer}

\begin{document}

\begin{frame}{This is my first slide}
This is my first slides content.

\[ PV = FV / (1 + r)^t \]
\end{frame}

This is the longer text that I want to appear in the notes/handouts, but not in the beamer.

\begin{frame}{This is the second slide}
Short content.
\end{frame}

Longer content.

\end{document}

But this doesn't work with Pandoc slides because I can't write between the frames because the frames are only split by ---.

I tried to write my own command gobble and it works fine when I compile to pdf, but not when I compile to beamer. Here is an example. Toggling the comments on the newcommand lines only provides the desired result for the article class. The beamer class won't compile.

% Chapter 1
% Richard
% May 15, 2015

\newcommand{\gobble}[1]{}
<!-- \newcommand{\gobble}[1]{#1} -->

---

# This is my first slide

This is my first slides content. Test.

$$ PV = FV / (1 + r)^t $$

\gobble{This is the longer text that I want to appear in the notes/handouts, but not in the beamer}

---

# This is the second slide

Short content.

Is there a way to approximate beamerarticle and ignorenonframetext in Pandoc markdown?

2
This is material for a good feature request to submit to Pandoc developers. You should ask for + discuss potential current workarounds here and submit a feature request for proper support here.Kurt Pfeifle
@KurtPfeifle - Thanks! I found the right way to achieve this (I think) and will post a solution below. Thanks for the prod.Richard Herron

2 Answers

1
votes

One solution is to wrap "notes" that you want to appear in the handout, but not in the slides, in <div class="notes"></div>. When you compile to beamer with something like pandoc -o temp.pdf -t beamer temp.md anything wrapped in this div tag will be wrapped in \notes{} in the intermediate \LaTeX\ file and not appear in basic beamer slide.

% Chapter 1
% Richard
% May 15, 2015

# This is my first slide

This is my first slides content. Test.

$$ PV = FV / (1 + r)^t $$

<div = class="notes">
This is the longer text that I want to appear in the notes/handouts, but not in the beamer
</div>

# This is the second slide {.allowframebreaks}

Short content.

\framebreak

Second part of second slide.

Another trick is to specify frame breaks with \framebreak and include {.allowframebreaks} at the slide level. If you compile the article version to \LaTeX\ rather than directly to pdf and define \framebreak to be an empty macro with

\def \framebreak {}

then you can get the best of both worlds.

0
votes

Another possible work around is using the --slide-level flag. Pandoc does not transfer content above the slide level. You can manually set the slide level and the insert a higher level header like

% Title
% Me
% today

#

This appears only in the supporting material.

## This is my first slide

This is my first slides content. Test.

$$ PV = FV / (1 + r)^t $$

#

This is the longer text that I want to appear in the notes/handouts, but
not in the beamer

## This is the second slide

Short content.

Running with pandoc --to=beamer -o mwe.pdf --slide-level=2 mwe.md generates the slide show without the content under level 1 headers. The downside is you get empty subsection headers in the document. If you're okay with not having section header slides, you can set the section-titles to false in the metadata block. I wound up post-processing the generated LaTeX to strip out the empty headers and running LaTeX separately from Pandoc.