r - 在 RMarkdown ioslides {.columns-2} 布局中强制分列

标签 r markdown r-markdown presentation ioslides

在使用 RMarkdown 的 ioslides 准备演示文稿时,我遇到了一个我无法找到解决方案的问题。 This answer也没有解决这个具体问题。

有时,两列布局最好用一侧的图像和另一侧的文本来解释某些内容。但是,在以下示例中,分栏符似乎没有按预期工作。

有什么办法可以到强制分列 在特定点?我曾考虑增加右侧的图像高度,但不幸的是,有时这不是一种选择。

---
title: "Some stange column break"
output: 
  ioslides_presentation:
    widescreen: true
---

## Slide Title {.columns-2 .smaller}
### Slide Subtitle

>- Some bullet points which take up some space space space space space space space

>- on the column on the left

>- which are then wrapped to the right column. 

>- *Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.*

>- line break after this longer bullet point but intead it breaks in some strange place even though it would have space at the bottom of the left column!

<!-- the columns should break here -->

```{r, echo = FALSE, out.width = "470px"}
plot(mtcars)
```

enter image description here

最佳答案

我过去使用过两种方法,都在您链接的问题中给出了答案。我是否遗漏了为什么这些不能满足您的需求?

方法 1 似乎是您所追求的,但我个人倾向于使用方法 2,因为我喜欢具有不同宽度列的灵活性。

注意:我只使用 ioslides 测试了这些方法格式

方法一:forceBreak,内联样式标签

这需要定义一个额外的 CSS 类,您可以在文档的开头进行内联。

---
title: "Untitled"
output: 
  ioslides_presentation:
      widescreen: true
---

<style>
.forceBreak { -webkit-column-break-after: always; break-after: column; }
</style>


## Slide Title {.columns-2 .smaller}
### Slide Subtitle

>- Some bullet points which take up some space space space space space space space

>- on the column on the left

>- which are then wrapped to the right column. 

>- *Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.*

>- line break after this longer bullet point but intead it breaks in some strange place even though it would have space at the bottom of the left column!

<p class="forceBreak"></p>

```{r, echo = FALSE, fig.width=4.7}
plot(mtcars)
```

forceBreakWide

方法二:HTML标签

此方法不需要任何额外的 CSS 定义或外部文件。
---
title: "Untitled"
output: ioslides_presentation
---

## Another Method for Two Column Layouts

<div style="float: left; width: 40%;">
+ This text is on the left
</div>

<div style="float: right; width: 60%;">
+ This text is on the right
</div>

关于r - 在 RMarkdown ioslides {.columns-2} 布局中强制分列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50378349/

相关文章:

r - 如何为日期滑动输入

r - 选择以另一个数据框为条件的数据框的行号

markdown - 使用 Pandoc 时禁用 'TeX math'

javascript - 如何将美人鱼图添加到 rocket.chat 实例?

html - rmarkdown 在 kable 中转义 html

r - 如何根据列名将函数应用于特定列?

r - 在 R 代码中使用分号或显式换行有什么区别

javascript - 如何在 BrowserWindow (Electron) 中打开 Markdown 文件?

rstudio - RMarkdown 和 RStudio 中的键盘快捷键 Ctrl+B 和 Ctrl+I

r - 从参数设置 Rmarkdown 中的文档标题