[FR] More flexible table of contents in tufte_html_book
I'm using tufte_html_book. I would like a feature in which the table of contents be either collapsible or in a navigation bar at the top (like here).
Currently the situation is that enabling the table of contents makes it appear at the top of every page of the html book, thereby wasting a lot of space.
in a navigation bar at the top (like here).
The website code source is at https://github.com/rstudio/bookdown-demo/
The TOC on the top is just some CSS : https://github.com/rstudio/bookdown-demo/blob/main/toc.css
You can probably achieve the same using similar CSS.
Also if you don't know about it, there is a new project called Quarto that unifies and extends what has been done over the years in the R Markdown ecosystem.
This tool is developed by a team close to R Markdown ecosystem too. it is not a replacement per-se but a lot of improvment has been made and design has been rethought. Especially:
- There is a Book project format: https://quarto.org/docs/books/
- Navigation has been improved and coherence accross layout and format: https://quarto.org/docs/books/book-structure.html
- Feature like you have in tufte has been made generic for all HTML and PDF format - no need for specific function: https://quarto.org/docs/authoring/article-layout.html
Maybe it could be of interest. For R users, it is quite similar to R Markdown.
I was looking for something more automated. I'm new to HTML so what I say might be total nonsense. Nevertheless, I can create a navigation bar at the top and use it via the in_header argument, but won't I have to update the contents of the bar manually at the end of the day?
I was putting off diving into Quarto but thanks to you I finally took the plunge. Thank you. :)
I was looking for something more automated.
We don't have such feature built-in. However, tweaking the generated TOC using CSS to make a different layout is automated, in the sense that if the TOC update, it will be updated.
Nevertheless, I can create a navigation bar at the top and use it via the in_header argument, but won't I have to update the contents of the bar manually at the end of the day?
If you create the navigation bar hard coding the TOC it won't update. Though you could also tweak the templates to insert the TOC where you want, but this is more complex IMO than CSS tweaks.
I was putting off diving into Quarto but thanks to you I finally took the plunge. Thank you. :)
Good! When looking for some specific new things like you do, having a dive into Quarto can be worth it IMO, even for an R user.