Skip to main content

Table of Contents

The toc content element generates a table of contents from the headings in your document. It produces clickable entries with dotted leaders and page numbers, plus a navigable PDF outline (sidebar bookmarks) for PDF viewers.

Place it anywhere in your content array — before all content, after a cover page, or between sections.

Basic usage​

Add { "toc": {} } to your content array. All defaults apply: H1–H3 headings are collected (default depth: 3), no title is drawn, and PDF outline bookmarks are enabled.

{
"document": {
"content": [
{ "toc": {} },
{ "h1": "Introduction" },
{ "p": "..." },
{ "h2": "Background" },
{ "p": "..." },
{ "h1": "Conclusion" },
{ "p": "..." }
]
}
}

The TOC is laid in the flow where it stands, and no page break is forced after it: the document content follows directly. Each entry links to the corresponding heading — clicking it navigates to that location in the PDF.

Properties​

PropertyTypeDefaultDescription
depthnumber3Maximum heading level to include — H1 through Hdepth are captured (e.g. 2 includes H1+H2 only). 1–6; 0 lists every level.
titlestring—Title text displayed above the entries. Absent, no title is drawn
titleStylestring"tocTitle"Named style applied to the title; only with title. tocTitle is built in: define a style of that name to restyle every TOC title
stylestring—Named style applied to each entry paragraph
outlinesbooleantrueGenerate PDF outline (sidebar bookmarks)
leaderstring"dotted"The pattern repeated between an entry and its page number: dotted (full stops), solid (a low line), space (blank), or any other text repeated as written ("-")

After a cover page​

Place the TOC after introductory content using a page break, and end it with another so the body starts on a fresh page:

{
"document": {
"content": [
{ "p": "Annual Report 2026", "style": "coverTitle" },
{ "p": "Confidential", "style": "coverMeta" },
{ "break": "page" },

{ "toc": { "title": "Contents", "style": "tocEntry" } },
{ "break": "page" },

{ "h1": "Executive Summary" },
{ "p": "..." },
{ "h1": "Financial Overview" },
{ "p": "..." }
]
}
}

This produces: page 1 = cover, page 2 = table of contents, page 3+ = document body.

Filtering heading levels​

Control how deep the TOC goes using the depth property — H1 through Hdepth are captured as a contiguous range:

{ "toc": { "depth": 2 } }

This includes only H1 and H2 headings, skipping H3–H6. Useful for long documents where deeper headings would make the TOC too verbose. The Word equivalent is the TOC \o "1-N" field switch — a single max rather than an explicit list.

Styling​

Apply named styles to the TOC title and entries:

{
"document": {
"styles": {
"tocTitle": { "fontSize": 20, "fontWeight": "bold", "color": "#1B3A5C" },
"tocEntry": { "fontSize": 10, "color": "#333333" }
},
"content": [
{ "toc": { "title": "Contents", "titleStyle": "tocTitle", "style": "tocEntry" } },
{ "h1": "Chapter One" },
{ "p": "..." }
]
}
}

Entries are automatically indented by heading level — H1 is flush left, H2 is indented, H3 is indented further.

An entry keeps the inline formatting its heading was written with — colour, weight, slant, decoration ([u], [s]), face ([font, …]) and language — over the entry style. Its size, baseline shift, highlight and spacing are the entry style's, since the entry is set level with its page number, and a link inside the heading is not carried: the entry's one action is the jump to its heading.

A footnote marked in a heading is not part of its entry: the entry and the bookmark read the heading's words alone.

An entry too long for its line wraps, as a line of text does, at its word breaks: every word of the heading is shown, and the leader and page number stand on the entry's last line. An entry's lines stay together on one page unless the entry is taller than the page, in which case it continues on the next. Entries are not hyphenated.

PDF outline bookmarks​

By default, the TOC also generates a PDF outline — the clickable bookmark tree visible in the sidebar of PDF viewers. The outline is nested: H2 entries appear as children of the preceding H1, H3 under H2, and so on.

To disable the outline and only render the visual TOC page:

{ "toc": { "outlines": false } }

To write the bookmark tree yourself instead, author it under the document's outlines (see Bookmarks): an authored tree replaces the heading tree, the two are never mixed, and the render says so with a NOTICE. The visual TOC is drawn from the headings either way.

Every TOC entry is a clickable link. Clicking a title or page number navigates directly to the heading in the document. This works in all major PDF viewers.

Full example​

{
"document": {
"metadata": { "title": "Compliance Report" },
"pageSetup": { "margin": [60, 50, 60, 50] },
"header": {
"content": [
{ "p": "Compliance Report 2026", "style": "hdr" },
{ "p": "Page $global.PAGE of $global.NUMPAGES", "style": "hdr" }
],
"skipPages": [1]
},
"styles": {
"hdr": { "fontSize": 8, "color": "#999999" },
"tocTitle": { "fontSize": 18, "fontWeight": "bold" },
"tocEntry": { "fontSize": 10 },
"body": { "fontSize": 10 }
},
"content": [
{ "p": "Compliance Report", "style": "tocTitle" },
{ "break": "page" },

{ "toc": { "depth": 3, "title": "Contents", "titleStyle": "tocTitle", "style": "tocEntry" } },

{ "h1": "Executive Summary" },
{ "p": "Overall compliance posture has improved year-over-year.", "style": "body" },

{ "h1": "Regulatory Framework" },
{ "h2": "Federal Requirements" },
{ "p": "All operations comply with federal guidelines.", "style": "body" },
{ "h2": "Provincial Standards" },
{ "p": "Provincial requirements met across jurisdictions.", "style": "body" },
{ "h3": "Quebec Privacy Framework" },
{ "p": "Law 25 compliance achieved.", "style": "body" },

{ "h1": "Recommendations" },
{ "p": "Accelerate remediation of outstanding findings.", "style": "body" }
]
}
}

Excluding a heading from the TOC​

Set outline: false on any h1–h6 content block to keep it visually intact while excluding it from both the TOC and the PDF outline tree. Useful for cover-page titles, decorative section banners, and any heading that exists only for visual hierarchy.

{ "h1": "Annual Report 2026", "style": "coverTitle", "outline": false },
{ "h2": "Confidential — Q4 2026", "style": "coverSub", "outline": false },
{ "break": "page" },

{ "toc": {} },

{ "h1": "Executive Summary" },
{ "p": "..." }

The cover-page h1 and h2 render at full size with their styling but stay out of the TOC entries and the sidebar bookmark tree. Default is true (included). The property is ignored on non-heading content shapes.

Both the DOCX and the PDF honour the flag.

In Word​

The DOCX writes the TOC as a Word table-of-contents field, each entry linked to its heading; its page numbers are page-reference fields that Word computes, since the page a heading lands on in Word is Word's to decide. Two differences are recorded, and the render reports each:

  • Word repeats only a dot, a hyphen, a low line or a middle dot: dotted, solid, space, "-" and "·" are written as such, and any other leader text is written as dots.
  • A TOC placed in a header or footer is not written.

Notes​

  • The TOC lists every heading in the body flow, including headings inside columns, tables and lists; headings in headers, footers and watermarks are not listed.
  • No page break is forced after the TOC: add { "break": "page" } after it to start the content on a fresh page.
  • If no headings match depth, only the title (if any) is drawn.
  • Page numbers in the TOC account for all preceding pages (cover, TOC itself, etc.).
  • The TOC works alongside headers, footers, and page numbers — they render correctly on all pages including the TOC page.