Html 使用rmarkdown中的选项卡时,防止TOC折叠(返回顶部)

Html 使用rmarkdown中的选项卡时,防止TOC折叠(返回顶部),html,r-markdown,tableofcontents,Html,R Markdown,Tableofcontents,在rmarkdown中,当使用浮动TOC和嵌套选项卡时,我遇到了一个问题,TOC返回到“顶部”选项卡。例如,如果我正在查看栏选项卡中的栏子选项卡中的更多详细信息,并且我在该子选项卡中单击TOC中的内容,它将继续折叠TOC并返回“顶部”选项卡。或者,如果我单击TOC中某个子选项卡的标题,一旦我开始滚动,TOC将折叠回“顶部”选项卡。下面是示例代码 是否可以防止TOC“未请求”崩溃/返回“顶部”选项卡,将TOC锚定到当前选项卡或子选项卡?或者,TOC是否可以仅显示当前选项卡或子选项卡的TOC项目来防

在rmarkdown中,当使用浮动TOC和嵌套选项卡时,我遇到了一个问题,TOC返回到“顶部”选项卡。例如,如果我正在查看
选项卡中的
子选项卡中的
更多详细信息,并且我在该子选项卡中单击TOC中的内容,它将继续折叠TOC并返回“顶部”选项卡。或者,如果我单击TOC中某个子选项卡的标题,一旦我开始滚动,TOC将折叠回“顶部”选项卡。下面是示例代码

是否可以防止TOC“未请求”崩溃/返回“顶部”选项卡,将TOC锚定到当前选项卡或子选项卡?或者,TOC是否可以仅显示当前选项卡或子选项卡的TOC项目来防止此问题

---
title: "test"
author: "tester"
date: "10/1/2020"
output:
  html_document:
    toc: true
    toc_float: true
    toc_collapsed: false
    number_sections: false
    toc_depth: 3
    theme: united
    code_folding: hide
---


<style type="text/css">

body{ /* Normal  */
      font-size: 16px;
  }
  
h1.title {
  font-size: 38px;
  color: DarkRed;
}
h1 { /* Header 1 */
  font-size: 28px;
  color: DarkGrey;
}
h2 { /* Header 2 */
    font-size: 24px;
  color: DarkGrey;
}
h3 { /* Header 3 */
  font-size: 20px;
  font-family: "Times New Roman", Times, serif;
  color: DarkBlue;
}

table, td, th {
  border: none;
  padding-left: 10px;
  padding-right: 1em;
  min-width: 50%;
  margin-left: auto;
  margin-right: auto;
  margin-top: 1em;
  margin-bottom: 1em;
}
</style>


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)

```
# FooBar {.tabset .unlisted}

## Foo {.tabset}
### More Details about Foo here
<h2> Foo Details </h2> 
<h3> Foo Reference  </h3>
1. Foo book

***
<h3> Foo styles </h3>
<h3> *First* </h3>
Very fun example.

<h3> *Second*</h3>
Equally fun.

<h3>*Third*</h3>
Almost as fun.

***
<h3>Foo Process</h3>
<h3> *Process prep*</h3>
1. Put it all together.

### Even more Details about Foo here
<h2> Foo Details 2 </h2> 
<h3> Foo Reference 2  </h3>
1. Foo book 2

***
<h3> Foo styles 2 </h3>
<h3> *First 2* </h3>
Very fun example 2.

<h3> *Second 2*</h3>
Equally fun 2.

<h3>*Third 2*</h3>
Almost as fun 2.

***
<h3>Foo Process 2</h3>
<h3> *Process prep 2*</h3>
1. Put it all together 2.

## Bar {.tabset}
### More Details about Bar here
<h2> Bar Details </h2> 
<h3> Bar Reference  </h3>
1. Bar book

***
<h3> Bar styles </h3>
<h3> *First* </h3>
Very fun example.

<h3> *Second*</h3>
Equally fun.

<h3>*Third*</h3>
Almost as fun.

***
<h3>Bar Process</h3>
<h3> *Process prep*</h3>
1. Put it all together.

### Even more Details about Bar here
<h2> Bar Details 2 </h2> 
<h3> Bar Reference 2  </h3>
1. Bar book 2

***
<h3> Bar styles 2 </h3>
<h3> *First 2* </h3>
Very fun example 2.

<h3> *Second 2*</h3>
Equally fun 2.

<h3>*Third 2*</h3>
Almost as fun 2.

***
<h3>Bar Process 2</h3>
<h3> *Process prep 2*</h3>
1. Put it all together 2.


***
<h3>Additional Item</h3>
<h3> *Make longer*</h3>
To demonstrate my issue.

<h3>Additional Item2</h3>
<h3> *Make longer2*</h3>
To demonstrate my issue2.

<h3>Additional Item3</h3>
<h3> *Make longer3*</h3>
To demonstrate my issue3.

<h3>Additional Item4</h3>
<h3> *Make longer4*</h3>
To demonstrate my issue4.
---
标题:“测试”
作者:“测试者”
日期:“2020年1月10日”
输出:
html_文件:
toc:没错
toc_浮动:正确
toc_崩溃:错误
分区数:false
toc_深度:3
主题:联合国
代码折叠:隐藏
---
身体{/*正常*/
字体大小:16px;
}
h1.标题{
字号:38px;
颜色:深色;
}
h1{/*头1*/
字号:28px;
颜色:暗灰色;
}
h2{/*头2*/
字体大小:24px;
颜色:暗灰色;
}
h3{/*头3*/
字体大小:20px;
字体系列:“泰晤士报新罗马”,泰晤士报,衬线;
颜色:深蓝色;
}
表,td,th{
边界:无;
左侧填充:10px;
右侧填充:1em;
最小宽度:50%;
左边距:自动;
右边距:自动;
边缘顶部:1米;
边缘底部:1米;
}
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
```
#FooBar{.tabset.unlisted}
##Foo{.tabset}
###更多关于Foo的详细信息,请点击此处
Foo详细信息
Foo参考
1.富书
***
富风格
*第一*
非常有趣的例子。
*第二*
同样有趣。
*第三*
几乎一样有趣。
***
Foo过程
*工艺准备*
1.把它们放在一起。
###这里有更多关于Foo的细节
食物详情2
Foo参考文献2
1.富书2
***
富风格2
*前2*
非常有趣的例子2。
*第二个2*
同样有趣2。
*第三个2*
几乎一样有趣2。
***
食品加工2
*工艺准备2*
1.把它们放在一起。
##条{.tabset}
###更多关于酒吧的详细信息
酒吧详情
酒吧参考
1.酒吧登记簿
***
酒吧风格
*第一*
非常有趣的例子。
*第二*
同样有趣。
*第三*
几乎一样有趣。
***
棒材加工
*工艺准备*
1.把它们放在一起。
###这里有更多关于酒吧的细节
酒吧详情2
参考文献2
1.酒吧登记簿2
***
酒吧风格2
*前2*
非常有趣的例子2。
*第二个2*
同样有趣2。
*第三个2*
几乎一样有趣2。
***
酒吧流程2
*工艺准备2*
1.把它们放在一起。
***
附加项目
*延长*
来证明我的问题。
附加项目2
*使变长*
来证明我的观点2。
附加项目3
*使变长*
来证明我的问题。
附加项目4
*使变长*
来证明我的问题。