首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rmarkdown缺少TOC HTML

Rmarkdown缺少TOC HTML
EN

Stack Overflow用户
提问于 2021-04-09 19:26:39
回答 2查看 87关注 0票数 0

我看过类似的问题,但还没能解决我目前的问题。我的HTML文档有一个有效的TOC,现在它不见了。我不确定发生了什么,或者是我不小心改变了什么。以下是我的代码

代码语言:javascript
复制
---
title: "Safari Park Analysis"
author: "Data Science Team"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output: 
  bookdown::html_document2:
  toc: true 
  toc_float: 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
  fig_caption: true
---
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-04-11 05:53:10

您的代码是Rmarkdown的YAML部分,它的语法非常特殊。您的问题不是在html_document之后添加另一个缩进

这里是我使用你的初始代码和适当的缩进,并得到我假设你想要的结果,我看到你回答了你自己的问题,但它仍然不清楚你是否正确缩进。

代码语言:javascript
复制
---
title: "Safari Park Analysis"
author: "Data Science Team"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output: 
  bookdown::html_document2:
    toc: true 
    toc_float: 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
    fig_caption: true
---


# Chapter 1 

# Chapter 2

但是使用您的答案代码,它仍然呈现相同的结果,而不是使用bookdown::html_document2:

代码语言:javascript
复制
---
title: "Safari Park Analysis"
author: "Data Science Team"
date: "`r format(Sys.time(), '%B %d, %Y')`"
output: 
  html_document:
    toc: true 
    toc_float: 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
    fig_caption: true
---


# Chapter 1 

# Chapter 2

票数 0
EN

Stack Overflow用户

发布于 2021-04-09 20:48:37

好的,我已经能够用下面的方法解决这个问题了

输出: html_document: toc: true toc_float: true

然而,我仍然不知道为什么之前的代码停止工作

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67020253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档