LaTeX is great for writing formal reports like a study project report, bachelor thesis, or master thesis. In this article, I will explain how Harvard referencing can easily be implemented in 'tex documents.
This article is based on a document from the University of Bath Library that lists their recommended Harvard referencing style.
Bib-file
First of all, you will need to add a new .bib file to your LaTeX project root. This file will hold all your references. In this example, let's call it resources.bib
@online{djangoDocMigrations01,
author = {docs.djangoproject.com},
year = {2024},
title = {Migrations},
url = {https://docs.djangoproject.com/en/5.0/topics/migrations/},
urldate = {2024-05-23}
}
Most of the fields are self-explanatory except for the difference between year and update. "Year" is the year the article was written. "urldate" is the date you visited the URL.
Setup
Once the .bib file is created, it can be used in your .tex document. Add the following to the top of your .tex before the \begin{document} statement in your document:
...
\usepackage[style=bath,sorting=ynt]{biblatex}
\assignrefcontextentries[]{*}
\addbibresource{resources.bib}
\newrefcontext[sorting=nyt]
\begin{document}
...
To print the list of references at use the \printbibliography function at the end of your document like this.
...
\printbibliography
\end{document}
This will make the reference list look like this:
Screenshot from resulting PDF
Using references
To actually use the references in your document, you can use the \autocite function where you pass in the name of your reference, like this:
...
\section{Citation test}
First, some text that has no citation, then "Migrations are Django’s way of
propagating changes you make to your models (adding a field, deleting a
model, etc.) into your database schema."\autocite{djangoDocMigrations01}
Here comes some more text that has no citation...
...
The resulting PDF will look like this.
Screenshot from resulting PDF
For more examples of using Harvard referencing in LaTeX documents, please read the PDF document at the top of this article.