我正在使用RStudio编写Markdown文档,并希望在文档顶部添加目录(TOC),以便用户可以点击相关部分进行阅读。之前在rpubs上有一些相关示例,但现在似乎找不到了。请注意,我不使用pandoc
,并且对Rmd
和knitr
都很陌生。是否有任何方法可以在不使用pandoc
的情况下添加目录?如果必须使用pandoc
,那么哪些函数是相关的?
编辑
这是一个小样本页面:
---
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:true
即可实现目录。 - baptiste