Richard Telford
Richard Telford

Reputation: 9923

Number some sections with rmarkdown

I am writing a manuscript with rmarkdown.

If I want to number all sections, I can use YAML like this

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

See Automatically number sections in RMarkdown

But I only want to number some sections, so my document looks like

Abstract
1. Introduction
2. Methods
3. Results
References

Is there anyway to do this?

Upvotes: 5

Views: 3749

Answers (1)

Gavin Simpson
Gavin Simpson

Reputation: 174948

From the Pandoc User Guide you want to add the .unnumbered attribute to the header. This is done using:

# My header {.unnumbered}

or the shortcut

# My header {-}

For example, using the following document

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

# Abstract {-}

# Introduction

# Methods

# Results

# References {-}

The HTML produced renders as:

enter image description here

Upvotes: 8

Related Questions