Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
506 views
in Technique[技术] by (71.8m points)

r markdown - Automatically number sections in RMarkdown

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?

question from:https://stackoverflow.com/questions/40120050/automatically-number-sections-in-rmarkdown

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...