Numbering Sections and Table of Contents

Amaya

## Numbering sections

Section headings (`h1` to `h6` elements) can be automatically numbered according to the document structure.

If there is only one `h1` element in the document, it is supposed to be the document title and it is not numbered. If there are several `h1` elements, they are considered as section headings and they are therefore numbered.

Headings receive a number that is computed according to their type and their position in the document structure. These numbers are generated in the document itself and numbers that were generated previously are removed, every time the Tools/Section numbering command is called.

## Generating a table of contents

Command Tools/Add-Update table of contents collects all section headings (`h1` to `h6` elements) that follow the current position and it generates a table of contents at the current position. The command updates the current table of contents if the selection is already within a table of contents.

If there is only one `h1` element in the document, it is not taken into account for the table of contents.

This command adds:

- An `id` attribute to each `h1` to `h6` element which does not have this attribute.
- A division (with a `class="toc"` attribute) that contains nested unnumbered lists (`ul`) at the current position. You can use this `class` attribute to set a particluar style to your tables of contents.
- A list item (`li`) for each `h1` to `h6` element including a link which points to the corresponding element in the document.

  The link element contains a copy of the `hn` element. If the `hn` element is numbered, this number is also copied.