Next: Consistency Checks, Up: The Index Phrases File

#### 5.2.1 Collecting Phrases

Phrases for indexing can be collected while writing the document. The command `C-c \` (`reftex-index-phrase-selection-or-word`) copies the current selection (if active) or the word near point into the phrases buffer. It then selects this buffer, so that the phrase line can be edited. To return to the LaTeX document, press `C-c C-c` (`reftex-index-phrases-save-and-return`).

You can also prepare the list of index phrases in a different way and copy it into the phrases file. For example you might want to start from a word list of the document and remove all words which should not be indexed.

The phrase lines in the phrase buffer must have a specific format. RefTeX will use font-lock to indicate if a line has the proper format. A phrase line looks like this:

         [key] <TABs> phrase [<TABs> arg[&&arg]... [ || arg]...]

`<TABs>` stands for white space containing at least one <TAB>. key must be at the start of the line and is the character identifying one of the macros defined in the file header. It is optional - when omitted, the first macro definition line in the file will be used for this phrase. The phrase is the phrase to be searched for when indexing. It may contain several words separated by spaces. By default the search phrase is also the text entered as argument of the index macro. If you want the index entry to be different from the search phrase, enter another <TAB> and the index argument arg. If you want to have each match produce several index entries, separate the different index arguments with ‘ `&&` ’1. If you want to be able to choose at each match between several different index arguments, separate them with ‘ `||` ’2. Here is an example:

         %--------------------------------------------------------------------
         I     Sun
         i     Planet         Planets
         i     Vega           Stars!Vega
               Jupiter        Planets!Jupiter
         i     Mars           Planets!Mars || Gods!Mars || Chocolate Bars!Mars
         i     Pluto          Planets!Pluto && Kuiper Belt Objects!Pluto

So ‘`Sun`’ will be indexed directly as ‘`\index*{Sun}`’, while ‘`Planet`’ will be indexed as ‘`\index{Planets}Planet`’. ‘`Vega`’ will be indexed as a subitem of ‘`Stars`’. The ‘`Jupiter`’ line will also use the ‘`i`’ macro as it was the first macro definition in the file header (see above example). At each occurrence of ‘`Mars`’ you will be able choose between indexing it as a subitem of ‘`Planets`’, ‘`Gods`’ or ‘`Chocolate Bars`’. Finally, every occurrence of ‘`Pluto`’ will be indexed as ‘`\index{Planets!Pluto}\index{Kuiper Belt Objects!Pluto}Pluto`’ and will therefore create two different index entries.

#### Footnotes

[1] ‘`&&`’ with optional spaces, see `reftex-index-phrases-logical-and-regexp`.

[2] ‘`||`’ with optional spaces, see `reftex-index-phrases-logical-or-regexp`.