繁体   English   中英

如何在Rmarkdown / ioslides演示文稿中修复列分隔符

[英]How can I fix column breaks in an Rmarkdown / ioslides presentation

使用目前RStudio(0.98.758)的开发版本,我很高兴能在rmarkdown创作ioslides演示文稿。

这种格式rmarkdown文档介绍了如何进行双列幻灯片,并附带警告:

请注意,内容将在列中流动,因此,如果要在一侧显示图像而在另一侧显示文本,则应确保图像具有足够的高度以将文本强制到幻灯片的另一侧。

但我似乎无法使图像足够大! 文本仍然被推离第一列的底部。 在下面的演示文稿中,我想在列中并排比较基本直方图和qplot直方图,并附上一些注释和代码。 我已经为一些相对简短的示例包含了一些基本的解决方案尝试的代码。 如果你要编织它,我认为这个问题很明显。 (请注意,您需要预览版本的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>

这是第4张幻灯片的图像,您可以看到左栏底部的文字被截断,而右栏有足够的空间。

隔断

我也一直在摸不着头脑。

您可以避免使用div并使用{.columns-2}作为标头属性。

对于图像,我使用fig_heightfig_width在yaml中默认设置相对较大的大小。 然后,使用块中的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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM