Geoff
Geoff

Reputation: 180

How to call rmdformat theme from rmarkdown::render function?

I'm trying to render an html document using the rmdformat readthedown theme from the script. However, it doesn't get recognized in the .Rmd file and now I'm trying to add it to the render() function.

The following works but the readthedown theme isn't generated when specified in the rmd file.

rmarkdown::render('myReport.Rmd',output_format = "html_document")

I tried the following but I get an error:

rmarkdown::render('myReport.Rmd',output_format = html_document(theme = readthedown(self_contained =  T, thumbnails=F,lightbox = T,gallery = T,highlight= "tango",toc_depth= 4,css="style.css")))

Any ideas on how to call the readthedown from the render() (i.e. from script)?

Upvotes: 0

Views: 665

Answers (1)

Virgil Ion
Virgil Ion

Reputation: 131

You can specify the options of readthedown theme in the Rmarkdown document (which you will be editing anyway) and then render it with the render() function just like in the documentation of readthedown theme.

This is the rmarkdown file:

---
title: "myReport"
output:
  rmdformats::readthedown:
    self_contained: true
    thumbnails: true
    lightbox: true
    gallery: true
    highlight: tango
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r ,results="asis" }
library(xtable)
xtable(summary(iris))

```


```{r}
head(iris)
```

According to the documentation you simply have to call render() to the rmarkdown file. The html_document it's not needed anymore.

Calling: rmarkdown::render('myReport.Rmd') will render the file with the readthedown theme.

Upvotes: 1

Related Questions