Skip navigation
Eleivana07
Currently Being Moderated

Creating an index with a script and using a style

Feb 17, 2013 10:14 PM

Tags: #styles #scripting #index_entries

Hello all

Using ID CS 4 on Win Vista

 

I would like to create an index for my book on plant oils. Each plant may have numerous synonyms and vernacular names.The words I would like to index will be noted in the screenshot below and follow the red lettered headings of:

  • Plant Species
  • Plant species synonyms
  • Other common names

 

The words are separated by commas and the only things I DON'T want under these headings are the abbreviations noted between parenthesis

These are language codes (SP) for Spanish (FR) French etc. I could probably go back and using find/replace and strip this particular style from these entries to exclude from the process if neccessary.

 

I have assigned a style called 'Indexing Style' to those words that I want included.

 

Is there a script or could one be devised which will MARK these words as index entries?

 

I know Jongware could probably spit one out in his sleep. Or either of the Peters

 

I know exactly zilch about scripting.

Oil book screenshot.jpg

 

Thanks again you wonderful guys

 
Replies
  • Currently Being Moderated
    Feb 18, 2013 12:19 AM   in reply to Eleivana07

    Peter has some clever stuff here.

     

    http://www.kahrel.plus.com/indesign/lists_indexes.html

     

    P.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 18, 2013 4:21 AM   in reply to Pickory
     
    |
    Mark as:
  • Currently Being Moderated
    Feb 20, 2013 12:58 AM   in reply to Eleivana07

    Hello,

     

    That seems to use a word list, I thought you wanted to index the styled words.

     

    P.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 20, 2013 4:33 AM   in reply to Eleivana07

    Eleivana07 wrote:

     

    Hi

    According to the description and the dialog box I thought it created an index in which you could select styles to include or exclude:

    I've never used that script, but I did a quick read of the description, and here's my take. You need to have an independent document with the list of words you want to index. You have the option to include or exclude those words from text in your other open document(s) based on the Paragraph Style of the paragraph in which they appear, but the script knows nothing about character styles. I don't see this as a problem in your case since your headings should all have a distinct paragraph style. Presumably after it is run -- if it has a list of words to use -- it will create an index story that you can put in your document. Just running the script without preparing a word list won't work.

     

    The script does not find words in a document and then add them to the word list. You have to do that yourself, or perhaps use a different script.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 20, 2013 4:36 AM   in reply to Peter Spier

    http://www.kahrel.plus.com/indesign/index_charstyles.html might be more appropriate in this case.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:04 AM   in reply to Eleivana07

    Lauren,

     

    You say the words that should appear in the index are in a style. Is that a character style or a paragraph style? If they're in a character style, then Peter Spier is correct: use index_charstyles. That script looks for all words in a selected character style and creates topics and page references in the text, so that you can generate an index later.

     

    To clarify the other script (independent index from word list): this script works with a text (the text for which you want to create an index) and a word list. The script looks up the word-list words in the text, and adds page numbers in that word list. The word list therefore becomes the index. The script does not add topics and page references in the text. It therefore does one-off indexes. Change the pagination in your text and you'll have to run the script again. The thing with styles is there just to refine searches and can be ignored entirely.

     

    Go for index_charstyles: it creates an easily updateable index.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:07 AM   in reply to Peter Spier

    Peter --

    > Loic Aigon has some good stuff, too

    That's Marc Autret;)

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:23 AM   in reply to Peter Kahrel

    Peter Kahrel wrote:

     

    Peter --

    > Loic Aigon has some good stuff, too

    That's Marc Autret;)

     

    Peter

    Very Sorry! My sincere apologies.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:24 AM   in reply to Peter Spier

    They're friends, they don't mind!

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:51 AM   in reply to Eleivana07

    I'm not clear on how this document is built.

     

    You say the data was in Excel. Do you have separate columns for each name, even when there is more than one name following the heading? Did you do a Data Merge? Did you apply character styles to the content you want to include? Do you understand the difference between a paragraph style and a character style?

     

    Frankly, I think this is going to be difficult, no matter what you do, and is going to involve a good bit of manual labor. The other Peter may need to clarify or correct me here, but I just ran a little test with the index_charstyles script, and you'll need to be very careful about how the styles are applied. The script makes a single listing of all contiguous text that carries the same style, so two-word names must have the space styled as well, and a list of names must have unstyled spaces and/or punctuation as separators. If the words in your file that you want to index are not already marked with a character style, you would have to add that manually and I don't know how much faster that would be than adding index markers manually (somewhat, for sure, but less flexible in how the index is presented, I think).

     

    Generating the word list in Excel may be the way to go, but if you have multiple names in a single cell you'll have to break them out into their own cells manually after generating the list.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 1:48 PM   in reply to Eleivana07

    Applying a character style to selected terms isn't all that hard, probably:

     

    1. Create a character style and call it, say, 'index'.

    2. Open the Find/Change dialog and do the following grep replacement:

     

    Find What: (?<=^Plant Species:\s).+

    Change To: leave the Change To field empty, in the Change Format panel, select the index character style.

    Press Change All.

     

    This grep query applies the character style to all paragraphs that start with Plant Species:, but ignores Plant Species: itself. \s stands for 'any space'.

     

    3. Do the same for any other paragraphs ('Other Common Names:' looks like a good candidate).

     

    4. In the Find/Change dialog, define the following grep replacement:

     

    Find What: ,\s

    Find Format: select the index character style

    Change To: leave blank

    Change Format: leave blank

     

    5. Now run the index_charstyles script.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:16 PM   in reply to Peter Kahrel

    Peter Kahrel wrote:

     

    4. In the Find/Change dialog, define the following grep replacement:

     

    Find What: ,\s

    Find Format: select the index character style

    Change To: leave blank

    Change Format: leave blank

    Um, I'm certainly not as adept at GREP as you are, but wouldn't that remove the ,\s, i.e the comma and space following it, from the text? I would have thought you should set the Change Format to the [None] character style.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:29 PM   in reply to Peter Spier

    > I would have thought you should set the Change Format to the [None] character style.

     

    Yes, yes! You're absolutely right. That's crucial. Thanks.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:34 PM   in reply to Peter Kahrel

    Glad I saw that. Time for another cup of coffee, I think.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:46 PM   in reply to Eleivana07

    I'm also fond of File > Revert if you save before doing this, butbeing the belt and suspenders sort I'd make a backup copy, too.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 2:54 PM   in reply to Peter Spier

    > Time for another cup of coffee, I think.

     

    More like G&T this time of day.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 3:00 PM   in reply to Eleivana07

    > It is changing the FIRST letter of the FIRST word only it seems

     

    Sounds like you forgot the +

     

    The dot is a wildcard, it stands for any character at all (except the paragraph break). The plus means 'more than one'. Therefore .+ (dot plus) finds sequences of any character up to the paragraph break.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2013 3:07 PM   in reply to Peter Kahrel

    Peter K won't plug it himself, but if you fee GREP-challenged I highly recommend his e-book on the subject (that's how I learned most of what I know about GREP). Costs about $10 at O'Reilly.com

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 22, 2013 1:22 AM   in reply to Eleivana07

    I've no idea. Under SYMBOLS come topics whose names don't start with a letter but with a symbol. What do those entries look like?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points