How to include all chapters in TOC in different html pages

↘锁芯ラ 提交于 2021-02-05 10:00:13

问题


I have a rmarkdown file which I need to knitr to get an html output composed of three different pages. Each page has some chapters (1 chapter in the first, 4 in the second page and 4 in the third). I need to repeat the full TOC (with all chapters within) in each page. With the code I have each TOC is split and refers to chapters of the single page only. I copied following code at the beginning of each page. I am very new to this thank you so much.

  ---
    title: "page"
    author: "me"
    date: "26/02/2020"
    output:
      html_document:
        toc: yes
        toc_depth: 3
        toc_float:
          collapsed: yes
          smooth_scroll: yes
      word_document: default
    ---

<style type="text/css">

body{ /* Normal  */
      font-size: 14px;
  }
td {  /* Table  */
  font-size: 12px;
}
h1.title {
  font-size: 38px;
  color: DarkRed;
}
h1 { /* Header 1 */
  font-size: 28px;
  color: DarkBlue;
}
h2 { /* Header 2 */
    font-size: 22px;
  color: DarkBlue;
}
h3 { /* Header 3 */
  font-size: 18px;
  font-family: "Times New Roman", Times, serif;
  color: DarkBlue;
}
code.r{ /* Code block */
    font-size: 12px;
}
pre { /* Code block - determines code spacing between lines */
    font-size: 12px;
}
</style>

<style type="text/css">

#TOC {
  margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
  position: relative;
  width: 100%;
}
}


.toc-content {
  padding-left: 30px;
  padding-right: 40px;
}

div.main-container {
  max-width: 1200px;
}

div.tocify {
  width: 20%;
  max-width: 260px;
  max-height: 85%;
}

@media (min-width: 768px) and (max-width: 991px) {
  div.tocify {
    width: 25%;
  }
}

@media (max-width: 767px) {
  div.tocify {
    width: 100%;
    max-width: none;
  }
}

.tocify ul, .tocify li {
  line-height: 20px;
}

.tocify-subheader .tocify-item {
  font-size: 1.00em;
  padding-left: 25px;
  text-indent: 0;
}

.tocify .list-group-item {
  border-radius: 0px;
}


</style>




```{r setup, include=FALSE}
knitr::opts_chunk$set(
echo = TRUE,
message = FALSE,
warning = FALSE, 
comment = "##",
tidy = TRUE
)
```

```{css,echo=FALSE}
button.btn.collapsed
{
    display:block;
}
button.btn:not(.collapsed):before
{

}
.hljs-comment {
    color: #000000;
}
```

来源:https://stackoverflow.com/questions/61382869/how-to-include-all-chapters-in-toc-in-different-html-pages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!