Previous: , Up: Writing a Texinfo File   [Contents][Index]


2.4 A Short Sample Texinfo File

Here is a short but complete Texinfo file, so you can see how Texinfo source appears in practice. The first three parts of the file are mostly boilerplate: when writing a manual, you simply change the names as appropriate.

The complete file, without interspersed comments, is shown in Short Sample Texinfo File.

See Beginning and Ending a File, for more documentation on the commands listed here.

Header

The header tells TeX which definitions file to use, names the manual, and carries out other such housekeeping tasks.

\input texinfo
@settitle Sample Manual 1.0

Summary Description and Copyright

This segment describes the document and contains the copyright notice and copying permissions. This is done with the @copying command.

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{} 2016 Free Software Foundation, Inc.
@end copying

Titlepage, Copyright, Contents

The title and copyright segment contains the title and copyright pages for the printed manual. The segment must be enclosed between @titlepage and @end titlepage commands. The title and copyright page does not appear in the online output.

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

‘Top’ Node and Master Menu

The ‘Top’ node starts off the online output; it does not appear in the printed manual. 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. The ‘Top’ node contains at least a top-level menu listing the chapters, and possibly a Master Menu listing all the nodes in the entire document.

@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 of the Document

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 of the Document

This may contain commands for printing indices, and closes with the @bye command, which marks the end of the document.

@node Index
@unnumbered Index

@printindex cp

@bye

Some Results

Here is what the contents of the first chapter of the sample look like:


This is the first chapter.

Here is a numbered list.

  1. This is the first item.
  2. This is the second item.

Previous: , Up: Writing a Texinfo File   [Contents][Index]