[net.text] Indexs for nroff/troff

kurt@rruxg.UUCP (K A Gluck) (02/24/86)

Does anyone out there have a way to generate indexs?

When I was using MTS's format system, I could define a pair of
macros.  The first, would make index entries (you gave it the word, it
took the page number from the registers). The second would print the
index (you put this at the end of the file).

Nroff/troff dont seem to have this ability.  It is non trivial to
write a pair of macros, lets say

.In WORD  \" make index entry for word WORD using current page #
          \" print word word here

.Ip       \" print index

The reasion that .In prints the word, is an attempt to keep the
reffrence and the word on the same page.

Any ideas ?

   - kurt gluck  Bellcore   rrc 4e727   201 699 2105
	ihnp4!bellcore!rruxg!kurt     

storm@diku.UUCP (Kim Fabricius Storm) (02/28/86)

In article <108@rruxg.UUCP> kurt@rruxg.UUCP writes:
>Nroff/troff dont seem to have this ability.  It is non trivial to
>write a pair of macros, lets say

>.In WORD  \" make index entry for word WORD using current page #
>          \" print word word here

>The reasion that .In prints the word, is an attempt to keep the
>reffrence and the word on the same page.

You better print the word before you enter it into the index with
the current page number; attempting to print the word may cause n/troff to
print out its partially filled line, placing the word on the first line
of the following page.  I have experienced this myself!

I have once written such a package to be used with a 
modified -me package.  It needed a separate execution of
troff to print the index (and a table of contents) because it
was based on the .tm command, something like

.de In
\\$1
.tm .IX "\\$1" \\n%
..

I then ran troff, piping the error output into another troff,
formatting the index (via a special IX macro).  In this way it
was even possible to sort the index before it was printed.

I'm sorry I can't send you the package - I don't have it at hand
at present, and as I said, it must be used together with a modified
-me package which I don't think I'm allowed to distribute (lots of diffs!).

However, if there is enough interest in my package (it makes really nice
indexes and tocs) and somebody is willing to adapt it to the standard packages,
I may be persuaded to distribute what I have.  But it is much more fun
to make your own package, I'm sure.

------------------
Kim F. Storm, storm@diku.UUCP  (seismo!diku!storm)
Institute of Datalogy(=CS), U of Copenhagen, Universitetsparken 1, DK-2100 OE