在rmarkdown :: beamer_presentation中将多个框架选项传递到单个框架 [英] Passing multiple frame options to a single frame in an rmarkdown::beamer_presentation
问题描述
如何在 rmarkdown :: beamer_presentation
中将多个帧选项传递到特定帧?
How to pass several frame options to a specific frame in an rmarkdown::beamer_presentation
?
在下面的MWE中,第二帧应该包含与前一帧相同的表,只是多几行.
In the MWE below, the second frame should contain the same table as on the frame before, just with a few more rows.
因此
-
理想情况下,两个框架的页面编号都是相同的(=>
{.noframenumbering}
)
为简单地将第2帧上的行添加到第1帧下的行,两个帧的内容应在顶部对齐(=> {.t}
).由于其他一些幻灯片需要框架内容的垂直居中对齐,因此不希望在YAML标头中设置 classoption:t
.
to simply add the rows on frame 2 below those on frame 1, the content of both frame should be top-aligned (=> {.t}
).
Since some other slides require vertical center alignment of frame content, setting classoption: t
in the YAML header would be undesired.
MWE
---
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
slide_level: 2
keep_tex: true
---
## Slide
```{r table, cars, echo = FALSE}
library(kableExtra)
knitr::kable(head(mtcars[1:3, 1:3]), caption = "Table caption")
```
## Slide {.noframenumbering}
```{r table, cars2, echo = FALSE}
library(kableExtra)
knitr::kable(head(mtcars[1:6, 1:3]), caption = "Table caption")
```
(在YAML标头中添加多个类选项是可行的,可以使用逗号将它们分开,例如 classoption:t,Aspectratio = 169
.对于我来说,使用相同的方法无法将它们调整为单帧,即 ##幻灯片{.noframenumbering,.t}
.)
(adding multiple classoptions in the YAML-header is feasible by separating them with a comma, e.g. classoption: t, aspectratio=169
. The same approach did not work for me in adjusting them for a single frame though, i.e., ## Slide {.noframenumbering,.t}
.)
推荐答案
您可以使用以下语法将多个选项传递给框架:
You can use the following syntax to pass multiple options to a frame:
---
output:
bookdown::pdf_book:
base_format: rmarkdown::beamer_presentation
slide_level: 2
keep_tex: true
---
## Slide {.t}
```{r table, cars, echo = FALSE}
library(kableExtra)
knitr::kable(head(mtcars[1:3, 1:3]), caption = "Table caption")
```
## Slide {.noframenumbering .t}
```{r table, cars2, echo = FALSE}
library(kableExtra)
knitr::kable(head(mtcars[1:6, 1:3]), caption = "Table caption")
```
这篇关于在rmarkdown :: beamer_presentation中将多个框架选项传递到单个框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!