next up previous
Next: About this document ... Up: Fancy Stuff Previous: Graphics

Cross References, Etc.

In a long paper, you will often want to say things like ``See Subsection 2.5.'' This is called a cross-reference. If you actually type numbers like ``2.5'' into the paper, though, you run into a problem when you add or delete sections, since that will change the numbering. You would have to hunt down all the cross-references in your paper and change the numbers.

LATEX has a cross-referencing system that makes this unnecessary. The idea is to associate a label or name to each place that you might want to reference. You do this with the \label command, which can immediately follow any command that uses automatic numbering, such as \section. The parameter to \label is a mnemonic name for the reference. LATEX will associate the actual number with this mnemonic name. For example, \section{Introduction}\label{S-intro} associates the mnemonic name S-intro with the section number for a section named ``Introduction.'' Later, you can retrieve the number by using the \ref command. This command takes the mnemonic name as a parameter. LATEX replaces the \ref command with the actual number associated with the mnemonic name. In our example, \ref{S-intro} would be replaced in the output with the section number of the ``Introduction'' section.

One fine point: When you use cross-references, you should process the LATEX input file twice. The first time allows LATEX to gather the reference numbers. The second time through, LATEX will insert the correct numbers in the correct places. (The numbers are actually stored in a separate file that LATEX creates automatically.)

LATEX is capable of helping with other bookkeeping chores as well. It can make a table of contents. It can number figures and tables and make cross-references to them. It provides a fairly easy way of creating an index for the document. And it has a bibliography environment that makes it easy to include citations to your references. If you are interested in any of this, it's time to start looking for a more comprehensive LATEX reference...


next up previous
Next: About this document ... Up: Fancy Stuff Previous: Graphics
David Eck 2003-10-21