Emacs includes bibtex-mode
for editing bibliography files used by BibTeX. Is there a way to make it support the bibliography files used by biblatex
?
[Tex/LaTex] Does Emacs support editing bibliography files for biblatex
biblatexemacs
Related Solutions
To parse BibTeX format files, Biber uses a C library called "btparse" which is, for all intents and purposes, 99.9% compatible with BibTeX. So, You should rarely have problem using Biber as a drop-in replacement for BibTeX. As mentioned by others, the issue is rather the slightly different data model which biblatex
has compared with the data model in BibTeX.
So, your question really relates to the difference in data models between plain BibTeX and BibLaTeX, regardless of whether you are using Biber as the biblatex
backend. Be aware that in the future, around BibLaTeX 2.x, BibTeX will no longer be supported as a biblatex
backend as it has too many limitations. Of course BibTeX format data files will always be supported.
The more important question is, as you mention, what the advantages of Biber might be even if you are not using any of the biblatex
data model specifics. Here are some advantages of Biber in this respect (you can get an idea by searching for the string "Biber only" in the biblatex
manual), omitting the features which require data source changes:
- Support of data sources other than
.bib
(currently RIS, Zotero RDF/XML, Endnote XML) - Support for remote data sources (
.bib
files available via ftp or http) - Support of other output formats (in 0.9.8 it will support GraphViz .dot output for data visualisation and conversion to the planned biblateXML format)
- Full Unicode 6.0 support (including file names and citation keys)
- A sorting mechanism which I think is probably as good or better than any commercial product - full Unicode, multi-field, per-field case and direction, CLDR aware and completely user configurable. BibTeX doesn't come close in this regard.
- Automatic name and name list disambiguation. I think this is quite an impressive feature.
See section 4.11.4 of the
biblatex
manual for a very good explanation of this with examples. - Completely customisable crossref inheritance rules. BibTeX has a very basic static rule only.
- Automatic encoding and decoding, including UTF-8 <-> LaTeX macros
- Very flexible configuration file "sourcemap" option which can be used to change the
.bib
data as it is read by Biber, without changing the actual data source itself. You
can use this to do all sorts of things like drop certain fields, add fields, conditionally drop/add fields, change fields using full Perl 5.14 regular expressions (see Biber manual section 3.1.2).
This last feature is particularly interesting for you as you can potentially map your pure BibTeX .bib
files into the biblatex
model on the fly as Biber reads them but without altering the files. It's also very useful for dropping fields like abstract
which often cause trouble due to LaTeX reserved characters.
There are also some other features implemented in Biber which are available in BibLaTeX 2.x:
- Customisable labels
- Multiple bibliographies in the same refsection with their own sorting/filtering
- "Related" entries - a general solution to the issue of all these "reprinted as", "translated as" etc. requirements.
I forgot to mention that Biber automatically applies the BibLaTeX field and entrytype mappings (address -> location etc.) mentioned in the documentation. It does this by implementing some driver-level source mappings (see \DeclareSourcemap
and its variants in the biblatex documentation).
It may be possible to have Emacs switch major modes depending on the position of point, but this can quickly become computationally-intensive and can break workflows (especially those that make heavy use of temporary variables). It would be better to adopt the Org model of source code editing: send the interesting bits to a separate buffer and change the mode on that buffer. (For the record, I tried using indirect buffers, but having different font-locks on two views of the same buffer seems to trip up Emacs a bit.)
Bind LaTeX-edit-Lua-code-start
to your favorite key. Beware though; editing is asynchronous. You must save for it to reinsert itself into the parent. Kill the buffer, lose your changes.
Update:
I've uploaded the code to GitHub
and submitted a pull request to MELPA under the name auctex-lua
,
and it is available to download through that package repository.
If you have not done so already,
you will have to 'install' MELPA by
adding it to your .emacs
anywhere before a call to package-initialize
:
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
I can confirm that the install works swimmingly!
For the code, please refer to GitHub.
It would be impossible to maintain on here. :-)
Best Answer
Since Emacs 24.1
bibtex-mode
supportsbiblatex
:To use it you can for example set it as a file variable to bibliography files by adding the following to their first line: