/

Table of contents

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.

Basic usage

The function accepts the following optional parameters:

ParameterDescriptionAcceptsDefault
titleTitle that precedes the table of contents. If unset, it is automatically localized.Inline contentAutomatically localized if .doclang’s locale is supported (e.g., Table of Contents for English)
maxdepthMaximum heading level to display. For example, maxdepth:{2} collects # and ## headings, but not ### or deeper.Integer3
focusHighlights the item matching this text. Inline formatting (bold, italics) is ignored when comparing.Inline content(none)

Example 1

.tableofcontents maxdepth:{2}

## A

...

### A.A

...

### A.B

...

## B

...

## C

### C.A

#### C.A.A

...
Table of contents

Behavior by document type

The table of contents adapts to different document types:

Theming

Layout themes greatly influence the appearance of the table of contents.

Example 2

Table of contents with minimal theme
'minimal' theme

Ignoring specific headings

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 heading

If you want decorative headings to appear in the table of contents anyway, enable the includeunnumbered parameter:

.tableofcontents includeunnumbered:{yes}

Custom numbering

You can customize how headings are numbered in the table of contents via the .numbering function. See Numbering for more information.

Focusing entries

The focus parameter highlights a specific entry in the table of contents, drawing attention to the current section.

Example 3

Adding focus:{A.B} to the previous example highlights that entry:

.tableofcontents maxdepth:{2} focus:{A.B}
Table of contents with focus

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.

Using markers for chapter navigation

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.