Create index (topics and page references) from a word list

Using the entries in a word list, the index adds topics and page references to all open InDesign documents.

Use

Open all documents that should be indexed, then open the word list. With the word list as the active document, run the script. It uses each item in the list to create a topic in each document and adds page references. The documents are saved and closed. Back up your documents before using the script.

The word list

The script considers an entry only up to the first comma or parenthesis. In this way the script can be used to create author indexes from a list that includes first names or initials. For instance, if the word list contains this line:

Leech, G.

Only Leech is used for the search: after all, a text is more likely to contain just an author's surname than their surname followed by their initials or first name. Similarly, when the word list has a line like this:

abomination (see also terribleness)

you needn't worry about the cross-reference: the script considers just abomination.

Some settings

The script can be set to search case-sensitively, to delete any existing index, and to consider only paragraphs formatted with certain paragraph styles.

Case-sensitivity

The script searches case-sensitively by default. To make it search case-insensitively, change this line:

case_sensitive = true;

to read case_sensitive = false;.

Whole words only

The script searches only for whole words.

Replace existing indexes

By default, the script deletes any existing topics and page references. To keep an existing index, change this line:

replace_index = true;

to read replace_index = false;.

Certain paragraph styles only

There are probably a number of parts in each document that you want to exclude from the index. Typically, indexes don't refer to such items as bibliographies, quotations, and chapter titles. Some publishers want to exclude tables as well. To allow for this, the script can be set to mark topics only in paragraphs formatted with certain paragraph styles.

The script defaults to ignore this feature, that is, everything it finds is marked for the index. To make the script look in certain paragraphs, list those paragraph styles, using only the first three letters of their names only, separated by a |, the vertical bar. Look in the script for this line:

paragraph_styles = "";

This is the default -- the script finds all paragraphs. To include only paragraphs that are formatted with the paragraph styles default and sectionA, sectionB, sectionC, etc., change the above line to this:

paragraph_styles = '|def|sec';

Again, use just the first three letters of the paragraph style (case sensitive), prefixed by |.


Show script (right click, Save Link/Target As to download)

Back to the main page on indexing

Back to the main script page

Installing and running scripts

Editing a script

Questions, comments? Get in touch