问题描述
我在 rmarkdown 文档中的节和子节上使用了不同的颜色,但在阅读器中,节(书签)窗格中的名称现在是空白的。
\textcolor{mycolor}{My section}
看起来即使我将 mycolor
恢复为黑色 ({RGB}{0,0}
),问题仍然存在,因此我认为我错误地使用了 \textcolor{mycolor}{Section text to color}
。
还有别的办法吗?另外,有没有办法将相同的颜色应用于所有部分/子部分?
解决方法
这是实现彩色部分标题目标的一种可以说是更好的方法:
---
title: "Untitled"
output: pdf_document
header-includes:
- \usepackage{sectsty}
- \sectionfont{\color{red}}
- \subsectionfont{\color{green}}
- \subsubsectionfont{\color{blue}}
---
```{r setup,include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
# Section
This section header should be red.
## Subsection
This subsection header should be green.
### Subsubsection
This subsubsection header should be blue.