[Tex/LaTex] Custom “online” entry formatting with biblatex+biber: use organisation in place of author when author is missing

biberbiblatexformatting

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},
  organization = {{Google, Inc.}}
}

@ONLINE{DalvikVM,
  title = {{D}alvik {V}irtual {M}achine},
  url = {http://code.google.com/p/dalvik},
  author = {{D}an {B}ornstein et al.},
  organization = {{Google, Inc.}}
}

@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
  \usebibmacro{addendum+pubstate}%
  \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?

Best Answer

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,
  author = {{Google, Inc.}},
  title = {Android (operating system)},
  url = {http://www.android.com}}
@ONLINE{DalvikVM,
  title = {Dalvik Virtual Machine},
  url = {http://code.google.com/p/dalvik},
  author = {Bornstein, Dan and {the Android VM team}},
  organization = {{Google, Inc.}}}
@ONLINE{Pachube,
  author = {Haque, Usman},
  title = {Pachube},
  url = {http://www.pachube.com}}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}
Related Question