[Tex/LaTex] Mac OS LaTeX install not compiling bibliography

bibtexmacmactex

I have recently installed LaTeX on my Mac using the standard MacTeX package. I have 2 documents (my thesis and a paper I'm writing) and I have tried to compile both.

Neither will compile the references or the bibliography… I keep getting the same error

Citation undefined,
Undefined references,

I have the following code

testDoc.tex:

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[applemac]{inputenx}     

\begin{document}

This is my first document with a bibliography generated by Bib\TeX. Now I cite an article by Duffie\cite{Duffie2001}.

\bibliographystyle{plain}
\bibliography{foo}    

\end{document}

In the same folder I have a foo.bib file.

foo.bib

@BOOK{Duffie2001,
title = {{Dynamic Asset Pricing Theory}},
year = {2001},
author = {Duffie, Darrell},
edition = {3}
}

Please note that this is just a simple example. My thesis has 100 references and my paper has 48.

When I compile that simple document it gives me the error :

LaTeX Warning: Citation `Duffie2001' on page 1 undefined on input line 7.
No file testDoc.bbl.

However I have not referenced a file testDoc.bib but foo.bib

If I rename foo.bib to testDoc.bib I get that same error.


Things I have tried

  • I have tried 3 different editors each has the same error, Texmaker is my favourite and is the one I'm trying to get working
  • I have checked the settings to ensure that Texmaker is pointing at the bibtex program, it is (I think) /usr/local/texlive/2012/bin/x86_64-darwin/bibtex %.aux

Could anyone point me in the right direction?

Best Answer

Seems like you din’t run bibtex but only (pdf)latex, right?

LaTeX cares for typsetting the bib but you need another program (bibtex) to preprocess your .bib to be used by pdflatex. That means that you’ll need the following steps to get a bibliography

  1. Create you tex file and the bib file.
  2. Add the bib to your document with \bibliography
  3. Run pdflatex mydoc.tex to get a first version of your document knowing which entries of your bib are needed
  4. Run bibtex mydoc to let bibtex do the preprocessing based on the aux file. That’ll generate mydoc.bbl including all information that pdflatex needs
  5. Run pdflatex mydoc.tex again to get the new bbl file included in your document

For further information please consult any (good) book about LaTeX this is a basic topic and should be explained there.


Pleas note that bibtex is kind of outdated. The better way is to use biber in combination with the package biblatex, which provides a great tool to format your citations and bibliography.