# Custom “online” entry formatting with biblatex+biber: use organisation in place of author when author is missing

I am using the superb biblatex package (with biber as backend) to typeset the bibliography of my thesis (compiled with pdflatex).

I would like to customise the formatting of @ONLINE type entries. By default biblatex formats such entries as (simplified):

Author. Title. Organisation. URl.

What I want is the following: when an entry does not have the author field set the formatting should treat the organisation field as the author:

Organisation. Title. Url.

Important: in this case the organisation field should also be used as the field to sort on.

If the both the author field and the organisation field are set it should apply the standard biblatex formatting (see above). When both are missing it should throw a warning. If only the author is set it should apply the default (organisation is optional anyway):

Author. Title. URl.

For example, I want the following entries:

@ONLINE{Android,
title = {{A}ndroid (operating system)},
url = {http://www.android.com},
}

@ONLINE{DalvikVM,
title = {{D}alvik {V}irtual {M}achine},
author = {{D}an {B}ornstein et al.},
}

@ONLINE{Pachube,
title = {{P}achube},
url = {http://www.pachube.com},
author = {{U}sman {H}aque}
}

To be formatted as:

1. Dan Bornstein et al. Dalvik Virtual Machine. Google, Inc. URL: http://...

2. Google, Inc. Android Operating System. URL: http://...

3. Usman Haque. Pachube. URL: http://...

Important: notice the sorting, the Android entry is sorted by its organisation field, the others by author (lastname).

I have tried to customise the formatting myself but so far it does not work like I wanted. My effort so far:

\DeclareBibliographyDriver{online}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\iflistundef{author}
{\iflistundef{organization}
{\BibliographyWarning{No author nor organisation on Online entry}}
{\printlist{organization}}}
{\usebibmacro{author/editor+others/translator+others}}
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{version}%
\newunit
\printfield{note}%
\newunit\newblock
\iflistundef{author}
{}
{\printlist{organization}}
\newunit\newblock
\usebibmacro{date}%
\newunit\newblock
\iftoggle{bbx:eprint}
{\usebibmacro{eprint}}
{}%
\newunit\newblock
\usebibmacro{url+urldate}%
\newunit\newblock
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}

The problem with this is that the orgisation field is now always used as author, even if there is an author. Also, when there is an author but no organisation only the title and url are shown. Also the organisation field is not used for sorting, instead the title seems to be used.

So my example entries are formatted as:

1. Google, Inc. Android Operating System. URL: http://...

2. Google, Inc. Dalvik Virtual Machine. URL: http://...

3. Pachube. URL: http://...

Can anyone help me to correct my \DeclareBibliographyDriver attempt so it produces the formatting and sorting I wanted?

-
I think replacing \iflistundef{author} with \ifnameundef{author} should fix the problem. Is there any particular reason why you're not simply using Google as a corporate author? –  Audrey Aug 8 '11 at 14:03
Don't forget that you can completely customise sorting in biblatex as long as you are using biber. –  PLK Aug 8 '11 at 16:29
Audrey: you are right, I should just put in organisations as authors when there are no known "human" authors. Much simpler. –  Matthias Aug 12 '11 at 20:31
@Matthias I've converted my comment into an answer. I added some changes to your use of braces in the entry fields. I'm not sure which style you're using, but it might help to read up on title case and have a look at the example bib file in the biblatex documentation. –  Audrey Aug 12 '11 at 23:46
@Audrey: accepted your answer. Thanks! –  Matthias Aug 15 '11 at 21:24

Either replace \iflistundef{author} with \ifnameundef{author} in your driver redefinition or simply use Google as a corporate author. Corporate author names are just wrapped in braces. See below for an example.

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@ONLINE{Android,
title = {Android (operating system)},
url = {http://www.android.com}}
@ONLINE{DalvikVM,
title = {Dalvik Virtual Machine},
author = {Bornstein, Dan and {the Android VM team}},
@ONLINE{Pachube,
author = {Haque, Usman},
title = {Pachube},
url = {http://www.pachube.com}}
\end{filecontents}