Go to the first, previous, next, last section, table of contents.

4. Ending a Texinfo File

The end of a Texinfo file should include commands to create indices and (usually) to generate detailed and summary tables of contents. And it must include the @bye command that marks the last line processed by TeX.

For example:

@node    Concept Index,     , Variables Index, Top
@c        node-name,    next, previous,        up
@unnumbered Concept Index

@printindex cp


4.1 Index Menus and Printing an Index

To print an index means to include it as part of a manual or Info file. This does not happen automatically just because you use @cindex or other index-entry generating commands in the Texinfo file; those just cause the raw data for the index to be accumulated. To generate an index, you must include the @printindex command at the place in the document where you want the index to appear. Also, as part of the process of creating a printed manual, you must run a program called texindex (see section 19. Formatting and Printing Hardcopy) to sort the raw data to produce a sorted index file. The sorted index file is what is actually used to print the index.

Texinfo offers six different types of predefined index: the concept index, the function index, the variables index, the keystroke index, the program index, and the data type index (see section 12.2 Predefined Indices). Each index type has a two-letter name: `cp', `fn', `vr', `ky', `pg', and `tp'. You may merge indices, or put them into separate sections (see section 12.4 Combining Indices); or you may define your own indices (see section 12.5 Defining New Indices).

The @printindex command takes a two-letter index name, reads the corresponding sorted index file and formats it appropriately into an index.

The @printindex command does not generate a chapter heading for the index. Consequently, you should precede the @printindex command with a suitable section or chapter command (usually @unnumbered) to supply the chapter heading and put the index into the table of contents. Precede the @unnumbered command with an @node line.

For example:

@node Variable Index, Concept Index, Function Index, Top
@comment    node-name,         next,       previous, up
@unnumbered Variable Index

@printindex vr

@node     Concept Index,     , Variable Index, Top
@comment      node-name, next,       previous, up
@unnumbered Concept Index

@printindex cp

Readers often prefer that the concept index come last in a book, since that makes it easiest to find. Having just one index helps readers also, since then they have only one place to look (see section 12.4.2 @synindex).

4.2 Generating a Table of Contents

The @chapter, @section, and other structuring commands supply the information to make up a table of contents, but they do not cause an actual table to appear in the manual. To do this, you must use the @contents and/or @summarycontents command(s).

Generate a table of contents in a printed manual, including all chapters, sections, subsections, etc., as well as appendices and unnumbered chapters. (Headings generated by the @heading series of commands do not appear in the table of contents.)
(@summarycontents is a synonym for @shortcontents; the two commands are exactly the same.) Generate a short or summary table of contents that lists only the chapters (and appendices and unnumbered chapters). Omit sections, subsections and subsubsections. Only a long manual needs a short table of contents in addition to the full table of contents.

Both contents commands should be written on a line by themselves. The contents commands automatically generate a chapter-like heading at the top of the first table of contents page, so don't include any sectioning command such as @unnumbered before them.

Since an Info file uses menus instead of tables of contents, the Info formatting commands ignore the contents commands. But the contents are included in plain text output (generated by makeinfo --no-headers).

The contents commands can be placed either at the very end of the file, after any indices (see the previous section) and just before the @bye (see the next section), or near the beginning of the file, after the @end titlepage (see section 3.5.1 @titlepage). The advantage to the former is that then the contents output is always up to date, because it reflects the processing just done. The advantage to the latter is that the contents are printed in the proper place, thus you do not need to rearrange the DVI file with @command{dviselect} or shuffle paper. However, contents commands at the beginning of the document are ignored when outputting to standard output.

As an author, you can put the contents commands wherever you prefer. But if you are a user simply printing a manual, you may wish to print the contents after the title page even if the author put the contents commands at the end of the document (as is the case in most existing Texinfo documents). You can do this by specifying @setcontentsaftertitlepage and/or @setshortcontentsaftertitlepage. The first prints only the main contents after the @end titlepage; the second prints both the short contents and the main contents. In either case, any subsequent @contents or @shortcontents is ignored (unless no @end titlepage is ever encountered).

You need to include the @set...contentsaftertitlepage commands early in the document (just after @setfilename, for example). Or, if you're using @command{texi2dvi} (see section 19.3 Format with @code{texi2dvi}), you can use its @option{--texinfo} option to specify this without altering the source file at all. For example:

texi2dvi --texinfo=@setshortcontentsaftertitlepage foo.texi

4.3 @bye File Ending

An @bye command terminates TeX or Info formatting. None of the formatting commands see any of the file following @bye. The @bye command should be on a line by itself.

If you wish, you may follow the @bye line with notes. These notes will not be formatted and will not appear in either Info or a printed manual; it is as if text after @bye were within @ignore ... @end ignore. Also, you may follow the @bye line with a local variables list. See section 19.7 Using the Local Variables List, for more information.

Go to the first, previous, next, last section, table of contents.