A professional report needs more than just content — it needs structure. In this chapter, you will learn how to add a table of contents, insert page breaks, and switch the page layout to landscape for wide tables or graphics.
Table of contents
Enabling a simple TOC
A table of contents is enabled in the YAML header:
---
title: "Penguin Report"
format:
docx:
toc: true
---Word automatically inserts a table of contents at the beginning of the document, based on the headings.
Setting TOC depth
By default, three heading levels are displayed. This can be adjusted:
format:
docx:
toc: true
toc-depth: 2| toc-depth | Displayed levels |
|---|---|
| 1 | Only #
|
| 2 |
# and ##
|
| 3 |
#, ##, and ### (default) |
Changing the TOC title
format:
docx:
toc: true
toc-title: "Contents"Page breaks
The pagebreak shortcode
To insert a page break, use the pagebreak shortcode:
# Introduction
Text of the introduction...
# Methods
Text of the methods...This is useful to ensure that a new chapter starts on a new page.
Automatic page breaks before headings
For automatic page breaks before each main heading, you can adjust the Word template (Chapter 4): In the “Heading 1” style under Format → Paragraph → Line and Page Breaks, enable the “Page break before” option.
Landscape orientation
Sometimes tables or graphics are too wide for portrait orientation. With the officedown package, you can rotate individual pages to landscape.
Setting up officedown
First, the package must be installed:
install.packages("officedown")Then change the format in the YAML header:
---
title: "Penguin Report"
format:
docx: default
output:
officedown::rdocx_document:
reference_docx: template.docx
---Currently, the integration of officedown into Quarto is still somewhat cumbersome. For simple cases, you can alternatively rotate the wide table manually in Word or split the table across multiple pages.
Landscape blocks
With officedown, you can set individual sections to landscape:
<!---BLOCK_LANDSCAPE_START--->
```{r}
#| label: wide-table
# Very wide table here
Everything between `BLOCK_LANDSCAPE_START` and `BLOCK_LANDSCAPE_STOP` appears in landscape orientation.
# Page margins
## In the YAML header
Page margins can be defined in the YAML header:
```yaml
format:
docx:
reference-doc: template.docx
geometry:
- top=2.5cm
- bottom=2.5cm
- left=3cm
- right=2.5cm
The most reliable method for page margins is to set them in the Word template (Chapter 4): Layout → Margins → Custom Margins.
Sections with different layouts
For more complex documents with different layouts (e.g., title page without page number, main part with page numbers), you need to work with Word section breaks in the template. This goes beyond the scope of this tutorial but is described in the officedown documentation.
Practical example
Here is a complete YAML setup for a professional report:
---
title: "Analysis of Adelie Penguins"
author: "Research Team"
date: today
lang: en
format:
docx:
reference-doc: templates/template.docx
toc: true
toc-depth: 2
toc-title: "Contents"
crossref:
fig-title: "Figure"
tbl-title: "Table"
fig-prefix: "Fig."
tbl-prefix: "Tab."
execute:
echo: false
warning: false
message: false
---The Officeverse ecosystem
For advanced Word documents, there is the “Officeverse” — a collection of R packages:
| Package | Purpose |
|---|---|
| flextable | Tables (already covered) |
| officedown | Extended Word features in R Markdown/Quarto |
| officer | Create Word documents programmatically |
| mschart | Native Word charts |
When to use officer instead of Quarto?
- Very complex layouts that Quarto does not support
- Mass production of documents (e.g., 100 personalized reports)
- Full programmatic control over every element
For most scientific reports, however, Quarto with flextable is completely sufficient.
- Create a document with at least three main chapters
- Enable the table of contents with
toc: true - Insert a page break before the first main chapter
- Experiment with different
toc-depthsettings - Render to Word and check the result
Further resources
- Quarto Word Options — All YAML options
- officedown — Extended features
- officer — Programmatic document creation
What is next
In Chapter 9, we will learn how to add citations and a bibliography to the document — essential for scientific publications.
Citation
@online{schmidt2026,
author = {{Dr. Paul Schmidt}},
publisher = {BioMath GmbH},
title = {8. {Table} of {Contents} and {Page} {Layout}},
date = {2026-02-07},
url = {https://biomathcontent.netlify.app/content/quarto/08_toc_and_layout.html},
langid = {en}
}