Automatic Table of Contents
A table of contents (TOC) is an index of section titles in an AsciiDoc document. When the TOC is enabled, the AsciiDoc processor automatically generates the TOC from the document’s structure and inserts it into the output document. The number of levels (i.e., depth) of the TOC is configurable.
Activate the TOC
To enable the autogenerated TOC, set the toc
document attribute.
The toc
attribute is activated with an attribute entry in the document header.
= The Intrepid Chronicles
Kismet Lee; B. Steppenwolf; Pax Draeke
:toc: (1)
== Certain Peril
Daylight trickles across the cobblestones...
=== A Recipe for Potion
We have to harvest the leaves by the light of the teal moons...
==== Searching for Ginseng
Crawling through the twisted understory...
== Dawn on the Plateau
Hanging from...
1 | Set the toc attribute in the header using an attribute entry.
When the value of toc is empty, the processor will use the attribute’s default value. |
By default, the TOC is rendered directly below the document header, is titled Table of Contents, and contains section 1 and section 2 level titles only. The result of Example 1 is displayed below.
You can customize the title of the TOC, the depth of the section levels, and the position of the TOC in the document. However, not all of the attributes are supported by all converters. See TOC Attributes Reference for which attributes are available to each converter.