问题描述
我正在尝试在 Rmarkdown 中输出一个 beamer_presentation,我想在其中显示一个代码块,然后在单击时显示作为该代码块结果的图形。我知道“xarigan”包非常简单地允许这样做 (--),但我更喜欢使用基本的 Rmarkdown,以实现可重复性目的。
示例:
---
title: "Untitled"
author: "BP"
output: beamer_presentation
---
## Slide with Bullets
- Making a plot
```{r cars,echo= TRUE}
plot(cars$speed,cars$distance)
```
理想情况下,演示文稿将显示项目符号和代码块,然后逐步构建绘图。
谢谢
解决方法
您可以稍微修改一下 Shaded
环境的定义
---
title: "Untitled"
author: "BP"
output:
beamer_presentation:
keep_tex: true
header-includes:
- \renewenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}\pause}
---
## Slide with Bullets
- Making a plot
```{r cars,echo= TRUE}
plot(cars$speed,cars$distance)
```
(如果您不想在整个文档中使用它,请围绕您的情节在一组中执行此操作)