Rmarkdown在带有.pull-left []的两列中无效两次

问题描述 投票:2回答:1

使用Rmarkdown用xaringan制作幻灯片。我想要文本在左列说明代码,在代码本身在右边。在每张幻灯片上,当我第一次尝试时,它都可以工作;但是第二次变得笨拙:右列开始after左列完成并且未对齐。

YAML标头

---
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的输出看起来像这样

Probelamtic slide

我应该以不同的方式使用这些功能吗?这看起来像个虫子吗?

r r-markdown multiple-columns xaringan
1个回答
0
投票

如果使用css: "ninjutsu",这似乎可以工作:

YAML标头

---
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))
    ```
]]]

结果:

“

© www.soinside.com 2019 - 2024. All rights reserved.