Next: , Previous: , Up: Nodes   [Contents][Index]

6.3 @anchor: Defining Arbitrary Cross Reference Targets

An anchor is a position in your document, labeled so that cross references can refer to it, just as they can to nodes. You create an anchor with the @anchor command, and give the label as a normal brace-delimited argument. For example:

This marks the @anchor{x-spot}spot.
@xref{x-spot,,the spot}.


This marks the spot.
See [the spot], page 1.

As you can see, the @anchor command itself produces no output. This example defines an anchor ‘x-spot’ just before the word ‘spot’. You can refer to it later with an @xref or other cross reference command, as shown (see Cross References).

It is best to put @anchor commands just before the position you wish to refer to; that way, the reader’s eye is led on to the correct text when they jump to the anchor. You can put the @anchor command on a line by itself if that helps readability of the source. Whitespace (including newlines) is ignored after @anchor.

Anchor names and node names may not conflict. Anchors and nodes are given similar treatment in some ways; for example, the goto-node command takes either an anchor name or a node name as an argument. (See Go to node in Info.)

Also like node names, anchor names cannot include some characters (see Node Line Requirements).

Because of this duality, when you delete or rename a node, it is usually a good idea to define an @anchor with the old name. That way, any links to the old node, whether from other Texinfo manuals or general web pages, keep working. You can also do this with the RENAMED_NODES_FILE feature of makeinfo (see HTML Xref Link Preservation). Both methods keep links on the web working; the only substantive difference is that defining anchors also makes the old node names available when reading the document in Info.

Next: , Previous: , Up: Nodes   [Contents][Index]