Template:Compact TOC
This template is used on approximately 7,200 pages and changes may be widely noticed. Test changes in the template's /sandbox or /testcases subpages, or in your own user subpage. Consider discussing changes on the talk page before implementing them. |
This is a table-of-contents replacement for alphabetical lists within mainspace articles. The template has all features of other TOC templates, such as optional "Top" "0–9" sections, and allows selecting other sections.
Usage
Features
- This template replaces the regular Table of Contents functionality. If you want a regular Table of Contents on a page where {{Compact TOC}} is in use, use
__FORCETOC__
or__TOC__
as explained at HELP:TOC. - The compact format goes sideways: A B C D E F G H I J K L ....
- The centering or numbers are optional: center=yes, num=yes.
- The "Contents" heading can go on top (default) or the side (side=yes).
- Letter ranges can be set (see below: #Letters): A B C–F G H–K L...
- Some letters can be omitted, instead of 26 separate letters.
- Other headers can be listed in the TOC (see below: #Listing custom headers).
- Set upper headers before "ABCDEF" by pre1, pre2, ... pre12.
- Set lower headers after "ABCDEF" by custom1, custom2, ... custom12.
- Conceal subheader link-text as "pre1name" over "pre1link" and "custom1name" over "custom1link" etc.
- Other options include: top=yes, seealso=yes, refs=yes, extlinks=yes, etc.
Syntax
- Typical use
{{Compact TOC |symnum=yes}}
- Alphabetic (i.e. "A", "B", … "Z") links only
{{Compact TOC}}
- Common applications
{{Compact TOC |center=yes |seealso=yes |refs=yes |further=yes}}
Full blank syntax
{{Compact TOC
|side=|center=|right=
|name=
|top=
|pre1=|pre1name=|pre1link=
|pre2=|pre2name=|pre2link=
<!--(etc, to:)-->
|pre12=|pre12name=|pre12link=
|prebreak=<!--yes-->
|num= |sym= |symnum=
|letters=
|custom1=|custom1name=|custom1link=
|custom2=|custom2name=|custom2link=
<!--(etc, to:)-->
|custom12=|custom12name=|custom12link=
|nobreak=
|seealso= |refs= |notesfirst=|notes= |further= |extlinks=
|a=|b= <!--(etc, until:)--> |z=
}}
Parameters
name=
: change the heading to an alternative name instead of "Contents", or hide it completely by enteringname=no
side=yes
: put the "Contents" heading on the left side with a colon, instead of the top without onecenter=yes
: float TOC centered in the horizontal middle of the page, instead of floated leftright=yes
: align the TOC horizontally to the right of the page (may require<br style="clear:right;" />
after it, depending on page layout), instead of floated left (this parameter is mutually exclusive with the "center" option above, and should be used sparingly and with good reason)nobreak=yes
: no linebreak between the A-B-C-etc. stuff and the See also/References/etc. stuff (note: does not affect the heading; useside=
for that)top=yes
: enable the "Top" link; this is only useful if this copy of the TOC is a secondary TOC not at the top of the page, e.g. in the middle of a long glossary. (Every rendered page has a hidden<a name="top" id="top"></a>
above the sitenotice which makes this link work without having to do anything but enable it in the template.)num=yes
: enable the "0–9" link for numeric entries section (create a heading of==0–9==
for the link to work)sym=yes
: enable the "!$@" link for symbolic entries sectionsymnum=yes
: enable the "!–9" link for combined symbolic and numeric entries section (create a heading of==!–9==
for the link to work)letters=no
: suppresses the "A", "B", ..., "Z" entries.pre1
topre12
: list up to 12 extra section headers before (pre-list) the "ABCDEF" list. These appear as [[#pre1|pre1]].pre1name
topre12name
: modifies the way the pre-list section headers appear: [[#pre1|pre1name]]pre1link
topre12link
: modifies the targets of the pre-list headers: [[pre1link|pre1]].prebreak=yes
: set break-line after all pre-list headerscustom1
tocustom12
: add up to 12 extra "custom" sections after the "ABCDEF" list. These appear as [[#custom1|custom1]].custom1name
tocustom12name
: modifies the way the custom section headers appear: [[#custom1|custom1name]]custom1link
tocustom12link
: modifies the targets of the custom sections: [[custom1link|custom1]]. Use this only for linking to another page. Use sparingly! About the only legitimate use for this is connecting the sub-pages of multi-page articles, like long lists that have been broken up. Do not repurpose the TOC as a makeshift navbox.seealso=yes
: enable link to the "See also" sectionnotesfirst=yes
: enable link to the "Notes" section, but placed before "References"; do not use withnotes
(and do observe that it is plural)refs=yes
: enable link to the "References" section (observe that it is plural)notes=yes
: enable link to the "Notes" section (observe that it is plural)further=yes
: enable link to the "Further reading" sectionextlinks=yes
: enable link to the "External links" sectiona=
throughz=
: individually disable particular letters that have no entries. Use with caution and check regularly to make sure that new entries do not require the removal of these parameters. Can also be used to create range links, e.g. "X-Z". (See following section for more detailed documentation of this feature.)- The equivalent of this for numbers is
0-9=
- note this is a hyphen and not a dash (the heading uses a dash)
- The equivalent of this for numbers is
allowtoc=yes
: disables the hiding of the automatically-generated table of contents that__NOTOC__
usually hides. (Since this template's purpose is usually to replace the existing table of contents, this functionality is usually only necessary on Wikipedia guideline pages that use this template in examples.)
Letters
Any letter can be omitted (i.e. when it has no entries in the list) by specifying it as a lowercase blank parameter, e.g. {{Compact TOC |side=yes |j=|q=}}
:
Or it can be replaced with an unlinked letter by using that letter (in uppercase), e.g. {{Compact TOC |side=yes |j=J|q=Q}}
:
Note: It is often better to create an empty placeholder span (e.g. <span id="Q"></span>
) where the letter's heading would be in the page if it existed, since in most cases it is quite possible that it will come to exist in the future. Using the span-id avoids confusing readers who might not realize the TOC-template has skipped some letters.
The letter-assignment feature can also be used to create range links, e.g. {{Compact TOC |side=yes |x=[[#X–Z|X–Z]] |y=|z=}}
:
Listing custom headers
The optional parameters pre1, pre2, ...pre12 and custom1, custom2, ...custom12 allow up to 24 other section headers to be listed before or after the "ABCDEF" list:
{{Compact TOC |name=no |center=yes |top=yes |custom1=New section |custom2=Additional section |seealso=yes|notes=yes}}
{{Compact TOC |name=no |center=yes |top=yes |custom1=New section|custom1name=Custom section name |custom2=Outside page|custom2link=Main Page |seealso=yes|notes=yes}}
Headers can be listed before & after "ABCDEF" using pre1 and custom1 :
{{Compact TOC |center=yes |top=yes |pre1=Scope of list |pre2=Abbreviations used |prebreak=yes |custom1=Popular entries |custom2=Excluded entries |notes=yes|seealso=yes}}
"short1"
{{Compact TOC |side=yes |center=yes |nobreak=yes |refs=yes}}
is a common configuration whose parameters may be replaced by the shortcut
{{Compact TOC |short1}}
i.e. by making |short1
the very first parameter.
Hacks
Sub-articles
The omitted letters feature explained above can also be used (very tediously) for linking to sub-articles (e.g. long lists that have been split into multiple pages):
{{Compact TOC |side=yes |name=[[Articlename]] |n=[[Articlename (N–Z)#N|N]] |o=[[Articlename (N–Z)#O|O]] |... |z=[[Articlename (N–Z)#Z|Z]]}}
{{Compact TOC |side=yes |n=[[Articlename (N–Z)| N–Z {{small|(next page)}}]] |o=|p=|...|z=}}
Abbreviated footer links
The template offers parameters to enable standard footer sections to be linked from the compact display (see § Parameters (e.g., |refs=yes
, |further=yes
, and |extlinks=yes
and others, above). However, these may add excessive length, and they appear on a separate line, after the letter indexes.
If you happen not to need letter 'Z' as a separate link, as shown in the last example in the Letters section above where it is combined as "X–Z", a hack is available to add an abbreviated link to one of the footer sections. For example, to link to the "References" section as "Refs" after the letter indexes and on the same line, you can do this:
{{Compact TOC |side=yes |x=[[#X–Z|X–Z]] |y= |z=[[#References|Refs]]}}
If you don't need a separate 'Y' link either (same X-Z example in the Letters section), then you can link two footers. Here's an example that links "Refs" to the § References section as in the previous example, and also links "Exts" to the § External links section:
{{Compact TOC |side=yes |x=[[#X–Z|X–Z]] |y=[[#References|Refs]] |z=[[#External links|Exts]]}}
Examples
{{Compact TOC |top=yes}}
{{Compact TOC |center=yes}}
{{Compact TOC |side=yes |sym=yes|num=yes |custom1=Other |seealso=yes |refs=yes}}
{{Compact TOC |name=Directory |top=no |refs=yes|notes=yes|extlinks=yes}}
{{Compact TOC |side=yes|right=yes |name=no |symnum=yes |seealso=yes}}
{{Compact TOC |short1 |sym=yes|num=yes|seealso=yes|notesfirst=yes|further=yes|extlinks=yes}}
Limitations
Unfortunately, it is not possible to center the contents due to the lack of supporting CSS in MediaWiki:Common.css.
Template data
TemplateData for Compact TOC
Data used by citation tools
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
No description.
|
See also
- Help:TOC
- {{Horizontal TOC}}
- {{Category TOC}}
- {{TOC limit}}
- {{TOC hidden}}
- Help:Magic words#Behavior switches for more help on:
- __NOTOC__
- __TOC__