I'm trying to come up with a good system for generating slides and accompanying handouts. The ideal system would have the following properties:
pandoc
slide separator format (automatically generate a new slide after headers of a specified level) is preferredsed
), but would prefer not to write a huge infrastructureHere's what I've discovered so far about the various options:
pandoc
slide separator format, although there is a workaround psnup
...)RStudio
presentations (.Rpres
files): pandoc
slide separator format rmarkdown
. It addresses many of the above issues with the .Rpres
format.pandoc
: may be the only markdown-translator that has features such as footnotes, bibliography support, etc.. I can also use pandoc
to generate LaTeX using the tufte-handout class, which meets my criteria of beauty. pandoc -s -S -i -t dzslides --mathjax knitr-slides.md -o knitr-slides.html
, but it doesn't seem to be ...Rnw
(knitr-dialect Sweave) rather than R markdown to begin with. This would give me ultimate flexibility ... 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.
This is an old Q, but I was recently plagued by a similar question, here's what I found:
Using the RPres format, two columns can be specified like so (details). Note that RPres can only be converted to HTML by clicking a button in RStudio, there doesn't seem to be any command line method, which is a bit annoying. Despite, that I'd say it is currently the simplest and most flexible method for getting slide columns with markdown:
=== Two Column Layout === This slide has two columns *** ```{r, echo=FALSE} plot(cars) ```
Some flexibility is afforded by adjusting the column proportions:
=== Two Column Layout === left: 30% This slide has two columns *** ```{r, echo=FALSE} plot(cars) ```
With rmarkdown we can get two columns, but with no control over where the break is, which is a bit of a problem:
--- output: ioslides_presentation --- ## Two Column Layout {.columns-2} This slide has two columns ```{r, echo=FALSE} plot(cars) ```
We can also mix markdown and LaTeX in an Rmd file using the beamer_presentation
format in RStudio to get two columns like this, but can't run any code in either column, which is a limitation:
--- output: beamer_presentation --- Two Column Layout ------- \begin{columns} \begin{column}{0.48\textwidth} This slide has two columns \end{column} \begin{column}{0.48\textwidth} If I put any code in here I get an error, see https://support.rstudio.com/hc/communities/public/questions/202717656-Can-we-have-columns-in-rmarkdown-beamer-presentations- \end{column} \end{columns}
Seems like a regular Rnw LaTeX doc is the best way to get columns if you want to use LaTex, not this markdown hybrid (cf. two column beamer/sweave slide with grid graphic)
In all of the above an image can be placed in an column.
The slidify website has instructions on making two columns here: http://slidify.org/customize.html but it's not clear what has to go into the assets/layouts folder to make it work
You can use fenced_divs
notation or :::
to create columns or `Two Content layout'. See also this page to know more about the notation.
## Slide With Image Left ::: columns :::: column left :::: :::: column right ```{r your-chunk-name, echo=FALSE, fig.cap="your-caption-name"} knitr::include_graphics("your/figure/path/to/the-image.pdf") #The figure will appear on the right side of the slide... ``` :::: :::
Since pandoc 2+
, which supports the notation, was implemented in RStudio v1.2+
, you may need to install RStudio v1.2+
first. The installation is easy enough (at least in my case); just download and install RStudio v1.2+
. In the way of installation, the former version of RStudio
on your computer will be replaced with the new one without uninstalling it manually.
The :::
notation can be used even when you knit .Rmd
files with beamer_presentation
option, as well as when you create HTML slides. So we don't have to neither mix markdown and LaTeX notation in one file, nor add additional codes any longer: just knit the file as you knit other .Rmd
with other options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With