tableofcontentsasciidocasciidoctor

How to set Asciidoc toc.section.depth value from simple 'asciidoctor file.txt -o file.html' command?


This FAQ section describes how to set the "section depth"/"TOC level"/toclevel shown in the table of contents. However, I've no idea how to implement this in my simple:

$ asciidoctor my.txt -o my.html

command. Does anyone?


Solution

  • The toclevels attribute controls this.

    From https://asciidoctor.org/docs/user-manual/#user-toc-levels:

    By default, the TOC will display level 1 and level 2 section titles. You can set a different depth with the toclevels attribute.

    :toc:
    :toclevels: 4
    
    1. The toc attribute must be set in order to use toclevels.
    2. toclevels is set and assigned the value 4 in the document’s header. The TOC will list the titles of the section 1, 2, 3, and 4 levels when the document is rendered.