0

In a custom citation with Biblatex, is there a way to use groupauthor when the field author is empty?

Dunno
  • 329

1 Answers1

0

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 \printfield and tested with \iffieldundef.
  • Literal lists are printed with \printlist and tested with \iflistundef.
  • Name lists are printed with \printnames and 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.

moewe
  • 175,683
  • When I use this, the field is always considered undefined. I tried \ifnameundef{title}{\thefield{title}}{nothing} and the title appeared. Why? – Dunno Aug 20 '21 at 11:30
  • 1
    @Dunno What one ordinarily calls 'field' in biblatex comes in three types: Literal field, list and name list. You need to use the correct command for the type of field you are handling. author is a name list, so you use \ifnameundef. title is 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
  • Thank you. I was going to edit my question with "\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
  • How could I print the date ? \iffieldundef{date}{}{\printfield{date}} doesn't seem to work. – Dunno Aug 20 '21 at 19:56
  • @Dunno The date is special. You print it with \printdate. You can check if it exists with \iffieldundef{year}. Note that biblatex's \print... commands are usually pretty good at doing nothing when the field is undefined, so often \iffieldundef tests 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 \setunit and friends is to handle missing field values. – moewe Aug 20 '21 at 20:20
  • I needed this check to print a word before the date. Thank you for your answer. – Dunno Aug 22 '21 at 13:37