Manual:Table of contents

From MediaWiki.org
(Redirected from TOC)
Jump to: navigation, search

By default, a table of contents (sometimes abbreviated to TOC) is automatically generated on a page when more than three section headings are used. Typically, the table reproduces and numbers these headings.

Contents

[edit] Hiding the TOC

See also Manual:FAQ#How can I hide the table of contents?
For one page
Place the magic word __NOTOC__ into the page markup.
For all pages
There are three ways to achieve this:
Per user
Users can individually opt to have the table of contents hidden. This is a user preference, set in Special:Preferences (Preferences > Appearance > Advanced options > Show table of contents).

[edit] Positioning the TOC

The default position of the TOC is directly above the first section heading. Any prior text is placed before the TOC. To place it elsewhere, use the magic word __TOC__ at the preferred position on the page.

[edit] Adding the TOC

If you have three or fewer headings but want to have a TOC, write either the magic word __FORCETOC__ anywhere on the page to make it display at the default location, or __TOC__ at the preferred position.

[edit] Customizing the TOC

[edit] Depth

The maximum level of headings displayed on the TOC is defined in $wgMaxTocLevel. To customize this for individual pages, the TOC can be enclosed in an element with class toclimit-<limit>, if the appropriate CSS rules are defined in Common.css. See Template:TOC and the relevant rules at MediaWiki:Common.css for an example implementation.

[edit] Auto-numbering

By default, the TOC automatically numbers the sections. The section headings themselves aren't numbered. This behavior of the table of contents can be customised in several ways:

  • It is possible to suppress the auto-generated section numbers in the TOC, if the proper class exists locally at MediaWiki:Common.css, defined as .tocnumber { display: none; }. To do this selectively, a wrapper element can be placed around the TOC, as in <div class="noautonum">__TOC__</div> on the page, and .noautonum .tocnumber { display: none; } at MediaWiki:Common.css.
  • There is a user preference to also auto-number the section headings, at Preferences > Appearance > Advanced options > Auto-number headings. This can be set globally for the whole wiki by defining $wgDefaultUserOptions['numberheadings'] = 1 in LocalSettings.php
    • This setting can be overridden individually by users, by changing their preferences as described above, or by setting .mw-headline-number { display: none; } in their user style page. Administrators who lack server access can also override the setting for all users, if it is activated as mentioned above. This is done by using the same CSS code in the site's global common.css file.

[edit] Floating

The TOC can be made to display as a floating element on the page, with text flowing around it. For this, enclose the TOC in an element with the CSS style float:left; or float:right;. See Template:TOC for an example implementation.

[edit] Extensions

The behaviour of the table of contents can be further adjusted using extensions. See Category:TOC extensions for a list.

[edit] External links

Language: English  • polski
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox