LaTeX provides the facility to automatically cross-reference various sections, tables, figures, pages etc whereby the author does not have to keep track of the actual section, table, figure, page numbers - LaTeX will insert the relevant values when it is run.
Use of this facility is particularly useful with documents to be
processed using latex2html
, since latex2html
will not only insert the relevant values, but also create hyperlinks
to the relevant html
page, figure, table etc.
Automatic cross-referencing requires the following:
\label{text}
text
is a string of the author's choosing).
\ref{text}
text
is obviously the same string as above).
\label{text}
commands
defined in a given file (though clearly each text
string must be
unique).
For example, the
RUNNING LATEX & LATEX2HTML section of this document has the
following command just after the \section
command:
\label{Sec:running}
A cross-reference to this section can therefore be made
using the \ref{}
command as follows:
resulting in a cross-reference to Section~\ref{Sec:running}.
resulting in a cross-reference to Section 4.
NOTE: LaTeX actually operates by storing the locations of any sections,
tables etc defined using the \label{}
command in the *.aux
file. In order for this is read, and the correct values be inserted into
the output *.dvi
file, LaTeX should be run at least twice.
LaTeX should (obviously !)
always be re-run if you get the following warning message:
LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.