Ever since Adobe included the use of Variables in InDesign, I have been thinking about ways to use it to create auto-generated index headings.
Well, after trying lots of different things, I finally came up with a simple solution that anyone can use.
Have you ever wanted to include "Real" index headers for your index file? Only to find that if anything changes or the index re-flows, you need to update them all manually?
Now this can be set up to happen "on-the-fly" by simply using Text Variables and invisible Nested Styles.
The biggest obstacle that I needed to overcome was how to have the header variable consistently pull the index listing while ignoring the page numbers.
Here is how I now set up my InDesign index files in order to make this happen:
Step 1: Set up your "Generate Index" settings
In your "Generate Index" dialog, set everything as you normally would.
The trick here lies inside the "Following Topic" field in the "Entry Separators" section at the bottom of the dialog.
In my example below, I have a comma followed by a Figure Space (,^/).
The reason I chose to use a Figure Space instead of just a regular space is because it gives me a "special character" that I can use later when setting up my custom Nested Style.
Feel free to use any "special character" that suits your needs. The key here is to choose something that is not otherwise being used in your document.
Step 2: Create an empty Character Style
You will need to create a Character Style with no attributes. This style will be applied as a Nested Style to your 1st level index Paragraph Style. In my example below, I named the style "Index_Header", but feel free to name this however you wish.
Notice that there are no settings being applied. This is because I do not want the Character Style to affect the text, visually, at all.
In a few steps, you will create a custom variable that will call upon this "hidden" Character Style.
Step 3: Update the Paragraph setting for your First Level index entries
This next step will add a Nested Style to your 1st level index entry Paragraph Style. In my example below, this style is named "Index Level 1", which is the default in InDesign. However, if you are using a different name for your 1st level index entry Paragraph Style, be sure to use that one.
Open up the Paragraph Style Options dialog for your style and then choose the "Drop Caps and Nested Styles" option from the list on the left.
As you can see in my example (above), I am Nesting the Character Style "Index_Header" up to the first instance of a "Figure Space" character.
Step 4: Create the custom header Variables
Now that our Character and Paragraph styles are set, it is time to create our header Variables.
We will need 2 separate Variables:
- The first will grab the first entry on the page
- The second will grab the last entry on the page
Go to Type-->Text Variables-->Define to open up the Text Variables dialog.
Select "New" to create the first Variable.
See my example (below) for the correct Variable settings.
- In my example (above), I named the Variable "Header_First", but feel free to name yours whatever you wish.
- From the Type drop down menu, be sure to choose "Running Header (Character Style)".
- Then, from the Style drop down menu, choose "Index_Header" (or whatever you named your empty Character Style back in step 2).
- Choose "First on Page" from the Use drop down menu.
- Finally, in the Options section, select the "Delete End Punctuation" check box. (This is only necessary because I am using a comma to separate my index entries from the corresponding page numbers. If you are not using a punctuation character here, it is not necessary to check this box). Checking this box makes sure to not include the end comma in the Variable.
- All other options in this dialog are up to you depending on how you want your Variable to look.
For the second Variable, give it a different name (I used "Header_Last).
All of the settings should match your first Variable, exactly (except for the Use drop down option). For this Variable, choose "Last on Page".
Step 5: Apply the Header Variables
Now that your Header Variables have been defined, all that is left to do is place them into your Master pages.
In my experience, there are 2 main ways that Index Headers are set up per spread:
- Left Page Header: "First entry on page";
Right Page Header: "Last entry on page"
- Left and Right Page Header: "First entry on page" - "Last entry on page"
Whichever way you prefer, your new Variables are ready to handle either.
To place your variables on your master page(s), simply draw a text frame in your preferred location on the Master page, and then go to Type-->Text Variables-->Insert Variable.
Here is an example of the first Variable in use on the left page of an Index spread:
Notice that the Variable is pulling the correct first Level One Index entry from the page. But also notice that the comma and page numbers have conveniently been left out in order to keep the Variable clean.
Now, your Index file can reflow at will, and your headers will always be correct.
I have included my example Index file for you to download and use or inspect if you wish to dig deeper (saved as .idml to be compatible with InDesign CS4, CS5, and newer):
Feel free to contact me with any questions or comments.