Coloring paragraph section headers

Advertisements

I am trying to color my paragraph section headers but the is not working. Could someone point out why this is not coloring my sections? Consider the example below:

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

>Solution :

Your code is pretty much correct, it’s just the indentation in the YAML header that’s slightly off:

---
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 should be at the left (not indented), and a missing space before \usepackage

Leave a ReplyCancel reply