Norwegian version of this page

Reference management in LaTeX

At UiO, you can use the web-based LaTeX editor Overleaf in its premium version, which you can connect to Zotero. You can also use Zotero if you work in a desktop LaTeX editor. Here, you will get help with both options. Regardless of your choice of editor and reference management tool, it is recommended that you use the BibLaTeX package to manage your references.

Integrating Zotero with Overleaf

At UiO, you can use the web based LaTeX editor Overleaf in premium version (log in with UiO's SSO) to work with LaTeX documents. You can also use Zotero if you are using a desktop editor for LaTeX.

After you have completed the set-up steps for Zotero integration, you will have access to various integration functions:

  1. Zotero Sync
  2. Zotero-linked .bib file
  3. Advanced reference search

Advanced reference search searches all the references you have linked to Zotero and makes it easy to cite with autocomplete. Use this advanced feature in combination with one of the other two solutions which will sync/refresh with the changes you do in Zotero. Follow the links above to set up.

How to set up a project

In this example, I have chosen to connect a Zotero-linked .bib file  to a project. I link to the .bib file under File → File upload → From Zotero. I name the .bib file references.bib. In the preamble, after I have specified documentclass, I add the following commands:

\usepackage{biblatex} %This imports the BibLaTeX package, which is a newer and better package for references than the older BibTeX system.
\addbibresource{references.bib} %This adds the .bib file that I have linked to.
\begin{document}

Here I can begin to write and cite with

\cite{…}

At the bottom I will add the refrence list

\printbibliography %This generates the reference list
\end{document}

In the end I click Recompile to make Overleaf compile the commands and generate a PDF.

BibLaTeX is the recommended package for reference management instead of  the older BibTeX system. Biblatex operates with biber as the backend program where biblatex takes care of how the references appear in the document while biber is the engine running in the background, sorting and processing your reference data. When you recompile, biber is activated and must therefore be available in the editor, which it is in Overleaf, where it is the default engine for processing reference data. 

Overleaf guide

Working offline with Overleaf

Overleaf can be used with UiO Dropbox. This means that you can work offline and synchronize with UiO Dropbox, or clone the document using Git, edit it, and synchronize the changes when you are back online. (UiO cloud services)

Setting up a project with more commands 

Here is a more detailed example of how you can set up a preamble in an editor:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{csquotes,graphicx}
\usepackage[backend=biber, style=numeric, sorting=none]{biblatex}
\usepackage{hyperref}
\addbibresource{references.bib}
\title{...}
\author{...}
\date{...}
\begin{document}
\maketitle
Her kan du begynne å skrive og sitere med \cite{...}
\printbibliography
\end{document}

Explanation of commands

  • \documentclass{article} Specifies the type of document you are creating—an article in this case. You can find an overview of different document classes here: https://www.ctan.org/topic/class
  • \usepackage[T1]{fontenc} Fontenc ensures the correct font encoding, and [T1] allows LaTeX to handle special characters—such as the Norwegian letters æ, ø, and å—properly. [T1] provides 8-bit encoding for letter characters rather than 7-bit encoding, doubling the number of possible character codes from 128 to 256. With 7-bit encoding, some special characters (such as ö) do not have their own character code and are instead composed of two characters (o + ¨).
  • \usepackage[english]{babel}  Adapts the document to the English language and automatically ensures that fixed text elements appear in English—for example, “References” instead of “Bibliography”—and enables English hyphenation rules.
  • \usepackage{csquotes,graphicx} Loads two useful packages at the same time:
    • csquotes: Handles quotation marks automatically according to the language you have selected, which is useful when quoting.
    • graphicx: Makes it possible to include images and illustrations in the document.
  • \usepackage[backend=biber, style=numeric, sorting=none]{biblatex} Loads BibLaTeX for reference management, with three additional settings:
    • backend=biber: Sets Biber as the backend program for BibLaTeX.
    • style=numeric: Uses numbered citations (numeric style), for example [1].
    • sorting=none: Sorts sources in the bibliography in the order in which they appear in the text, rather than alphabetically.
  • \usepackage{hyperref} Turns all citations, table-of-contents entries, and web addresses into clickable hyperlinks in the PDF file.
  • \addbibresource{references.bib} Tells LaTeX where your sources are stored—that is, in which file. It specifies that your references are in a separate file called references.bib, located in the same folder as the .tex file.
  • \maketitle Retrieves the information entered in title, author, and date, and creates a title block using this information.
  • \cite{…} This is the command used to cite a source.
  • \printbibliography This is the command used to print the list of cited references. The default title is “References” for the article document class and “Bibliography” for books and reports.

More options for reference styles and commands

UiO support in LaTeX and BibLaTex

If you have questions about LaTeX and Zotero, you can contact: latexguru@ub.uio.no 

Also see our course schedule: Getting started with LaTeX and Overleaf

Integrating Zotero with desktop editor

If you want to work with LaTeX in a local desktop editor, instal the recommended software for your platform:

  • Linux: TeX Live (already installed on UiO Linux machines with the editor Kile)
  • Mac: MacTeX (available on UiO machinies from Managed Software Center) (MacTeX comes with the editor TexShop)
  • Windows: MiKTeX (available for UiO machines from Company Portal and Software Center) (MikTeX comes with the editor TeXworks) 

Creating bib files with references for LaTeX

You will need a .bib file with your references. You can use a reference tool such as EndNote or Zotero (recommended) for this.

If you do not use Zotero, JabRef is another good free application for managing .bib files for LaTeX. 

Zotero plugin: Better BibTeX

Better BibTeX is a recommended Zotero plugin for LaTeX. Better BibTeX is particularly useful if you use a desktop editor as it can keep exported .bib files automatically updated (Overleaf has its own functionality for this). Better BibTeX also ensures stable citation keys. 

Exporting bib files from Zotero to LaTeX

  1. In Zotero, go to File → Export Library...
  2. Select Better BibLaTeX as the format if you have installed the Better BibTeX add-on; otherwise, select BibLaTeX.
  3. Place the exported .bib file (for example, references.bib) in the same folder as your .tex file (for example, mythesis.tex).
  4. With the Better BibTeX add-on for Zotero, the .bib file will update automatically when you make changes in Zotero.
  5. In a local desktop editor, use Biber as the backend program for BibLaTeX.
It is very important that the .tex file and the .bib file are in the same folder. 
MyThesis/
├── mythesis.tex
└── references.bib 

Settings and commands

In TeXShop for Mac:

  • Go to settings → engine → write biber in the box for BibTeX Engine

TeXworks for Windows:

  • TeXworks comes with biber as an option in the dropdown menu for LaTeX compilation

Kile for Linux: 

  • Kile comes with Biber as an option under Build in the menu for LaTeX compilation

In the preamble of your .tex file, after you have specified documentclass, activate the biblatex package with biber as the backend program:

\usepackage[backend=biber]{biblatex} 
  • When you begin to write and cite, you must compile to see your changes. 
  • You must run biber between the pdflatex runs when you change your references.

Compiling in TexShop for Mac: Go to Typeset in the menu

Select LatTeX,
then BibTex (which in settings you have set to run biber),
then LaTeX again,
repeat LaTeX.

Compiling in TeXworks for Windows: In the dropdown manu next to the green play button:

Select pdfLaTeX and push the green button.
Select Biber and push the green button.
Select pdfLaTeX again and push the green button.
Repeat pdfLaTeX.

Compiling in Kile for Linux: Kile has better support for automating the compilation process. For compiling go to Build in the menu and run

Build → Compile
Build → Biber
Build → Compile
Build → Compile

If Kile has Latexmk in the Build menu, this is the simplist option. Latxmk will run all the necessary compilation steps automatically, including Biber, when your document uses backed=biber. 

Build → Compile → Latexmk