User:Athrash/Template3

For each page with more than three headings, a table of contents (TOC) is automatically generated from the section headings, unless: When either or  (with two underscores on either side of the word) is placed in the wikitext, a TOC is added even if the page has fewer than four headings.
 * (for a user) preferences are set to turn it off
 * (for an article) the magic word (with two underscores on either side of the word) is added in the edit box

Section 1
Thus there may be some introductory text before the TOC, known as the "lead". Although usually a header after the TOC is preferable, can be used to avoid being forced to insert a meaningless header just to position the TOC correctly, i.e., not too low.

Preferences can be set to number the sections automatically.

In a page calling a template with sections, the sections in the template are numbered according to their position in the rendered page, e.g. if the template tag is in the third section, then the first section of the template is numbered four. Any text in the template before its first section shows up as part of the section with the template tag, and any text after the tag before a new header shows up as part of the last section of the template. This may be done deliberately, but can usually better be avoided (see also below).

Using it's possible to disable the normal Table of Contents. Section links as explained below allow to create compact ToCs, e.g. alphabetical A B etc.

The Table of contents can be forced onto a floating table on the right hand of the screen with the code below