1

I'm trying to stick to the author-year-style of citation. Unfortunately I've to cite several webpages with no specific author. In that case BibLaTeX uses the title of an @online-entry as next resort. For the sake of compactness I would like to use the publisher and date instead.

E.g.: \parencite{my-bibid} producing something like

(A fancy publisher, 2020)

That's my MWE:

\documentclass[fontsize=11pt, a4paper, titlepage, parskip=half]{scrartcl} 
\usepackage{typearea}
\usepackage[a4paper, left=5cm, right=2.5cm, top=2.5cm, bottom=2.5cm]{geometry}
\usepackage[onehalfspacing]{setspace}   

\usepackage[scaled=.92]{helvet} 
\renewcommand{\familydefault}{\sfdefault} 
\usepackage[T1]{fontenc}    
\usepackage[utf8]{inputenc} 
\usepackage[ngerman]{babel} 


\usepackage[babel, german=quotes]{csquotes}
\usepackage[backend=biber, style=authoryear, sorting=nyt, giveninits=true,]{biblatex}

\DeclareNameAlias{sortname}{family-given}
\addbibresource{mybib.bib}
\DefineBibliographyStrings{german}{%
    andothers = {et al.},
}

\usepackage{filecontents}
\begin{filecontents}{mybib.bib}
    @online{my-bibid,
        title       = {This is a title way to long to put in the text as a whole string omg look it's so long it doesn't even stop good help us},
        publisher   = {A fancy Publisher},
        year        = {2020},
        url         = {https://latex.is.super.omg},
        urldate     = {2020-04-18}
    }   
\end{filecontents}

\begin{document}
    I want to cite the publisher and the year \parencite{my-bibid}. <- looks bad

    I want to cite the publisher and the year \citefield{my-bibid}{publisher} \citefield{my-bibid}{year} <- but why?! 


    \printbibliography
\end{document}

I found some great code from @cfr on Cite publisher in text from BibLaTeX

\DeclareCiteCommand\citepublisher
  {\boolfalse{citetracker}% supplemented from moewe's answer: https://tex.stackexchange.com/a/207676/
   \boolfalse{pagetracker}}
  {\printlist{publisher}}
  {\multicitedelim}
  {}

Unfortunately I didn't manage to also print the year in the same command. Oh, and TexStudio won't show me suggestions for the new \citepublisher command. Is there a trick?

I appreciate all your help.

0

\citefield won't work on publisher, because publisher is not a normal literal field, it is a list. For lists you have to use \citelist instead. That's why cfr's \citepublisher from Cite publisher in text from BibLaTeX uses \printlist and not \printfield. If you don't know the type of a field, you can look it up in the biblatex documentation (§2 Database Guide > § 2.2 Entry Fields).

It is of course possible to change the output of \parencite and friends directly by manipulating the relevant bibmacros.

If authoryear.cbx can't find an author or editor it prints a replacement label with

\newbibmacro*{cite:label}{%
  \iffieldundef{label}
    {\printtext[bibhyperref]{\printfield[citetitle]{labeltitle}}}
    {\printtext[bibhyperref]{\printfield{label}}}}

You modify this macro to print the publisher if available

\renewbibmacro*{cite:label}{%
  \printtext[bibhyperref]{%
    \iffieldundef{label}
      {\iflistundef{publisher}
         {\printfield[citetitle]{labeltitle}}
         {\printlist{publisher}}}
      {\printfield{label}}}}

There is one issue with this approach: Technically speaking @online entries don't have publishers, instead they use organization. You will for example find, that the publisher field is not shown in the bibliography at all. Using it in the citation seems risky.

So you could use organization

\renewbibmacro*{cite:label}{%
  \printtext[bibhyperref]{%
    \iffieldundef{label}
      {\iflistundef{organization}
         {\printfield[citetitle]{labeltitle}}
         {\printlist{organization}}}
      {\printfield{label}}}}

But I would like to suggest two different approaches.

Depending on the exact nature of the real world entry you have in mind, it is a much better idea to

  1. Upgrade the publisher to author or editor. There is no problem in having a 'corporate' author. authors don't have to be people. Keep in mind that 'corporate names' with spaces need protection with double braces in name fields (see Using a 'corporate author' in the "author" field of a bibliographic entry (spelling out the name in full)).

    See also my introductory remarks in my answer to If no author use organization or institution or the recent 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?.

    If required an abbreviation of the name can be given in the shortauthor field: Show only first word of parenthetical citation in BibLaTeX.

  2. You can use the label field to give a replacement label in case author, editor and translator are all missing. It should be mentioned, however, that with label Biber does not calculate uniqueness data, so you will not get disambiguation letters after the years if there are two works by the same label from the same year.

Usually I prefer option 1, but maybe option 2 is better suited to your particular entry.

\documentclass[fontsize=11pt, a4paper, titlepage, parskip=half]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[autostyle, german=quotes]{csquotes}
\usepackage[backend=biber, style=authoryear, giveninits=true,]{biblatex}

\DeclareNameAlias{sortname}{family-given}

\DefineBibliographyStrings{german}{%
  andothers = {et\addabbrvspace al\adddot},
}

\begin{filecontents}{\jobname.bib}
@online{test:author,
  title       = {This is a title way to long to put in the text as a
                 whole string omg look it's so long it doesn't even
                 stop good help us},
  author      = {{A fancy Publisher}},
  year        = {2020},
  url         = {https://latex.is.super.omg},
  urldate     = {2020-04-18}
}
@online{test:label,
  title       = {This is a title way to long to put in the text as a
                 whole string omg look it's so long it doesn't even
                 stop good help us},
  label       = {Publisher},
  year        = {2020},
  url         = {https://latex.is.super.omg},
  date        = {2020-04-18},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
  I want to cite the publisher and the year \autocite{test:author}.

  I want to cite the publisher and the year \autocite{test:label}.

  \printbibliography
\end{document}

A fancy Publisher 2020//Publisher 2020


A few comments about the code shown in the question

  • Bare .s should not appear at the end of bibstrings. Instead of andothers = {et al.}, write

    \DefineBibliographyStrings{german}{%
      andothers = {et\addabbrvspace al\adddot},
    }
    
  • sorting=nyt, is the default with style=authoryear, so need not be given explicitly.

  • You can use \autocite instead of \parencite. \autocite can be configured to give parenthetical citations or footnote citations. So it makes it easier to switch styles.
  • The option babel of csquotes was renamed to autostyle 10 years ago.
| improve this answer | |

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.