RMarkdown:开始时浮动TOC和TOC [英] RMarkdown: Floating TOC and TOC at beginning

查看:349
本文介绍了RMarkdown:开始时浮动TOC和TOC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可能有一个浮动目录,而在文档的开头有另一个目录.我当前的首要问题是这样的:

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.

我尝试添加另一个toc: true,但这只会向我抛出一条错误消息.预先感谢!

I've tried adding another toc: true, but that just throws me an error message. Thanks in advance!

推荐答案

您只需要在toc_float前面添加true:

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

还请注意,您在rmarkdown文件中包含一个注释,该注释将被解释为标题:

Also note that you have a comment within in your rmarkdown file, which will be interpreted as a header:

这篇关于RMarkdown:开始时浮动TOC和TOC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