【发布时间】:2017-10-06 21:30:18
【问题描述】:
我试图在 Rmarkdown 生成的 HTML 文档中添加目录。首先,我找到了this answer,这似乎是一个简单的方法,在 HTML 文件中添加一个带有这段代码的 CSS 文件:
#TOC {
position: fixed;
left: 0;
top: 0;
width: 200px;
height: 100%;
overflow:auto;
}
body {
max-width: 800px;
margin: auto;
margin-left:210px;
line-height: 20px;
}
但我想修改 Rmarkdown 中的 CSS。解决我找到this other post的问题,如何添加自定义CSS标签。但这并不是我想要的,也不知道如何以正确的方式将其与答案混合。
我的代码如下所示:
---
title: "R"
output: html_document
toc: yes
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r results="asis"}
cat("TOC {
position: fixed;
left: 0;
top: 0;
width: 200px;
height: 100%;
overflow:auto;
}
body {
max-width: 800px;
margin: auto;
margin-left:210px;
line-height: 20px;
}")
```
我想我错过了一些重要的事情。提前致谢!
【问题讨论】:
标签: html css r knitr r-markdown