I was wondering if it is possible to have a floating table of contents and another one at the beginning of the document. My current front-matter looks like this:
---
title: "TEST"
author: brettljausn
date: January 15, 2018
output:
html_document:
toc: true
toc_float:
toc_collapsed: true
toc_depth: 3
number_sections: true
theme: lumen
---
# Rest of the sample document: --------
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# R Markdown
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>.
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 cars}
summary(cars)
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
I've tried adding another toc: true
, but that just throws me an error message. Thanks in advance!
The following sections dive into the three components of an R Markdown document in more details: the markdown text, the code chunks, and the YAML header.
1 Table of contents. You can add a table of contents (TOC) using the toc option and specify the depth of headers that it applies to using the toc_depth option. For example: --- title: "Habits" output: html_document: toc: true toc_depth: 2 ---
R Markdown is an extension of the markdown syntax. R Markdown files are plain text files that typically have the file extension . Rmd . They are written using an extension of markdown syntax that enables R code to be embedded in them in a way which can later be executed.
RMarkdown is an extension to markdown which includes the ability to embed code chunks and several other extensions useful for writing technical reports. The rmarkdown package extends the knitr package to, in one step, allow conversion between an RMarkdown file (.Rmd) into PDF, HTML, word document, amongst others.
you just have to add true in front of toc_float:
---
title: "TEST"
output:
html_document:
toc: true
toc_float: true
toc_collapsed: true
toc_depth: 3
number_sections: true
theme: lumen
---
Also note that you have a comment within in your rmarkdown file, which will be interpreted as a header:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With