Create index topics from character styles

The script creates topics for and page references to all text formatted with certain character styles. (For a comparable script see Martin Fischer's script.)

Use

Open the documents that you want to process and run the script. It shows this dialog:

[image: index from character styles 1]

Style groups are shown in parentheses after a style name (nested style groups are separated by a colon).

Select any character styles from the list in the usual way. Check Replace existing index to delete all existing topics and page references. Tick Use style group and name for nesting topics to use the style's parent style group (if any) and the style's name as parent topics.

Indexing text formatted with the character styles selected as above and using group and style names for subtopics would result in an index like this:

[image: index panel]

Changing the order of first and last names

To change the order of first and last names, so that the text occurrence James McCawley appears in the index as McCawley, James, add @@ at the end of the character style, as in Authors@@.

By default, the script assumes that the first word of the found content is the first name, the second, the last name. If a name consists of two or more words and the first two words form the first name, insert a non-joiner after the last part of the first name. For instance, to have the text occurrence J. S. Bach appear as Bach, J. S., add a non-joiner immediately after S.

:

[image: non-joiner]

To insert a non-joiner, go to Type > Insert special character > Other > Non-joiner). When you enable the display of hidden characters (Type > Show hidden characters), the non-joiner is shown as a hacek accent (a.k.a. caron).

Troubleshooting

Errors are usually caused when a character style was applied to a special character such as an en-rule or a paragraph return. The script displays an error message and shows which style was involved. Look for instances of the style in the document and fix the problem, then run the script again.


Useful script? Saved you lots of time?

Consider making a donation. To make a donation, please press the button below. This is Paypal's payment system; you don't need a Paypal account to use it: you can use several types/brands of credit and debit card.

Peter Kahrel's paypal account

Version history

28 Aug. 2017: Added functionality to change the order of first and last names, e.g. 'John Smith' > 'Smith, John'. See the text for details.

25 Oct. 2016: Fixed a display problem in CS6/Windows 10.

11 Sept. 2016: Improved the support for style groups, and added the addition of subtopics.

3 Sept. 2015: The script now deals with the InDesign bug that causes page reference markers to be placed incorrectly in documents that contain tables.

21 March 2014: Some minor changes to make the script more efficient.

20 Dec. 2012: The script sometimes missed some styles. Fixed.


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

Installing and running scripts

Back to the main page on indexing

Editing a script

Questions, comments? Get in touch