[Tex/LaTex] Unable to generate references using .bib in Texlipse

bibliographiesbibtexerrors

I'm writing a LaTeX file using Texlipse.
So here is my LaTeX file:

\documentclass[10pt,psfig,letterpaper,twocolumn]{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{natbib}
\usepackage{verbatim}
\usepackage[scaled=0.9]{helvet}
\singlespacing
\paperwidth 8.5in
\paperheight 11in
\oddsidemargin 0in
\headsep 1.3cm 
\geometry{left=0.75in,top=0.75in,right=0.75in,bottom=1in}
\textwidth 7in 
\textheight 9.25in
\columnsep 0.4in
\footskip 0in 
\renewcommand{\bibname}{REFERENCE}
\pagestyle{empty} 
\begin{document}
\bibliographystyle{acm} 

\title{\fontfamily{phv}\selectfont{\huge{\bfseries{Title here}}}} \author{
{\fontfamily{ptm}\selectfont{\large{\bfseries{author name}}}}\thanks{contact
info }}

\maketitle
\thispagestyle{empty}

\section*{\fontfamily{phv}\selectfont{\normalsize{\bfseries{Section name}}}}

\begin{figure}
\centering
\includegraphics[width=3in]{fig1.png}
\caption{Caption}
\label{Fig.1}
\end{figure}

\pagebreak[4]
\vspace*{5.52in}
\bibliography{ref}
\end{document}

and here is my .bib file:

@BOOK{notsurewhatitisfor,
   author = "Author's name",
   title = "Book's title",
   publisher = "Springer",
   year = 2011
   }

@Article{notsurewhatitisfor,
  author =       {author's name},
  title =        {article's title},
  journal =      "EEEE",
  year =         {2011},
  volume =    {1},
  number =    {1},
  month =     {},
  pages =     {4-27},
  note =      {},
  annote =    {}
}

The bib file is named ref.bib and was copied to the same folder with the .tex file. However, I have nothing generated in the References section.

Here is the message in the console that I think is relevant:

pdflatex>(./document.bbl
pdflatex> 
pdflatex> Package natbib Warning: Empty `thebibliography' environment on input line 3.
pdflatex> 
pdflatex> )

I noticed that the document.bbl in the tmp folder is empty.
Can someone please let me know where the problem is?

Best Answer

To get something in the references, you have to cite it. The generic command for this is \cite, and the argument to the command is what you have called notsurewhatitisfor in your bibfile. In other words, you want this key to be different for each entry in your bib-file, and then you can use \cite{notsurewhatitisfor} to cite that article/book/whatever.

If you don't want to put a reference in your text, just fill up the References section with all the entries in your bibfile, you can use \nocite{*}.


Another thing to note, is if one doesn't use an IDE/script that handles the compilation sequence, one has to compile the document in four steps to have the bibliography and citations show up correctly. TeXlipse does this for you, but if it didn't, you would have to go through the following sequence:

pdflatex file.tex
bibtex file.aux
pdflatex file.tex
pdflatex file.tex

Roughly what happens is this:

  1. On the first run of pdflatex (or latex, xelatex, lualatex), every occurrence of a \cite command will be written to a temporary file, called file.aux.

  2. When you run bibtex on this file (specifying the file ending, .aux isn't necessary), the BibTeX program will find all these occurrences in the .aux file, find the entries in the .bib file corresponding to them, and write a .bbl file that contains the References section, with the entries sorted according to the bibliography style you have chosen.

  3. On the second rund of pdflatex, this .bbl file will be read, and the References section will be printed in the document.

  4. On the final run of pdflatex the citations will be put in.

As mentioned, I guess TeXlipse does all of this for you automatically if necessary, but I thought it could be nice to add a quick explanation of what's happening.