rmarkdown
rmarkdown copied to clipboard
Tabsets don't appear in ToC
It appears that when headers are put in tabset format, they don't appear in the table of contents. Even stranger : when there are subheaders inside the tabsets, these will appear in the toc, but there will be no separation or distinction between the subheaders of different tabs
---
title: Hello World
output:
html_document:
toc: TRUE
toc_float: true
toc_depth: 4
---
# My header {.tabset}
## Tab 1
### subheader1
### subheader2
## Tab 2
### subheader1
### subheader2
Just came across this. Making sure it doesn't get forgotten :rocket:
Any solution to this?
I am using rmarkdown v1.16 and knitr v1.25. I am experiencing the same behavior as the above reported question. Have there been any updates to this?
Here's a tricky workaround
---
title: Hello World
output:
html_document:
toc: TRUE
toc_float: true
toc_depth: 4
---
```{css}
.tabset h2 {display: none;}
```
# My header {.tabset}
<h2>Tab 1</h2>
## Tab 1
### subheader1
### subheader2
<h2>Tab 2</h2>
## Tab 2
### subheader1
### subheader2
@atusy this is great ! However, tabpanel is trickier as I don't think the toc will allow to navigate in the headers that are inside the tabbed panel. In my case it doesn't. Does it work for you ?
I think it would need to activate the correct tab (show
) when one of the header in the panel is clicked. I am looking into JS to see if this is possible - that would complete your trick I guess.
From what I saw up to now, it is not so easy to get the TOC to work with tabbed content.
@cderv You are right. My trick just shows ToC whose links are out of order. We need one (?) more trick by JS! Thanks for your help.
I also think this should be looked into after #1260 when bootstrap upgrade is done because it will change some things. Maybe bs4 will also help with this.
found this: https://stackoverflow.com/questions/54803465/rmarkdown-is-it-possible-to-display-the-toc-of-the-current-tab-only-in-a-tabse
the stackoverflow link didn't work for me so i'm definitely still waiting for a solution for this! the previous sort-of workaround without navigation is better than nothing though so thanks @atusy
I made some hacks. With files below, you can navigate to tabsets from floating ToC.
https://gist.github.com/atusy/4b076cc084d9e920b34d6d25f85e5176
I think the above trick needs lots more improvements which is still difficult for me.
Alternatively, I implemented the feature in minidown::mini_document
.
Install it with remotes::install_github("atusy/minidown")
and follow the directions at
https://minidown.atusy.net/#tabset
Feed backs are welcome!
I think the above trick needs lots more improvements which is still difficult for me.
What are the improvement to be made ? What makes it more difficult to support here than in minidown ? Do you want to discuss it in a PR ? (as if we were not already late on your previous ones 😅 )
Great package by the way ! There are a lot of great feature in your mini_document
! It is a really nice addition to the ecosystem ! 👍
@cderv
Tow major difficulties are:
- Navigation to the hidden tab from the ToC requires clicking twice. I tried
anchor.click(); anchor.click();
, but no luck. - Navigation to tabs when their name are not unique. Current implementation navigates to the last tab.
Anyway, let's draft and discuss the PR.
Great package by the way ! There are a lot of great feature in your mini_document ! It is a really nice addition to the ecosystem ! :+1:
Thanks a lot! I'm so glad to hear it!!
Is it likely that this feature will be implemented? I have a template that builds on bookdown::html_document2()
and would like to avoid trying to rewrite it using minidown
:)
Sorry, I have no ideas...