Reputation: 2206
I'm working with some ioslides generated from RMarkdown using RStudio. I'd like to be able to include the rendered slides from one Rmd in another.
As of now I only know how to include the raw Rmw -- not the HTML output.
---
title: "Main course slides"
author: "author"
date: "November 8, 2015"
output: ioslides_presentation
---
## Some content
```{r child='lecture1.Rmd'}
```
```{r child='lecture2.Rmd'}
```
The problem with this is that it has to render each Rmd file even if it has already been compiled to HTML.
Does anyone know of a way to include the HTML output from ioslides into another ioslides directly?
Upvotes: 2
Views: 276
Reputation: 23889
Well I tried it and it is possible. My solution works in Firefox. Probably not in another browser (try it out) and certainly not in RStudio Viewer.
Take the following two files inner.Rmd
and outer.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!
I tried different approaches. Only the iframe
method gave me what I want. Centering the inner slides though is tricky. I ended up with centering the wrapping div like
left: 54%;
transform: translate(-50%, 0);
Not sure why this difference of 4% is necessary. But it works:
Upvotes: 4