The Table of Contents macro scans the headings on the current Confluence page to create a table of contents based on those headings. This helps readers find their way around lengthy pages, by summarising the content structure and providing links to headings.

Using the Table of Contents macro

Hint: For quick access from the editor toolbar, choose Insert > Table of Contents.

To add the Table of Contents macro to a page:

  1. In the Confluence editor, choose Insert > Other Macros.
  2. Find and select the required macro.

Speeding up macro entry with autocomplete: Type { and the beginning of the macro name, to see a list of suggested macros. Details are in Using Autocomplete.

To edit an existing macro: Click the macro placeholder and choose Edit. A macro dialog window will open, where you can edit the parameters of the macro.

On this page:

Related topics:

Macro parameters

Parameters are options that you can set to control the content or format of the macro output.

Parameter

Default

Description

Output Type

list

  • list — produces a typical list-type table of contents.
  • flat — produces a horizontal menu-type series of links.

Display Section Numbering

clear

Select the check box to apply outline numbering to your headings, for example: 1.1, 1.2, 1.3.

List Style

disc

Select the style of bullet point for each list item.  You can use any valid CSS style.  For example:

  • none — no list style is displayed
  • circle —  the list style is a circle
  • disc — the list style is a filled circle. This is the typical bullet list, and is used for this example list.
  • square — the list style is a square
  • decimal — the list is numbered (1, 2, 3, 4, 5)
  • lower-alpha — the list is lower-case, alphabetised (a, b, c, d, e)
  • lower-roman — the list style is lower roman numerals (i, ii, iii, iv, v, vi)
  • upper-roman — the list style is upper roman numerals (I, II, III, IV, V, VI)

Heading Indent

 

Sets the indent for a list according to CSS quantities. Entering 10px will successively indent heading groups by 10px. For example, level 1 headings will be indented 10px and level 2 headings will be indented an additional 10px.

Separator

brackets

This parameter applies to flat lists only.  You can enter any of the following values:

  • brackets — Each item is enclosed by square brackets: [ ].
  • braces — Each item is enclosed by braces: { }.
  • parens — Each item is enclosed by parentheses: ( ).
  • pipe — Each item is separated by a pipe:
  • anything — Each item is separated by the value you enter. You can enter any text as a separator, for example "***". If using a custom separator, be aware that text displays exactly as entered, with no additional white space to further separate the characters.

Minimum Heading Level

1

Select the highest heading level to start your TOC  list.  For example, entering 2 will include levels 2, and lower, headings, but will not include level 1 headings.

Maximum Heading Level

7

Select the lowest heading level to include.  For example, entering 2 will include levels 1 and 2, but will not include level 3 headings and below.

Include Headings

 

Filter headings to include according to specific criteria. You can use wildcard characters. See Sun's Regex documentation for examples of constructing regular expression strings.

 

Exclude Headings

 

Filter headings to enclude according to specific criteria. You can use wildcard characters. See Sun's Regex documentation for examples of constructing regular expression strings.

 

Printable

checked

By default, the TOC is set to print. If you clear the check box, the TOC will not be visible when you print the page.

CSS Class Name

 

If you have custom TOC styles in your CSS style sheet, use this parameter to output the TOC inside <div> tags with the specified class attribute.

Examples

The examples below are based on this table of contents:

Filtered Table of Contents

This example filters the headings to include those that contain 'Favourite', but excludes headings which end with 'Things'. The list is styled with Roman numerals.

ParameterValue
List Styleupper-roman
Include Headings
Favourite.*
Exclude Headings
.*Things

The resulting table of contents is:

Flat List

This example filters all headings to render a flat list of 'Unknowns' enclosed in square brackets (the default list style).

ParameterValue
Output Type
flat
Maximum Heading Level
2
Include Headings
Unknown.*

The resulting table of contents is:

Notes

  • When you use a Table of Contents macro in a template, you will see an error when you preview the template itself. But the Table of Contents macro works on the pages that people create from the template – the table of contents shows up after they have saved the page. (This is probably because the template is not defined as a page, and the Table of Contents macro works for pages only.)

  • Due to an outstanding issue in the Table of Contents macro (CONF-10619), the macro browser's Refresh function does not render any parameter modifications. Currently, the rendering of parameter value modifications to the Table of Contents macro occurs only after the page is saved.
  • Using HTML heading markup with the Table of Contents macro
    The Table of Contents macro cannot handle HTML heading markup on its own. Hence, if you use the HTML and HTML Include macros to render HTML heading markup in a Confluence page, the Table of Contents macro will not create a contents list out of these headings. (For more information about this issue, please refer to TOC-93.)
    However, if you insert an HTML anchor into each HTML heading on your page (based on the following syntax), the Table of Contents macro will incorporate these headings into your contents list.

    <h2><a name="pagename-headingname"></a>Heading Name</h2>

    The syntax for the anchor name is the page name and heading name separated by a hyphen. Remove all spaces and convert all text to lower case. Convert all punctuation marks to their URL-encoded equivalent.

Code examples

See: