html - 为 Rmarkdwon 中的更多页面设置通用目录
问题描述
我有一些 markdown 文件,我需要 knitr 来获得由三个不同页面组成的 html 输出。每页都有一些章节(第一页1章,第二页4章,第三页4章)。我需要在每一页中重复完整的目录(包含所有章节)。使用我的代码,每个 TOC 都被拆分,并且仅指单页的章节。这是我在每个 rm 文件/页面开头的代码,我对此非常陌生,非常感谢。
---
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
解决方案
推荐阅读
- java - Eclipse 无法识别 JavaFX
- racket - 如何比较球拍中的语法对象?
- logic - 比较多个集合的基数并从最大集合的成员中获取特定值
- javascript - Javascript 等效于 Python 的 operator.add
- git - 优先考虑本地更改
- python - 为什么用 Keras 制作的恢复的 TensorFlow 模型给了我 0 个预测?
- generics - 借来的值对于“AsRef”结果的寿命不够长,即使它的“自我”寿命足够长
- go - Chaincode GetState 返回一个空响应
- python - 直线和矩形的交点
- swift - 无法从 google Firestore 获取数据,出现 Thread 1: EXC_BAD_INSTRUCTION 错误