Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RStudio Pandoc Beamer add \frame options

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>
like image 591
JAllen Avatar asked Nov 23 '15 21:11

JAllen


2 Answers

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.

like image 192
mb21 Avatar answered Oct 23 '22 07:10

mb21


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
like image 31
samcarter_is_at_topanswers.xyz Avatar answered Oct 23 '22 06:10

samcarter_is_at_topanswers.xyz