0

I'm trying to renew the macro for my footcite. For Books and others it works as aspected. But for type online I have some problems.

I want to show the author and if no author exists, I want to display the organization.

author/organization, year, "Onlinequelle"

\renewbibmacro*{cite}{%
  \ifentrytype{online}%
    {
    \iffieldundef{author}
      {\printnames{labelname}}
      {\printlist{organization}}
    {\usebibmacro{cite:labeldate+extradate}}
    \printtext[]{Onlinequelle}
    }
   {
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}}
       {\usebibmacro{cite:label}%
        \setunit{\printdelim{nonameyeardelim}}
        }
       {\printnames{labelname}%
        \setunit{\printdelim{nameyeardelim}}}%
       \ifboolexpr{   test {\iffieldundef{labelyear}}
                 or test {\iffieldequalstr{labelyear}{nodate}}}
       {\usebibmacro{cite:labeltitle}}
       {\usebibmacro{cite:labeldate+extradate}}}
    {\usebibmacro{cite:shorthand}}}
    }

I get this result: enter image description here

@Online{Inc2015,
  citationkey  = {Inc2015},
  title        = {Class ArrayList<E>},
  url          = {https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html},
  year         = {2015},
  note         = {in: Java™ Platform, Standard Edition 7 API Specification},
  organization = {Oracle America Inc.},
  urldate      = {2021-01-03},
}
1

author is a name field, so you need to ask with \ifnameundef if it is given, not with \iffieldundef. Since author is not a field, but a name list, \iffieldundef{author} always gives true, so your code never gets to \printlist{organization}. You need to use \ifnameundef here.

Since you print labelname, you probably shouldn't be testing for author, but for labelname instead.

In total

    \iffieldundef{author}
      {\printnames{labelname}}
      {\printlist{organization}}

should be

    \ifnameundef{labelname}
      {\printnames{labelname}}
      {\printlist{organization}}%

The code shown in the question is likely to produce several spurious spaces because it is missing % to comment out line ends. Read more about why you need to add % at the end of some lines in What is the use of percent signs (%) at the end of lines? (Why is my macro creating extra space?).

Streamlining some other bits of the code and using the indentation style of the biblatex standard styles, I would probably write your code as

\NewBibliographyString{onlineresource}

\DefineBibliographyStrings{german}{
  onlineresource = {Onlinequelle},
}

\renewbibmacro*{cite}{%
  \ifentrytype{online}%
    {\ifnameundef{labelname}
       {\printnames{labelname}}
       {\printlist{organization}}
     \setunit{\printdelim{nameyeardelim}}%
     \usebibmacro{cite:labeldate+extradate}%
     \setunit{\addspace}%
     \bibstring{onlineresource}}
   {\iffieldundef{shorthand}
      {\ifnameundef{labelname}
         {\usebibmacro{cite:label}%
          \setunit{\printdelim{nonameyeardelim}}}
         {\printnames{labelname}%
          \setunit{\printdelim{nameyeardelim}}}%
       \iffieldequalstr{labeldatesource}{nodate}
         {\usebibmacro{cite:labeltitle}}
         {\usebibmacro{cite:labeldate+extradate}}}
      {\usebibmacro{cite:shorthand}}}}

(Untested, because you did not provide an example document for testing.)


In cases like this I think it is usually perfectly fine to "upgrade" the organization to author (or editor if that is more appropriate). There is no rule against using organisations or corporations in the author or editor field (Using a 'corporate author' in the "author" field of a bibliographic entry (spelling out the name in full)), so a non-person author should not automatically be pushed off into the organization field. author and editor are fields that describe the function or role of an entity, not their ontological properties. If an organization/non-person takes over that role, then it is perfectly fine to name them as such in the .bib file. The organization field, on the other hand, is much more similar to the publisher field. See also my comments in Cite Publisher and Date when no author is available - eg. website, If no author use organization or institution and Why is biblatex defaulting to using title instead of author when no author is provided and how do I change it to using journaltitle instead?.

Using author/editor here instead of organization not only makes the code for the cite macro simpler, it also won't require structurally similar changes to the bibliography driver.

1
  • Thank you very much! I really appreciate your effort for this answer. Also, a lot of additional information given!
    – wit4r7
    Jan 4 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.