Skip to main content
Inspiring
May 17, 2023
Answered

Multiple Page cross reference

  • May 17, 2023
  • 5 replies
  • 1353 views
In a paragraph I want to create a cross reference to list all the pages that contain the word "Oregon". Something like this:
Oregon is a state in the pacific northwest (see pages 85,96, 105)
 
But is seems like to do this I would have to create multiple text anchors or multiple cross references to achieve this which will make this task very time consuming and prone to human error on a larger scale book. Is there a way to create a a cross reference that will search the entire document for the word "Oregon" and show all the pages it is listed on, similar to an index to achieve the desired effect in the example above?
This topic has been closed for replies.
Correct answer Eric Dumas

Hi,

As far as I know it is not automated (unlike the Index  Create an index in InDesign (adobe.com))

Have you looked at point 2 (scroll down a bit) from Insert and manage cross-references in InDesign (adobe.com)

Alternatively, you might be lucky and find a script (look at Solved: How create CrossReference link to paragraphs or te... - Adobe Support Community - 4710059)

 

5 replies

Community Expert
May 21, 2023

that replacent I mentioned -- \(see page.+?\) -- deletes the whoile parenthetical, which is wrong: you want to delete just the cross-references, so use

\(see page\K.+?(?=\))

instead.

Community Expert
May 20, 2023

Here's a script, a bit rudimentary, but it does the job. As I said, it's pretty straightforward.  The core of the script is in fact quite short, most of it is auxiliary things like checking and comments. A script like this can be done in various ways, the script below is just one possibility. It created InDesign cross-references so if the text changes all you need to do is to update the cross-references.

 

The script doesn't cater for referenced text that's deleted, but that can be added. The easiest is to delete all \(see page.+?\) and run the script again.

 

First, create a cross-reference format and call it xref. Use only the page-number variable:

 

Then where you want the cross-reference to appear, enter (see page) and place the cursor between the e and the ). Then run the script. A small dialog is displayed, enter the term you want cross-referenced (e.g. Oregon). Click OK and the references are added.

 

 

(function () {
  var indd = app.documents[0];
  var cr_format = indd.crossReferenceFormats.item ('xref');
  var find, found;
  var source, destination;
  var i;

  if (!app.selection || !(app.selection[0] instanceof InsertionPoint)) {
    alert ('Select an insertion point');
    exit();
  }

  find = prompt ('Enter a search term', '', 'Cross-references');
  if (!find) {
    exit();
  }

  app.findTextPreferences = app.findChangeTextOptions = null;
  app.findChangeTextOptions.properties = {
    caseSensitive: true,
    wholeWord: true,
    searchBackwards: false,
  }

  app.findTextPreferences.findWhat = find;
  found = indd.findText();

  // More than one cross-ref: pluralise 'page'
  
  if (found.length > 1) {
    app.selection[0].contents = 's ';
  } else {
    app.selection[0].contents = ' ';
  }

  for (i = found.length-1; i >= 0; i--) {
    // Ignore the selected paragraph
    if (found[i].paragraphs[0] == app.selection[0].paragraphs[0]) {
      continue;
    }
    // Create a cross-reference: a source (an xref source), 
    // a destination (a text anchor), and a hyperlink
    source = indd.crossReferenceSources.add (app.selection[0], cr_format);
    destination = indd.hyperlinkTextDestinations.add (found[i]);
    indd.hyperlinks.add (source, destination);
    // Don't add a comma after the last cross-ref
    if (i > 1) {
      app.selection[0].contents = ', ';
    }
  }
}());

 

 

P.

 

 

Community Expert
May 19, 2023

How did InDesign ever become the standard in the industry is beyond me.

 

Two factors. One: there's no real competition. Two: InDesign's scripting support is stellar. There's not much that you can't script. What you're after is pretty straightforward to script. The main problem is going to be how you want to constrain the references. In the Oregon example, should all occurrences of Oregon be included?

Inspiring
May 19, 2023
Yes, I would like to be able to find all occurrences of Oregon or any other
word or phrase that I want to include.
Barb Binder
Community Expert
May 17, 2023

Hi @DexAlpenglow:

 

Adobe will consider adding features that are requested by a user, and upvoted by others. You can log this as a feature request here: https://indesign.uservoice.com

 

For now, Eric is correct: the options are an index with multiple markers, multiple cross-references or a script.

 

~Barb

~Barb at Rocky Mountain Training
Inspiring
May 18, 2023

It's quite disturbing that I would have to recommend such a useful feature for reference books. How did indesign ever become the standard in the industry is beyond me.

FRIdNGE
Inspiring
May 18, 2023

 

Scriptable! …

 

(^/)  The Jedi

Eric Dumas
Eric DumasCorrect answer
Community Expert
May 17, 2023

Hi,

As far as I know it is not automated (unlike the Index  Create an index in InDesign (adobe.com))

Have you looked at point 2 (scroll down a bit) from Insert and manage cross-references in InDesign (adobe.com)

Alternatively, you might be lucky and find a script (look at Solved: How create CrossReference link to paragraphs or te... - Adobe Support Community - 4710059)

 

Inspiring
May 17, 2023

Thanks for the response, unfortunately all those options are way to time consuming for a large book. I can't understand why indesign lacks on this type of automation.