[Tex/LaTex] Biblatex and custom bibtex entries – is it possible

biblatexbibtexmacros

Is it possible to have entries in a bib file with custom @entry types? For example, below I have entries I've created for a legal encyclopaedia and a United Nations document.

@undocument{modeleclaw,
        Author = {United Nations Commission on International Trade Law (UNCITRAL)},
        Date-Added = {2011-04-11 15:27:46 +0800},
        Date-Modified = {2011-04-11 15:44:53 +0800},
        Shorttitle = {Model Law},
        Title = {Guide to Enactment of the UNCITRAL Model Law on Electronic Commerce},
        Year = {1996}}
@encyclopaedia{halsbury,
        Chapternumber = {7},
        Chaptertitle = {Contract: General Principles},
        Date = {31 August 2006},
        Date-Added = {2011-04-11 11:22:57 +0800},
        Date-Modified = {2011-04-11 11:25:06 +0800},
        Encyclopaediatitle = {Halsbury's Law of Australia},
        Publisher = {LexisNexis},
        Title = {An offer is comprised of particular elements},
        Titlenumber = {7.1.460},
        Volume = {TLA [7.1.460]},
}

I've been through the biblatex manual but I can't find anything that says I can define my own type. Is it possible? Then, if so, how would I define drivers in the bbx and cbx files to manage the types? I tried creating this as an example but I'm not sure I'm on the right track:

% United Nations Document (undocument)
\DeclareBibliographyDriver{undocument}{%
  \usebibmacro{bibindex}%
  \usebibmacro{title}%
  \setunit{\addcomma\space}%
  \iffieldundef{resolutionnumber}{}{\thefield{resolutionnumber}\setunit{\addcomma\space}}%
  \iffieldundef{officialrecords}{}{\thefield{officialrecords}\setunit{\addcomma\space}}%
  \iffieldundef{committeenumber}{}{\thefield{committeenumber}\setunit{\addcomma\space}}%
  \iffieldundef{sessionnumber}{}{\thefield{sessionnumber}\setunit{\addcomma\space}}%
  \iffieldundef{meetingnumber}{}{\thefield{meetingnumber}\setunit{\addcomma\space}}%
  \iffieldundef{agendaitem}{}{Agenda Item \thefield{agendaitem}\setunit{\addcomma\space}}%
  \iffieldundef{supplement}{}{Supp No \thefield{supplement}\setunit{\addcomma\space}}%
  \iffieldundef{undocnumber}{}{UN Doc\thefield{undocnumber}\setunit{\addcomma\space}}%
  \iffieldundef{date}{}{\mkbibparens\thefield{date}\setunit{\addcomma\space}}%
  \iffieldundef{annex}{}{\thefield{annex}\setunit{\addcomma\space}}%
  {\printlist{publisher}\setunit{\addcomma\addspace}}%
}


% ENCYCLOPAEDIA (encyclopaedia)
\DeclareBibliographyDriver{encyclopaedia}{%
  \usebibmacro{bibindex}%
  {\printlist{publisher}\setunit{\addcomma\addspace}}%
  \usebibmacro{encyclopaediatitle}
}

When I compile my tex file I get this:


Package biblatex Warning: No driver for entry type 'misc'.
(biblatex)                Skipping entry 'modeleclaw' on input line 146.

I'm not sure if I'm going about this the right way or not.

Best Answer

A hack: it's very easy to modify a .bst file so that it recognises new entry types: simply append lines to the .bst file such as, to make @undocument a synonym for @misc:

FUNCTION { undocument } { misc }

which just means that the function Bibtex calls to produce the .bbl entry for an @undocument just calls the function it uses to produce an @misc entry.

Biblatex does things a little differently, since it passes the type information as follows:

FUNCTION {article} { type$ output:entry }

where output:entry is the generic function used to dump all the information about the record to the .bbl for Biblatex to work with (if you didn't pass the type information, as per the first line, Biblatex would think, e.g., @undocument was an @misc entry).

You can then just clone the site definition of biblatex.bst into your local texmf tree (for Texlive), and add some lines such as:

FUNCTION { undocument } { type$ output:entry }

to your personal version of biblatex.bst. Bibtex will then treat these types just like the other types and you can use them in your bbx/cbx styles.

Postscript

As domwass notes, if you change your version of biblatex.bst in this way, you have to be aware that upgrades might break Biblatex if you use a local fork based on an older version. While most revisions don't introduce incompatible changes to biblatex.bst (there were no changes from 0.9e to 1.3 that would have caused problems, I think), the last revision, 1.4, introduced a very big change in the way biblatex.bst represented information in .bib files that certainly would have required creating a new patched file.