带有 .pull-left[] 的两列中的 Rmarkdown 不起作用两次
Rmarkdown in two columns with .pull-left[] does not work twice
使用 Rmarkdown 制作幻灯片xaringan
。我想要解释左栏代码和右栏代码本身的文本。在每张幻灯片上,我第一次尝试时,它起作用了;但第二次它变得笨拙:右栏开始 之后 左栏完成并且未对齐。
YAML header
---
title: "reprex-left.right"
author: "Ramon Gallego"
date: "4/10/2020"
output: xaringan::moon_reader
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
```
第一次使用时效果很好
.pull-left[
```{r}
y <- data.frame(A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]
.pull-right[
Some text in here talking abut indexing, dataframes, accessing stuff
]
第二次好像是从左栏下方第二栏开始
.pull-left[
See how the right box is going down
so down.
]
.pull-right[
```{r}
y <- data.frame(A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]
Rmarkdown 的输出如下所示
我应该以不同的方式使用这些功能吗?这看起来像是一个错误吗?
如果你使用 css: "ninjutsu"
似乎有效:
YAML header
---
title: "reprex-left.right"
author: "Ramon Gallego"
date: "4/10/2020"
output:
xaringan::moon_reader:
css: "ninjutsu"
---
代码块:
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
```
```{css echo=FALSE}
.pull-left {
float: left;
width: 44%;
}
.pull-right {
float: right;
width: 44%;
}
.pull-right ~ p {
clear: both;
}
```
.pull-left[This is <br> the first text block.]
.pull-right[This is <br> the second <br> text block.]
.pull-left[This <br> is <br>text 3.]
.pull-right[This <br> is <br> <br> text 4.]
.pull-left[
This is text 5.]
.pull-right[This is text 6.]
.pull-left[
```{r}
# code #1 (past 6)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]
.pull-right[This is text 7.]
.pull-right[.full-width[.content-box-yellow[
```{r}
# code #2 (past 7)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]]]
.pull-left[.full-width[.content-box-white[This is text 8.]]]
.pull-left[.full-width[.content-box-white[
```{r}
# code #3 (after 8)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]]]
.pull-right[.full-width[.content-box-white[
```{r}
# code #4 (after c3)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]]]
结果:
我发现您可以将“默认”css 添加到 YAML header 中,以便像这样将此功能添加到您的幻灯片中(您仍然可以组合其他样式,只是先放默认):
output:
xaringan::moon_reader:
css: ["default", "metropolis"]
使用 Rmarkdown 制作幻灯片xaringan
。我想要解释左栏代码和右栏代码本身的文本。在每张幻灯片上,我第一次尝试时,它起作用了;但第二次它变得笨拙:右栏开始 之后 左栏完成并且未对齐。
YAML header
---
title: "reprex-left.right"
author: "Ramon Gallego"
date: "4/10/2020"
output: xaringan::moon_reader
---
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
```
第一次使用时效果很好
.pull-left[
```{r}
y <- data.frame(A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]
.pull-right[
Some text in here talking abut indexing, dataframes, accessing stuff
]
第二次好像是从左栏下方第二栏开始
.pull-left[
See how the right box is going down
so down.
]
.pull-right[
```{r}
y <- data.frame(A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]
Rmarkdown 的输出如下所示
我应该以不同的方式使用这些功能吗?这看起来像是一个错误吗?
如果你使用 css: "ninjutsu"
似乎有效:
YAML header
---
title: "reprex-left.right"
author: "Ramon Gallego"
date: "4/10/2020"
output:
xaringan::moon_reader:
css: "ninjutsu"
---
代码块:
```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
```
```{css echo=FALSE}
.pull-left {
float: left;
width: 44%;
}
.pull-right {
float: right;
width: 44%;
}
.pull-right ~ p {
clear: both;
}
```
.pull-left[This is <br> the first text block.]
.pull-right[This is <br> the second <br> text block.]
.pull-left[This <br> is <br>text 3.]
.pull-right[This <br> is <br> <br> text 4.]
.pull-left[
This is text 5.]
.pull-right[This is text 6.]
.pull-left[
```{r}
# code #1 (past 6)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]
.pull-right[This is text 7.]
.pull-right[.full-width[.content-box-yellow[
```{r}
# code #2 (past 7)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]]]
.pull-left[.full-width[.content-box-white[This is text 8.]]]
.pull-left[.full-width[.content-box-white[
```{r}
# code #3 (after 8)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]]]
.pull-right[.full-width[.content-box-white[
```{r}
# code #4 (after c3)
y <- data.frame(
A = LETTERS[1:5],
B = 1:5,
C = sqrt(6:10))
```
]]]
结果:
我发现您可以将“默认”css 添加到 YAML header 中,以便像这样将此功能添加到您的幻灯片中(您仍然可以组合其他样式,只是先放默认):
output:
xaringan::moon_reader:
css: ["default", "metropolis"]