Stephan Claus
Stephan Claus

Reputation: 475

R Markdown: Remove tabset configuration when rendering

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

with tabset

without tabset

Thanks Stephan

Upvotes: 0

Views: 402

Answers (1)

r2evans
r2evans

Reputation: 160397

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

side-by-side renderings

Upvotes: 3

Related Questions