【问题标题】:How can I fix column breaks in an Rmarkdown / ioslides presentation如何修复 Rmarkdown / ioslides 演示文稿中的分栏符
【发布时间】:2014-05-17 06:53:44
【问题描述】:

使用目前的 RStudio 开发版本 (0.98.758),我很高兴我可以在 rmarkdown 中编写 ioslides 演示文稿。

rmarkdown docs for this format 描述了如何进行两列幻灯片,并附带以下警告:

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

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

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

【问题讨论】:

    标签: r rstudio r-markdown


    【解决方案1】:

    我也一直在为这个问题摸不着头脑。

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

    对于图像,我在 yaml 中使用fig_heightfig_width 默认设置了一个相对较大的尺寸。 然后,使用块中的 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)))
    ```
    

    【讨论】:

    • 不错!我在让它工作时遇到了麻烦,但我意识到 RStudio 的浏览器窗口仍然显示问题,但在 Chrome/Firefox 中看起来很棒。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-05
    • 2014-09-01
    • 1970-01-01
    • 2019-04-03
    • 2018-12-31
    相关资源
    最近更新 更多