6

Is it possible to control chapter/section numbering in bookdown?

e.g.

# Introduction {1}
# Theory {14}
# Methods {3}

would give the following in the output...

1. Introduction
14. Theory
3. Methods
Paul
  • 328
  • 2
  • 11

2 Answers2

1

Sorry for the late answer, but I've just bumped into the same issue.

If you globally turn off numbering, adding the line

number_sections: false

under bookdown::gitbook: to your _output.yml file, then you can number your chapters and sections in any way you like:

# 1. Introduction

# 14. Theory

# 3. Methods

To repeat: my _output.yml file contains the lines

bookdown::gitbook:
  number_sections: false
Julian Neuer
  • 306
  • 1
  • 8
  • When I render this output as a `git_book` the chapter number is no longer set in bold and I suspect because the number is no longer different from the title. In the `pdf_book` (and a custom style class) the difference is even more prominent. – stats-hb Nov 13 '20 at 09:42
  • 1
    I was just able to get the desired result in the pdf version with the help of \stepcounter{chapter} or `\setcounter{chapter}{8}` – stats-hb Nov 13 '20 at 10:09
  • In my case it was `\setcounter{section}{8}`. Try that if chapter does not work. – Mikko May 03 '23 at 08:46
0

I'm not sure what you are trying to do: The curly brackets at the end of a header are not to control section numbering. You can use it to manually assign an ID to a section header

e.g. # Introduction {#intro}

and/or to exclude the header from numbering

e.g. # Introduction {-} respectively at the same time # Introduction {- #intro}.

petzi
  • 1,430
  • 1
  • 17
  • 32