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代碼。 –