Skip to main content
Inspiring
August 2, 2025
Answered

Index and sub-level 1 and multiple entries

  • August 2, 2025
  • 2 replies
  • 364 views

I'm creating a book index, entering all the topics first before I begin to mark references. Some main topics have multiple sub-topic level-1 entries. I can create these "by hand" by typing the main topic, typing one sub-topic, and entering, repeating the process for as many times as I have sub-topics. Is there a way to enter multiple sub-topics under the main topic at one time, separated by some sort of marker that InDesign recognizes as a "new line" character in the sub-topic list?

 

For example, one main topic is Abstention. It has five level-1 subtopics: Burford, Colorado River, Pullman, Thibodaux, and Younger. Below is a sample of what I'm trying to do:

 

Main topic: Abstention

Sub-topic: Burford [new line], Colorado River [new line], Pullman [new line],  Thibodaux [new line], Younger [new line]

 

So that when I generate the index, it would line up like this:

***********************************************************************

Abstention

     Burford

     Colorado River

     Pullman

     Thibodaux

     Younger

***********************************************************************

 

Abstention is easy; it has only five sub-topics, but I have a bunch of main topics that have 30 or more level-1 subtopics. I know that in the text I can enter a soft new line, but I don't know whether that will work in the index-entry pop-up box, and I've already put in enough work that I don't want to risk messing up what I've done.

 

Many thanks.

Correct answer Peter Kahrel

First of all, use .jsx as the file type, not .idjs (idjs is a newer format; jsx is older but will be around for many years and is still more mature and stable).

 

Then copy/move the script to inDesign's Scripts folder, which is easy:

 

1. Open InDesign's Scripts panel (Windows > Utilities > Scripts)

2. In the panel right-click the User folder. Select Reveal in Explorer on the Mac that'll be Reveal in Finder)

3. Your OS's file manager is opened. Drop the script file on the Scripts Panel folder (or open that folder and drag the script file to it)

 

The script should appear in the panel. Double-click it to run it.

 

If you have a file with topics and their subtopics, the script could be modified to read all that and add the lot to the Index panel. That list would be a list of strings in the format set up for the script. If you're interested let me know.

 

As I mentioned, InDesign's index feature has a lot of shortcomings, but it's almost always possible to do a workaround. And many scripts exist to fix problems with InDesign's index, for example

https://www.kerntiff.co.uk/products-4-indesign/indexutilities

https://creativepro.com/files/kahrel/indesign/lists_indexes.html

https://creativepro.com/files/kahrel/indesign/index-fixes.html

 

2 replies

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
August 3, 2025

First of all, use .jsx as the file type, not .idjs (idjs is a newer format; jsx is older but will be around for many years and is still more mature and stable).

 

Then copy/move the script to inDesign's Scripts folder, which is easy:

 

1. Open InDesign's Scripts panel (Windows > Utilities > Scripts)

2. In the panel right-click the User folder. Select Reveal in Explorer on the Mac that'll be Reveal in Finder)

3. Your OS's file manager is opened. Drop the script file on the Scripts Panel folder (or open that folder and drag the script file to it)

 

The script should appear in the panel. Double-click it to run it.

 

If you have a file with topics and their subtopics, the script could be modified to read all that and add the lot to the Index panel. That list would be a list of strings in the format set up for the script. If you're interested let me know.

 

As I mentioned, InDesign's index feature has a lot of shortcomings, but it's almost always possible to do a workaround. And many scripts exist to fix problems with InDesign's index, for example

https://www.kerntiff.co.uk/products-4-indesign/indexutilities

https://creativepro.com/files/kahrel/indesign/lists_indexes.html

https://creativepro.com/files/kahrel/indesign/index-fixes.html

 

Inspiring
August 3, 2025

Peter,

Ignore my last post, please. For the few level-2 sub-topics I have, it occurred to me that I can just use InDesign's regular indexing process as long as I'm careful about typing in the main topic and the level-1 sub-topic correctly. 

 

You have saved me countless hours, and I am grateful. 

Peter Kahrel
Community Expert
Community Expert
August 2, 2025

Is there a way to enter multiple sub-topics under the main topic at one time, separated by some sort of marker that InDesign recognizes as a "new line" character in the sub-topic list?

 

No, that's not possible. And as you proceed with your index, you'll discover that InDesign's index feature has various limitations. But a script can do what you're after.

 

(function () {

  var items,
      index,
      topic,
      subtopics;

  items = prompt ('Topic#subtopic@subtopic@...', '', 'Multiple level-1 subtopics');
  if (!items) {
    exit();
  }

  parts = items.split('#');
  if (parts.length < 2) {
    alert ('Illegal format');
  }

  subtopics = parts[1].split('@');

  if (app.activeDocument.indexes.length === 0) {
    index = app.activeDocument.indexes.add();
  } else {
    index = app.activeDocument.indexes[0];
  }

  topic = index.topics.add(parts[0]);
  for (var i = 0; i < subtopics.length; i++) {
    topic.topics.add (subtopics[i]);
  }

}());

 

The script shows a rudimentary interface:

 

 

Enter the topic and its subtopics in the format as shown, then click OK to add them.

 

You can add more subtopics to the same topic later, just use the same format.

 

Inspiring
August 2, 2025

Peter,

Thank you for the long, swift reply. You credit me with more knowledge than I have. I know what scripts are, of course, and can write them in Linux (simple ones, at least), but I do not know how to take your code and use it in InDesign because I am still new to InDesign.

 

I did some online research and came upon a YouTube spot by Becky's Graphic Design. I'm sure you have seen it, and she sings your praises.  She is talking about scripts that one downloads from the web, whereas you have given me the code directly. I am guessing that I need to place the code in a file and save it as an idjs file. (I may be way wrong.) After that, I need to import the new script file into InDesign, which Becky does show how to do. (Which is not the same thing as saying that I can do it without screwing it up.)

 

Then I would run the script in my index file. Do I run the script once for each main topic?

 

I may not even be close, but I hope I can use your script; it would save me quite a lot of time. I appreciate the time you have put into this and look forward to hearing from you.

Inspiring
August 2, 2025

Update: I made a text file with the code and saved it as an .idjs file.