RMarkdown PDF部分和小节颜色 [英] RMarkdown PDF section and subsection color

查看:51
本文介绍了RMarkdown PDF部分和小节颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在rmarkdown文档中的节和小节上使用了不同的颜色,但是在阅读器中,节(书签)窗格中的名称现在为空白.

I used a different color on sections and subsections in my rmarkdown document, but in the reader the names in sections (bookmarks) pane are now blank.

\textcolor{mycolor}{My section}

即使我将 mycolor 还原为黑色( {RGB} {0,0,0} ),看起来问题仍然存在,所以我认为我错误地使用 \ textcolor {mycolor} {将文本着色的部分} .

It looks like even if I revert mycolor to black ({RGB}{0,0,0}), the issue persists, so I assume I'm incorrectly using the \textcolor{mycolor}{Section text to color}.

还有另一种方法吗?另外,是否可以将相同的颜色应用于所有部分/子部分?

Is there another way? Also, is there a way to apply the same color to all sections/subsections?

推荐答案

以下是可以更好地实现彩色节标题的目标的方法:

Here is an arguably better approach to accomplish your goal of colored section headings:

---
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.

这篇关于RMarkdown PDF部分和小节颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