57. Appendix

You can indicate that a section, part, or chapter is an appendix by adding an [appendix] line above the section title.

[appendix]
== Copyright and License

While the AsciiDoc structure allows appendices to be placed anywhere, it’s customary to place them at the end of the document, after all other sections.

Sections marked as appendix have a different title, which is built as follows:

  • A fixed prefix (taken from the value of the appendix-caption attribute, which defaults to “Appendix”)

  • A letter that represents the number of this appendix within the sequence of appendices (A, B, C, …​)

  • A colon

  • The original section title

For example:

Appendix A: Copyright and License

The prefix can be modified by defining the appendix-caption attribute. This value can be changed using:

:appendix-caption: Appx

Or it can be unset using:

:appendix-caption!:

Appendices can have subsections. However, there are some rules to follow depending on which type of document you are creating.

For articles, the appendix must be defined as a level-1 section. (If a level-0 section is used, a level-1 section is implied). For example:

= Article Title
:appendix-caption: Appx
:sectnums:
:toc:

== First Section

=== Subsection

[appendix]
== First Appendix

=== First Subsection

=== Second Subsection

[appendix]
== Second Appendix

The table of contents will appear as follows:

1. First Section
  1.1. Subsection
Appx A: First Appendix
  1.1. First Subsection
  1.2. Second Subsection
Appx B: Second Appendix

For books, the appendix must be defined as a level-1 section if you want the appendix to be a adjacent to other chapters (and in the current part if the book has multiple parts). In a multi-part book, if you want the appendix to be adjacent to other parts, the appendix must be defined as a level-0 section. In either case, the first subsection of the appendix must be a level-3 section, not a level-2 section. That’s because an appendix cannot contain chapters.

The following example shows how to define an appendix for a multi-book (take away the part title if you’re creating a simple book):

= Book Title
:doctype: book
:appendix-caption: Appx
:sectnums:
:toc:

= First Part

== First Chapter

=== Subsection

[appendix]
= First Appendix

=== First Subsection

=== Second Subsection

[appendix]
= Second Appendix

The table of contents will appear as follows:

First Part
1. First Chapter
  1.1. Subsection
Appx A: First Appendix
  1.1. First Subsection
  1.2. Second Subsection
Appx B: Second Appendix