Sort and Combine Cross References

This script is part of the Indexes and Concordances collection. See the full collection here.ย  For more information about working with indexes and concordances in InDesign, see here.

Unlike subtopics, which InDesign sorts, cross-references are printed in the order in which they were added to the document. If you create a cross-reference to the topic UXP, and later, at the same topic, create a cross-reference to the topic JavaScript, then another one to AppleScript, the Index panel shows them in the order you created them:

Sort and combine index cross-references; before

After generating the index you’ll see that the cross-references weren’t sorted:

Sort and combine index cross-references; after

In addition, cross-references of the same type (See, See also) arenโ€™t grouped. What we’re after is See also AppleScript; Javascript; UXP. In addition, subtopics are often placed after the page references:

Sort and combine index cross-references; after

This script fixes all these problems. Run it against a generated index.

It has no interface, but you need to set two parameters: the text (language) of the cross-reference label and whether the cross-references should be moved. The script defaults to See also and placing cross-references after page references. To change these settings, open the script in a plain-text editor and change these two lines, which are at the top of the script:

var xrefString = 'See also';
var moveCrossRefs = true;

Change 'See also' to e.g. 'Zie ook' and true to false. Save the script (as a plain-text file)

With See cross-references moving them isn’t relevant, so make sure that moveCrossRefs is false.

Return to Index Fixes page.


Peter Kahrel Script Repository
Hosted as a community service, and with deep appreciation, by CreativePro.com


Scripts by Topic | Script Index
Basic Script Installation and Use
How to Modify or Configure These Scripts
Resources for Scripting and Publishing Automation
About This Repository


Repository Home Page


Contact Peter Kahrel


Note to users: You run scripts at your own risk: CreativePro and the author accept no liability for anything that may be caused by any of these scripts. Always take the necessary precautions. We encourage you to save backups and test scripts on copies of your documents.

Bookmark
Please login to bookmark Close

This article was last modified on September 5, 2026

Comments (0)

Leave a Reply

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

Loading comments...