我看过类似的问题,但还没能解决我目前的问题。我的HTML文档有一个有效的TOC,现在它不见了。我不确定发生了什么,或者是我不小心改变了什么。以下是我的代码
---
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
---发布于 2021-04-11 05:53:10
您的代码是Rmarkdown的YAML部分,它的语法非常特殊。您的问题不是在html_document之后添加另一个缩进
这里是我使用你的初始代码和适当的缩进,并得到我假设你想要的结果,我看到你回答了你自己的问题,但它仍然不清楚你是否正确缩进。
---
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:
---
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

发布于 2021-04-09 20:48:37
好的,我已经能够用下面的方法解决这个问题了
输出: html_document: toc: true toc_float: true
然而,我仍然不知道为什么之前的代码停止工作
https://stackoverflow.com/questions/67020253
复制相似问题