Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

Indexing a Range Rather Than Individual Pages

Miguel wrote:

I just finished doing an Index and one of the topics looks like this: University 3,12,13,14,56
Is there a way to make indesign represented continuous pages like a range? like this: University 3,12-14,56

The answer is “yes,” but it depends on how your document is created, and how you set up your indexing. If you add three different index markers — one on page 12, 13, and 14, in your example — then you’re going to get three separate entries in your index. InDesign assumes that if you’ve set up your index markers like that, then you obviously want separate page numbers like that.

(By the way, if you don’t know how to index documents, check out my title at Lynda.com, or Michael Murphy’s excellent videocasts on the subject.)

If you want a range (such as 12-14) just add one index entry at the beginning and then set the Type pop-up menu to a range. For example, a range of pages:

indexrange1

There are a couple of annoying things about page ranges in InDesign. For example, let’s say you put an index entry on page 1, choose Next # of Pages, and specify 2 pages. The page range will be “1-2”. That makes no sense to me, because it should be 1-3 (page 1 plus the next two pages).

Even worse, however, it’s not “the next two pages of the story,” it’s the next two pages of the document. That means, if your story skips a page, InDesign isn’t smart enough to leave that page out. Let’s say you use the range “To End of Story,” but the story skips page 3 because there’s an ad there. InDesign still includes page 3 in the range.

Indexing is far from perfect in InDesign. In fact, I find it downright frustrating most of the time. But you can usually get what you need if you bang on it long enough.

David Blatner

David Blatner

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

Latest posts by David Blatner (see all)

  • - November 30, -0001
Related Articles
Comments

