Here is a very short but complete Texinfo file, in the six conventional parts enumerated in the previous section, so you can see how Texinfo source appears in practice. The first three parts of the file, from `\input texinfo' through to `@end titlepage', look more intimidating than they are: most of the material is standard boilerplate; when writing a manual, you simply change the names as appropriate.
See Beginning a File, for full documentation on the commands listed here. See GNU Sample Texts, for the full texts to be used in GNU manuals.
In the following, the sample text is indented; comments on it are not. The complete file, without interspersed comments, is shown in Short Sample Texinfo File.
The header does not appear in either the Info file or the printed output. It sets various parameters, including the name of the Info file and the title used in the header.
\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename sample.info @settitle Sample Manual 1.0 @c %**end of header
A real manual includes more text here, according to the license under which it is distributed. See GNU Sample Texts.
@copying This is a short example of a complete Texinfo file, version 1.0. Copyright @copyright{} 2005 Free Software Foundation, Inc. @end copying
The titlepage segment does not appear in the online output, only in the
printed manual. We use the @insertcopying
command to
include the permission text from the previous section, instead of
writing it out again; it is output on the back of the title page. The
@contents
command generates a table of contents.
@titlepage @title Sample Title @c The following two commands start the copyright page. @page @vskip 0pt plus 1filll @insertcopying @end titlepage @c Output the table of contents at the beginning. @contents
The `Top' node contains the master menu for the Info file. Since the printed manual uses a table of contents rather than a menu, it excludes the `Top' node. We repeat the short description from the beginning of the `@copying' text, but there's no need to repeat the copyright information, so we don't use `@insertcopying' here. The `@top' command itself helps makeinfo determine the relationships between nodes.
@ifnottex @node Top @top Short Sample This is a short sample Texinfo file. @end ifnottex @menu * First Chapter:: The first chapter is the only chapter in this sample. * Index:: Complete index. @end menu
The body segment contains all the text of the document, but not the indices or table of contents. This example illustrates a node and a chapter containing an enumerated list.
@node First Chapter @chapter First Chapter @cindex chapter, first This is the first chapter. @cindex index entry, another Here is a numbered list. @enumerate @item This is the first item. @item This is the second item. @end enumerate
The end segment contains commands for generating an index in a node and
unnumbered chapter of its own, and the @bye
command that marks
the end of the document.
@node Index @unnumbered Index @printindex cp @bye
Here is what the contents of the first chapter of the sample look like:
This is the first chapter.Here is a numbered list.
- This is the first item.
- This is the second item.