Table of contents

How to include a table of contents

A table of contents can be included anywhere in a Mau document with the syntax << toc. The table can be included multiple times, and collects all headers defined in the document, whether they appear before or after the inclusion.

Mau source code
== Header 1

Content of header 1

=== Header 1.1

Content of header 1.1

== Header 2

Content of header 2

*The ToC is rendered below*

<< toc

Header 1

Content of header 1

Header 1.1

Content of header 1.1

Header 2

Content of header 2

The ToC is rendered below

Labels and arguments

The table of contents supports arguments and labels. As for other types of include, arguments can be either inline or boxed, but never both.

Mau source code
[arg1, arg2]
.title A ToC with boxed arguments
<< toc


.title A ToC with inline arguments
<< toc: arg1, arg2

Control conditions

The table of contents supports control conditions.

Mau source code
:var:42

@if var == 42
.title This ToC will be rendered
<< toc

@if var == 43
.title This ToC will NOT be rendered
<< toc

Block isolation

Headers included in blocks are not added to the document ToC automatically, as blocks are isolated by default. To turn off isolation you can use the argument isolate

Mau source code
----
=== Header A

This block is isolated, so the header won't appear in the ToC
----

[isolate=false]
----
=== Header B

This block is NOT isolated, so the header will appear in the ToC
----

*The ToC is rendered below*

<< toc

Header A

This block is isolated, so the header won't appear in the ToC

Header B

This block is NOT isolated, so the header will appear in the ToC

The ToC is rendered below