如何在Rmarkdown中添加目录?

我正在使用RStudio编写markdown文档,并希望在文档顶部添加目录(TOC),以便用户可以单击相关章节进行阅读。 在rpubs上有一些相关的例子,但现在我似乎无法find它们。 请注意,我不使用pandoc而且对于Rmdknitr是相当新的。 有没有办法添加TOC而不使用pandoc ? 如果使用pandoc必须那么哪些function是相关的?

编辑

这里是一个小样本页面:

 --- title: "Sample Document" output: html_document: toc: true theme: united --- Header 1 --------------- This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>. ## Header 2 When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this: ```{r} summary(cars) ``` You can also embed plots, for example: ```{r, echo=FALSE} plot(cars) ``` ### Header 3 Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot. 

我试着在RStudio v 0.98.864中运行它,它工作! 但可悲的是,它不适用于0.98.501和0.98.507。 我正在0.98.501的论文中工作,在更新RStudio之后,我的一些分析失败了。 所以,我回到了0.98.501。 我现在应该怎么做? 我真的很想要TOC,但不会损害其他分析的输出。

语法是

 --- title: "Sample Document" output: html_document: toc: true theme: united --- 

在文档中

具有更多选项的语法:

 --- title: "Planets" author: "Manoj Kumar" date: "March 3, 2016" output: html_document: toc: true # table of content true toc_depth: 3 # upto three depths of headings (specified by #, ## and ###) number_sections: true ## if you want number sections at each table header theme: united # many options for theme, this one is my favorite. highlight: tango # specifies the syntax highlighting style css: my.css # you can add your custom css, should be in same folder ---