How to Use Two-Column Layout with Reveal.Js

How can I fix the reveal-md rendering of this two-column slide (code+image)?

Another way to do it by using a little more modern CSS attribute called flex. I think your problems resulting in some wired template settings of the environment you are using. So here is my second go:

--
title: "Bad two-columns rendering"
author: "Yours truly"
---
<style>
.container{
display: flex;
}
.col{
flex: 1;
}
</style>

<div class="container">

<div class="col">

```python

print("Is the rendering bad?")
print("Yeah!")
print("How can you be sure?")
print("Look at the beak of Tux")

```
<!-- .element: style="width: 100%;" -->

</div>

<div class="col">

![tux](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/Tux-simple.svg/768px-Tux-simple.svg.png)

</div>

</div>

Here I'm using classes to set the CSS attributes.

example screenshot

asynchronus content in two-column reveal.js presentation

I don't think the iframe will work very well for multiple reasons:

  • The scaling problem that you already encountered. iframes are notoriously hard to scale, as the size has to be hardcoded when embedding them.
  • The nested presentation will have its own navigation, so it wont be clear where to proceed with the presentation.

You also already anticipated teh next problem - when putting the same video on multiple slides indeed the video will "restart" - first the old video will fade out and then the new copy will fade in. This is because each slide is it's own self-contained HTML element. So this also won't do what you want.

Instead I would propose to use Fragments. Fragments are the way you can have individual elements on a page change without changing the whole slide (commonly used for making bullet points appear).

In your case you can implement your "sub slides" on the left side as individual fragments that appear on top of each other using the css classes fragment fade-in-then-out (to make them appear/disappear) and r-stack (to make them appear on top of each other). You can see an example on the "Layout" page in the documentation (the second one with cat pictures).

If you put all of your sub-slides as fragments, then you can just have your video embedded as normal on the right and it will play independently from the subslides changing. Once the last sub-slide is passed, the presentation will move on to the next real slide (stopping the video).

columns in reveal.js with org-mode

I found a solution in this presentation, where the column class is used.

To use it with org-reveal, I did the following:

#+REVEAL_HTML: <div class="column" style="float:left; width: 50%">
Column 1
#+REVEAL_HTML: </div>

#+REVEAL_HTML: <div class="column" style="float:right; width: 50%">
Column 2
#+REVEAL_HTML: </div>

Incremental slides do not work with a two-column layout

It is a bit of a hack but you could use the template feature of remarkjs coupled with --.

-- tells remarkjs to use the previous slide as a template. In a template you could use {{content}} to tell where to put the next content. If you don't, it is append at the end of the template. it is why -- is used for incremental slide.

As explained in other answer, you cannot use -- inside a .class[] call as it isn't a template then. However, you can use {{content}} inside .class[] so that using -- after will put the next text inside your previous .class[].

It is a bit of a hack because I don't think it will work with complicated incremental logic.

---
title: "Title"
author: "Myself"
date: "`r format(Sys.Date(), '%d.%m.%Y')`"
output:
xaringan::moon_reader:
css: ["default"]
nature:
highlightStyle: dracula
highlightLines: true
countIncrementalSlides: false
---

```{r setup, include=FALSE}
options(htmltools.dir.version = FALSE)
```

.left-column[
## Left column title
]
.right-column[
A whole sentence

+ one `Markdown` bullet point
{{content}}

]

--

+ a second bullet point
{{content}}

--

+ a third bullet point
{{content}}

--

+ a sub level

in the previous exemple, the right column has text appearing incrementally.

two-column layouts in RStudio presentations/slidify/pandoc

I now have what I think is a reasonable solution that should apply at least to ioslides-based solutions, and maybe (?) to other HTML5-based formats. Starting here, I added

<style>
div#before-column p.forceBreak {
break-before: column;
}
div#after-column p.forceBreak {
break-after: column;
}
</style>

to the beginning of my document; then putting <p class="forceBreak"></p> within a slide with {.columns-2} breaks the column at that point, e.g.

## Latin hypercube sampling {.columns-2}

- sample evenly, randomly across (potentially many) uncertain parameters

<p class="forceBreak"></p>

![](LHScrop.png)
[User:Saittam, Wikipedia](https://commons.wikimedia.org/wiki/File:LHSsampling.png#/media/File:LHSsampling.png)

There may be an even better way, but this isn't too painful.

@ChrisMerkord points out in comments that

.forceBreak { -webkit-column-break-after: always; break-after: column; }

worked instead (I haven't tested ...)



Related Topics



Leave a reply



Submit