I am trying to write my own biblatex style, and…
- The first field in each bibliography entry must be in uppercase;
- When there is no author or editor, I must print the organization first and it must be in uppercase;
- If there is no author, editor or organization, then the title goes first and it's in uppercase;
- If there is an author and an organization, the author goes first and the organization goes last.
So here's what I tried to do:
\begin{filecontents}{\jobname.bib}
@book{withorg,
year =1985,
title ={The History and Social Influence of the Potato},
organization = {Some Organization}}
@book{withoutorg,
year =1985,
title ={The History and Social Influence of the Potato}}
\end{filecontents}
\documentclass{article}
\usepackage[backend=biber, bibstyle=standard]{biblatex}
\addbibresource{\jobname.bib}
\DeclareFieldFormat{uppercase}{\MakeUppercase{#1}}
\DeclareListFormat{uppercase}{\MakeUppercase{#1}}
\DeclareBibliographyDriver{book}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/organization}% 1.
\setunit{\labelnamepunct}\newblock
\usebibmacro{maintitle+title}% 2.
\newunit\newblock
% The organization is always printed here,
% but it should be printed only when it wasn't already
% in \usebibmacro{author/editor+others/organization}
\printlist{organization}% 3.
\usebibmacro{finentry}}
\newbibmacro*{author/editor+others/organization}{% 1.
\ifboolexpr{%
test {\ifnameundef{author}}
and
test {\ifnameundef{editor}}
}
{\printlist[uppercase]{organization}}
%\clearlist{organization}} This causes the title to be capitalized when it shouldn't.
{\usebibmacro{author/editor+others}}}
\renewbibmacro*{title}{% 2.
\ifboolexpr{%
test {\iffieldundef{title}}
and
test {\iffieldundef{subtitle}}
}
{}
{\printtext[title]{%
\ifboolexpr{%
test {\ifnameundef{author}}
and
test {\ifnameundef{editor}}
and
test {\iflistundef{organization}}
}
{\printfield[uppercase]{title}}
{\printfield[titlecase]{title}}
\normalfont{\setunit{\subtitlepunct}%
\printfield[noformat]{subtitle}}}%
\newunit}%
\printfield{titleaddon}}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
First the
author/editor+others/organizationmacro checks if there is no author or editor, and if there isn't it prints the organization.Then the
titlemacro checks if there is no author, editor or organization, and if there isn't it prints the title in uppercase.Then the organization is printed, and as it is it's always printed, but I need it there only when it wasn't already printed before in the
author/editor+others/organizationmacro.
So my first thought was to use \clearlist{organization} after printing the organization, at the end of item 1 there. The problem is that item 2 checks if there is an organization to decide if the title should be capitalized or not. So if I use \clearlist it will be capitalized even if the organization was already printed.
So here's what I get if I don't use \clearlist:
The organization is printed twice in that first entry.
And here's what I get if I do use \clearlist:
The title is capitalized in the first entry, when it shouldn't be.
The bottomline is: if I clear previous fields, I need a way to tell if the title is the first field printed without checking if the previous fields are undefined, so I can make it uppercase only when it's the first. Or else, if I don't clear the previous fields, I need a way to tell if the organization was already printed so I don't print it again. Any ideas?
(I know I could use the author/editor fields for the organization when necessary, but I'd rather not do that… hopefully other people will use my style and their bibliographies are already using the organization field like this, and also that would give me headaches with my custom name formats… and an organization isn't actually a name after all, so I think this is better.)


authorfield. But please consider that thebiblatexdocumentation has no probems with using an organization asauthor(it calls them "corporate authors" and even has a section about them in the documentation: §2.3.3 Corporate Authors and Editors). Corporate authors should not interfere with the name format if they are given in the proper format (see here). – moewe May 01 '16 at 15:03biblatexdocs a@bookdoesn't have anorganization(it is neither an optional nor required field), so those that build their.bibfile strictly by those rules won't haveorganizations for@booksanyway. – moewe May 01 '16 at 15:05