首页 > 解决方案 > xaringan code output same style as bookdown

问题描述

Is it possible to customize xaringan to have the code output bookdown style, that is, code and output in the same block?. For instance, see this:

library(tidyverse)
#> ── Attaching packages ────────────────────────────────── tidyverse 1.2.1 ──
#> ✔ ggplot2 3.1.0.9000     ✔ purrr   0.2.5     
#> ✔ tibble  2.0.0          ✔ dplyr   0.7.8     
#> ✔ tidyr   0.8.2          ✔ stringr 1.3.1     
#> ✔ readr   1.3.1          ✔ forcats 0.3.0
#> ── Conflicts ───────────────────────────────────── tidyverse_conflicts() ──
#> ✖ dplyr::filter() masks stats::filter()
#> ✖ dplyr::lag()    masks stats::lag()

The default style has the code and the output in two different blocks:

标签: rxaringan

解决方案


使用knitr chunk选项 collapse = TRUE例如:

```{r, collapse=TRUE}
library(tidyverse)
```

推荐阅读