Floating table of contents for your html reports using knitr

April 27, 2014
By

(This article was first published on socialdatablog » R, and kindly contributed to R-bloggers)

If you love knitr and rstudio and use them to produce long reports, you probably know that you can produce a table of contents in your html (and pdf) documents. In the newer rstudio (Version 0.98.801 or later) you do it by requesting a toc in the doc header, something like this.


  title: "cssTest"

  output:

  html_document:

  toc: yes

But wouldn’t it be nice if the table of contents, instead of being stuck at the top of the document, was available at the edge of the browser window and doesn’t move when you scroll?

This post: http://rpubs.com/stevepowell99/floating-css shows a live example of a floating toc and also tells you how easily to produce one automatically by adding a custom css file.

Comments and improvements are welcome!

To leave a comment for the author, please follow the link and comment on his blog: socialdatablog » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.