[英]How can I fix column breaks in an Rmarkdown / ioslides presentation
Using what is currently the development version of RStudio (0.98.758), I'm loving that I can author an ioslides
presentation in rmarkdown
. 使用目前RStudio(0.98.758)的开发版本,我很高兴能在rmarkdown
创作ioslides
演示文稿。
The rmarkdown docs for this format give a description of how to do a two-column slide, and it comes with the warning that: 这种格式的rmarkdown文档介绍了如何进行双列幻灯片,并附带警告:
Note that content will flow across the columns so if you want to have an image on one side and text on the other you should make sure that the image has sufficient height to force the text to the other side of the slide. 请注意,内容将在列中流动,因此,如果要在一侧显示图像而在另一侧显示文本,则应确保图像具有足够的高度以将文本强制到幻灯片的另一侧。
But I can't seem to possibly make an image big enough! 但我似乎无法使图像足够大! Text still gets pushed off the bottom of the first column. 文本仍然被推离第一列的底部。 In the presentation below, I'd like to compare a base histogram with a qplot
histogram side-by-side in columns, with a few comments and code. 在下面的演示文稿中,我想在列中并排比较基本直方图和qplot
直方图,并附上一些注释和代码。 I've included code for a relatively short example with some basic solution attempts. 我已经为一些相对简短的示例包含了一些基本的解决方案尝试的代码。 If you'll knit it, I think the problem will be obvious. 如果你要编织它,我认为这个问题很明显。 (Note that you will need a preview version of RStudio .) (请注意,您需要预览版本的RStudio 。)
---
title: "Two Column"
author: "Some guy on Stack Overflow"
date: "Friday, April 04, 2014"
output: ioslides_presentation
---
## Two-Column Attempt {.smaller}
<div class="columns-2">
Base graphics can be quick...
```{r, fig.width = 3, fig.height = 4}
par_opts <- names(par())
hist(nchar(par_opts),
breaks = seq(1.5, 9.5, by = 1))
```
But `ggplot2` can be quick too:
```{r, fig.width = 2.5, fig.height = 2.5}
require(ggplot2, quietly = T)
qplot(factor(nchar(par_opts)))
```
</div>
## Two-Column Attempt: Taller Hist {.smaller}
<div class="columns-2">
Base graphics can be quick...
```{r, fig.width = 3, fig.height = 6}
par_opts <- names(par())
hist(nchar(par_opts),
breaks = seq(1.5, 9.5, by = 1))
```
But `ggplot2` can be quick too:
```{r, fig.width = 2.5, fig.height = 2.5}
require(ggplot2, quietly = T)
qplot(factor(nchar(par_opts)))
```
</div>
## Two-Column Attempt: Extra div {.smaller}
<div class="columns-2">
Base graphics can be quick...
```{r, fig.width = 3, fig.height = 4}
par_opts <- names(par())
hist(nchar(par_opts),
breaks = seq(1.5, 9.5, by = 1))
```
<div>
...
</div>
But `ggplot2` can be quick too:
```{r, fig.width = 2.5, fig.height = 2.5}
require(ggplot2, quietly = T)
qplot(factor(nchar(par_opts)))
```
</div>
Here's an image of the 4th slide, you can see text is cut off at the bottom of the left column, while the right column has plenty of space. 这是第4张幻灯片的图像,您可以看到左栏底部的文字被截断,而右栏有足够的空间。
I've been scratching my head around this also. 我也一直在摸不着头脑。
You can avoid using the divs and use {.columns-2}
as a header attribute. 您可以避免使用div并使用{.columns-2}
作为标头属性。
For the images I set a relatively large size by default in the yaml using fig_height
and fig_width
. 对于图像,我使用fig_height
和fig_width
在yaml中默认设置相对较大的大小。 Then, using the out.width attribute in the chunk I control the size of the output (350px seems to work well in this layout) 然后,使用块中的out.width属性我控制输出的大小(350px似乎在此布局中运行良好)
---
title: "Two Column"
author: "Some guy on Stack Overflow"
date: "Friday, April 04, 2014"
output:
ioslides_presentation:
fig_height: 7
fig_width: 7
---
## Two-Column Attempt {.smaller .columns-2}
Base graphics can be quick...
```{r, out.width = '350px'}
par_opts <- names(par())
hist(nchar(par_opts),
breaks = seq(1.5, 9.5, by = 1))
```
But `ggplot2` can be quick too:
```{r, out.width = '350px'}
require(ggplot2, quietly = T)
qplot(factor(nchar(par_opts)))
```
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.