JezK
Edit File: Format-with-tex_002ftexindex.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <!-- Created by GNU Texinfo 6.8, https://www.gnu.org/software/texinfo/ --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- This manual is for GNU Texinfo (version 6.8, 8 June 2021), a documentation system that can produce both online information and a printed manual from a single source using semantic markup. Copyright (C) 1988, 1990-1993, 1995-1999, 2001-2021 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". --> <title>Format with tex/texindex (GNU Texinfo 6.8)</title> <meta name="description" content="Format with tex/texindex (GNU Texinfo 6.8)"> <meta name="keywords" content="Format with tex/texindex (GNU Texinfo 6.8)"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="texi2any"> <meta name="viewport" content="width=device-width,initial-scale=1"> <link href="index.html" rel="start" title="Top"> <link href="Command-and-Variable-Index.html" rel="index" title="Command and Variable Index"> <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents"> <link href="Hardcopy.html" rel="up" title="Hardcopy"> <link href="Print-with-lpr.html" rel="next" title="Print with lpr"> <link href="Format-with-texi2dvi.html" rel="prev" title="Format with texi2dvi"> <style type="text/css"> <!-- a.copiable-anchor {visibility: hidden; text-decoration: none; line-height: 0em} a.summary-letter {text-decoration: none} blockquote.indentedblock {margin-right: 0em} div.display {margin-left: 3.2em} div.example {margin-left: 3.2em} kbd {font-style: oblique} pre.display {font-family: inherit} pre.format {font-family: inherit} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} span.nolinebreak {white-space: nowrap} span.roman {font-family: initial; font-weight: normal} span.sansserif {font-family: sans-serif; font-weight: normal} span:hover a.copiable-anchor {visibility: visible} ul.no-bullet {list-style: none} --> </style> </head> <body lang="en"> <div class="section" id="Format-with-tex_002ftexindex"> <div class="header"> <p> Next: <a href="Print-with-lpr.html" accesskey="n" rel="next">Print with <code>lpr</code> from Shell</a>, Previous: <a href="Format-with-texi2dvi.html" accesskey="p" rel="prev">Format with <code>texi2dvi</code></a>, Up: <a href="Hardcopy.html" accesskey="u" rel="up">Formatting and Printing Hardcopy</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p> </div> <hr> <span id="Format-with-tex_002ftexindex-1"></span><h3 class="section">18.3 Format with <code>tex</code>/<code>texindex</code></h3> <span id="index-Shell-formatting-with-tex-and-texindex"></span> <span id="index-Formatting-with-tex-and-texindex"></span> <span id="index-DVI-file"></span> <p>You can do the basic formatting of a Texinfo file with the shell command <code>tex</code> followed by the name of the Texinfo file. For example: </p> <div class="example"> <pre class="example">tex foo.texi </pre></div> <p>TeX will produce a <em>DVI file</em> as well as several auxiliary files containing information for indices, cross-references, etc. The DVI file (for <em>DeVice Independent</em> file) can be printed on virtually any device, perhaps after a further conversion (see the previous section). </p> <span id="index-texindex"></span> <p>The <code>tex</code> 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 <code>tex</code> command, you first need a sorted index to work from. The <code>texindex</code> command sorts indices. (<code>texi2dvi</code>, described in the previous section, runs <code>tex</code> and <code>texindex</code> as necessary.) </p> <span id="Names-of-index-files"></span><span id="index-Names-of-index-files"></span> <span id="index-Index-file-names"></span> <p><code>tex</code> outputs unsorted index files under names following a standard convention: the name of your main input file with any ‘<samp>.texi</samp>’ or similar extension replaced by the two letter index name. For example, the raw index output files for the input file <samp>foo.texi</samp> would be, by default, <samp>foo.cp</samp>, <samp>foo.vr</samp>, <samp>foo.fn</samp>, <samp>foo.tp</samp>, <samp>foo.pg</samp> and <samp>foo.ky</samp>. Those are exactly the arguments to give to <code>texindex</code>. </p> <span id="index-Wildcards"></span> <span id="index-Globbing"></span> <p>Instead of specifying all the unsorted index file names explicitly, it’s typical to use ‘<samp>??</samp>’ as shell wildcards and give the command in this form: </p> <div class="example"> <pre class="example">texindex foo.?? </pre></div> <p>This command will run <code>texindex</code> on all the unsorted index files, including any two letter indices that you have defined yourself using <code>@defindex</code> or <code>@defcodeindex</code>. You can safely run ‘<samp>texindex foo.??</samp>’ even if there are files with two letter extensions that are not index files, such as ‘<samp>foo.el</samp>’. The <code>texindex</code> command reports but otherwise ignores such files. </p> <p>For each file specified, <code>texindex</code> generates a sorted index file whose name is made by appending ‘<samp>s</samp>’ to the input file name; for example, <samp>foo.cps</samp> is made from <samp>foo.cp</samp>. The <code>@printindex</code> command looks for a file with that name (see <a href="Printing-Indices-_0026-Menus.html">Printing Indices and Menus</a>). TeX does not read the raw index output file, and <code>texindex</code> does not alter it. </p> <p>After you have sorted the indices, you need to rerun <code>tex</code> on the Texinfo file. This regenerates the output file, this time with up-to-date index entries. </p> <p>Finally, you may need to run <code>tex</code> one more time, to get the page numbers in the cross-references correct. </p> <p>To summarize, this is a five-step process. (Alternatively, it’s a one-step process: run <code>texi2dvi</code>; see the previous section.) </p> <ol> <li> Run <code>tex</code> 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). </li><li> Run <code>texindex</code> on the raw index files. This creates the corresponding sorted index files (with three letter extensions). </li><li> Run <code>tex</code> 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. </li><li> Sort the indices again, with <code>texindex</code>. </li><li> Run <code>tex</code> one last time. This time the correct page numbers are written for the cross-references. </li></ol> <ul class="section-toc"> <li><a href="Formatting-Partial-Documents.html" accesskey="1">Formatting Partial Documents</a></li> <li><a href="Details-of-texindex.html" accesskey="2">Details of <code>texindex</code></a></li> </ul> </div> <hr> <div class="header"> <p> Next: <a href="Print-with-lpr.html">Print with <code>lpr</code> from Shell</a>, Previous: <a href="Format-with-texi2dvi.html">Format with <code>texi2dvi</code></a>, Up: <a href="Hardcopy.html">Formatting and Printing Hardcopy</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Command-and-Variable-Index.html" title="Index" rel="index">Index</a>]</p> </div> </body> </html>