Cross referencing
use the most informative synonym.In scientific writing, this principle implies we must avoid wishy-washy imprecise references such as "above", "below" and "later". Instead, employ precise cross-references such as "equation (4)", "Section 5", and "Appendix A".
One of the immense 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 around and modify large and small chunks of the document 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 does 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 additionally insert a Table of Contents of just the current chapter or Part in a book or report. It very usefully helps 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 typesets a numerical flag at the location of the footnote command and places the footnote text at the bottom of the page.
Labels and references
See video discussion 32Somewhat more sophisticated are references to equations, sections, figures, and so on. 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 need to refer to the objects. I recommend you first include near the end of the preamble
\usepackage[capitalise,nameinlink ,noabbrev]{cleveref} \crefname{equation}{}{} \crefname{enumi}{}{}Then to refer to the objects use the \cref{label-name} command as seen in fractals23.tex.
One also labels and refers to chapters, subsections, subsubsections, theorems, definitions, tables, figures, enumerated lists, and so on. A comma separated list of labels within \cref{} expands beautifully:
LaTeX code | Typeset example |
---|---|
\cref{fa,fe} | Figures 1 and 2 |
\cref{thmb,defc} | Theorem 2 and Definition 3 |
\cref{eqd,eqe,eqf} | (4) to (6) |
But ensure you \usepackage{amsthm}, and then all \newtheorem{} definitions must be after the \usepackage{cleveref}.
Warning: cleveref does not work with the eqnarray maths environment; use align instead.
Avoid unhelpful and easy to misinterpret phrases
Avoid using "we will do","in the figure below", and "from the above equation". Instead use precise cross-references such as "Section~2 does", "Figure~4 plots", "using equation~(3)" (\cref{} remembers non-breaking spaces in the first two, you need to in the last).You might ask why I do not recommend the automatic name 'equation' when cross-referencing an equation? The reason is that for best comprehension by readers, we need to refer to mathematics by the most informative synonym such as "system (1)", "PDE (2)", "bound (3)", "approximation (4)", "inequality (5)", "transform (6)", and so on. It is not practical to code such informative synonyms automatically, so instead we write them explicitly.
Drafts and electronic reading
When drafting a document, you often lose track of labels. Possibly include \usepackage{showkeys} in the preamble which causes names of labels to also appear in a (draft) printed document for your ready reference. Add it to Src/fractals23.texCross-reference into enumerated lists
Also ensure you cross-reference to enumerated lists, instead of coding the numbers by hand. Such cross-references are best done via \usepackage{enumitem}. As one example, this package empowers you to do the following in typesetting an algorithm.\begin{enumerate}[ref=Step~\theenumi] \item\label{s1} Proceed to \cref{s2}. \item\label{s2} Go to \cref{s1}. \end{enumerate}To get typeset
- Proceed to Step 2.
- Go to Step 1.
\begin{assumption} \label{ass} Assume the following. \begin{enumerate} [ref=Assumption~\thetheorem.\theenumi] \item\label{a1} This is \cref{a1}, \item\label{a2} and this is \cref{a2} \end{enumerate} \end{assumption}To get typeset something like
Assumption 3. Assume the following.
- This is Assumption 3.1,
- and this is Assumption 3.2
Collaborating with mature age people
Some of your collaborators use the original LaTeX command \ref{} for cross-referencing. I recommend you then also include the following in the preamble, after the \usepackage{cleveref}:\let\ref\cref \let\eqref\cref \let\autoref\crefThese commands automatically map older cross-referencing commands to the modern \cref.
Hypertext linking
See video discussion 33A feature of LaTeX is the ability to automatically insert hypertext links within a document:
- the \cref{} command puts in a clickable link to the referred object;
- the \label{} command automatically inserts a target;
- table of contents, footnotes, citations, and so on, all generate appropriate hyperlinks,
Warning: the .toc files generated with and without hyperref may be incompatible, so best to delete the current .toc file before using hyperref.
Bibliography
See video discussion 34A 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 (for reports or books, use \bibname instead \refname).
Achieve citations in the text to the bibliography items by the command
\cite{bib-name}This typesets the number of the bibitem in square brackets as seen in Src/fractals24.tex.
Generally put a non-breaking space before the cite command as in
Mandelbrot~\cite{Mandel}...
The actual citation has no meaning
Avoid the odius perversion, that somehow has spread throughout modern writing, of using citations in your sentences in the form "in [2]" or "by [3]". The bracketed number of a citation is just a pointer to more information. The bracketed number must not be part of the meaning of the sentence.- Bad "as expressed in the following ditty by~\cite{Rich}."
- Good "as expressed in the following ditty by L.~F. Richardson~\cite{Rich}."
- Bad "correlation coefficient, refer to \cite{zim1986}"
- Good "correlation coefficient~\cite{zim1986}"
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 plain text 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 JabRef appears OK for preparing and maintaining such a databasealthough I use BibDesk on a Macintosh. Packages Mendelay or with Zotero promise a more complete functionality that you may prefer. - Then whenever you prepare a document, instead of
thebibliography environment, include the
commands
\bibliographystyle{plain} \bibliography{ajr}
Use \cite{...} as normal within the document. - Lastly, after executing LaTeX at least once, execute the
program bibtex (it looks in the .aux file to
determine what references are needed) which creates a
.bbl file. Subsequent executions of LaTeX read
this .bbl file to typeset 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. The big advantage of Harvard style is that the citations are mostly invariant: "Smith (1987)" means the same (mostly) in each article that a reader reads; whereas "Smith [13]" means different things in different articles; and lastly, "[13]" is completely meaningless to a reader.In LaTeX, obtain a Harvard style of citations as follows, 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 ``Australian Government Style Manual'' 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};
- 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 cite the work.
- Finally, the default style for URLs in natbib is very ugly. So in the preamble after \usepackage{natbib} and \usepackage{url}, include the statement \let\harvardurl\url
As for the bracketed citation style, the parenthetical
form is just a pointer to more information and must not
contribute to the meaning of the sentence. Also avoid
physically impossible statements such as as predicted in
Rosenblat (2001)
; instead use as predicted by
Rosenblat (2001)
.
Collaboration with BibTeX
See video discussion 35In your first use of LaTeX you will probably be working on your own, in which case ignore this subsection. But as soon as you start to collaborate on writing, then come back and read this.
Collaboration with BibTeX is only reasonable with the following which merges from all your collaborators the relevant bib entries from their database into the common database bibexport.bib for the particular article you are collaborating on.
- Ensure your system has the script bibexport or bibexport.sh ---it comes with most LaTeX systems.
-
Say three people are collaborating: you are Alice with
collaborators Bob and Eve, and you each have separate bib
files say alice.bib, bob.bib and
eve.bib, respectively. Then, in your LaTeX source,
say doc.tex, include a line for each collaborator
of the following form,
\bibliography{bibexport,alice} %\bibliography{bibexport,bob} %\bibliography{bibexport,eve}
- Execute LaTeX on the source (which records in doc.aux the bibfiles to use).
- Execute bibexport doc (usually via a terminal application) which merges into the local file bibexport.bib the necessary bib information from itself (first) and alice.bib (second). Ignore warnings about duplicated bib entries.
- Execute bibtex doc to get the new doc.bbl file generated, and away you go as usual.
- When your collaborators want to merge in information from their personal bibfiles, bob.bib and eve.bib respectively, then they uncomment the bibliography line for themselves, comment out the other bibliography lines, and then proceed as above.
-
One can even choose the bibliography command automatically
by lines in the source doc.tex such as
\IfFileExists{alice.sty} {\bibliography{bibexport,alice}}{} \IfFileExists{bob.sty} {\bibliography{bibexport,bob}}{} \IfFileExists{eve.sty} {\bibliography{bibexport,eve}}{}
provided each individual has a personal style file implementing their personal preferences for style!
Gather bibliographic data via Zotero
To find articles, one often searches the internet: use "Google Scholar" rather than just Google or other web search engine (as they are too indiscriminant).Once found on the internet, mostly it is good to use Zoterro (an App + plugin to browsers) to download the article and the bibliographic information (despite occasional failure). Then a right-click to "Export Item(s)..." saves bibliographic info in a *.bib file: edit and merge with your own database.
BibLaTeX replaces BibTeX
This is a new more powerful and flexible method for citations from .bib data. Build your bibliography and citations via the usual LaTeX-BibTeX-LaTeX cycle. But in the preamble of your documents do the following (or set this up in your style file).-
Essential
% Use biblatex for the bibliography \usepackage[backend=bibtex8 ,style=authoryear % for Harvard-like % ,style=numeric % for Vancouver-like ,backref=true % optional ]{biblatex}
Omit backend=bibtex8 if the default (biber) works for you. -
Essential: in the preamble tell BibLaTeX your
.bib files (in a comma separated list).
\bibliography{...}
-
Essential: tell BibLaTeX to typeset your bibliography at the
end of the document (or else explicitly tell it where). Line
breaks are sometimes problematic in a bibliography, so avoid
with ragged right justification.
\AtEndDocument{{\raggedright \printbibliography}}
-
Optional: DOIs are to be preferred over
URLs, and if you know both, then surely
you only need to typeset the DOI.
% Further, only print url info if there is no doi \DeclareFieldFormat{url}{% \iffieldundef{doi}{% \mkbibacro{URL}\addcolon\space\url{#1}}{}} \DeclareFieldFormat{urldate}{% \iffieldundef{doi}{% \mkbibparens{\bibstring{urlseen}\space#1}}{}}
-
Optional: the variety of citation packages illogically use
different LaTeX commands for cites! So depending upon
habits of collaborators, your past practice, and publishers,
you may need this hack near the end of the preamble.
% Map various illogical cites to biblatex cites!! \let\citet\textcite \let\citep\parencite \makeatletter% omit these 3 lines if not Harvard-like \def\cite{\@ifnextchar[{\parencite}{\textcite}} \makeatother
Divide and conquer 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.