Rmarkdown toc for tabbed content (only showing corresponding headings)

Viewed 163

I want to display a floating table of contents in a rmarkdown document which has tabbed content. I only want to show the headings of the current tab selected.

This is a minimal code example:

---
title: "Test"
output:
  html_document:
    toc: true
    toc_float:
      collapsed: false
---

# Tabbed content {.tabset}

## Tab 1

### Tab 1 - Heading 1

## Tab 2

### Tab 2 - Heading 1

## {- .leave-tabset}

This is what the output looks like:

table of contents with tabbed content

I want to show only the corresponding headings in the toc when the respective tab is selected (so "Tab 1 - Heading 1" when Tab 1 is selected and "Tab 2 - Heading 1" when Tab 2 is selected).

I found a suggested solution with Javascript, which unfortunately didn't work in my case: solution including Javascript

0 Answers
Related