Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
One should add that this is, as you said, only a hack. You have to do these changes everytime you update biblatex. –  domwass Apr 13 '11 at 8:16
add comment

At the moment, it is not possible to create your own document types. This is a limitation of BibTeX (the program), since biblatex has to define the entrytypes in the bst file. In the future, this could be possible, as soon as biblatex will drop support of the BibTeX program and will only work with biber (this is targeted for version 2.0 of biblatex). But defining your own document types might be scheduled not earlier than for version 3 (this is at least how I understand the roadmap). In the meantime, however, you can use the entrytypes custom[a–f] (meaning: customa, customb, etc.). Thus, you could just replace your undocument by customa and it should work.

For encyclopaedia, you should use reference which is intended for encyclopedias, dictionaries and the like.

Edit:

You will also have to change your customized fields like agendaitem to usera etc. There are different kinds of custom fields available, as the following quote from the biblatex manual shows:

  • name[a–c] list (name)

Custom lists for special bibliography styles. […]

  • name[a–c]type field (key)

Similar to authortype and editortype but referring to the fields name[a-c]. […]

  • list[a–f] list (literal)

Custom lists for special bibliography styles. […]

  • user[a–f] field (literal)

Custom fields for special bibliography styles. […]

  • verb[a–c] field (literal)

Similar to the custom fields above except that these are verbatim fields. […]

(I always omitted one sentence in the above quote, namely “Not used by the standard bibliography styles.”)

You can read more about the different kinds of fields in the biblatex manual, section 2.2.1 “Data Types”.

share|improve this answer
    
@domwass - many thanks! If I switch undocument to customa, can I still have my custom fields inside? ie: agendaitem, undocnumber etc. –  Mark Ferraretto Apr 12 '11 at 9:16
    
@Mark: You also have to use custom fields instead of your own fields, for the same reasons. I edited my answer accordingly. –  domwass Apr 12 '11 at 9:42
4  
There is preliminary, undocumented (and currently unusable) support for this in biber already but it's not planned to develop this until bibtex (the program) is dropped, probably in version 2.0 biblatex. With the planned interface, it should be possible to define custom entry types and fields with biblatex macros and have this information passed to biber via the .bcf file. Another benefit of this is that biber can validate your .bib file. You can even try this now with the biber "--validate_structure" option –  PLK Apr 12 '11 at 15:14
    
@PLK: Thanks for the information and clarification. –  domwass Apr 13 '11 at 8:14
1  
I would also point out that with Biber, you can use any custom type names you want in your .bib file and have them automatically mapped to the custom biblatex entry types mentioned in this answer by using a biber.conf sourcemap option. See the Biber 0.9.8 manual, section 3.1.1 –  PLK Dec 21 '11 at 17:55
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.