5

There doesn't seem to be a problem when I add a table of contents to an r markdown file but nothing happens when I add this to an r notebook:

output: 
   html_document:
   html_notebook:
      toc: true
      depth: 3
      theme: united

Is it possible to add a table of contents to an R notebook or do I have to make this into a markdown file too?

GR1818
  • 139
  • 1
  • 13

3 Answers3

3

I had to format it like this in the end:

output: 
  html_notebook:
    theme: united
    toc: yes
Community
  • 1
  • 1
GR1818
  • 139
  • 1
  • 13
2

Try formatting like this:

title: "Title"
output:
  html_notebook:
    theme: united
    toc: yes
  • Also, looks like a duplicate of [this question](https://stackoverflow.com/questions/23957278/how-to-add-table-of-contents-in-rmarkdown) – Russell Shepherd Aug 22 '17 at 20:09
  • 1
    I saw that question but it is about R markdown, which I have had no problem adding a TOC to, instead of R notebooks. – GR1818 Aug 22 '17 at 20:22
1

html_document: is not followed by any attributes that’s why the html_notebook settings are not being executed properly.

Either remove html_document: or specify some attributes underneath it.

Lennart
  • 58
  • 7