R语言 着色段落节标题

x6h2sr28  于 2023-02-20  发布在  其他
关注(0)|答案(1)|浏览(133)

我正在尝试给段落标题上色,但是效果不好。有人能指出为什么不能给我的部分上色吗?考虑下面的例子:

---
title: "number_sections"
output:
  pdf_document:
    number_sections: yes
    toc_depth: 4
    toc: true
  header-includes:
     -\usepackage{color}
     - \usepackage{sectsty}
     - \allsectionsfont{\color{red}}  
   
---

# Main Section

The above section and the ones below should be red

## 2nd Level

### 3rd Level

# Second Section

## another section

### yet another

#### and the last one please
mklgxw1f

mklgxw1f1#

您的代码非常正确,只是YAML头中的缩进有点不对:

---
title: "number_sections"
output:
  pdf_document:
    number_sections: yes
    toc_depth: 4
    toc: true
header-includes:
   - \usepackage{color}
   - \usepackage{sectsty}
   - \allsectionsfont{\color{red}}  
---

header-includes应位于左侧(不缩进),并且\usepackage前缺少空格

相关问题