2019.2

Table Of Contents
Note
Post Pagination Scripts run only when a Print section is previewed or outputted.
To verify the results of Post Pagination Scripts on a certain Master Page, preview the
Print section to which that Master Page is applied.
Creating a Table Of Contents
This topic explains how to create a multi-page, cross-section Table Of Contents (TOC) using a
Post Pagination Script.
For information about Post Pagination Scripts in general, see "Post Pagination Scripts" on
page900.
The basics of script-writing in the Designer are explained in the following topic: "Writing your
own scripts" on page853.
Step 1: Opening a Print template
Create or open a Print template.
Make sure to use HTML headings level 1 and level 2 (<h1> and <h2>) in your Print sections, if
you want to use the script sample that is given in Step 3.This script collects the text and page
numbers of these headings and puts them in the TOC.
To quickly change a paragraph into a Heading, place the cursor inside of it, or select the
paragraph (see: "Selecting an element" on page632). Then select the appropriate element,
either on the Format menu, or from the 'Element type' drop-down on the toolbar.
Of course, you could just as well create a table of contents using other heading levels, or even
other elements. In that case you'll have to adjust the script accordingly.
Step 2: Creating a placeholder for the TOC
Create one extra Print section to put the Table Of Contents in.
Inside the extra section, insert an Article element (see "Inserting an element" on page631).
Give the element an ID, for example: toc-content. This element is the placeholder for the TOC.
Step 3: Inserting the Post Pagination script
Insert a Post Pagination script (see "Adding a Post Pagination Script" on the previous page).
Double-click on the new script to open it.
Set its selector to the ID that you specified in Step 2, preceded by a #, for example: #toc-
content.
Paste the following code in the script editor:
Page 902