Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In RStudio, making slide deck with RMarkdown, how can I easily change the theme?

I'm writing an .rmd file in RStudio, and using the Knit button to create a slide deck. I have two options, it appears, ioslides and slidy. I don't really like the default look-and-feel of either. (I think ioslides uses screen real estate inefficiently, and slidy feels like a graphic designer wasn't involved.)

I did a web search for alternative templates/styles/themes, and came upon pages like this gallery, but the tools there seem to be for use outside RStudio, as completely independent projects. In other words, they're not just themes for what I've got, but entirely other solutions that would change my workflow.

Is there a simple way to tell RStudio to use a different template/theme with either ioslides or slidy? For example, can I download a CSS file from somewhere, and point RStudio to it with the css: option in the yaml header of my .rmd file? If so, is there a gallery of such CSS templates?

like image 914
Nathan Avatar asked Apr 13 '16 17:04

Nathan


People also ask

How do you create a presentation in R?

To create a new R Presentation you execute the New File -> R Presentation command: After specifying the location to save the presentation, a new presentation will be created and a preview will show within the Presentation tab in the upper right corner of the IDE.

How do I display Markdown in R?

To open a new file, click File > New File > R Markdown in the RStudio menu bar. A window will pop up that helps you build the YAML frontmatter for the . Rmd file. Use the radio buttons to select the specific type of output that you wish to build.


2 Answers

Here's what I ended up doing. It's not as smooth as I'd like it to be, but it's decent. I'm glad to entertain better answers.

  1. Download any of the style files linked to from this knitrBootstrap code into the same folder as your R Markdown file.
  2. Edit it so that the URL at the start of the file begins with http: so that knitr knows not to look on your filesystem for the additional resources (fonts), but on the Web.
  3. Edit it further to remove any pipes (|) in that URL, because knitr can't handle them (as far as I can tell). (Remove everything after the pipe, too.)
  4. Edit it further to change everything of the form url('../fonts/***.eot'); to now instead be of the form url('https://netdna.boostrapcdn.com/bootswatch/3.0.0/fonts/***.eot');.
  5. Link to it from your R Markdown file with the css: attribute in the YAML header.
like image 191
Nathan Avatar answered Oct 16 '22 13:10

Nathan


Have you tried using the built in Bootswatch themes? They're fairly limited, but in doing so you can quickly customise many elements.

e.g

title: "Test"
author: "John"
date: "5 June 2017"
output: 
  slidy_presentation: 
    fig_width: 12.5
    font_adjustment: -1
    theme: readable        

Other themes may be found here Bootswatch.

edit: removed a typo

like image 1
JohnL_10 Avatar answered Oct 16 '22 14:10

JohnL_10