33 Comments on “Indexing a Range Rather Than Individual Pages

  1. one thing you can consider is buying a more robust plugin to do your indexing, like Sonar Bookends InDex (or the Pro version) from VirginiaSystems.com. They offer more powerful options on indexing. I don’t know how it addresses this specific instance because my copy is at home (and i’m not there), but, as you said, indexing is far from perfect in InDesign and this is exactly the kind of thing the plugin system is designed for.

  2. Excellent point, Greg. However, last I checked, the V.S. plug-in was really more of a concordance-builder. That is, you feed it a list of words you don’t want it to index, or those that you do, and it finds all those words in the document. That’s great for things like catalogs or some technical docs, but it’s not suitable (in my opinion) for most documents. You need a human looking at every page to make a really great index.

  3. One way around your n-pages issue, David, is to use n-paragraphs. Those ranges do follow the story. Hmm: better check that … yes, it works. I just created an index reference that called for “next n paragraphs” with n set to 5 and got back 1-3 even though page 2 was empty.

    Still, it measure 5 paragraphs, not this one plus the next 5.

    But, it measures from the start of the first paragraph to the start of the last, so if you have a paragraph that spans three pages (as can happen iin some technical documents) and you try to index it with a range (“For next 1 paragraph”) all it gives you is a single reference to the first page holding the paragraph.

  4. Dave, it sounds like n paragraphs has the same problem I pointed out: If the story jumps from 1-3, even though page 2 was empty, then that’s not very helpful at all. I would want InDesign to say 1,3, as the topic clearly does not appear on page 2.

    That said, I agree that “next n paragraphs” is generally useful, though the range I use the most is “until next style.” That way I can tag a whole section based on going from one heading1 to the next heading1. Whatever the case, there are lots of great “range” options.

  5. One thing worth remembering is that if a topic is mentioned “sporadically” – so that it gets touched on on page 12, then again on page 13, and again on page 14, say, but the discussion is not continuous – most indexers think it is best to write the page locators as ’12, 13, 14′. Only if the topic is treated continuously on those pages should it be written ’12-14′. That’s the best way of avoiding the old-fashioned word ‘passim’ (which no one understands!)

  6. i haven’t really put the VS plugin through any heavy paces, but the one job i did with it a couple of years ago, it gave you a lot more options on how to construct/structure the index, even if you did mark it manually (which i think we did, if i remember correctly).

  7. I need to create an index from character style. Can I create it?
    I have a lot of words in my pages with Charcater styles applied that i Want to get into the index. Thk´s

  8. I’d rather have a triple root canal than make an index in ID, with its native system or with a plugin (I’ve tested the Sonar one, and hated it too). Well, there’s always hope for this being improved in InDesign CS17 . . .

  9. I’d rather have a root-canal than do an index — that goes without saying — but surely you’d rather use ID than Quark or Word for an embedded index? Are you talking about non-embedded indexes?

  10. Jeremy, I’d also rather have a root canal than use either Word or Quark for . . . well, anything. ID is a given for me, but at present I just refuse to do *any* indexing. Even when my dentists asks me.

  11. For InDesignSecrets readers who have to create an index from scratch — without the ID indexing process –, the free script “IndexBrutal” for ID CS/CS2/CS3 can help. You have just to build a text file containing your entries. IndexBrutal search the keys in the active Document or Book and generate the complete index. Advanced features, samples and download here:
    http://marcautret.free.fr/geek/indd/indexbrut/
    (ok, that’s a French page, but the script interface toggles to EN language according to the app locale).

  12. Marc, I tried your script some more, on a longish document (450+ pages), and it’s still working splendidly! I notice that it’s the page-grouping (like “12-14”) which seems to consume the most CPU, and disabling that speeds things up drastically, right? This script will do some indexing jobs quite nicely for me, without having to waste a painful second on ID’s native indexing — so thank you for this contribution! Now all I need is a version which creates PDF bookmarks from the page citations with hyperlinks to the actual pages . . . well, I can dream, can’t I? :-)

  13. Klaus, Thanks for your feedback. The script shows its best performance on ID CS3. Of course, it depends ‘drastically’ on the pagination (how many pages) AND on the indexor’s length (how many keywords). The page-grouping feature is not the most consuming process but disabling it can speed up the job. A “auto-bookmarks” feature? That’s a great idea for a next version. I’ll think about it.

  14. Hi Marc,

    We also discussed your wonderful Index Brutal-Script at our swiss InDesign-forum and I translated some of the explanations about the operators to german. We wondered if there is a possibility to add several levels to the index?
    I’ve read through the explanations but there seems to be only the possibilty to use the operator “|” …

    Example:

    entering text
    …creating text frames
    …importing text
    ……Excel data
    ……tagges text

  15. Marc, I’m glad to hear you’ll think about it! Feel free to email me privately about testing beta versions of your script(s).

    Also, it could be very useful to have a similar script which, instead of page citations, sums up the number of occurrences of each word in the text.

  16. Gabriel (#7 above): No, unfortunately, you cannot make an index based on character styles in InDesign. I keep hoping that they will allow character styles in table of contents (like QX does), which lets you sort of fake what you want.

    [[edited july 08: Correction. See this post.]]

  17. Marc, to give you more feedback on your great script, I now used a 6,000+ word list to create a concordance of a document containing almost 200,000 words spread across about 450 pages. My 2.9GHz XP box with IDCS3 crunched away for about 15 gut-wrenching minutes — and then it generated a splendid concordance for all of those 6,000+ words!

    So I’m very grateful to you, Marc, for contributing this splendid indexing script to the InDesign community — and I hope you’ll keep tinkering with it, to improve it even further.

  18. I’ve written a script that will search an index containing sequential page numbers and “collapse” them down to a page range. For example, “14, 17, 18, 19, 20, 24, 25” would collapse to “14, 17-20, 24-25”. It is a hack script I threw together for a singular unusual application, so no guarantees of workability for your use, but if anyone would like the script, I’d be happy to share it.

  19. Marc, not to rain on your great parade, but I’ve found a bug. The alphabetic sorting mechanism doesn’t know what to do with the Scandinavian æøåÆØÅ characters, so words with those letters are sorted . . . weirdly (e.g., “o” and “ø” are mixed together).

    I’ve not checked with other non-standard characters (from a French and English perspective!), but it’s conceivable that letters used in other languages might also be sorted . . . weirdly?

    I can easily sort the lines of your TXT file properly in a text editor, so this bug is no great problem for me — but I thought I’d tell you and others about my finding.

  20. Sacha, Klaus, Thanks for all your comments and suggestions. I don’t want my script to “engulf” this discussion, so I’ll try to answer shortly:

    “Add several levels to the index” ? Just an idea: set to false the SORT_TERMS var in the script and try to use a custom tab marker (§ for example) in the TERM syntax:
    key1|section
    key2|§sub-section
    key3|§§sub-sub-section

    After index generation, replace § by tab (\t).

    “keeping the number of occurrences of each word in the text”? Very possible, but you’ve to hack the script (before a next version). Try to deal with the TIndexList.prototype.scanPages() method. The number of current term occurrences is results.length…

    “alphabetic sorting mechanism”? You’re right, the Scandinavian specific alphabet (and probably other ones!) is mistreated. Universal sort is a hard problem! The script overwrite the default Javascript Array.sort() method (awfully based on Unicode numeric codes!). I explain here how to improve it : http://marcautret.free.fr/geek/indd/indexbrut/#S6
    As you see, French words (with diacritics) are correctly sorted by IndexBrutal (because that’s the alphabet I know). The static properties String.DIAS and String.DIAS_TO_ASCII provide a Unicode-to-Ascii “immersion” used by the smartAlphaComp() function. We could adapt or extend this code in a more universal way, but that’s not so simple. From one language to the other, a same Unicode character does not take up the same rank in the alphabet… (I suppose.)

    For continuing privately the dissussion: marcautret[[at]]free[[dot]]fr

  21. I’ve now been in frequent email contact with Marc, who’s very kindly sent me beta versions of “scripts pertaining to indexing” — including proper sorting of the Dano-Norwegian alphabet. He’s doing terrific work in this field, and I’m very grateful to him — and I just wanted to publicly pat his back a little. Do go to his website and try out his indexing script — it rocks! (As does the other scripts he’s working on.)

  22. I am currently making an index in a language with 14 declinations, (Estonian) so list of index entries should include too many of them to think about it.
    As the index consists of names, it is good to have index palette that lets you choose from list of previous entries where you want the new one to go. I.e. if I have Sander and Pant in text I can ctrl+U them and select “Pant, Sander, a clown” in the index entries sub-thing in the index palette. Real shame that the index palette can not be resized and the scroll doesn’t work.

    As I am indexing single occurrences of names, and some of them are often mentioned it is necessary that I use the page ranges, instead of a paragraph of consecutive numbers.
    Could the feat described in the original question be pulled with GREP?

  23. I’m not sure if it’s something I’ve done wrong or if I’m trying to do something InDesign (CS3) can’t do, but using IndexBrutal to create an index for data that’s entirely in tables doesn’t appear to work. I ended up waiting a long time (at least it felt that way) to only get the same 1846 items I’d fed the script returned to me.
    Is it because data inside tables can’t be seen in the Story Editor?

    I don’t make indexes regularly (less than once a year actually), so paying for a plug-in that’ll do the job is out of the question. But I really do need to get this index made before the end of the week…

  24. Just wanted to say I officially hate MS Excel. Rather than saving into the text file only the selected fields or those that actually have content, it created ‘entries’ like this:
    12345[space][tab]
    12346[space][tab]

    The second I figured that out, I did a find & replace in the text file to replace [space][tab] with nothing and then ran the script again.
    15 minutes later all 1846 items have been indexed.

  25. The url to the script doesn’t work.

    I have index done but we need the change the pages written as 2, 3, 4, 5 to a range of pages like 2-5. All the time we do that by controlling and re-writing those. But, after that as you assume we can not update the index again…

    So, do you have any script to do the range of pages for a totally finished index?

    Thank you.

Leave a Reply

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