I'm writing a book for which I produce sections for glossaries, acronyms and index entries using the glossaries, acronym and makeidx packages on a template derived from the Springer book template. To support this I have a build process using SED to run around 230 sed commands like this:


the \myac command is defined as:


That is, try to find matching whole words and insert acronym, glossary or index entries.

This approach is very fragile - if the glossary entries get inserted into captions or labels my build process almost always fails.

Is there some way to define \myac, or any other command for that matter, so that it will not interfere with things like labels or other commands and environments if it finds itself embedded somewhere it shouldn't be?

Or, alternatively, is there a better way to batch index a document? My doc is about 250 pages, and I don't really have time to go through it all manually entering index entries.

  • I'm not very good at "reading" sed substitution directives. Could you maybe say in words what the particular sed directive is supposed to do. E.g., "whenever the string UML is found, replace it with UML\acs{UML}\index{UML}? Please advise. – Mico Jul 4 '14 at 5:05
  • 1
    I'm not sure that adding an index entry for every appearance of an acronym is really sensible. – egreg Jul 4 '14 at 8:40
  • @mico - that's pretty much what the sed script does. – Andrew Matthews Jul 4 '14 at 9:12
  • @egreg - if I decided that the acronym was important (e.g. it's a technical architecture standard for a company, and UML is very important in that context) then why wouldn't I include every occurrence in the index too? What would you suggest otherwise? – Andrew Matthews Jul 4 '14 at 9:13
  • 1
    If the acronym only occurs 3 or 4 times, that is sensible. But suppose it occurs on 25 pages. Unless you provide additional context, the index entry will be pretty useless. You'd either need to pick the key occurrences or create sub-entries which indicate the context e.g. UML 23-24; historical development 15, 33, 35, 37-9; commercial usage 40, 156-7; criticism 189-191, 203. Or whatever. Should the acronym's entry just redirect to the expanded version of the acronym? – cfr Jul 5 '14 at 2:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.