Difference between revisions of "Template:TOC limit/doc"
m |
m |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | The template {{ | + | The template {{tlg|TOC limit}} inserts a Table of Contents which omits subheadings beyond a certain depth. The table obeys the same layout rules as the <nowiki>__TOC__</nowiki> magic word. Omitted sections still have section edit links in the article body; the main use for this template is situations where you want section edit links for ease of editing but don’t want to clutter the table of contents. |
=== Usage === | === Usage === | ||
− | : {{nowrap|{{ | + | : {{nowrap|{{tlg|code=yes|nolink=yes|TOC limit}}}} or {{nowrap|{{tlg|code=yes|nolink=yes|TOC limit|3}}}} |
The template defaults to including second‐ and third‐level headings, e.g. those numbered “1” and “1.1” in the TOC. (Note: the first‐level heading on a page is, by default, the page title.) | The template defaults to including second‐ and third‐level headings, e.g. those numbered “1” and “1.1” in the TOC. (Note: the first‐level heading on a page is, by default, the page title.) | ||
Line 9: | Line 9: | ||
You can specify a different limit by adding a header level: | You can specify a different limit by adding a header level: | ||
− | : {{nowrap|{{ | + | : {{nowrap|{{tlg|code=yes|nolink=yes|TOC limit|4}}}} |
4 allows for fourth‐level headings, e.g. “1.1.1” but omits any subheadings below that from the TOC. | 4 allows for fourth‐level headings, e.g. “1.1.1” but omits any subheadings below that from the TOC. | ||
Line 17: | Line 17: | ||
=== TOC levels versus wikitext header levels === | === TOC levels versus wikitext header levels === | ||
− | The heading levels in the table of | + | The heading levels in the table of contents normally correspond to the header levels in the wikitext, so a “== Level‐2 header ==” will normally generate the first‐level (“1”) TOC headings, a “=== Level‐3 header ===” will normally generate the second‐level (“1.1”) TOC headings, and so on. This correspondence does {{em|not}} hold if the page contains “= Level‐1 headers =” or skips header levels. For example, wikitext like this: |
== Level‐2 heading (A) == | == Level‐2 heading (A) == | ||
Line 27: | Line 27: | ||
=== Level‐3 heading (G) === | === Level‐3 heading (G) === | ||
− | will generate a table of | + | will generate a table of contents like this: |
{| class="toc" | {| class="toc" | ||
Line 50: | Line 50: | ||
=== Conflicts === | === Conflicts === | ||
− | This template does not interact well with the {{nowrap|{{ | + | This template does not interact well with the {{nowrap|{{tlg|code=yes|nolink=yes|TOC right}}}} template. To achieve the correct effect, use those with a limit parameter. For example, {{nowrap|{{tlg|code=yes|nolink=yes|TOC right|2=limit=2}}}} has the effect that {{nowrap|{{tlg|code=yes|nolink=yes|TOC right}}}} and {{nowrap|{{tlg|code=yes|nolink=yes|TOC limit|2}}}} would have if they worked together. |
− | Due to the way the table of | + | Due to the way the table of contents is generated with MobileFrontend (mobile and tablet view) this template does not currently affect how the mobile table of contents is displayed. |
== See also == | == See also == | ||
− | * {{ | + | * {{tlg|TOC right}} |
− | [[Category:Templates]] | + | [[Category:Templates]][[Category:Table of contents templates]][[Category:Templates documentation]] |
− | [[Category:Templates documentation]] |
Latest revision as of 16:44, 21 July 2020
The template {{TOC limit}} inserts a Table of Contents which omits subheadings beyond a certain depth. The table obeys the same layout rules as the __TOC__ magic word. Omitted sections still have section edit links in the article body; the main use for this template is situations where you want section edit links for ease of editing but don’t want to clutter the table of contents.
Usage
{{TOC limit}}
or{{TOC limit|3}}
The template defaults to including second‐ and third‐level headings, e.g. those numbered “1” and “1.1” in the TOC. (Note: the first‐level heading on a page is, by default, the page title.)
You can specify a different limit by adding a header level:
{{TOC limit|4}}
4 allows for fourth‐level headings, e.g. “1.1.1” but omits any subheadings below that from the TOC.
The template works by hiding the lower levels with CSS.
TOC levels versus wikitext header levels
The heading levels in the table of contents normally correspond to the header levels in the wikitext, so a “== Level‐2 header ==” will normally generate the first‐level (“1”) TOC headings, a “=== Level‐3 header ===” will normally generate the second‐level (“1.1”) TOC headings, and so on. This correspondence does not hold if the page contains “= Level‐1 headers =” 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 table of contents like this:
Contents
|
Using
on this page 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.
Conflicts
This template does not interact well with the {{TOC right}}
template. To achieve the correct effect, use those with a limit parameter. For example, {{TOC right|limit=2}}
has the effect that {{TOC right}}
and {{TOC limit|2}}
would have if they worked together.
Due to the way the table of contents is generated with MobileFrontend (mobile and tablet view) this template does not currently affect how the mobile table of contents is displayed.
See also
- {{TOC right}}