简体   繁体   English

如何从 rmarkdown::render 函数调用 rmdformat 主题?

[英]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.我正在尝试使用脚本中的 rmdformat readthedown 主题呈现 html 文档。 However, it doesn't get recognized in the .Rmd file and now I'm trying to add it to the render() function.但是,它没有在 .Rmd 文件中被识别,现在我试图将它添加到 render() 函数中。

The following works but the readthedown theme isn't generated when specified in the rmd file.以下工作但在 rmd 文件中指定时不会生成 readthedown 主题。

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() (ie from script)?关于如何从 render() (即从脚本)调用 readthedown 的任何想法?

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.您可以在 Rmarkdown 文档中指定 readthedown 主题的选项(无论如何您将对其进行编辑),然后使用 render() 函数对其进行渲染,就像在readthedown主题的文档中一样

This is the rmarkdown file:这是 rmarkdown 文件:

---
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.根据文档,您只需将 render() 调用到 rmarkdown 文件即可。 The html_document it's not needed anymore.不再需要它的 html_document。

Calling: rmarkdown::render('myReport.Rmd') will render the file with the readthedown theme.调用: rmarkdown::render('myReport.Rmd')将使用 readthedown 主题渲染文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM