Rmarkdown演示文稿幻灯片代码

时间:2015-02-20 09:02:10

标签: r rstudio r-markdown

我正在使用rmarkdown在RStudio中制作投影仪。我想在演示文稿的顶部获得幻灯片代码。德累斯顿主题应该支持那些代码Dresden enter image description here

那么通过使用rmarkdown可以获得这些代码吗?当我编织pdf时,我得到没有幻灯片代码的演示文稿。

示例代码:

---
title: "Example"
output: beamer_presentation
theme: Dresden
---

# R Markdown

This is an R Markdown presentation. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

# Slide with Bullets

- Bullet 1
- Bullet 2
- Bullet 3

# Slide with R Code and Output

```{r}
summary(cars)
```

# Slide with Plot

```{r, echo=FALSE}
plot(cars)
```

1 个答案:

答案 0 :(得分:4)

我认为slide_level选项可能就是您要找的地方:

  

slide_level选项定义定义单个幻灯片的标题级别。默认情况下,这是层次结构中最高的标题级别,后面紧跟内容,而不是文档中某处的另一个标题。可以通过指定显式slide_level来覆盖此默认值   documentation source

例如slide_level: 2

---
title: "Example"
output: 
  beamer_presentation:
    slide_level: 2
theme: Dresden
---

为您提供以下输出

enter image description here

但是,您需要为幻灯片标题提供较低级别的标题,例如

# R Markdown

## Description
This is an R Markdown presentation. Markdown is a simple formatting 
syntax for authoring HTML, PDF, and MS Word documents. For more 
details on using R Markdown see <http://rmarkdown.rstudio.com>.

When you click the **Knit** button a document will be generated that 
includes both content as well as the output of any embedded R code 
chunks within the document.

修改要获得与附加图像相同的输出,请按以下方式对演示文稿进行分区:

---
title: "Example"
output: 
  beamer_presentation:
    slide_level: 3
theme: Dresden
---
# Section 1
## Subsection 1
### Title A
### Title B
## Subsection 2
### Title A
## Subsection 3
### Title A
### Title B
### Title C
# Section 2
## Subsection 1
### Title A
### Title B

并生成以下演示文稿标题:

enter image description here