TOC Macro
![]() | Generates a Table Of Content for titles (headings) |
Type | JAR |
Developed by | XWiki Development Team |
Active Installs | 0 |
Rating | |
License | GNU Lesser General Public License 2.1 |
Bundled With | XWiki Standard |
Table of contents
Description
Each title has an anchor associated to it.
Usage
From WYSIWYG Editor
From Wiki Syntax
Parameters definition
Name | Optional | Allowed values | Default value | Description |
---|---|---|---|---|
start | yes | 1 - 6 | 2 | an initial level where the TOC generation should start at (the default is level 2 because level 1 is considered as a document title) |
depth | yes | 1 - 6 | 6 | maximum level the TOC is generated for |
numbered | yes | true/false | false | if should generate numbering for titles (see examples below) |
scope | yes | page/local | page | If 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. Not used if a reference is specified (since in this case the scope is always page) |
reference | yes | Reference to a page | Current page | The page for which to generate the TOC for. If not specified, generate a TOC for the current page. |
Example 1: Simple
= Level 1
Hello
== Level 2
Result
Example 2: Floating
= Level 1
Hello
== Level 2
Result
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 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):
= Level 1
== Level 2
== Level 3
= Level 4
== Level 5
Result
Example 4: TOC numbering corresponding at Numbered Headings
(Proposed by Pascal B)
If you use Numbered Headings and TOC macro to display a floating TOC, you can use the same numerotation.
You must install Numbered+Headings, Box macro and of course TOC Macro.
Then add a StyleSheetExtension Object to your page and put the following content (you can select Always on this wiki):
div.box.floatinginfobox 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):
{{box cssClass="floatinginfobox" title="**Nice TOC**"}}
{{toc numbered="true" depth="3"/}}
{{/box}}
= Level 1
== Level 2
== Level 3
= Level 4
== Level 5
Result
Tested on
This extension has been tested with the following configurations.
Extension Version | XWiki Flavor | Notes |
---|---|---|
6.1 | XWiki Enterprise 6.1 |
Prerequisites & Installation Instructions
We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.
You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.
Dependencies
Dependencies for this extension (org.xwiki.rendering:xwiki-rendering-macro-toc 13.1):