R Markdown: Remove tabset configuration when rendering

 ̄綄美尐妖づ 提交于 2020-06-01 07:40:12

问题


I have the following question: I am creating an HTML document using RMD and html_document. I use tabset and tabset-pills to structure the content. My question now is:

Can I render the same RMD document but do not interprete the tabset settings?

To provide an example: Can I render this RMD file resulting in the two different outputs below?

---
output: html_document
---

# Headline 1

## Headline 2 {.tabset}

### Headline 3 in a tab

### Headline 4 in a tab

### Headline 5 in a tab

Thanks Stephan


回答1:


You can use a parameterized document and inline code:

---
title: Hello
output: html_document
params:
  intab: TRUE
---

# Headline 1

## Headline 2 `r if (isTRUE(params$intab)) "{.tabset}"`

### Headline 3 in a tab

### Headline 4 in a tab

### Headline 5 in a tab
Rscript.exe -e "rmarkdown::render('62095186.Rmd')"                            # default
# Rscript.exe -e "rmarkdown::render('62095186.Rmd', params=list(intab=TRUE))" # same
Rscript.exe -e "rmarkdown::render('62095186.Rmd', params=list(intab=FALSE))"  # by exception



来源:https://stackoverflow.com/questions/62095186/r-markdown-remove-tabset-configuration-when-rendering

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!