Template:Toclimit/doc

This template inserts a table of contents which omits subheadings lower than a certain level. The table obeys the same layout rules as the  magic word. Omitted sections still have section edit links in the article body.

The main use for this template is situations where it is advantageous to have section edit links for ease of editing, but the table of contents would be too long and cluttered, and/or the Tocright template could not be used instead.

Using this
Place the following on a page in the position where the table of contents should be.
 * Toclimit

Parameters

 * unnamed parameter 1 - (optional) An integer to specify the heading level limit. Possible values range from 2 - 7.
 * The template defaults to including only first- and second-level headings, i.e. those numbered "#" and "#.#" in the TOC..

Example
This would allow for third-level headings, i.e. "#.#.#", but would omit any subheadings below that from the TOC.

Details

 * The template works by hiding the lower levels with CSS. See MediaWiki:Common.css.
 * This template does not interact well with the Tocright template.

TOC levels versus wikitext header levels
The heading levels in the TOC normally correspond to the header levels in the wikitext, so a " " will normally generate the first-level ("#") TOC headings, a " " will normally generate the second-level ("#.#") TOC headings, and so on. This correspondence does not hold if the page contains " " or skips header levels. For example, wikitext like this: == Level-2 heading (A) == === Level-3 heading (B) === == Level-2 heading (C) == ====== Level-6 heading (D) ====== = Level-1 heading (E) = == Level-2 heading (F) == === Level-3 heading (G) === will generate a TOC like this: Using Toclimit in this instance would not hide header D, because even though it is a level-6 heading it is shown at the second level in the TOC. And it would hide header G even though it is a level-3 heading just like header B, because header G is shown at the third level in the TOC while header B is shown at the second level.