In a custom citation with Biblatex, is there a way to use groupauthor when the field author is empty?
- 329
1 Answers
You can check if there are any authors with \ifnameundef{author}, so the following might work
\ifnameundef{author}
{% no author, so try groupauthor
\printnames{groupauthor}}
{% we have an author, so print that
\printnames{author}}
Note that there are three different types of fields for biblatex.
- (literal/normal) fields
- literal lists
- name lists
These three types are implemented differently and are usually handled with different macros.
- Fields are printed with
\printfieldand tested with\iffieldundef. - Literal lists are printed with
\printlistand tested with\iflistundef. - Name lists are printed with
\printnamesand tested with\ifnameundef.
You can find out the types in the biblatex documentation, §2.2 Entry Fields.
See also Unable to Call "Publisher" or "Location" in Biblatex, How to extract BibTeX entries (as DOI, abstract, etc.).
I only know of one biblatex style that uses groupauthor: biblatex-apa. groupauthor will be removed in the next release of biblatex-apa, because it was not semantically meaningful (https://github.com/plk/biblatex-apa/pull/144): There is a reading of the APA style guidelines that doesn't require special treatment of group authors/corporate authors. All apparent differences in output can be explained by the absence of a given name part.
- 175,683
\ifnameundef{title}{\thefield{title}}{nothing}and the title appeared. Why? – Dunno Aug 20 '21 at 11:30biblatexcomes in three types: Literal field, list and name list. You need to use the correct command for the type of field you are handling.authoris a name list, so you use\ifnameundef.titleis a literal field, so you test it with\iffieldundef. (See the edit.) If you use the wrong test for the field you will always get the 'undefined' branch. – moewe Aug 20 '21 at 11:44\ifnameundef{author}{author undefined}{name defined} \ifnameundef{title}{title undefined}{title defined}always detects my title as undefined". When I saw your last comment, I was going to ask here I can see which field belongs to which type. You answered both. – Dunno Aug 20 '21 at 12:29\iffieldundef{date}{}{\printfield{date}}doesn't seem to work. – Dunno Aug 20 '21 at 19:56\printdate. You can check if it exists with\iffieldundef{year}. Note thatbiblatex's\print...commands are usually pretty good at doing nothing when the field is undefined, so often\iffieldundeftests are not required. E.g.\ifnameundef{title}{}{\printfield{title}}could just be\printfield{title}. Similarly\iffieldundef{year}{}{\printdate}is no better than\printdate. The whole point of\setunitand friends is to handle missing field values. – moewe Aug 20 '21 at 20:20