How to interrupt an incremental list of items in Rmarkdown, then retake it after a plot or figure?

本秂侑毒 提交于 2020-01-05 03:36:35

问题


I'm really interested in interrupting incremental lists of items created in Rmarkdown with RStudio, to show plots and figures, then retake the list highlighting. This is quite straightforward in Latex, but I couldn't figure out how to achieve the same result using Rmarkdown. Below is some beamer example.

---
title: "Sample Document"
author: "Author"
output:
 beamer_presentation:
  fonttheme: structurebold
  highlight: pygments
  incremental: yes
  keep_tex: yes
  theme: AnnArbor
  toc: true
  slide_level: 3
---

# Some stuff 1
### Some very important stuff

- More detail on stuff 1 
- More detail on stuff 1
- More detail on stuff 1

# The following chart should appear between the first and second item above

```{r, prompt=TRUE}
summary(iris[, "Sepal.Length"])

# Stuff 2
### There are other kinds of stuff?

```{r, prompt=TRUE}
summary(mtcars[, "cyl"])


回答1:


You're asking about the behaviour of pandoc's incremental option that makes "list items in slide shows display incrementally (one by one)." The option causes pandoc to generate the following LaTeX (which in turn generates the PDF):

\\begin{itemize}[<+->]

I'm not sure of the exact LaTeX behaviour, but what about the following?

- More detail on stuff 1
- ```{r, prompt=TRUE}
  summary(iris[, "Sepal.Length"])
  ``` 
- More detail on stuff 1
- More detail on stuff 1



回答2:


You can insert slides in between the items like this:

---
title: "Sample Document"
author: "Author"
output:
 beamer_presentation:
  fonttheme: structurebold
  highlight: pygments
  incremental: yes
  keep_tex: yes
  theme: AnnArbor
  toc: true
  slide_level: 3
---

# Some stuff 1
``` {=latex}
\end{frame}
\begin{frame}<1>[label=foo]
\frametitle{some very important stuff}
```


- More detail on stuff 1 
- More detail on stuff 1
- More detail on stuff 1

``` {=latex}
\end{frame}
```

### Some chart

insert chart here

``` {=latex}
\end{frame}
\againframe<2->{foo}
```

### other stuff


来源:https://stackoverflow.com/questions/37770348/how-to-interrupt-an-incremental-list-of-items-in-rmarkdown-then-retake-it-after

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!