is now part of CreativePro.com!

*** From the Archives ***

This article is from May 8, 2012, and is no longer current.

Formatting in InDesign Index Entries

21

[This article was written and contributed by Patricia Neyman, based on a book she created for the Nevada Native Plant Society. She wrote, “InDesign Secrets articles and discussions have been an invaluable resource for me!” and she tells us that she wants to “give back” to the community by providing this answer to a puzzle that had eluded her, hoping that her solution might help someone else in the future. –DB]

Different paragraph styles can be applied to different levels of an Index, but (as of this writing) there is no provision for formatting within a level. For example, my document lists many plant species:

1 Sample composite pageB

I need to index these species both by common name and latin name, and the latin names need to be listed in italic in the index.

One option is to manually apply formatting after you generate the index, but if you ever have to re-generate the index, the formatting will have to be done all over again. The option I describe below is a workaround, accomplished by marking the index entries manually (in this case, with periods before and after the entry) and then adding two GREP styles within the Style set up for the Index (one to make the text italic, and one to make those periods disappear).

To see a clear demonstration of just how to add a GREP style to a Style, I recommend this video by Anne-Marie Concepcion and David Blatner (although it does not deal with an index but rather a paragraph style applied to text). One very useful feature of this video is it that it demonstrates a method to preview the effects of your GREP expressions as you build them. You can do this with an index, too, by setting up a dummy text and index, and using this procedure (that’s what I’ve done in the images below). Then you can import the final style back into your working document.

In the video they employ and talk about GREP codes which may seem daunting, but they instantly seem a lot simpler if you read Michael Murphy’s PDF called GREP in InDesign 3 (which is still applicable to users of any version). He does a super job of explaining the different types of symbols and what they do, complete with formulas in multicolors with simple yet detailed explanation of just what each element in the formula does; a well as how to think about text so that you can come up with a formula that will accommodate variation.

However, ultimately, I could not find any reference on the internet describing exact procedure nor the exact code I needed get italics into the index.

So here is a step by step description of how to get italics into an index. Although it looks complex at first, it really isn’t that difficult to do. What is difficult and time-consuming is to find all this info in one place. I hope this can help others avoid the considerable time it cost me to get to this point.

Assume that a style called Index Level 1 has been set up for the Index. (If you’re working with a book that you are synchronizing, be sure these changes and additions for the Index go into the Master document, not just the one where the index is located. I had trouble with styles I made reverting to old versions when I synchronized.)

  1. Create two new character styles (use the regular InDesign Character Style panel):
    1. A character style named Index L1 Italics: will be the same as your Index Level 1 Style except set for italics. (For purposes of testing I often set character color to red, because it’s easy to spot on the page.)
    2. A character style named Index L1 Hide Periods, which has a character color of none, and a size of 0.1 points.
  2. Now you will nest these two character styles under the Index Level 1 Style as GREP styles. To start, right-click in the Paragraph Styles panel on Index Level 1 Style and choose Edit Index Level 1.
    1. Select GREP Style from the list at left, and click New GREP Style button near bottom of window.
    2. Select Index L1 Italics from the Apply Style pop-up menu.
    3. Click to the right of where it says ‘To Text’. Type or paste in this formula: (?<=\.)(.+)\s(.+)(?=\.)
    4. Click New GREP Style again, and in Apply Style, select Index L1 Hide Periods
    5. In the To Text area, enter this formula \.+

    Grepstyle2

  3. Since these nested styles are now part of the Index Level 1 Style the marked text will be automatically changed whenever the index is generated. Now we just need to set up the proper marking for the index entries:
    1. Before starting, note if you have already marked (as index topics) the items you want to be italicized in the index, you will have to remove them as topics (using the Index Panel menu) before you follow these directions. Otherwise you will end up with duplicate entries. Also, when you perform the steps below be sure you have Reference selected at the top of the Index Panel, not Topic.
    2. Select an item you want indexed (in this case, a plant species).
    3. Press Cmd/Ctrl-7, which bringing up the New Page Reference dialogue box. The text you have highlighted appears on left at top of the Topic Levels column.
    4. Copy that text in the Topic Levels column and paste it on the right in the Sort By column (otherwise the initial period you are about to put in will mess up the sorting order).
    5. Go back to the Topic Levels column and manually insert a period before and after the entry.
    6. Press Enter to record the new index entry. You should now see the item and periods in the Index panel.
  4. Generate index. The items you just marked with periods should now be italicized in the newly generated Index. The periods should not appear because of the “hidden” character style that is being applied to them.

Testindex2

Making All-Caps Revert to Normal Text in the Index

Though all-caps is looked down on by many people, it does have its uses. We used it for the common names of plants in our publication (see above) in order to avoid the controversy over whether common names should be capitalized, and if so should all the words be capitalized, etc.

In my index-formatting adventures I discovered first that the appearance of an Index is determined only partly by the Styles you have set up for the different levels of the Index. It can be affected by how you have typed the items in your text. The all-caps look in the above text was first achieved by typing all the names in capitals using the caps-lock.

