TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Precisely what is the "protocol" between LaTeX and BibTeX?

That is, if I run latex foo, bibtex foo, and latex foo, exactly how does information flow from LaTeX to BibTeX and back?

My current guess is that the data flows are as follows:

  1. LaTeX generates the file foo.aux.
  2. BibTeX reads the file foo.aux. It only pays attention to lines of the form \citation{...}, \bibstyle{...}, and \bibdata{...}.
  3. BibTeX generates the file foo.bbl.
  4. When LaTeX notices that foo.bbl exists, the \bibliography command behaves like \input{foo.bbl}.

Is this accurate or is there more to it? For example, is \citation{...} always precisely one line of text?

Are there some commonly used document classes and packages that affect the protocol somehow? Obviously with biblatex things will be different, but is there anything less obvious to be aware of?

Background: I am interested in writing a script that I could use as a drop-in replacement for BibTeX (in the sense that from the LaTeX side, nothing would change, but the generation of the foo.bbl file would be different).

share|improve this question
up vote 14 down vote accepted

Your guess is more-or-less correct, including the fact that biblatex alters the approach a bit (other packages modify it also, but not to the same degree). Taking the simplest case of a single .tex file without any requirement for multiple bibliographies or similar:

  • \bibliographystyle writes the \bibstyle{...} line to the .aux file: this can therefore be given in the preamble
  • \bibliography writes the \bibdata{...} line to the .aux file, and also inputs the .bbl file, if it is available.
  • \cite writes a \citation{...} line to the .aux file, and also creates the citation in the LaTeX document
  • \nocite writes a \citations{...} line to the .aux file, but does not do anything in the LaTeX document.

When BibTeX reads the .aux file, it looks for one \bibstyle line and one \bibdata line along with multiple \citation lines. It will then write a .bbl file, but what goes in there depends on the instructions in the .bst file. The usual convention is that the .bbl file will contain just the bibliography environment which holds formatted citations, although this is not always the case.

There are many additions which can be made to this workflow. For example, biblatex defines \bibliography to be used in the preamble, as it does not work with a .bbl file containing data for printing directly. Multiple bibliographies may be created by using more than one .aux file to create a set of .bbl files. I've also seen an implementation where an XML version of the bibliography is written as a LaTeX 'comment' within the .bbl file. These approaches still use the same underlying interface, in the sense that BibTeX is still looking for the same commands in the .aux file and writing a .bbl file.

Taking the example of multibib, at the LaTeX end it defines a set of commands for each new type of bibliography, for example

\newcites{sec}{Secondary Literature}

creates a new citation command


These new commands write to a separate .aux file from the main one, which means that BibTeX has to be run twice, once on the \jobname.aux file and once on the sec.aux file. This will generate two .bbl files, \jobname.bbl and sec.bbl, which are then read as normal by \bibliography and \bibliographysec, respectively. Thus the overall process is almost unchanged from the standard case, but there are simply more files involved.

share|improve this answer

yes, for the default case with one aux file. But there can be 2 or more aux files, eg using multibib or chapterbibor ... Withmultibib you have to run the main aux file and the one which is defined by the user; it also has the extension .aux For chapterbib you have one aux file per chapter. both cases are easy to handle: bibtex *.aux. Same for package bibunits.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.