Quarto - Book Structure (2024)

Overview

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.

The simple book configuration generated by quarto create project book illustrates the basics:

book: title: "mybook" author: "Jane Doe" date: "5/9/2021" chapters: - index.qmd - intro.qmd - summary.qmd - references.qmd
  • The index.qmd file is required (because Quarto books also produce a website in HTML format). This page should include the preface, acknowledgements, etc. and headings in the index.qmd file are unnumbered by default. The HTML version of the book will use the index.qmd as the home page and if provided, will place the cover-image on that page.
  • The remainder of chapters includes one or more book chapters.
  • The references.qmd file will include the generated bibliography (see References below for details).

Titles

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

# Introduction

Note that the following is also still perfectly valid:

---title: "Introduction"---

In the absence of a level-one header or a title set in the YAML front matter, the first header in the page will be used as the title.

Chapter Numbers

All chapters are numbered by default. If you want a chapter to be unnumbered simply add the .unnumbered class to its main header. For example:

# Resources {.unnumbered}

You can mix together numbered and unnumbered chapters. Note however that while you can link to unnumbered chapters, you can’t cross reference figures, tables, etc. within them. Unnumbered chapters are therefore mostly useful for prefatory content or references at the end of your book.

Section Numbers

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

number-depth: 1

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).

References

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:

# References {.unnumbered}::: {#refs}:::

Note that you can change the chapter title to whatever you like, remove .unnumbered to have it be numbered like other chapters, and add other content before or after the bibliography as necessary.

Creating an Index

For PDF output, you can create an index using the LaTeX makeidx package along with the \index command.

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: quart

format: html: theme: cosmo pdf: documentclass: scrreprt include-in-header:  text: | \usepackage{makeidx} \makeindex include-after-body:  text: | \printindex

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

Markdown\index{Markdown} allows you to write usingan easy-to-read, easy-to-write plain text format.

Note that \index commands are automatically ignored for non-PDF output.

Parts & Appendices

Please Note

Note that EPUB and Word (Docx) formats do not currently support organizing books into parts. When rendering a book with parts to these formats, the parts will be ignored.

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

chapters: - index.qmd - preface.qmd - part: dice.qmd chapters:  - basics.qmd - packages.qmd - part: cards.qmd chapters: - objects.qmd - notation.qmd - modifying.qmd - environments.qmd

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:

- part: "Dice" chapters:  - basics.qmd - packages.qmd

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

book: title: "mybook" author: "Jane Doe" date: "5/9/2021" chapters: - index.qmd - intro.qmd - summary.qmd - references.qmd appendices: - tools.qmd - resources.qmd 

Parts and appendices show up like this in HTML output:

Quarto - Book Structure (1)

In LaTeX output, the \part command is used for parts. In EPUB and MS Word output parts are ignored entirely.

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:

crossref: appendix-title: "App." appendix-delim: ":"

Which would result in the above example being output as: “App. A: Additional Resources”.

Page Navigation

If you have a book with several pages in a section or subsection, it is often convenient to offer the user the ability to navigate to the next page (or previous page) at the bottom of the page that they’ve just finished reading. You can enable this using:

book: page-navigation: true

When enabled, page navigation will be displayed at the bottom of the page whenever there is a next or previous page (including in the next or previous section). This option is enabled by default for books but not for websites.

You can also enable or disable page navigation at the page level by specifying page-navigation in the YAML header, e.g.:

basics.qmd
---page-navigation: false---

Or to control page navigation for all pages in a directory specify page-navigation in _metadata.yml:

_metadata.yml
page-navigation: false
Quarto - Book Structure (2024)
Top Articles
Latest Posts
Article information

Author: Rueben Jacobs

Last Updated:

Views: 6256

Rating: 4.7 / 5 (57 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Rueben Jacobs

Birthday: 1999-03-14

Address: 951 Caterina Walk, Schambergerside, CA 67667-0896

Phone: +6881806848632

Job: Internal Education Planner

Hobby: Candle making, Cabaret, Poi, Gambling, Rock climbing, Wood carving, Computer programming

Introduction: My name is Rueben Jacobs, I am a cooperative, beautiful, kind, comfortable, glamorous, open, magnificent person who loves writing and wants to share my knowledge and understanding with you.