An Example of Using bibtex to Manage References

Bibtex is powerful system where you build up a database (or subject specific databases) of references for use with latex. Using latex and bibtex, only the references you cite within your document will appear in the references. This eliminates much tedious cross-checking. An example of using latex and bibtex is given below:

Cut and paste the following latex document into a file called bibtex_example_new.tex


\documentclass[a4paper,12pt,fleqn]{report}
\usepackage{graphicx}
\usepackage{/export/home/rahm/docs/aas_macros}

\begin{document}

\section*{Introduction}

Here is short introduction to using Bibtex and here is an example
reference \cite{Kluckers97}.

% Bibliography appears wherever \bibliography command is, but must be
% after \begin{document} and before \end{document}

\bibliographystyle{unsrt}

\addcontentsline{toc}{chapter}{References}

\bibliography{refs1,refs2}

\end{document}

Now go to ADS and search for a paper, eg those by author "Kluckers" and you will get 7 papers, click on the second reference, and scroll down to the end of the page where is says "Bibtex entry for this abstract", click on that button. Cut and paste the reference entry (shown below) into a file called refs1.bib created using an editor like emacs or nedit.
@ARTICLE{1997MNRAS.284..711K,
   author = {{Kluckers}, V.~A. and {Edmunds}, M.~G. and {Morris},
R.~H. and 
{Wooder}, N.},
    title = "{Reality and the speckle imaging of stellar surfaces -
II. The asymmetry of Alpha Orionis}",
  journal = {\mnras},
     year = 1997,
    month = jan,
   volume = 284,
    pages = {711-716},
   adsurl =
{http://ukads.nottingham.ac.uk/cgi-bin/nph-bib_query?bibcode=1997MNRAS.284..711K&db_key=AST},
  adsnote = {Provided by the Smithsonian/NASA Astrophysics Data
System}
}
The first field "1997MNRAS.284..711K" is your nickname for the reference, it would make sense to edit this to something more memorable, eg "Kluckers97" in the .bib file. So do this, and now your refs1.bib file should look like this:

@ARTICLE{Kluckers97,
   author = {{Kluckers}, V.~A. and {Edmunds}, M.~G. and {Morris},
R.~H. and {Wooder}, N.},
    title = "{Reality and the speckle imaging of stellar surfaces -
II. The asymmetry of Alpha Orionis}",
  journal = {\mnras},
     year = 1997,
    month = jan,
   volume = 284,
    pages = {711-716},
   adsurl =
{http://ukads.nottingham.ac.uk/cgi-bin/nph-bib_query?bibcode=1997MNRAS.284..711K&db_key=AST},
  adsnote = {Provided by the Smithsonian/NASA Astrophysics Data
System}
}
Now we need to run latex, bibtex, then latex again to pick up the reference. Sometimes we need to run latex 3 times to make sure all changes to references are assimilated. One way to do this is to use a script. For example make a file called dolat with an editor, put the following commands in it:

bibtex $1
latex $1
\rm $1.ps
dvips -f $1 > $1.ps
ghostview -magstep -2 $1.ps
bibtex $1
Change the permissions to make the file executable, "chmod +x dolat", then run the command "./dolat bibtex_example_new"

The bibtex database (the .bib file) can be managed in a number of ways. Xemacs has a colour coded mode for editing .bib files or you could use the very useful tkbibtex command.

Note 1: You can use journal style files for putting your references and citations in a specific format. If you have copy of the aas_macros.sty file then you can use abbreviations for journal names, such as "mnras" for "Monthly Notices of the Royal Astronomical Society".

Note 2: Often a journal will set up all the reference and citation formats when you use the documentclass line at the top of the .tex file eg for MNRAS "\documentclass[usenatbib]{mn2e}" and later "\bibliographystyle{mn2e}" or for A\&A "\documentclass[twocolumn]{aa}" and later using "\bibliographystyle{aa}".

Note 3: If you are writing a long document with many chapters, for example a thesis, you could have store references for each chapter in a different .bib file. As long as the names of the files are included in the "\bibliography" line this can be any number of .bib files.


Rhys Morris
Last modified: Wed Jun 29 12:41:54 BST 2005