Index Fixes: No Styling in Topic Names

Topic names cannot natively be styled in the Index panel. However, a simple solution is to add text tags such as <i>. . .</i> and use two GREP queries in the generated index to apply character styles and remove the tags, or set up a GREP style in the topic paragraph styles to hide those tags and apply some styling.

If the style code is at the start of the topic name you should set the sort order to the topic name without the codes to ensure that the topic is sorted correctly.

In this example, text tags for italic are added to a topic name, and because the opening tag is at the start of the name we set the topic’s sort order as well:

You then use two GREP queries to apply a character style that applies italic and to remove the text tags:

Apply a character style

Find what: <i>.+?</i>

Change to: $0

Change Format: The Italic character style

Remove the text tags

Find what: </?\l>

Change to: <Leave empty>

Find and Change Format: <Leave empty>

Alternatively, you can use two GREP styles to achieve the same appearance. First, create a character style that hides the text that it is applied to: point size 0.1, 1% horizontal scale, paper colour. Call the style e.g. Hide. Then add the following two GREP styles to the paragraph styles used for the index entries:

Apply Style: Italic

To Text: <i>.+?</i>

Apply Style: Hide

To Text: </?\l>

GREP styles are convenient, but you can’t use ‘hiding styles’ in Epubs, and they won’t do much good for accessibility.


Return to Index Fixes page.


Peter Kahrel Script Repository
Hosted as a community service, and with deep appreciation, by CreativePro.com


Scripts by Topic | Script Index
Basic Script Installation and Use
How to Modify or Configure These Scripts
Resources for Scripting and Publishing Automation
About This Repository


Repository Home Page


Contact Peter Kahrel


Note to users: You run scripts at your own risk: CreativePro and the author accept no liability for anything that may be caused by any of these scripts. Always take the necessary precautions. We encourage you to save backups and test scripts on copies of your documents.

Bookmark
Please login to bookmark Close

This article was last modified on September 5, 2026

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading comments...