9
votes

I would like to be able to pass frame options to beamer via RStudio-Rmarkdown-Pandoc-Beamer path. This would allow to take advantage of beamer's options to suppress frames from being printed. Beamer allows the following:

\documentclass[handout]{beamer}
\begin{document}

\begin{frame}
Slide 1
\end{frame}

\begin{frame}<handout:0>
Slide 2 to be suppressed
\end{frame}

\end{document}

I am aware that the pandoc .tex template can be altered to statically add options to slide frames but would like to do this on the fly something like:

##Slide 1

## Slide 2 <handout:0>
2

2 Answers

4
votes

The pandoc maual has the section Frame attributes in beamer.

But since handout is not on the list, you can use a pandoc filter to remove certain things instead. Put the following in a file named e.g. filter.lua

function Div(el)
  if el.classes[1] == 'hidden' then
    return {}
  else
    return el
  end
end

To use from rmarkdown:

---
output:
  beamer_presentation:
    pandoc_args: ["--lua-filter=filter.lua"]
---

# In the morning

::: hidden :::
## This part is removed

content
:::

## Breakfast

- Eat eggs
- Drink coffee

To keep the slide, simply run it without the filter.

1
votes

Dirty hack to hide a frame in handout mode:

---
output: 
  beamer_presentation:
    keep_tex: true
classoption: handout

---

# normal frame




``` {=latex}
\end{frame}
\begin{frame}<handout:0>
\frametitle{special}
```

hidden in handout


# normal frame