The references that you include in your scientific work are of central importantance; they can serve to provide background and introductory/ learning material for your subject area, as motivation for exploring the topic of your document itself, or support the results of your work either numerically or theoretically. Needless to say, it is important to include references in your work and to manage your sources carefully. We aren't going to go into the details of how to reference professionally (in the sense of writing a document) here, instead we are going to show you how you can use $\LaTeX$ to manage your external sources and include citations in your work.
If you haven't already got a $\LaTeX$ source file to hand that you don't mind editing for the purposes of this lesson, you can download our source code from the previous lesson here.
Whilst it is possible to create a bibliograhy within your document's source file, there are several inconveniences with doing this:
\bibitem
based on the reference style you’re asked to use\bibitems
yourselfBibTeX is a helpful bibliography management tool which helps us overcome some of these problems.
Rather than writing bibliography entries in the source file, we will keep them in a separate file and ask BibTeX to handle the creation of our bibliography.
The first thing we need to do is create a bibliography file, which is a file containing text and having the extension .bib
(like how our source file is contains text and has the extension .tex
so it can be interpretted by $\LaTeX$).
References are kept in a bibliography file whose extension is .bib
, and this file consists of a list of records and fields.
Each bibliography record holds relevant information for a single reference - a book, article, website, etc.
The fields of a given record hold the information like author, title, published date, and the like.
First, let's create a bibliography file which includes some references for our main document.
NOTE: Like with the images you want to include in your document, you should save your .bib
file to the same directory as your source .tex
file.
If you are familar with paths, you can ignore this advice and insert the path to the .bib
file like we described with images.
MagicalThesisBib.bib
is our bibliography and it looks like this:
@book{rowling2001fantastic,
title={Fantastic Beasts and Where to Find Them},
author={Rowling, J. K.},
year={2001},
publisher={Bloomsbury}
}
@book{lewis2001chronicles,
title={The Chronicles of Narnia},
author={Lewis, Clive Staples},
year={2001},
publisher={Harper Collins}
}
@book{tolkien2012lord,
title={The Lord of the Rings: One Volume},
author={Tolkien, John Ronald Reuel},
year={2012},
publisher={Houghton Mifflin Harcourt}
}
@article{graham2019anatomy,
author = {Graham, William M.},
title = {Anatomy of Magical Beasts},
journal = {Magical Enquires of Muggles},
volume = {134},
number = {10},
pages = {1--2572},
year = {2019},
DOI = {"http://dx.doi.org/some_relevant_numbers}
}
MagicalThesisBib.bib
contains records in a special format.
There are many different types of record you can include, but here we have only included the two most common:
@article{}
: For journal articles or arXiv pre-prints.@book{}
: For textbooks.Notice that records are started with the @
symbol and not a backslash as in the main .tex
document.
The @article{...}
syntax itself tells BibTeX that this record is an article, and so can only contain fields corresponding to articles.
Fields are set using their keywords, followed by an =
and then putting the value of the field in curly braces { }
.
Fields are separated by commas (see the ends of the lines above) - line breaks are not necessary but they make everything look a lot nicer!
The syntax
title = {Anatomy of Magical Beasts}
sets the value of the title
field to "Anatomy of Magical Beasts", for example.
Each record has a list of required and optional fields. BibTeX will complain to you if you do not provide a value for a required field in a record, but will ignore any mising optional fields. When generating your bibliography, BibTeX will by default include as much information as you provide it, which might mean that some references print differently in the document (even if they are of the same record type) because optional information has been provided for one.
Once we have created a bibliography file, we need to link it to the source .tex
file using the command \bibliography{bib_file}
.
Replace bib_file
with the name of your bibliography, of course.
If you are using a local editor, you might even get away with not including the .bib
extension in the filename, but it's always safer to include it.
NOTE: If you didn't save the .bib
file to the same directory as your .tex
file, this is where you will need to include the path to the file too.
We also need to provide a \bibliographystyle
so that BibTeX knows how to format our references for us - in this lesson we'll stick with the unsrt
style.
Below is a minimum working example:
\documentclass{article}
\begin{document}
There are several magical animals that are yet undiscovered \cite{rowling2001fantastic} that could provide huge boons to our everyday lifestyle and working environment.
Oliphaunts \cite{tolkien2012lord} have the potential to eliminate the need for heavy construction machinery and heavy-goods transport, and provide little to no air pollution as an additional benefit.
Indeed, we can even predict the resulting pattern in the concentration of carbon dioxide in the atmosphere ($c_{atm}$) on a timescale of years ($t$) after this switch:
\begin{equation} \label{eq:CO2Reduction}
c_{atm} = c_{0} e^{-\sigma t},
\end{equation}
where $c_{0}$ is the current concentration of carbon dioxide in the atmosphere and $\sigma>0$ is the so-called ``Oliphaunt efficiency coefficient". \newline
Phoenixes, with their healing ability and ease of flight, could effectively act quickly to prevent disaster in environmental crises.
Indeed these remarkable healing properties were discussed in a recent work \cite{graham2019anatomy} which hypothesised how such an ability could have developed through the process of evolution.
\bibliographystyle{unsrt}
\bibliography{MagicalThesisBib.bib}
\end{document}
Important things to note are that we include the two bibliography commands inside the document
environment, that is not in the preamble.
When you render/ compile the .tex
file you should notice a list of references inserted at the end of the document, and your cite
commands should be replaced by the appropriate reference number that BibTeX
has assigned to each record.
Other useful features of using BibTeX to handle our sources include:
.tex
file are automatically omitted from the bibliography. This means that you can have (in theory) one master .bib
file which you use for all your documents!\bibliographystyle
will automatically reformat the reference list, and the appearance of the inline citations (\cite
commands).