Extensions Wiki » Extensions » TOC Macro

TOC Macro

Last modified by Vincent Massol on 2013/03/11 09:39
cogGenerates a Table Of Content for titles (headings) in a document
TypeJAR
Developed by

XWiki Development Team

LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Enterprise, XWiki Enterprise Manager

Description

Each title has an anchor associated to it.

Usage

{{toc start=2 depth=6 numbered=false scope=page /}}

Parameters definition

NameOptionalAllowed valuesDefault valueDescription
startyes1 - 62an initial level where the TOC generation should start at (the default is level 2 because level 1 is considered as a document title)
depthyes1 - 66maximum level the TOC is generated for
numberedyestrue/falsefalseif should generate numbering for titles (see examples below)
scopeyespage/localpageIf local, only section in the current scope will be listed. For example if the macro is written in a section, only subsections of this section will be listed.

Example 1: Simple

{{toc /}}

= Level 1

Hello

== Level 2

Result

toc1.png

Example 2: Floating

{{box cssClass="floatinginfobox" title="**Contents**"}}{{toc/}}{{/box}}

= Level 1

Hello

== Level 2

Result

toc2.png

Example 3: Different numbering of sub lists

With a bit of CSS you can change the numbering of subitems. For example add a StyleSheetExtension Object to your page and put the following content (select Always on this page):

ol { list-style-type: none; counter-reset: say; }
ol li:before { counter-increment: say; content: counters(say,".") ". "; }

With this extension, the following content will have, for example, Level 2 displayed as 1.1 (see Result below):

{{toc numbered="true"/}}

= Level 1
== Level 2
== Level 3
= Level 4
== Level 5

Result

toc3.png

Tags:
Created by Thomas Mortagne on 2008/09/30 11:44

Download XWiki