3.7 Node and Menu Illustration

Here is a diagram that illustrates a Texinfo file with three chapters, each of which contains two sections.

The “root” is at the top of the diagram and the “leaves” are at the bottom. This is how such a diagram is drawn conventionally; it illustrates an upside-down tree. For this reason, the root node is called the ‘Top’ node, and ‘Up’ node pointers carry you closer to the root.

                         Top
                          |
        -------------------------------------
       |                  |                  |
    Chapter 1          Chapter 2          Chapter 3
       |                  |                  |
    --------           --------           --------
   |        |         |        |         |        |
Section  Section   Section  Section   Section  Section
  1.1      1.2       2.1      2.2       3.1      3.2

Using explicit pointers (not recommended, but shown for purposes of the example), the fully-written command to start Chapter 2 would be this:

@node     Chapter 2,  Chapter 3, Chapter 1, Top
@comment  node-name,  next,      previous,  up

This @node line says that the name of this node is “Chapter 2”, the name of the ‘Next’ node is “Chapter 3”, the name of the ‘Previous’ node is “Chapter 1”, and the name of the ‘Up’ node is “Top”. You can (and should) omit writing out these node names if your document is hierarchically organized, but the pointer relationships still obtain.

To go to Sections 2.1 and 2.2 using Info, you need a menu inside Chapter 2. (See Menus.) You would write the menu just before the beginning of Section 2.1, like this:

   @menu
   * Sect. 2.1::    Description of this section.
   * Sect. 2.2::    Description.
   @end menu

The automatic pointers for the node for Sect. 2.1 correspond to:

@node     Sect. 2.1, Sect. 2.2, ,         Chapter 2
@comment  node-name, next,      previous, up

Note that no ‘Prev’ pointer is generated, since there is no other node at the same hierarchical level before Sect. 2.1.

Using explicit pointers, the node for Sect. 2.1 could be written like this:

@node     Sect. 2.1, Sect. 2.2, Chapter 2, Chapter 2
@comment  node-name, next,      previous,  up

With automatic pointers, the ‘Next’ and ‘Previous’ pointers of a node lead to other nodes at the same level—from chapter to chapter or from section to section. As shown, when using explicit pointers, the pointers can also lead somewhere else, here, for example, the ‘Previous’ pointer points up. An ‘Up’ pointer usually leads to a node at the level above (closer to the ‘Top’ node; and a ‘Menu’ leads to nodes at a level below (closer to ‘leaves’). (A cross-reference can point to a node at any level; see Cross-references.)

Technically, explicit node pointers can carry you to any node, regardless of the structure of the document; even to nodes in a different Info file. However, it would be very confusing for readers to have the ‘Next’, ‘Previous’ and ‘Up’ pointers lead to nodes that do not correspond, even loosely, to the next, previous and up node.

A @node command and a chapter structuring command are conventionally used together, in that order, often followed by indexing commands. (As shown in the example above, you may follow the @node line with a comment line, e.g., to show which pointer is which if explicit pointers are used.) The Texinfo processors use this construct to determine the relationships between nodes and sectioning commands.

Here is the beginning of the chapter in this manual called “Ending a Texinfo File”. This shows a @node line followed by a @chapter line, and then by indexing lines.

@node Ending a File
@chapter Ending a Texinfo File
@cindex Ending a Texinfo file
@cindex Texinfo file ending
@cindex File ending