Viewing File: /usr/share/doc/texinfo/html/Format-with-tex_002ftexindex.html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is for GNU Texinfo (version 6.7, 23 September 2019),
a documentation system that can produce both online information and a
printed manual from a single source using semantic markup.

Copyright (C) 1988, 1990, 1991, 1992, 1993, 1995, 1996, 1997,
1998, 1999, 2001, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 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". -->
<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Format with tex/texindex (GNU Texinfo 6.7)</title>

<meta name="description" content="Format with tex/texindex (GNU Texinfo 6.7)">
<meta name="keywords" content="Format with tex/texindex (GNU Texinfo 6.7)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2any">
<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="Formatting-Partial-Documents.html" rel="next" title="Formatting Partial Documents">
<link href="Format-with-texi2dvi.html" rel="prev" title="Format with texi2dvi">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {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}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en">
<span id="Format-with-tex_002ftexindex"></span><div class="header">
<p>
Next: <a href="Print-with-lpr.html" accesskey="n" rel="next">Print with <code>lpr</code></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">Hardcopy</a> &nbsp; [<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">19.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
&lsquo;<samp>.texi</samp>&rsquo; 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&rsquo;s typical to use &lsquo;<samp>??</samp>&rsquo; 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
&lsquo;<samp>texindex foo.??</samp>&rsquo; even if there are files with two letter
extensions that are not index files, such as &lsquo;<samp>foo.el</samp>&rsquo;.  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 &lsquo;<samp>s</samp>&rsquo; 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 &amp; 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&rsquo;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>

<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="Formatting-Partial-Documents.html" accesskey="1">Formatting Partial Documents</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="Details-of-texindex.html" accesskey="2">Details of <code>texindex</code></a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr>
<div class="header">
<p>
Next: <a href="Print-with-lpr.html" accesskey="n" rel="next">Print with <code>lpr</code></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">Hardcopy</a> &nbsp; [<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>
Back to Directory File Manager