Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bookdown: TOC with html_document2

Tags:

r

bookdown

How can I create a single output document with bookdown, e.g. using its bookdown::html_document2 format, and still have a Table of Contents somewhere in the output document?

For example, I check out the content from https://github.com/tidyverse/style, and run

Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::html_document2')"

Then I get a _main.html as desired, with all the text from all chapters, but no TOC is present.

like image 730
Ken Williams Avatar asked Oct 16 '22 22:10

Ken Williams


1 Answers

You can use the dots (...) argument of bookdown::html_document2 to pass toc = TRUE to rmarkdown::html_document:

Rscript -e "bookdown::render_book('index.Rmd', bookdown::html_document2(toc = TRUE))"
like image 64
RLesur Avatar answered Oct 21 '22 04:10

RLesur