44757

Bookdown: TOC with html_document2

Question:

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 <a href="https://github.com/tidyverse/style" rel="nofollow">https://github.com/tidyverse/style</a>, 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.

Answer1:

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))"

Recommend

  • Generate all combinations in bit version
  • Sampling a specific age distribution from a dataset
  • ggplot2 plot function with several arguments
  • Pandas: select rows where two columns are different
  • How can I maintain a color scheme across ggplots, while dropping unused levels in each plot?
  • Exactly what should happen in a CALayer's display/drawRect methods?
  • Is it possible to disable jQuery's mobile responsive design?
  • Find text using jQuery?
  • set or change php variable in javascript
  • Dump Chrome dev console to text file?
  • Reading .mat file in C++
  • How to transform Byte[](decoded as PNG or JPG) to Tensorflows Tensor
  • send data back from jsp iterator to struts action class
  • Inserting a (g) node in the middle of a tree (SVG) using jQuery
  • Text copied from JTextArea have broken encoding after paste in FoxPro application
  • Excel passing a range into a function
  • JConsole Main class
  • WP7 difficulties binding data to listbox itemssource - won't refresh
  • Ruby 1.8.6 Array#uniq not removing duplicate hashes
  • Configure Spring's MappingJacksonHttpMessageConverter
  • Application level floating views with navigation in Android
  • AppleScript : find open tab in safari by name and open it
  • How to generate and display a QR Code in ionic 2
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • How to avoid particles glitching together in an elastic particle collision simulator?
  • Recording logins for password protected directories
  • Splitting given String into two variables - php
  • RectangularRangeIndicator format like triangular using dojo
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • Cross-Platform Protobuf Serialization
  • Check if a string to interpolate provides expected placeholders
  • Shallow update not allowed (git > 1.9)
  • jquery mobile loadPage not working
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • How do I rollback to a specific git commit
  • Unanticipated behavior
  • Revoking OAuth Access Token Results in 404 Not Found
  • Load html files in TinyMce
  • Free memory of cv::Mat loaded using FileStorage API
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass