Ben Bolker Ben Bolker - 4 months ago 115
R Question

two-column layouts in RStudio presentations/slidify/pandoc

I'm trying to come up with a good system for generating slides and accompanying handouts. The ideal system would have the following properties:

  • beautiful in both presentation (PDF/HTML) and handout (PDF) layouts (handouts should have room for taking notes)

  • embedded R chunks, figures, other JPG/PNG pictures, etc.

  • easy to compose

  • build using command-line tools

  • bibliography support

  • pandoc
    slide separator format (automatically generate a new slide after headers of a specified level) is preferred

  • I can live with a little bit of additional processing (e.g. via
    ), but would prefer not to write a huge infrastructure

  • two-column layouts: there is a SO post on how to get multi-column slides from pandoc, but it is LaTeX- rather than HTML-oriented.

  • ability to adjust sizes of embedded images (other than R-generated figures) and column widths on the fly

Here's what I've discovered so far about the various options:

  • Slidify:

    • doesn't do
      slide separator format, although there is a workaround

    • the suggestion for creating handouts is to print to PDF; I'd like to leave room for notes etc. (I could probably figure out a way to do that using something like PDFtk or

  • RStudio
    presentations (

    • does lots of things nicely, including multi-columns with specified widths

    • doesn't support
      slide separator format

    • I can't figure out what's going on under the hood. There is RStudio documentation that describes the translation process for regular HTML, but it doesn't seem to cover the R presentation format (which isn't quite the same). (I have previously invested some effort in figuring out how to get RStudio-like output via pandoc ...), which means I can't generate slides etc. from the command line.

  • RStudio's Development Version (as of March 2014) comes bundled with Pandoc and version 2 of
    . It addresses many of the above issues with the

  • pandoc
    : may be the only markdown-translator that has features such as footnotes, bibliography support, etc.. I can also use
    to generate LaTeX using the tufte-handout class, which meets my criteria of beauty.

    • Unfortunately, it seems not to have built-in two-column format support. Yihui Xie's HTML5 example doesn't show any two-column examples, and it claims (on slide 5) that clicking the "Knit HTML" button in RStudio is equivalent to
      pandoc -s -S -i -t dzslides --mathjax -o knitr-slides.html
      , but it doesn't seem to be ...

  • LaTeX/beamer: I could simply compose in
    (knitr-dialect Sweave) rather than R markdown to begin with. This would give me ultimate flexibility ...

    • despite many years of LaTeX use I do find LaTeX composition more of a pain than markdown composition.

After all that, my specific question is: what's the best (easiest) way to generate a two-column layout for HTML output?

Any other advice will also be appreciated.


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

div#before-column p.forceBreak {
    break-before: column;
div#after-column p.forceBreak {
    break-after: column;

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>

[User:Saittam, Wikipedia](

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