可以在另一个 ioslides 中 nest/include ioslides 吗?

Possible to nest/include ioslides in another ioslides?

我正在处理一些使用 RStudio 从 RMarkdown 生成的 ioslides。我希望能够将一个 Rmd 中渲染的幻灯片包含在另一个 Rmd 中。

截至目前,我只知道如何包含原始 Rmw——而不是 HTML 输出。

---
title: "Main course slides"
author: "author"
date: "November 8, 2015"
output: ioslides_presentation
---

## Some content

```{r child='lecture1.Rmd'}
```

```{r child='lecture2.Rmd'}
```

问题在于它必须渲染每个 Rmd 文件,即使它已经被编译为 HTML。

有谁知道将 ioslides 的 HTML 输出直接包含到另一个 ioslides 中的方法吗?

好吧,我试过了,这是可能的。 我的解决方案适用于 Firefox。在另一个浏览器中可能 而不是 (试试看),当然在 RStudio Viewer 中也不会。 取下面两个文件inner.Rmdouter.Rmd

outer.Rmd

---
title: "Test"
output: ioslides_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```


<style>
    #frame {
        -moz-transform: scale(0.6, 0.6); 
        -moz-transform-origin: 0 0;
        width: 1200px; 
        height: 720px;
    }

    #wrapper {
        position: relative;
        width: 100%;
        left: 54%;
        transform: translate(-50%, 0);
    }
</style>

## R Markdown

Does nesting presentations work well?

## Slide with another presentation inside

<div id="wrapper">
<iframe id="frame" src="inner.html"></iframe>
</div>

inner.Rmd

---
title: "Test"
output: ioslides_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```

## R Markdown

It works!

## Yay!

Yippie!

我尝试了不同的方法。只有 iframe 方法给了我想要的东西。将内部幻灯片居中虽然很棘手。我最终将包装 div 居中,如

left: 54%;
transform: translate(-50%, 0);

不确定为什么需要这个 4% 的差异。但它有效: