Version 27 (modified by athomas, 9 years ago) (diff)


Table of Contents Macro


The TocMacro generates a table of contents for the current page or a set of pages.

If no arguments are given, a table of contents is generated for the current page, with the top-level title stripped:


To generate a table of contents for a set of pages, simply pass them as comma separated arguments to the TOC macro. This is the macro call for the table of contents visible on the right side of this page:

[[TOC(TracGuide, TracInstall, TracUpgrade, TracIni, TracAdmin, TracBackup, TracLogging,
TracPermissions, TracWiki, WikiFormatting, TracBrowser, TracRoadmap, TracChangeset,
TracTickets, TracReports, TracQuery, TracTimeline, TracRss, TracNotification)]]

A wildcard '*' can be used to fetch a sorted list of all pages starting with the preceding pagename stub (Since [2801]):

[[TOC(Trac*, WikiFormatting, WikiMacros)]]

For 'titleindex' argument, an empty pagelist will evaluate to all pages (Since [2801]):

[[TOC(titleindex, notitle, heading=All pages)]]

The following control arguments change the default behaviour of the TOC macro (Since [22]):

Argument Meaning
heading=<x> Override the default heading of "Table of Contents" or "Page Index" for titleindex.
noheading Suppress display of the heading.
depth=<n> Display headings of subsequent pages to a maximum depth of <n>.
inline Display TOC inline rather than as a side-bar.
titleindex Only display the page name and title of each page, similar to TitleIndex. (Since [37]).
notitle Supress display of page title (Since [2801]).

Bugs/Feature Requests

Existing bugs and feature requests for TocMacro are here.

If you have any issues, create a new ticket.



TocMacro requires that AnchorPatch be applied to 0.8? Trac. Trac 0.9? already includes this patch.


You can check out the source for TocMacro from Subversion at


[[TOC(inline, heading=Trac Table of Contents, TracGuide, TracInstall, depth=2,
 TracLogging, depth=99, TracPermissions)]]

On the right you can see the TOC macro version of the default TracGuideToc macro.

Do not forget to enable the macro in trac.ini (at least with 0.11 and 0.10.4) in the components section like this:

tractoc.* = enabled

Change Log

14544 by rjollos on 2015-04-20 16:03:19 tag_svn_revision is not supported in setuptools ≥ 10.
14509 by rjollos on 2015-03-29 00:47:54 Avoid traceback by ensuring that is a string. Fixes #12254.
13602 by rjollos on 2014-01-21 07:53:51 Indicate in documentation when reverse argument was added. Refs #11513.


Authors: athomas, jouvin, coderanger, cboos, osimons