12 Tweaking the YAML header
The YAML block appears at the top of every Quarto document.
A simple example:
---
title: "Introduction to Fluid Mechanics"
author: "Dr Jane Smith"
date: today
---12.1 Table of Contents
Enable a table of contents:
format:
html:
toc: true12.2 Section Numbering
format:
html:
number-sections: true12.3 Themes
Quarto provides several built-in themes.
format:
html:
theme: cosmoOther popular themes include:
- flatly
- litera
- united
- lumen
- sandstone
If you specify a light and dark theme, then Quarto will add in a toggle button to allow users to switch.
format:
html:
theme:
light: cosmo
dark: darklyIf you use dark mode, please if you images have transparency (if you have black text on a transparent background this can be illegible).
12.4 Multiple Output Formats
Quarto can render several formats from the same source.
format:
html:
toc: true
pdf:
toc: true
docx: defaultRendering the document then produces HTML, PDF, Word simultaneously.
Always check each output. Sometimes things may note always compile as you wish!
12.5 Creating Books and Lecture Notes
A common approach is to keep all chapter files in a dedicated chapters folder and store chapter-specific images in an images directory within that folder.
project:
type: bookExample structure:
course-notes/
│
├── _quarto.yml
├── index.qmd
├── references.bib
│
└── chapters/
├── week1.qmd
├── week2.qmd
├── week3.qmd
│
└── images/
├── lecture-diagram.png
├── experiment-setup.jpg
└── results-plot.svg
Example _quarto.yml:
project:
type: book
book:
title: "Physics 1A Lecture Notes"
chapters:
- index.qmd
- chapters/week1.qmd
- chapters/week2.qmd
- chapters/week3.qmd