Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

Using BibTeX

📅 2011-Aug-23 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ bibtex, latex ⬩ 📚 Archive

BibTeX is used to add citations to a LaTeX document. Using it along with a LaTeX document is a bit unconventional. It is illustrated below with a simple example.

  1. Assume, the LaTeX document is Main.tex and the bibliographic records have been placed in a file named References.bib.

  2. Add a bibliographystyle command to Main.tex to indicate the bibliography style to use. For example, to use the default plain style use:

  1. Add a bibliography command to Main.tex to indicate the file containing the bibliographic entries to be used. Multiple bibliography files can be specified (separated by commas) and the .bib file extension is dropped. For example, add this line to Main.tex:
  1. Compile Main.tex. For example:
pdflatex Main

It will compile, but will output warnings that there were undefined references. The compilation produces a Main.aux file.

  1. Run BibTeX on Main.tex:
bibtex Main

This is one of the confusing aspects of BibTeX: it is run on the LaTeX file and not on the bibliography file! 😁

BibTeX will look for the Main.aux file, look at the undefined references in it and try to resolve them using the bibliography file(s) indicated in Main.tex.

BibTeX produces a file named Main.bbl, which is a database of references.

  1. Compile Main.tex (just like in step 4). It will still complain about undefined references.

  2. Compile Main.tex again (you heard it right!). The output file now should have its citations correctly.

To summarize, here are the commands for Main.tex and References.bib:

pdflatex Main
bibtex Main
pdflatex Main
pdflatex Main

Tried with: MikTeX 2.9