1
我试图在由Rmarkdown生成的HTML文档中添加一个目录。首先,我发现this answer,这似乎是一个简单的方法,在HTML文件中添加CSS文件丝毫验证码:在Rmarkdown的HTML文档的左侧添加一个目录
#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;
}")
```
我觉得我失去了一些东西重要。提前致谢!
因此,不可能从Rmarkdown修改.css? –
我不知道。你可以用'file = custom.css'来尝试'cat'。在运行Pandoc for HTML代码之前,这可能会首先运行R代码。 –