BibTeX/LaTeX integration

From refbase

This page shows how to use refbase with BibTeX and LaTeX:


BibTeX import & export

refbase supports import & export of BibTeX files via Bibutils, and offers user-specific options to honour the user's existing cite keys, or to generate new cite keys from the record metadata via a flexible placeholder syntax. W.r.t. the handling of cite keys on import or export, refbase can:

  • auto-generate cite keys for:
    • all records (thus ignoring any existing cite keys)
    • all records with empty 'Cite Key' field (i.e. refbase will honour any existing cite keys specified by the user, but will generate new cite keys for all records where no cite key is available)
  • use a custom (i.e. user-specific) format when auto-generating cite keys
  • normalize cite keys, i.e. refbase can be instructed to transliterate any contained non-ASCII characters to their ASCII equivalents, or strip unwanted characters from cite keys
  • append incrementing numbers to duplicate cite keys

Generating formatted bibliographies

refbase can make formatted lists of citations and output them directly as a LaTeX (.tex) or LaTeX bibliography (.bbl) file.

By default, references are sorted by author, in which case refbase outputs a LaTeX document with the list of references contained in a {thebibliography} environment. Here's an example:


refbase can also output a .bbl variant that can be used as a drop-in replacement for the .bbl file generated with BibTeX and natbib. This may be useful in some cases, e.g. if you've designed a custom citation style that's not available as a BibTeX style (.bst) file. Here's an example .bbl output:


It's also possible to sort your reference list hierarchically, i.e. the bibliography entries can be grouped by year, record type, or first by type, then by year. In this case, refbase will output a regular LaTeX document with the group labels given as section (or subsection) titles. Examples:


Note that if you omit the citeType=LaTeX parameter from the above URLs, refbase will return your list of references as HTML. More info about the show.php API is given here and here.

Keeping a local BibTeX file in sync with a refbase online database

The 'refbase' command line client allows you to append found records to a local BibTeX file (if they don't yet exist in that file), and update existing records in that file if their modification date on the server is more recent. By default, a backup file is created before adding or changing anything in the local file, and the script will report all records that were updated or modified.

As an example, to scan a LaTeX file for any contained citations (cite keys), and update a local BibTeX file with matching records from your refbase server (taking care of any additions or updates done on the server), perform these steps:

  • Enter your citations as usual in your paper.tex file. Here's a minimal example document:





  • Run latex to create or update the corresponding paper.aux file. The 'refbase' command line client can use this file to get a list of all citations used in your LaTeX document.
  • Run the 'refbase' command line client to extract all citations from the paper.aux file, and to create or update the local paper.bib file with any matching additions or updates from the refbase server:
refbase -F=bibtex -E=paper.aux -A=paper.bib -B=1
Note that the above command requires that you have specified the refbase server URL, your login credentials as well as your refbase user ID at the top of the 'refbase' CLI script. However, these can also be given as options on the command line. Here's a working example that (when run on the above created paper.aux file) should produce a BibTeX file (paper.bib) containing the three cited records:
refbase -H= -P=user -u=1 -F=bibtex -E=paper.aux -A=paper.bib -B=1
  • Finally, run the usual bibtex, latex, latex to update the citations and bibliography section of your paper.tex file.

Let us know if you've got any further questions or suggestions.