Cross referencing
One of the strengths of LaTeX is its capability to cross-reference through information it places in auxiliary 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.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\tableofcontentsat the desired location in the document; see Src/fractals21.tex.
The first time this is LaTeX'ed the table will not appear because the information is being stored in the associated .toc file. Subsequent LaTeX'ing 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 Src/minitoceg.tex.
Footnotes
Unlike most publishers, LaTeX easily handles footnotes with contemptuous ease. Just use the\footnote{some-text} command with one argument being the text of the footnote. As seen in Src/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 Src/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.
Drafts and electronic reading
When drafting a document, you often lose track of labels. Further, you want to read the document comfortably on screen rather than printing it. These desires are solved by two packages.First, \usepackage{showkeys} in the preamble will cause names of labels to also appear in a (draft) printed document for your ready reference.
Second, \usepackage[a5paper]{geometry} in the preamble will cause the document to be typeset with A5 paper size which is great for electronic reading. See Src/fractals23.tex and the next section where we also incorporate hypertext links.
Hypertext linking
A feature of LaTeX is the ability to automatically insert hypertext links within a document:- the \ref{} command puts in a clickable link to the referred object;
- the \label{} command automatically inserts a target;
- table of contents, footnotes, citations, etc all generate appropriate hyperlinks.
Warning: 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 Src/fractals24.tex.Hint: if you want the entry "References" to appear in the table-of-contents then put the line
\addcontentsline{toc}{section}{\refname} at the start of thebibliography environment (use \bibname instead \refname for reports or books). 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, pages = 23, }or@article{Roberts95b, author = {A. J. Roberts and A. Cronin}, journal = {Physica A}, pages = {867--878}, title = {Unbiased estimation of multi-fractal dimensions of finite data sets}, volume = 233, year = 1996, }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 thebibliography 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.
Some people use a Harvard style
Many people need to know how to use a Harvard style of citations. In LaTeX this is obtained with the same format for the .bib data files, and very similar commands in the document.- In the preamble put \usepackage{natbib} (get it from a CTAN site if your system does not have the package).
- In the place you want the bibliography put \bibliographystyle{agsm} then \bibliography{ajr} as before but now using the AGSM bibtex style instead of the default plain style.
- Then to get the following citations use the given command
- "Roberts & Cronin (1996)" use \cite{Roberts95b};
- "(Roberts & Cronin, 1996)" use \cite[]{Roberts95b};
- this form also typesets an afterword, for example, for "(Roberts & Cronin, 1996, p.15)" use \cite[p.15]{Roberts95b};
- and a foreword example, "(see Roberts & Cronin, 1996, e.g.)" use \cite[see][e.g.]{Roberts95b};
- for three or more authors \cite{Roberts95b} will typeset "Roberts et al. (1996)" which is good, but the convention is that the first time a three author work is cited the three authors ought to be explicitly given so then use \cite*{Roberts95b} to get "Roberts, Cronin & Another (1996)" the first time you site the work.
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 Src/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:
- front matter, see Src/frac25a.tex;
- section 1, see Src/frac25b.tex;
- section 2 and bibliography, see Src/frac25c.tex.
- 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.
Appendices
Often large documents have one or more appendices. If so just insert the command \appendix immediately before the first appendix, then use chapter and/or sectioning commands as before. The first chapter or section after \appendix will become Appendix A, the second will be Appendix B, etc.Summary
Cross-referencing is important in professional documents. Cross-referencing is absolutely vital in research as you must `plug' your work into the world's knowledge base, and must connect information across pages and sections within your own work. LaTeX provides incredibly easy tools to do this.For documents with significant mathematics we will need more than the simple mathematics structures seen so far.