6

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?

2
  • 2
    The linked file seems to contain no \cite commands: do I understand this correctly? If so, you need some citations for LaTeX/BibTeX to actually include anything in your bibliography.
    – Joseph Wright
    Dec 9, 2011 at 16:48
  • to me the issue was I didn't actually use the citation I inserted, so it didn't put it in the bibliography in the pdf... Dec 11, 2020 at 22:21

1 Answer 1

12

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.

4
  • Thanks a lot Torbjorn. Not only you helped me fix the error but also you helped me understand what the 'notsurewhatitisfor' is for :)
    – chepukha
    Dec 9, 2011 at 16:56
  • 1
    @chepukha: Welcome to the wonderful world of LaTeX! The neat thing about the default behaviour is that you can have a giant bib file with everything you've ever read in it, and LaTeX with BibTeX will pick out only the relevant articles (i.e. the ones you cited with cite or asked to be put in with nocite).
    – qubyte
    Dec 9, 2011 at 17:15
  • Thanks, Mark. So I used \cite{*} to cite everything from my .bib file and for some reason, there is a symbol '(0)' at the end of my references list. I wonder how I can get rid of that '(0)'? Any suggestion please?
    – chepukha
    Dec 9, 2011 at 18:44
  • @chepukha As mentioned, to put everything in the bib-file in the References section, without adding citations, use \nocite{*}, not \cite{*}. I can't say why you get a "(0)" though. Dec 9, 2011 at 18:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .