Web Historical Disclaimer:

This is a historical page and is no longer maintained. Read our Web history statement for more information.

                                                       

  " "
   | UT Home | Graduate School Home |
" "

" "
 

LaTeX: from quick and dirty to style and finesse

Cross referencing
by Tony Roberts

One of the strengths of LaTeX is its capability to cross-reference through information it places in auxilary files. Done properly, this feature permits one to extract, insert, move and modify large and small chunks of the document around without having to manually renumber cross-references, it is all done automatically.

Contents of this section
Table of contents

One of the easiest things to do is to insert a table of contents into a document simply by placing the LaTeX command

\tableofcontents

at the desired location in the document; see fractals21.tex.

The first time this is LaTeXed the table will not appear because the information is being stored in the associated .toc file. Subsequent LaTeXing will typeset the table of contents.

The minitoc package may be used to insert a Table of Contents of just the current chapter or Part in a book or report. Very useful to help map out the parts of the dissertation for a reader. See the scheme laid out in the skeleton file minitoc.tex.

Footnotes

Unlike most publishers, LaTeX easily handles footnotes with comtemptuous ease. Just use the

\footnote{some-text}

command with one argument being the text of the footnote. As seen in fractals22.tex, this will typeset a numerical flag at the location of the footnote command and will place the footnote text at the bottom of the page.

Labels and references
Somewhat more sophisticated are references to equations and sections. First one has to label them as in

\section{...} \label{sec-name} or in

\begin{equation} ... \label{eq-name} \end{equation}

which associates a string such as "sec-name" with the number of the section, and a string such as "eq-name" with the number of the equation. See fractals23.tex.

Having created the labels, you refer to the objects using the \ref{label-name} command as seen in fractals23.tex. Note the use of the command \S to typeset a symbol for "section" and "subsection", and the need to put parentheses around the equation number in its reference.

One also labels and refers to chapters, subsections, subsubsections, tables, figures, and enumerated lists.

Often you begin to lose track of the labels used. In such a case \usepackage{showkeys} in the preamble will cause names of labels to also appear in a (draft) printed document for your ready reference.

Hypertext linking
An emerging feature of LaTeX is the ability to automatically insert hypertext links within a document:
  • the \ref{} command puts in a clickable link to the refered object;
  • the \label{} command automatically inserts a target;
  • table of contents, footnotes, citations, etc all generate appropriate hyperlinks.
To get this feature just inserts the command \usepackage{hyperref} at the end of the preamble.

Warnings:

  • at the time of writing, only very recent versions of LaTeX and dvi viewers support the hypertext links;
  • the hyperref and showkeys packages are currently incompatible;
  • the .toc files generated with and without hyperref are incompatible, so delete the current .toc file before using hyperref (try it in the fractals23.tex document).
Bibliography
A bibliography is handled as a sort of enumerated list with labels.

The following list like environment

\begin{thebibliography}{99}
\bibitem{bib-name1} article-description1
\bibitem{bib-name2} article-description2
...
\end{thebibliography}

typesets the bibliography with the heading References and associates the labels, the strings such as "bib-name1", with the description of the article or reference. See the end of fractals24.tex.

Hint: if you want the entry "References" to appear in the table-of-contents then put the line

\addcontentsline{toc}{section}{References}

at the start of the bibliography environment.

Citations in the text to the bibliography items are achieved by the command

\cite{bib-name}

This typesets the number of the bibitem in square brackets as seen in fractals24.tex.

Generally put a non-breaking space before the cite command as in

Mandelbrot~\cite{Mandel}...

BibTeX et al
The basic bibliography environment is fine for your first project report. However, in time you develop enough so that you want to keep one central database of all your references which you then access via the \cite command in any document you prepare.
  • First you prepare your database, say ajr.bib, consisting of records such as
    @ARTICLE{Roberts94a,
            AUTHOR   = {A.J.~Roberts},
            JOURNAL  = {Australasian Science},
            MONTH    = apr,
            TITLE    = {The importance of beings fractal},
            YEAR     = {1994},
            KEYWORDS = {fractal geometry}
    }
    The program bibcard on the Suns is excellent for preparing and maintaining such a database; I wish it was ported to other platforms. BibDB is available for PCs, and of course alpha on Macintoshes is great.
  • Then whenever you prepare a document, include the commands
    \bibliographystyle{plain}
    \bibliography{ajr}
    instead of the bibliography environment. Use \cite{...} as normal within the document.

  • Lastly, after running LaTeX, execute the program bibtex (it will look in the .aux file to determine what references are needed) which creates a .bbl file that later runs of LaTeX will read to form the bibliography. This sounds complicated, but it is all worth it.
There are also publicly available databases of .bib files covering specialist areas of research. For example there is one for dynamical systems.
Large documents
Large documents, especially dissertations and books, can be a pain to deal with just because of their size. LaTeX gives a facility to split the source, the .tex file, into manageable sized chunks to make editing easier and to speed typesetting by only doing that chunk of interest at any one time.
  • Establish the main file, as in fractals25.tex, of the form
    \documentclass{article}
    \begin{document}
    \include{frac25a}
    \include{frac25b}
    \include{frac25c}
    \end{document}
    with as many divisions as there are logical chunks in your document.

  • Then put all your normal LaTeX text and commands in the corresponding .tex files. Here I have broken the input file into:
  • Typeset the main file and all appears as normal (except pagebreaks are enforced between the included files).

  • To typeset only one of the chunks, say the first section, just insert the command
    \includeonly{frac25b}
    in the preamble as you see commented out in fractals25.tex.


12 August 1998

Professor A J Roberts
Dept Mathematics & Computing
University of Southern Queensland
Toowoomba 4350, Australia
E-mail: aroberts@usq.edu.au
 
" "
Graduate School, Main Building 101, Austin, TX 78712
(512) 471-4511, FAX: (512) 471-7620
Privacy statement