1
我正在准备一个RMarkdown reveal.js演示文稿。 我希望幻灯片中的R代码部分在本质上是可折叠的。RMarkdown reveal.js演示代码折叠
我的yaml标题看起来像这样,但代码折叠在最终演示文稿中不可见。
---
title: "Untitled"
output:
revealjs::revealjs_presentation:
code_folding: hide
---
## 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 R Code and Output
```{r}
summary(cars)
```
## Slide with Plot
```{r, echo=FALSE}
plot(cars)
```
添加code_folding: hide
适用于普通RMarkdown文件。
是否code_folding不可用于演示? 有没有其他方法可以尝试?
我会假设它不是。但是你仍然可以用一些JavaScript创建类似的。也许这会有所帮助:https://stackoverflow.com/a/37839683/1777111 –
谢谢Martin,我曾尝试过这段代码,但它似乎只适用于HTML文件,而不是幻灯片。 – Vasim
这是真的。原因是演示文稿的DOM(文档对象模型)与普通的RMarkdown HTML文档不同。你将不得不调整一下代码才能使它工作。 –