Add table of contents with Tufte theme

I'm working with a .Rmd file and am trying to create a table of contents. In the past I have used a code block like this in yaml:

title: "My Analysis"
output:
  html_document:
    df_print: kable
    toc: true
    toc_float: true
    toc_collapsed: true
toc_depth: 2
---

This would result in a table of contents generated based on my use of # Headers, ## Header2 etc.

Currently I'm using a Tufte template and am unable to get this table of contents to generate:

---
title: "My Analysis"
subtitle: "Day 7 to day 365 analysis"
date: "`r Sys.Date()`"
author: "My Name"
output:
  tufte::tufte_html: default
    toc: true
    toc_float: true
    toc_collapsed: true
  tufte::tufte_handout:
    citation_package: natbib
    latex_engine: xelatex
    bibliography: /home/rstudio-myname/dh_d7_d365_rpi/radhoc/dh_d7_d365_rpi/skeleton.bib
link-citations: yes
---

The script runs and generates HTML output however there is no toc. I tried playing around with the indenting to figure out where to add the toc paraemeters but with no success.

Any pointers welcome.

The following YAML header worked for me using the Tufte template found when creating an R Markdown document throug RStudio.

---
title: "Tufte Handout"
subtitle: "An implementation in R Markdown"
author: "JJ Allaire and Yihui Xie"
date: "`r Sys.Date()`"
output:
  tufte::tufte_html: 
    toc: true
  tufte::tufte_handout:
    citation_package: natbib
    latex_engine: xelatex
  tufte::tufte_book:
    citation_package: natbib
    latex_engine: xelatex
bibliography: skeleton.bib
link-citations: yes
---

Note that it differs from yours by a few things:

  • no default after tufte_html
  • no toc_collapsed
  • no toc_float
2 Likes

Yep, this is working now thank a lot. Would be nice to be able to get a floating toc in there but this is a step up than what I had

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.