Format first lines in index sections

Take this list:

aardvark
ape
bear
beaver
cat
cheetah
cricket

The script applies a named paragraph style to all paragraphs whose first letter changes from that in the previous one. In this example, that would be bear and cat. The result would be this:

aardvark
ape

bear
beaver

cat
cheetah
cricket

You get this result by creating the paragraph style index_skip based on the level-1 index style and adding some space before.

You can add section letters so that the list would look like this:

aardvark
ape

B
bear
beaver

C
cat
cheetah
cricket

When you opt to insert headings (A, B, etc.), the paragraph style is applied to them.

Use

The script expects a paragraph style called index_skip. To change this, look for this line in the script:

var skip_style = 'index_skip';

and change index_skip to the name of the paragraph style you want to use. To have the script insert section headings, set insert_letter to true.

To run the script, select a story in the usual way (select a text frame or an insertion point in a story) and run the script from InDesign's Scripts panel.

The script has no interface.


Show script (right-click, Save Target/Link 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