When making an RMarkdown containing tabs, some extra (blank) items appear in the table of contents.
Example
This generates the html doc below
---
output:
html_document:
toc: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# First Tabs {.tabset .tabset-fade .tabset-pills}
Text before tabs
## First tab
Content in first tab
## Second tab
Content in second tab
#
# here is another section
Some further content.
Everything is as expected, except there's a blank line in the TOC.
What I've tried
I tried replacing the #
that ends the tabbed content with </div>
as described here. This causes the TOC to populate correctly, but (strangely) causes the content after the tabs to left-align (no idea why)
For ease of reproducibility, here's the code and a screengrab of the resulting HTML
---
output:
html_document:
toc: true
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# First Tabs {.tabset .tabset-fade .tabset-pills}
Text before tabs
## First tab
Content in first tab
## Second tab
Content in second tab
</div>
# here is another section
Some further content.