Next: , Previous: , Up: Hardcopy   [Contents][Index]

21.3 Format with tex/texindex

You can do the basic formatting of a Texinfo file with the shell command tex followed by the name of the Texinfo file. For example:

tex foo.texi

TeX will produce a DVI file as well as several auxiliary files containing information for indices, cross references, etc. The DVI file (for DeVice Independent file) can be printed on virtually any device, perhaps after a further conversion (see the previous section).

The tex formatting command itself does not sort the indices; it writes an output file of unsorted index data. To generate a printed index after running the tex command, you first need a sorted index to work from. The texindex command sorts indices. (texi2dvi, described in the previous section, runs tex and texindex as necessary.)

tex outputs unsorted index files under names following a standard convention: the name of your main input file with any ‘.texi’ or similar extension replaced by the two letter index name. For example, the raw index output files for the input file foo.texi would be, by default, foo.cp, foo.vr, foo.fn,, and Those are exactly the arguments to give to texindex.

Instead of specifying all the unsorted index file names explicitly, it’s typical to use ‘??’ as shell wildcards and give the command in this form:

texindex foo.??

This command will run texindex on all the unsorted index files, including any two letter indices that you have defined yourself using @defindex or @defcodeindex. You can safely run ‘texindex foo.??’ even if there are files with two letter extensions that are not index files, such as ‘foo.el’. The texindex command reports but otherwise ignores such files.

For each file specified, texindex generates a sorted index file whose name is made by appending ‘s’ to the input file name; for example, foo.cps is made from foo.cp. The @printindex command looks for a file with that name (see Printing Indices & Menus). TeX does not read the raw index output file, and texindex does not alter it.

After you have sorted the indices, you need to rerun tex on the Texinfo file. This regenerates the output file, this time with up-to-date index entries.

Finally, you may need to run tex one more time, to get the page numbers in the cross references correct.

To summarize, this is a five step process. (Alternatively, it’s a one-step process: run texi2dvi; see the previous section.)

  1. Run tex on your Texinfo file. This generates a DVI file (with undefined cross references and no indices), and the raw index files (with two letter extensions).
  2. Run texindex on the raw index files. This creates the corresponding sorted index files (with three letter extensions).
  3. Run tex again on your Texinfo file. This regenerates the DVI file, this time with indices and defined cross references, but with page numbers for the cross references from the previous run, generally incorrect.
  4. Sort the indices again, with texindex.
  5. Run tex one last time. This time the correct page numbers are written for the cross references.

Next: , Previous: , Up: Hardcopy   [Contents][Index]