Create LaTeX/BibTeX bibliographies

RefDB integrates quite nicely with the LaTeX/BibTeX system. If you previously used a flat text file to store your BibTeX references, you will notice that there is only one additional command to run when you process your source document. Instead of keeping all of your references in a text file, refdbib will retrieve only the required references from the SQL database and store them in an intermediate text file.

  1. Prepare the document

    Use the LaTeX commands cite and nocite to include the references as usual. The extended commands from the natbib package should work as well. All these commands take an identifier for the reference as an argument. These reference definitions can come in two flavours just like in DocBook documents: Either you use the same database for all references in the text. Then you just specify the citation key of the reference and tell the processing application which database to use. Or you specify the database name with each citation. In this case, you can pull the references from different databases in the same document. The two versions look like this:

    \cite{Miller1999}
    	\cite{litibp:Myers2001}
    	

    The first version cites the reference with the citation key Miller1999 in the database passed to the processing application as an argument. The second form cites the reference with the citation key Myers2001 in the database litibp. Please note that, in contrast to SGML/XML citations, the database part is separated by a colon from the citation key.

    The LaTeX \bibliography command takes as an argument the name of the intermediate bibliography file without the extension. A simple choice would be the basename of your LaTeX document.

    Note

    Keep in mind that even if you pull references from different RefDB databases, you still need to specify only one reference database in your LaTeX document as RefDB consolidates all cited references into one bibliography file.

  2. Create the auxiliary file

    Run the latex interpreter with the basename of your document (foo.tex) as an argument:

    	  #~ 
    	  latex foo
    	

    latex will create, among other files, foo.aux. latex stores all sorts of information in these auxiliary files for later use in subsequent runs. The interesting part for us is the list of citations.

  3. Create the intermediate bibliography file

    Now RefDB enters the stage. We process the auxiliary file to create a BibTeX bibliography tailored to our document. Either we do it manually:

    	  #~ 
    	  sort foo.aux | uniq | refdbib -d mybib -S name -t bibtex > foo.bib
    	

    Note

    The .aux file should be preprocessed through sort and uniq as shown here to avoid duplicate entries in your bibliography.

    Or we use the runbib shell script:

    	  #~ 
    	  runbib -d mybib -S name -t bibtex foo
    	

    Remember that the basename of the file that receives the bibliographic information (foo.bib in our example) must match the name given in the bibliography command in the LaTeX document.

    The resulting bibliography file will contain all references that were requested from the LaTeX document. If you add more citations to this document, you have to run refdbib again to update the intermediate bibliography file (it won't hurt if you remove citations from your LaTeX document, though).

    Note

    For the sake of consistency with bibtex, it is possible (though not necessary) to specify the auxiliary file without the .aux extension (foo in the above example).

  4. Run bibtex

    From here, everything runs as you are used to from LaTeX/BibTeX:

    	  #~ 
    	  bibtex foo
    	
  5. Run latex

    Run latex on your LaTeX document at least twice to get all references right:

    	  #~ 
    	  latex foo && latex foo