WinEdt Macro Library  | LaTEX previous macro  | next macro

# indexing

## Description

This macro can be used to put \index{} commands before or after all instances of all word of a word list.

Invoke it on a file (let's call it "Fishy.tex"), if you have a list of all terms to be indexed in a file "Fishy.index" of the following form:

red herring -> herring!red
herring ->
herring's -> herring


Here, every instance of the phrase "red herring" will become "red herring\index{herring!red}", every herring will be appended by \index{herring} etc.

• There must be one pair of terms in a line.
• Lines without a "->" will be ignored.
• If the string in the index command is the same as the word, you can just leave it blank (as for "herring").
• Parts of words will not be recognized (i.e. "herring-pond" will not get indexed).
• If the last word of a phrase coincides with a single word that you want to index as well (like "red herring" and "herring"), put the phrase before the word. Then only the phrase will be indexed. (But if you want to index "red" and "red herring", both will be indexed. Sorry!)

Note that the index you'll get won't be a very good one. To get an index that is usable you'll still have to edit it a lot (mainly removing those \index command, where the term is not used in a substantial way).

1. To get a list of all words of a file you can use the macro \text\allwords.edt, which will produce a file %N.index.
2. Sort this file using the 'Tools | Sort Lines' tool.
3. Remove all words you don't want to be indexed.
4. Append the string " ->  " to all lines using WinEdt's tool: Edit | Move | Insert String (check "Append"),
5. and add index strings that are different from the terms to be indexed.
6. Invoke the macro indexing.edt.
It will not edit your file directly but produce the new file %n.index%t (in our case Fishy.index.tex).
7. If you are happy with all \index commands you can simply rename the file to Fishy.tex
(but I wouldn't do this before being absolutely sure that I don't want to change anything to the original text).

## Installation

Put the macro in a folder (preferably %b\WinEdt\LaTeX\).

## Options

You could use indexing.edt for any other append job of course. You'll find instructions in the macro.