Difference between revisions of "Template:TOC limit/doc"

From Summertime Saga Wiki
Jump to: navigation, search
m
m
Line 1: Line 1:
This template 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.
+
The template {{tl|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|{{tlx|TOC limit}}}} or {{nowrap|{{tlx|TOC limit|3}}}}
+
{{nowrap|{{tlc|TOC limit}}}} or {{nowrap|{{tlc|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.)
  
 
You can specify a different limit by adding a header level:
 
You can specify a different limit by adding a header level:
  
{{nowrap|{{tlx|TOC limit|4}}}}
+
{{nowrap|{{tlc|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.
  
 
The template works by hiding the lower levels with CSS.
 
The template works by hiding the lower levels with CSS.
Line 17: Line 17:
 
=== TOC levels versus wikitext header levels ===
 
=== TOC levels versus wikitext header levels ===
  
The heading levels in the TOC 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:
+
The heading levels in the TOC 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) ==
  === Level-3 heading (B) ===
+
  === Level‐3 heading (B) ===
  == Level-2 heading (C) ==
+
  == Level‐2 heading (C) ==
  ====== Level-6 heading (D) ======
+
  ====== Level‐6 heading (D) ======
  = Level-1 heading (E) =
+
  = Level‐1 heading (E) =
  == Level-2 heading (F) ==
+
  == Level‐2 heading (F) ==
  === Level-3 heading (G) ===
+
  === Level‐3 heading (G) ===
  
 
will generate a TOC like this:
 
will generate a TOC like this:
Line 32: Line 32:
 
|<div style="text-align:center"><b>Contents</b></div>
 
|<div style="text-align:center"><b>Contents</b></div>
 
<ul>
 
<ul>
<li class="toclevel-1 tocsection-1"><span class="tocnumber">1</span> <span class="toctext">Level-2 heading (A)</span><ul>
+
<li class="toclevel-1 tocsection-1"><span class="tocnumber">1</span> <span class="toctext">Level‐2 heading (A)</span><ul>
<li class="toclevel-2 tocsection-2"><span class="tocnumber">1.1</span> <span class="toctext">Level-3 heading (B)</span></li>
+
<li class="toclevel-2 tocsection-2"><span class="tocnumber">1.1</span> <span class="toctext">Level‐3 heading (B)</span></li>
 
</ul></li>
 
</ul></li>
<li class="toclevel-1 tocsection-1"><span class="tocnumber">2</span> <span class="toctext">Level-2 heading (C)</span><ul>
+
<li class="toclevel-1 tocsection-1"><span class="tocnumber">2</span> <span class="toctext">Level‐2 heading (C)</span><ul>
<li class="toclevel-2 tocsection-2"><span class="tocnumber">2.1</span> <span class="toctext">Level-6 heading (D)</span></li>
+
<li class="toclevel-2 tocsection-2"><span class="tocnumber">2.1</span> <span class="toctext">Level‐6 heading (D)</span></li>
 
</ul></li>
 
</ul></li>
<li class="toclevel-1 tocsection-1"><span class="tocnumber">3</span> <span class="toctext">Level-1 heading (E)</span><ul>
+
<li class="toclevel-1 tocsection-1"><span class="tocnumber">3</span> <span class="toctext">Level‐1 heading (E)</span><ul>
<li class="toclevel-2 tocsection-2"><span class="tocnumber">3.1</span> <span class="toctext">Level-2 heading (F)</span><ul>
+
<li class="toclevel-2 tocsection-2"><span class="tocnumber">3.1</span> <span class="toctext">Level‐2 heading (F)</span><ul>
<li class="toclevel-3 tocsection-3"><span class="tocnumber">3.1.1</span> <span class="toctext">Level-3 heading (G)</span></li>
+
<li class="toclevel-3 tocsection-3"><span class="tocnumber">3.1.1</span> <span class="toctext">Level‐3 heading (G)</span></li>
 
</ul></li>
 
</ul></li>
 
</ul></li>
 
</ul></li>
Line 46: Line 46:
 
|}
 
|}
  
Using <code><nowiki>{{TOC limit}}</nowiki></code> 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.
+
Using {{TOC limit}} on this page {{em|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 {{em|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 ===
 
=== Conflicts ===
  
This template does not interact well with the {{nowrap|{{tl|TOC right}}}} template. To achieve the correct effect, use those with a limit parameter. For example, {{nowrap|{{tlx|TOC right|2=limit=2}}}} has the effect that {{nowrap|{{tlx|TOC right}}}} and {{nowrap|{{tlx|TOC limit|2}}}} would have—if they worked together.
+
This template does not interact well with the {{nowrap|{{tl|TOC right}}}} template. To achieve the correct effect, use those with a limit parameter. For example, {{nowrap|{{tlc|TOC right|2=limit=2}}}} has the effect that {{nowrap|{{tlc|TOC right}}}} and {{nowrap|{{tlc|TOC limit|2}}}} would have if they worked together.
  
Due to the way the TOC is generated with MobileFrontend (mobile/tablet view) this template does not currently affect how the mobile TOC is displayed.
+
Due to the way the Table Of Content is generated with MobileFrontend (mobile and tablet view) this template does not currently affect how the mobile table of content is displayed.
  
 
[[Category:Templates]]
 
[[Category:Templates]]
 
[[Category:Templates documentation]]
 
[[Category:Templates documentation]]

Revision as of 18:09, 13 July 2020

The template Template:Tl 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

Template:Tlc or Template:Tlc

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:

Template:Tlc

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 TOC 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 TOC like this:

Contents
  • 1 Level‐2 heading (A)
    • 1.1 Level‐3 heading (B)
  • 2 Level‐2 heading (C)
    • 2.1 Level‐6 heading (D)
  • 3 Level‐1 heading (E)
    • 3.1 Level‐2 heading (F)
      • 3.1.1 Level‐3 heading (G)

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 Template:Tl template. To achieve the correct effect, use those with a limit parameter. For example, Template:Tlc has the effect that Template:Tlc and Template:Tlc would have if they worked together.

Due to the way the Table Of Content is generated with MobileFrontend (mobile and tablet view) this template does not currently affect how the mobile table of content is displayed.