A table of contents provides a quick overview of your document by displaying links to headings in a visual hierarchy. Readers can click on any entry to jump directly to that section. You can see a table of contents right now in the right sidebar, or at the end of the page if you’re on a mobile device.
You can display a table of contents through the .tableofcontents docs ↗ function.
The function accepts the following optional parameters:
| Parameter | Description | Accepts | Default |
|---|---|---|---|
title | Title that precedes the table of contents. If unset, it is automatically localized. | Inline content | Automatically localized if .doclang’s locale is supported (e.g., Table of Contents for English) |
maxdepth | Maximum heading level to display. For example, maxdepth:{2} collects # and ## headings, but not ### or deeper. | Integer | 3 |
focus | Highlights the item matching this text. Inline formatting (bold, italics) is ignored when comparing. | Inline content | (none) |
.tableofcontents maxdepth:{2}
## A
...
### A.A
...
### A.B
...
## B
...
## C
### C.A
#### C.A.A
...
The table of contents adapts to different document types:
paged and slides documents, each entry also displays the corresponding page number.slides documents, the table of contents has a constrained height and becomes vertically scrollable when content overflows.Layout themes greatly influence the appearance of the table of contents.

Sometimes you want certain headings to appear in your document but not in the table of contents. Decorative headings serve this purpose: they are not numbered and do not appear in the table of contents by default.
To mark a heading as decorative, append ! to the last # sign:
##! A decorative headingIf you want decorative headings to appear in the table of contents anyway, enable the includeunnumbered parameter:
.tableofcontents includeunnumbered:{yes}You can customize how headings are numbered in the table of contents via the .numbering function. See Numbering for more information.
The focus parameter highlights a specific entry in the table of contents, drawing attention to the current section.
Adding focus:{A.B} to the previous example highlights that entry:
.tableofcontents maxdepth:{2} focus:{A.B}
This feature is particularly useful in presentations, where you might want to show a mini table of contents at the beginning of each chapter to orient your audience.
For slide presentations, you can combine focusing with markers to create elegant chapter navigation. The .marker function creates an invisible level-0 heading, which is not normally possible with the standard #-based syntax.
Here is a practical pattern for chapter slides:
.function {chapter}
name:
.tableofcontents maxdepth:{0} focus:{.name}
.marker {.name}You can then invoke it with .chapter {My chapter} at the start of each section. Setting maxdepth:{0} ensures only markers appear in the table of contents, creating a clean chapter-level overview rather than showing all headings.