How to reference with Bi­bla­tex and TeXworks

I am now at the University of York, studying for a MSc in Advanced Computer Science. It has been interesting to see how different universities do different things. An example of this is report writing. Before York I had never heard of LaTeX (pronounced lay-tech).

LaTeX is basically a word processing system that produces high quality documents (mostly in PDF format). It’s different to your average word processor, such as Microsoft Word, because it is written like programming code. You write your document in source code and compile it into your final document. The advantage here is that you don’t worry about the formatting of the document while you write. You choose what to write in the code, so you’re more likely to get the output you want.

I am using MiKTeX for Windows and TeXworks as my GUI editor. It took me a whole morning to work out how to do citations and references, something that’s important for University documents. The information is on the internet but it’s all scattered. I want to help give clearer instructions in one place so hopefully someone might see this next time and not have to figure it out for themselves.

So, here is some help on how to get references working in TeXworks. I assume that you already have at least a basic knowledge of how to use LaTeX, and have looked at how to do referencing in general (this is a useful site).

LaTeX uses packages to handle references. Your document needs to be extended to output references properly. We’re going to use Biblatex and Biber as the engine for this. As far as I know, this is the newest method of doing references in LaTeX. In the preamble of your document add this:

\usepackage[backend=biber, style=ieee]{biblatex}
\addbibresource{references.bib}

‘references.bib’ is the file where the bibliography database is stored. You should put it in the same directory as the .tex file. You’ll also want to set the referencing style (here I’ve chosen IEEE). Then add:

\printbibliography

where you want the bibliography to be displayed in your document. Don’t forget to use \cite{} when you want to reference a source somewhere.

Now, in TeXworks, go to Edit > Preferences > Typesetting

LaTeXsettings

Click the plus button to the right of ‘processing tools’ to add a new one. Biber, the backend used to process the bibliography, needs to be added to the list of tools as it’s not in there by default (or it wasn’t in mine). Luckily MiKTex comes with Biber and can be found in (<install location>/miktex/bin/biber.exe). I’ve heard it is not included in the 64-bit version but haven’t checked myself.

Add the tool as shown in the screenshot. Add $basename to the arguments, as this provides the program with the location of your .tex file to be processed. Press ‘OK’ to those windows and return to your document.

If you’ve written your LaTeX document properly, you’re good to go. You need to run the tools in a specific order (from the dropdown box in TeXworks). To compile your document into a PDF:

  1. Run pdfLaTeX
  2. Run Biber
  3. Run pdfLaTeX again

After the third time, the citations and bibliography should be correctly displayed in your PDF. You won’t have to run Biber again unless you change your bibliography file.

That’s it! There’s lots of other ways of doing this, but I believe this is the most up-to-date method, (using Biblatex and Biber). I’m interested to see how I get on with LaTeX in larger projects - kinda wish I knew about it in Hull for my dissertation. Oh well, that’s all for now.