[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4 Ending a Texinfo File

The end of a Texinfo file should include commands to create indices and (perhaps) to generate both the full and summary tables of contents. Finally, it must include the @bye command that marks the last line to be processed.

For example:

@node Index
@unnumbered Index

@printindex cp

@shortcontents
@contents

@bye

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Printing Indices and Menus

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 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 separate types of predefined index, each with a two-letter abbreviation, as illustrated in the following table. However, you may merge indices (see section Combining Indices) or define your own indices (see section Defining New Indices).

Here are the predefined indices, their abbreviations, and the corresponding index entry commands:

cp

concept index (@cindex)

fn

function index (@findex)

vr

variable index (@index)

ky

key index (@kindex)

pg

program index (@pindex)

tp

data type index (@tindex)

The @printindex command takes a two-letter index abbreviation, 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 @appendix or @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
@unnumbered Variable Index

@printindex vr
@node Concept Index
@unnumbered Concept Index

@printindex cp

We recommend placing the concept index last, since that makes it easiest to find. We also recommend having a single index whenever possible, since then readers have only one place to look (see section Combining Indices).


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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).

@contents

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.

@shortcontents
@summarycontents

(@summarycontents is a synonym for @shortcontents.)

Generate a short or summary table of contents that lists only the chapters, appendices, and unnumbered chapters. Sections, subsections and subsubsections are omitted. 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), unless makeinfo is writing its output to standard output.

When makeinfo writes a short table of contents while producing html output, the links in the short table of contents point to corresponding entries in the full table of contents rather than the text of the document. The links in the full table of contents point to the main text of the document.

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 @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 dviselect or shuffle paper.

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, at this writing). 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). We recommend using texi2dvi (see section Format with texi2dvi) to specify this without altering the source file at all. For example:

texi2dvi --texinfo=@setcontentsaftertitlepage foo.texi

[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 @bye File Ending

An @bye command terminates TeX or Info formatting. None of the formatting commands reading anything 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 for Emacs. See section Using Local Variables and the Compile Command, for more information.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated on a sunny day using texi2html.