In my last post I discussed the awkward natbib package. That was pretty bad. Now natbib is actually the old fashioned way of referencing. The advantage: it does the job for simple tasks. The disadvantage: everything else. So here's the hip new way of referencing: biblatex.
Yes, I'm being a cynic here. It's a big mess again. But for all of you who like a decent walkthrough, here you are.
Compiling BibTex
First of all, biblatex relies on the biber code, not bibtex. This means that you have to reset your editor to instruct biber where it asks for the bibtex path. Obvious? Not at all. I use TexMaker.- On a Windows machine: options > configure TM > commands > bibtex %
- On the Mac: same, ending in > usr/texbin/bibtex % (or something like that. No .aux!)
Next, you'll need a sequens of parsing. I do this, repeating step 2 and 3 twice if it doesn't work the way I expected.
- pdflatex
- bibtex
- pdflatex
- view pdf
Note that you can define the parsing sequens as a user command in TexMaker/TexStudio.
Citing in line and bibliography
Ok, so let's turn back to your .tex file. You'll basically need this syntax in the preamble (before \begin{document}:
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa, natbib=true]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
%\addbibresource{/Users/username/folder/database.bib} %MAC
\addbibresource{D:/folder/database.bib} %PC
There's no need to specify backend=biber in the biblatex options, yet it does no harm. The standard style is numeric, an alternative is authoryear-comp, or you can follow some journal style, like the APA in this case. Because of the biblatex-apa call here, we need babel, csquotes and \DeclareLanguageMapping. You can change american for a language of your choice, such as dutch, german or french. Do this everywhere it appears in this block of syntax. Do not use multiple languages. This is a shame, as many non-English authors may want to quote in English. Well, you can't.
In the body of your text, after \begin{document} you use the biblatex commands \cite, \textcite and \parencite, or the old natbib commands \cite, \citet and \citep for reasons of compatibility or demands from the publisher. To make the latter work, I specified the option natbib=true. there are a number of other options, such as the suppression of urls and ISBN or DOI numbers, you may want to add.
Before \end{document}, you put \printbibliography. This generates a bibliography, with appropriate translation: 'october' (EN) becomes 'oktober' (NL) in datas, 'references' becomes 'referenties' as heading, etc.
It took me a full day to find this out. I hope you found this post quick enough to keep some time for the real work.
End note
If along the way you get stuck, three things you may want to do:
- Update your editor and your packages. Use TexLive. It's a fat ugly program, but it's made to be updated (the program you need is texutility on OS X and tl-tray-menu on windows)
- Restart your editor. Sometimes it remembers old lines for no reason.
- Erase all latex files except the database (.bib), the text (.tex) and maybe the pdf to save your ass if you miss out on the first two.