biblatex: numbered citations as footnotes

Most chemistry journals use numbered citation styles, with all of the references appearing at the end of the article in a References section. However, there are some that place the references at the bottom of the page they occur on, as footnotes. This is a bit more awkward to achieve than a simple section, but as biblatex has all of the citation data available from the start of a document I thought it should be easy to do.

It turns out that biblatex has the very handy \footfullcite macro, which nearly does what is needed. This macro will print the reference as a footnote, but uses LaTeX’s footnote numbering system to do this. The result is that repeating citations, compressing several citations into a range and so on is not so easy. In the end, I decided to drop Philipp Lehman (the author of biblatex) an e-mail for some guidance. He came back with two approaches, one for citations in the text and one for superscript citations:

\documentclass{article}
\usepackage[style=numeric-comp]{biblatex}
\bibliography{biblatex-examples}
\makeatletter

\ExecuteBibliographyOptions{citetracker,sorting=none}

\DeclareCiteCommand{\notefullcite}[\mkbibbrackets]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{notefullcite}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}%
   \usebibmacro{postnote}}

\newbibmacro*{notefullcite}{%
  \ifciteseen
    {}
    {\footnotetext[\thefield{labelnumber}]{%
       \usedriver{}{\thefield{entrytype}}.}}}
\DeclareCiteCommand{\superfullcite}[\cbx@superscript]%
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}
     {}
     {\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}
     {}
     {\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \usebibmacro{superfullcite}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

\newbibmacro*{superfullcite}{%
  \ifciteseen
    {}
    {\xappto\cbx@citehook{%
       \noexpand\footnotetext[\thefield{labelnumber}]{%
         \fullcite{\thefield{entrykey}}.}}}}

\newrobustcmd{\cbx@superscript}[1]{%
  \mkbibsuperscript{#1}%
  \cbx@citehook
  \global\let\cbx@citehook=\empty}
\let\cbx@citehook=\empty

\makeatother
\begin{document}

Some filler text \notefullcite{cotton}, then some more text
\notefullcite{hammond}. Perhaps some more text and the same
citation again \notefullcite{hammond}. Yet another one
\notefullcite{knuth:ct:a}. Now all again
\notefullcite{cotton,hammond,knuth:ct:a}.

Some filler text,\superfullcite{augustine} then some more
text.\superfullcite{companion} Perhaps some more text and the
same citation again.\superfullcite{companion} Yet another
one.\superfullcite{kastenholz} Now all
again.\superfullcite{augustine,companion,kastenholz}

\end{document}

I might add this to my biblatex styles, but I’ll wait to see if Philipp puts the code or some notes into the biblatex core before I do. I should also point out that if you want footnote citations and other footnotes then you’ll need something like the bigfoot package to do the job. But this is a pretty good place to start from.

Building biblatex-biber (again)

I recently posted some information on building biblatex-biber. Since then, v0.5 of biblatex-biber has appeared and there are some positive changes. The code now creates its own file to grab the required Perl modules. So on Mac OS X (Snow Leopard) and Ubuntu (9.10) all I needed to do after downloading the source was

perl Build.PL
sudo ./Build installdeps
./Build
./Build test
sudo ./Build install

at the Terminal. The second step grabbed all of the modules needed and everything worked fine.

On Windows, life is still a bit complicated but I now can get things to work. A bit of a trawl on the Internet led to a blog post about Text::BibTeX. At the moment, the solution is still in beta and so there is a bit of work to do. With Strawberry Perl installed I went to the Command Prompt (as Administrator) and started the cpan program. At its prompt I did

install Config::AutoConf Capture::Tiny IPC::Run
install A/AM/AMBS/Text/Text-BibTeX-0.40_3.tar.gz

which all seemed to work. After downloading and unzipping the source for biblatex-biber (which is in .gz format, so use something like 7-Zip to open it), still as Administrator at the Command Prompt I did

perl build.pl
build installdeps
build
build test
build install

and everything worked. So I’ve finally got it working across all platforms. Hopefully the Text::BibTeX install will become easier when it moves from beta status.

biblatex reaches v0.9

A couple of days ago biblatex v0.9 appeared on CTAN. As usual, there is a long list of changes, bug fixes and so on. The restrictions on inclusion in TeX distributions have been lifted, and so it’s already available in TeX Live. At the same time, biblatex-biber has been uploaded to CTAN, so hopefully ready to use versions will be added to the distributions at some point (MikTeX is likely to be first, I suspect).

I’ve just uploaded an updated version of biblatex-chem to CTAN, to keep in sync with the changes in biblatex. I’ll try to get biblatex-nature and biblatex-science done in soon (today) so that everything is working.

Building biblatex-biber

The biblatex-biber project provides probably the best way for biblatex users to switch to pure UTF-8 bibliography information. However, getting it to build can cause problems: biblatex-biber is a Perl programme, and needs various downloads from CPAN. I thought it would therefore be useful to put some simple recipes here, explaining what I’ve done to get a working biblatex-biber on Windows, Ubuntu and Mac OS X. I’m assuming that the latest biblatex-biber release has been downloaded and unzipped somewhere, and that the Command Prompt/Terminal/Shell is open in that directory (folder).

Mac OS X 10.6 (Snow Leopard)

Mac OS X comes with Perl installed, so life is relatively easy. At the Terminal, you need to run the cpan script as root:

sudo cpan

The cpan script has its own prompt, but this is very similar to the Terminal one. First, I updated cpan itself and installed a helper module with

install CPAN
reload cpan
install YAML

That done, the various requirements for biblatex-biber can be installed, using the single call

install Data::Dump List::AllUtils Readonly Text::BibTeX Readonly::XS

For the more cautious person (such as me), each install instruction can be given on a separate line: this keeps things a bit more controlled. I accepted the standard settings, except when asked about installing items that were only needed for testing, where I said no.

Once cpan has done all of the installing, you can leave it by typing

exit

So now back at the Terminal prompt, a few simple instructions

perl Build.PL
./Build
sudo ./Build install

That put biblatex-biber onto the path for all users: everything then worked correctly.

Ubuntu 9.10

Once again, Perl is installed as standard in Linux distributions: I’m using Ubuntu as a representative system. Before starting cpan, there is an additional step, which is to install an extra Ubuntu package. So at the Terminal, you need to do

sudo apt-get install libxml2-dev

This is needed as otherwise you get some very odd errors in a bit. Now, essentially the same recipe works as for the Mac. First run cpan running and update and install YAML. Then there is a long list of items to install

install Data::Dump List::AllUtils Readonly Text::BibTeX Readonly::XS XML::Writer XML::LibXML File::Slurp

which can again be done one at a time, for the more cautious.

After exiting cpan, the same three lines at the Terminal should work as in the Mac section.

perl Build.PL
./Build
sudo ./Build install

Windows (XP, Vista and 7)

To date, my attempts to build biblatex-biber on Windows (using Strawberry Perl) have failed as I can’t get the Perl module Text::BibTeX to install. This is supposed to be optional, but without it biblatex-biber does not seem to work, although I do get it to build. Luckily, there is a self-contained binary for Windows available from the project site. This includes its own Perl system, so there is no need to get Perl set up before trying it. Everything seems to work for me with this version. Any ideas on what is necessary would be helpful!

biblatex-chem update

I’ve just spotted a bug in biblatex-chem, and a fix is on the way to CTAN. It looks like changes in the biblatex core have made the comma after journal titles when using the chem-rsc style disappear. This was working earlier: I’ve retested an old version and it is not due to anything I’ve done.

On another matter, I’ve been asked to look at turning page ranges into single pages in biblatex-chem. I need to add the appropriate functions to biblatex, so there may be a delay (I have lots on at the moment). It is definitely on my list to do. Why do this? Well, some journals insist on first-page only, but in a database both pages will be present. So the code needs to handle things. There should be another update once I sort this: a few days.

Beyond BibTeX: the first biber beta release

A notice in my inbox from François Charette alerted me yesterday to the first beta release of biber. This is a cross-platform (Perl) replacement for BibTeX for biblatex users. By moving on from BibTeX, there are a number of advantages. First, the problems inherent in the BibTeX code (no Unicode support, memory limitations and so on) are removed. The need for something beyond BibTeX is a well-known problem.

More importantly, biber comes with an experimental XML file format as a replacement for the .bib file type. The limitations of the .bib approach are more subtle than those of BibTeX itself. A lot of problems stem from the simplicity of the .bib format. This severely limits how much detail can be given for complex data types. For example, there is no good way to give multiple publishers and locations in the .bib format:

publisher = {{First Company} and {Second Company}},
location = {Town and OtherTown}

So which place goes with which publisher? We might assume the first with the first, the second with the second, but why not both locations for both publishers or something more complex? By starting from the biblatex experience, biber can build in this type of data from the start. Particularly in arts subjects, this looks like a great idea.

One important question is publicity. Within the LaTeX world, biblatex is still not that widely used. This is of course partly as it is still in beta. However, for biber to succeed both it and biblatex need publicity outside of LaTeX. One obvious route is to talk to the people who develop things like JabRef, BibDesk and so on. These programmes use the .bib format to store data, but can be used without ever going near LaTeX. Other ideas are I’m sure welcome!

Over all, I’m very excited by biblatex and biber. It’s clear that biblatex is a major advance for LaTeX users, and anything that makes life easier is welcome.