[Tex/LaTex] Why does bibtex not compile

bibtex

I have added the bib file refs.bib to the directory but I get errors indicating that the references are undefined.

foo.tex:

\documentclass[10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{natbib}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{fullpage}
\setcounter{secnumdepth}{2}
\date{}
\title{The Database Users Guide}
\author{Me}
\begin{document}
\maketitle 
%...document body
\ref{author2000}

\bibliographystyle{plainnat}
\bibliography{refs}

%... some figures and tables
\end{document}

refs.bib:

@article{author2000,
author = {someone},
journal = {Journal},
number = {1},
pages = {1--2},
title = {{Title}},
volume = {4},
year = {2000}
}

Best Answer

in your document you make a reference to a label:

\ref{author2000}

This label does not exist, hence the reported error.

While what you want is a reference to a bibliographic item:

\cite{author2000}

so, do:

  1. [optional] clean up your compilation files (foo.aux in particular)
  2. run latex (detects a citation)
  3. run bibtex (formats the citation)
  4. run latex (makes the link)
  5. run latex (you are done)

this sequence is for understanding how it works. When concentrating on writing a paper for instance, there's a lot of tools to automate this (try F1 in texmaker or command-T in texshop for instance)

Related Question