Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Coloring paragraph section headers

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading