Setup of Mendeley with Biber/Latex and Texmaker - a short Tutorial

Setup of Mendeley with Biber/Latex and Texmaker - a short Tutorial

Published

Categories
Latex

There exist a plethora of tools for reference managment. Many of them come with support for propietary software like Microsoft's Word. If one is writing in Latex there are some challenges in finding a good reference manager that suits oneself and to make it work automatically with Latex.

There are a lot of reference managers like Endnote, Citavi or Mendeley out of which I have found Mendeley to be the easiest to use and the most convenient to setup with Latex. I use Texmaker on Linux and Windows and here I will describe the steps necessary to establish a workflow so that you can add a reference to Mendeley and then are able to immediately cite it in Latex. We will be using the Biber package which is superior to the older BibTex. This setup will provide you with all your Mendeley references in every Latex document you write on your local maschine without additional configuration.

Installing the software

You need the following software:

  • Texmaker
  • Mendeley
  • a Tex distribution installed on your system such as MikTex for Windows or TexLive for Linux

Updating your installation of Latex

To avoid incompatibilities it is often necessary to update the Tex distribution installed on your system. On Windows with MikTex just execute the programm "Update (Admin)" provided by MikTex and execute it twice to update all packages. This post on StackOverflow provides you with a step by step tutorial: How do i update my Tex Distribution - StackOverflow

Setup in Mendeley

First, create folders in Mendeley with a name for your latest project such as "PhDthesis" or "termpaper" and then add your references to it by drag and drop, with the web import or by entering them manually. Check if Mendeley correctly recognized the entry. Then go to "Tools" - "Options" and change the following settings:

Mendeley Settings

Choose any location you like on your hard drive. I chose the Dropbox folder simply for the convenience of having an additional backup. It is important that the checkbox for escaping Latex symbols is checked. Otherwise you might run into problems if one of the authors has a funny name with a special character like mine does or if an exotic character is used in one of the fields. If you don't want journal names abbreviated you can uncheck it.

How to get Latex to read in our Bibtex file

With the above settings we now have generated a bibtex file in the location we specified for each group in Mendeley. The directory (in my case C:/Users/Simon/Dropbox/BibTex) could now look as follows:

  • thesis.bib
  • termpaper2015.bib
  • PaperMethane.bib
  • ...

Now close Mendeley and go to Texmaker. Now we have to tell the Latex compiler (we'll be using pdflatex) where it can find our bib files. Texmaker is the software that calls the compiler for us which is why we have to adjust the settings there. In principle this setup works with any other Latex editor or for the command line. Just use the same commands we will now add to the Texmaker settings. Go to Texmaker, "Options" -> "Texmaker configuration" and adjust the settings as follows for the biblatex option. Also check the "Build folder" option to clean up your directory structure a bit.

Texmaker Settings

We will use biber instead of biblatex which is why the new command for biblatex is:

biber --input-directory='C:/Users/Simon/Dropbox/BibTex/' build/%

With the flag --input-directory we tell biber where to find the bib files and build/% tells biber where it can find the output of pdflatex. Adjust the input directory path to the path you chose in Mendeley. In theory you could also copy the bib file to the folder where your current document is but then you always would have to update it if you add new references to Mendeley. Say in Latex we define the name of our bib file as "thesis.bib" biber will first look in the current directory and if it is not there it will look in the --input-directory. There Mendeley will always save the updated bib files for you.

Setup in you Latex document

Now in your Latex document you have to load the biblatex package, tell it which frontend (biber) to use and where the bib file is located. These settings have to be added to every Latex document to the preamble. Just adjust the name of your bib file to the group in Mendeley you want to use.

 \usepackage[
     backend=biber,
     style=chem-acs, %style to use, other styles are nature, science or apa
     sorting=none,
     natbib=true,
     url=false, 
     doi=true, %display DOI with link
     eprint=false, %display arxiv id etc
     maxnames=25, %number of names in List of references
     maxcitenames=2, % number of names for textcite command
     autocite=superscript
 ]{biblatex}
 %Path of bib file (either in current dir or in --input-directory)
 \addbibresource{Bachelorsthesis.bib}

To cite now use the citation keys provided by Mendeley (usually AuthorYear) with the commands \textcite, \cite or \supercite and add \printbibliography in your document.