Skip to content

Commit ee5ca05

Browse files
committed
Clarify context of options
1 parent c92c595 commit ee5ca05

File tree

1 file changed

+67
-33
lines changed

1 file changed

+67
-33
lines changed

docs/books/book-structure.qmd

Lines changed: 67 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ project-type: book
88

99
The structure of a Quarto book can be as simple as a list of chapters, or can alternatively incorporate multiple parts and/or appendices. Quarto book chapters and sections are automatically numbered (for cross-referencing), however you can also specify that some parts of the book should remain unnumbered.
1010

11-
The simple book configuration generated by `quarto create project book` illustrates the basics:
11+
The simple book configuration generated by `quarto create project book` illustrates the basics.
12+
Book properties like the title, author and chapter structure are listed under `book`:
1213

13-
``` yaml
14+
``` {.yaml filename="_quarto.yml"}
1415
book:
1516
title: "mybook"
1617
author: "Jane Doe"
@@ -26,17 +27,33 @@ book:
2627
- The remainder of `chapters` includes one or more book chapters.
2728
- The `references.qmd` file will include the generated bibliography (see [References] below for details).
2829

30+
Rendering options that should apply to all chapters and all formats are listed at the top-level of `_quarto.yml`(i.e. not nested under `book`):
31+
32+
``` {.yaml filename="_quarto.yml"}
33+
bibliography: references.bib
34+
```
35+
36+
Rendering options that should apply to all chapters for specific formats are listed under `formats`:
37+
38+
``` {.yaml filename="_quarto.yml"}
39+
format:
40+
html:
41+
theme: cosmo
42+
pdf:
43+
documentclass: scrreprt
44+
```
45+
2946
## Titles
3047

3148
Since rendering options are provided in `_quarto.yml`, you'll typically see a simple level-one header at the top of chapters. For example:
3249

33-
``` markdown
50+
``` {.markdown filename="intro.qmd"}
3451
# Introduction
3552
```
3653

3754
Note that the following is also still perfectly valid:
3855

39-
``` yaml
56+
```{.yaml filename="intro.qmd"}
4057
---
4158
title: "Introduction"
4259
---
@@ -58,17 +75,26 @@ You can mix together numbered and unnumbered chapters. Note however that while y
5875

5976
You can set the numbering depth via the `number-depth` option. For example, to only number sections immediately below the chapter level, use this:
6077

61-
``` yaml
78+
```{.yaml filename="_quarto.yml"}
6279
number-depth: 1
6380
```
6481

65-
Note that `toc-depth` is independent of `number-depth` (i.e. you can have unnumbered entries in the TOC if they are masked out from numbering by `number-depth`).
82+
Note that `number-depth` is a format option, not a `book` option so it is placed at the top-level of `_quarto.yml`, not nested under `book`.
83+
If you want `number-depth` to only apply to a certain format, nest it under `format`:
84+
85+
```{.yaml filename="_quarto.yml"}
86+
format:
87+
pdf:
88+
number-depth: 1
89+
```
90+
91+
The `toc-depth` option is independent of `number-depth` (i.e. you can have unnumbered entries in the TOC if they are masked out from numbering by `number-depth`).
6692

6793
## References
6894

6995
You should include a `div` with the id `#refs` at the location in your book where you'd like the bibliography to be generated. For example the `references.qmd` file generated by `quarto create project book` includes this:
7096

71-
``` markdown
97+
```{.markdown filename="references.qmd"}
7298
# References {.unnumbered}
7399

74100
::: {#refs}
@@ -83,7 +109,7 @@ For PDF output, you can create an index using the LaTeX [makeidx](https://ctan.o
83109

84110
To add an index to the PDF output for a book, add these `include-in-header` and `include-after-body` entries to your `pdf` format configuration in `_quarto.yml`:
85111

86-
``` yaml
112+
```{.yaml filename="_quarto.yml"}
87113
format:
88114
html:
89115
theme: cosmo
@@ -100,15 +126,15 @@ format:
100126

101127
Then, add `\index{entry}` commands wherever you want an index entry. For example:
102128

103-
``` latex
129+
```{.latex filename="chapter.qmd"}
104130
Markdown\index{Markdown} allows you to write using
105131
an easy-to-read, easy-to-write plain text format.
106132
```
107133

108134
Alternatively, you can also use the [imakeidx](https://ctan.org/pkg/imakeidx) package.
109135
This packages offers additional features for formatting the index. For example:
110136

111-
``` yaml
137+
```{.yaml filename="_quarto.yml"}
112138
format:
113139
html:
114140
theme: cosmo
@@ -142,34 +168,39 @@ Note that EPUB and Word (Docx) formats do not currently support organizing books
142168

143169
You can divide your book into parts using `part` within the book `chapters`. For example:
144170

145-
``` yaml
146-
chapters:
147-
- index.qmd
148-
- preface.qmd
149-
- part: dice.qmd
150-
chapters:
151-
- basics.qmd
152-
- packages.qmd
153-
- part: cards.qmd
154-
chapters:
155-
- objects.qmd
156-
- notation.qmd
157-
- modifying.qmd
158-
- environments.qmd
171+
```{.yaml filename="_quarto.yml"}
172+
book:
173+
chapters:
174+
- index.qmd
175+
- preface.qmd
176+
- part: dice.qmd
177+
chapters:
178+
- basics.qmd
179+
- packages.qmd
180+
- part: cards.qmd
181+
chapters:
182+
- objects.qmd
183+
- notation.qmd
184+
- modifying.qmd
185+
- environments.qmd
159186
```
160187

161188
Note that the markdown files `dice.qmd` and `cards.qmd` contain the part title (as a level one header) as well as some introductory content for the part. If you just need a part title then you can alternatively use this syntax:
162189

163-
``` yaml
164-
- part: "Dice"
165-
chapters:
166-
- basics.qmd
167-
- packages.qmd
190+
```{.yaml filename="_quarto.yml"}
191+
book:
192+
chapters:
193+
- index.qmd
194+
- preface.qmd
195+
- part: "Dice"
196+
chapters:
197+
- basics.qmd
198+
- packages.qmd
168199
```
169200

170201
You can include appendices by adding an `appendices` key to your `book` config. For example:
171202

172-
``` yaml
203+
```{.yaml filename="_quarto.yml"}
173204
book:
174205
title: "mybook"
175206
author: "Jane Doe"
@@ -193,12 +224,15 @@ In LaTeX output, the `\part` command is used for parts. In EPUB and MS Word outp
193224

194225
Appendices are numbered using uppercase alpha, and have a prefix inserted into their title to indicate they are an appendix (e.g. "Appendix A --- Additional Resources"). You can customize the prefix and delimiter using the following options:
195226

196-
``` yaml
227+
```{.yaml filename="_quarto.yml"}
197228
crossref:
198229
appendix-title: "App."
199230
appendix-delim: ":"
200231
```
201232

202-
Which would result in the above example being output as: "App. A: Additional Resources".
233+
Which would result in the above example being output as: "App. A: Additional Resources".
234+
Note that `crossref` is a format option and is not nested under `book`.
235+
236+
{{< include ../websites/_page-navigation.md >}}
203237

204-
{{< include ../websites/_page-navigation.md >}} {{< include ../websites/_footer.md >}}
238+
{{< include ../websites/_footer.md >}}

0 commit comments

Comments
 (0)