asciidocasciidoctorasciidoctor-pdf

Asciidoctor: Is it possible to activate section numbering in themes yml


I know that I can use :sectnums: all after the title to enable section and subsection numbering. But is it possible to define this in the theme yml? I have a lot documents which use the same theme file, and it would be nice to have it defined only once.


Solution

  • The PDF theme.yml does not support setting AsciiDoc attributes, so that approach won't work.

    However, you can specify attributes on the command-line:

    asciidoctor-pdf -a sectnums=all file.adoc
    

    It might be better to create an AsciiDoc file that only defines attributes, say attributes.adoc. You would specify any attributes that you want to use globally:

    :sectnums: all
    :toc: left
    

    Then, in every document that needs to use those attributes:

    = My document
    include::attributes.adoc[]
    
    Lorem ipsum...
    

    Once you've done that for all documents, adjusting the attributes requires editing only the attributes.adoc file.