Automatically number sections in RMarkdown

R Markdown

R Markdown Problem Overview


I am trying to create a report in R markdown that has sections ordered

  1. Section 1 Header

    1.1 sub section 1

    1.2 sub section 3

  2. Section 2 Header

    2.1

    2.2 sub section

       2.2.1 another sub section
    

Is there a way get R markdown to generate an ordered list like this?

R Markdown Solutions


Solution 1 - R Markdown

Add the option number_sections: true to your YAML header:

---
title: "My Report"
output: 
  html_document:
    number_sections: true
---

# Main Section

## 2nd Level

### 3rd Level

And voilá, your sections are numbered:

The above text in an image with numbered sections

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionH.BananasView Question on Stackoverflow
Solution 1 - R MarkdownMartin SchmelzerView Answer on Stackoverflow