When it came to doing the index we discovered that capitals which have been typed using the Caps lock will persist in the Index regardless of your Index Styles. If you have typed any words in all Caps this way you will have to retype them, and then change the character or paragraph style applied to them to make All Caps part of it. You will then see all-caps in the text but not in the index. The capitals you leave (made with the Caps key) will continue to show up in the Index. (see also this article on the subject).

Here is my final index:

3 Index sample pageB

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • Rudi says:

    The idea adding a special character to the index entry and then using GREP styles in the actual index is brillant. Just as an additional idea, you could pre-format index entries within the Index Entry dialog window like this, which might even be a little easier, and which won’t affect the entries’ sorting:

    Index entry for italic (e.g.): voluntas-
    (note the trailing dash)
    Index entry for bold (e.g.): very important#
    (note the trailing hash)

    and so on.

    After having generated the index, you can either delete the trailing dashes and hashes – which would definitely be my first choice – by a simple GREP Find/Change, or you can of course make them “invisible” by 1% horizontal scaling and assigning character color “None”.

  • Mike Perry says:

    I’ve got at similar technique, but I use a pair of totally unambiguous markers: «This is italic» I use those characters (quote marks in some European languages) for no other purpose, and each clearly signals either the start or the end of italicization.

    I insert them as I create each index entry. Then I run a GREP script on the generated index that applies an Italic style to anything between the marks and strips way the marks. Since the marks are still in the index tags, they’re there every time I recompile the index.

    This technique also works for importing text created in a simple text editor that doesn’t understand italics. It’s more obvious and less prone to trouble that the Markdown approach of doing italics like this: *italic text.*

    Actually, I use this as a set of marks that take care of the most common character formatting:

    «««This is Bold and Italic»»»

    ««This is Bold»»

    «This is italic»

    All I need to remember it to run the GREP scripts for each character style in the order above, converting all the bold-italic passages first.

    By the way, if some talented GREP coder has the time, it’d be great to have scripts that convert some of the common Markdown tags to ID styles, particularly:

    # Heading 1
    ## Heading 2

    and so forth.

  • Jongware says:

    Mike, A Funny Thing Happened on the way to the Forum (a Mel Brooks reference!).
    I answered your inquiry about Markdown in the What We Love.. post without realizing you asked about it here earlier!

  • JimB says:

    I notice in the example above each index entry refers to only one page. When I try the technique, italics are produced just fine, but I can no longer format the the page numbers when there are > 1 per entry. They just run together so instead of getting say 23, 45, 102 I get 2345102 – which isn’t much use.

  • JimB says:

    These further comments apply to CS4.
    All the formats applied in the Patricia Neyman’s entry above are applied by InDesign to whatever material is specified as “Between page numbers”. So if you specify say “, ” to appear between page numbers these are rendered as Italic, no colour, 0.1 pt and therefore disappear. Doesn’t matter what you choose to appear between page numbers, they are all reformatted and disappear. These effects occur not only to lines on which the entries are converted to Italics, but to all lines.
    The solution seems to be to choose a symbol other than “.” to mark of the plant names you want to make into Italics eg “#”. The instead of using (?<=\.)(.+)\s(.+)(?=\.) as above, use (?<=\#)(.+)\s(.+)(?=\#). Do not try to convert the "#" to no colour, 0.1 pt within the index generating step. That means the page numbers run together.
    When you generate the index, the names will be in Italics but preceded and followed with a #.
    You can't just remove the # signs using Find/replace. That also removes the formatting! Instead make them small and invisible (no colour, 0.1 pt) with find/change. That seems to work.

  • Anna Tanneberger says:

    whenever I generate the index in this particular document, the commas that separate each page number, have a five-line-high band attached. The only way to get rid of it is to select all text, click on UNDERLINE (to make everything underline) and the unclick underline.
    Is this some sort of bug?

  • @Anna: Hard to know what’s going on, but I would check to make sure no character style is being applied accidentally (check the generate index dialog box, for example).

  • David Harrison says:

    Just spent a head-scratching hour wondering why this tip only seemed to work for topics with more than one word ?single-word topics remained stubbornly unchanged (I’m applying a bold, rather than italic style to particular topics, but the principle’s the same).

    Eventually I tried simplifying the formula with (?<=\.)(.+)(?=\.)

    It worked :-D To be honest this scripting lark's a bit beyond me but I promise to work through Michael Murphy's beautifully produced GREP pdf. Thanks for all the help! Will my simplified script cause problems down the line? It seems to work equally for multi-word topics too…

  • peterdanckwerts says:

    I can’t help feeling that there should be a better way to mark index words as italic. I’ve been delimiting mine with double quotes (which is fine for me as I don’t use them for anything else in the index) and it works well, BUT I also want to take the first word of the the first level 1 heading on the page and the first word of the last level 1 heading of the page and put them in the running head. Applying a nested style (which does nothing) to the first word of each level 1 heading and then using text variables to place these in the running head is simple BUT if the word is marked with double quotes these will appear in the header. Because grep styles can’t be applied to text variables, they’re impossible to hide.

    Instead of using a simple nested style to mark the first word of the paragraph, is there some way to apply a grep style to the first word EXCLUDING double quotes?

  • Jongware says:

    Peter: that’s possible, you can try this one:
    (?<=^”)\S+(?=”)
    — an application of Find Between.
    (… long answer explaining why you can’t have “word between quotes OR the first word” in a single GREP …)

    This GREP query will match either a first word in quotes, excluding the quotes themself, or just the first word!
    ^[^”]\S+|(?<=^”).+?(?=”)

  • Brad Fenley says:

    I know this if off topic but I’m looking into starting my own blog and was wondering what all is required to get set up? I’m assuming having a blog
    like yours would cost a pretty penny? I’m not very internet savvy so I’m not 100% positive. Any suggestions or advice would be greatly appreciated. Many thanks

  • Robin Loxley says:

    Hello,
    I am very surprised by this topic. After first index generation in ID and manual character styles enhancements of this index text, a [JS] can convert these character styles in the index entries by tags set in them, then once the index regenerated, these tags are replaced using Grep by corresponding character styles, and these tags are finally deleted. The only real work to be done is, once and for all, to properly apply the character styles in a basic generated index, the easier and more excited to do.
    Robin

  • George says:

    Very helpful thanks a bunch, doing an index of species and genus as well. To set up the document I used find/change:
    Find = (\w+) with +italic in find format
    Change = {$0}
    this puts {brackets} around italic words individually
    Then I ran find change again:
    Find = {
    Change = format font size .1, font color none, char width =1%, char height =1%
    This makes the “{” bracket invisible, I repeat the above for the other bracket “}”

    after that I just used the formula (?<=\{)(.+)(?=\}) like said above to make anything between the brackets italic in the index, and hid them like above.

  • Linda Ronan says:

    I can’t believe this a two year old thread and nothing has been done about this italics thing…. Do you have to perform #3 to each and every entry that you want italicized? I have a concordance with over 3000 entries, do I need to add periods every time? Does anyone know if any new work-around has been made? This is insane!

    • Mike Rankin says:

      Linda- Unfortunately, InDesign doesn’t have any new features that would help with this problem. Nor do any of the third party indexing utilities AFAIK, so you still need to do some kind of workaround to add tags to the entries that indicate what kind of formatting you want, and then do a find/change after you generate the index. In my course on long documents for lynda.com I demo’d a method similar to what Mike Perry describes above.

      • Linda Ronan says:

        I would love to watch how-tos on lynda.com but my budget doesn’t allow for it.

        The thing I don’t understand is how I’m supposed to tag each instance of a film title? Where/when does that happen? Do I need to add code to each index entry as they are tagged?

  • Linda says:

    Is it possible to use a GREP solution to add a period to the beginning and ending of every string of character styled italics?

  • Robert Whyte says:

    Here is perhaps a simpler method,

    When adding a scientific name as an index item put a # (hash character) directly after the genus and the species names. Genus is Level 1, species is Level 2. for example,

    Level 1 Opisthoncus#
    Level 2 polyphemus#

    The object of the following procedure is to detect a hash in the generated index and make it and the preceding word italic, then hide the hash character.

    * Make sure paragraph style Index level 2 is based on Index level 1 so all you have to update is Index level 1

    * Create an italic style for Scientific names called “Scientific Names Italic”
    style italic

    * Create Character Style called “HIDE #”
    size .1 point
    character colour none.

    * Open paragraph style Index level 1
    from the options in the style panel select “Add GREP style”
    Choose Scientific Names Italic from the drop down character style menu
    Add Grep formula ^.+#
    ^ = beginning of a paragraph,
    .+ = any number of wildcard characters (wildcard . = any character, + = all) [UNTIL IT GETS TO]
    # = # (it is just a character and matches itself)
    Add a second GREP style.
    Choose HIDE # from the drop down character style menu
    This will find any # and make it .1 point and no colour

    Only the # characters in the index will be affected because only the text in the index has the styles Index level 1 & Index level 2

    The only place in the document the # is inserted is the “New page Reference” when making an index item.

  • Rich Harvey says:

    You can’t keep a good thread down!

    I’m deciding that it’s easier to format an eBook first, using a copy of the original word file, then create a print edition with Indesign. (I used to do it the other way around.) My challenge … can I format an eBook with an INDEX … and and then place it into InDesign CS3? Something tells me this is a pipe dream, but I figured it’s worth asking.

  • Anthony says:

    How do you create a Table of Authorities in InDesign?

  • Mahesh Kaku says:

    How I enter data in index entry which has “comma” in it.
    For examples:
    Delta Mechcons (India) Ltd. v. Marubeni Corporation, (2008) 15 SCC 772.
    A v. B, AIR 2020 SC 231.

  • >
    Notice: We use cookies on our websites to give you a great online experience. If you keep browsing, we'll assume you're ok with this. For more information, see our privacy policy. By closing this banner, you agree to the use of cookies.I AGREENo