4

Here lockstep asked how to additionally use the shortauthor field in the bibliography.

I, however, would like to completely replace the author field with shortauthor.

Instead of

International Energy Agency (2005). World Energy Outlook 2005....

and

IEA - International Energy Agency (2005): World Energy Outlook 2005....

I prefer

IEA (2005): International Energy Agency. World Energy Outlook 2005....

Example code

\documentclass[ngerman]{scrartcl}
\listfiles
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{iea,
author = {{International Energy Agency}},
title = {World Energy Outlook},
shortauthor = {IEA},
date = {2005}
}
\end{filecontents}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel,csquotes}

\usepackage[
    style=authoryear,
  backend=biber
]{biblatex}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}


\begin{document}
\cite{companion,iea}
\printbibliography
\end{document}

Thank you.

lockstep
  • 250,273
Kris O
  • 43

1 Answers1

3

A solution here has to be slightly more involved. We have to modify the author macro quite a bit.

\makeatletter
\renewbibmacro*{author}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\usebibmacro{bbx:savehash}%
        \ifnameundef{shortauthor}% <-------- this is new: prefer shortauthor
          {\printnames{author}}
          {\printnames{shortauthor}}
        \iffieldundef{authortype}
          {\setunit{\addspace}}
          {\setunit{\addcomma\space}}}%
     \iffieldundef{authortype}
       {}
       {\usebibmacro{authorstrg}%
        \setunit{\addspace}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{date+extrayear}%
  \ifnameundef{shortauthor}% <-------- this is new: delay real author until after year
    {}
    {\setunit{\labelnamepunct}\newblock
     \printnames{author}%
     \printunit{\newunitpunct}\newblock}
  }
\makeatother

We added two \ifnameundef{shortauthor} blocks: One to prefer shortauthor over author at the beginning and one to print the author after the year if we had a shortauthor.

In the MWE we also modified the editor macro in a similar fashion

\documentclass[ngerman]{scrartcl}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{iea,
author = {{International Energy Agency}},
title = {World Energy Outlook},
shortauthor = {IEA},
date = {2005}
}
\end{filecontents}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel,csquotes}

\usepackage[
    style=authoryear,
  backend=biber
]{biblatex}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\renewcommand*{\labelnamepunct}{\addcolon\space}

\makeatletter
\renewbibmacro*{author}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\usebibmacro{bbx:savehash}%
        \ifnameundef{shortauthor}
          {\printnames{author}}
          {\printnames{shortauthor}}
        \iffieldundef{authortype}
          {\setunit{\addspace}}
          {\setunit{\addcomma\space}}}%
     \iffieldundef{authortype}
       {}
       {\usebibmacro{authorstrg}%
        \setunit{\addspace}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{date+extrayear}%
  \ifnameundef{shortauthor}
    {}
    {\setunit{\labelnamepunct}\newblock
     \printnames{author}%
     \printunit{\newunitpunct}\newblock}}

\renewbibmacro*{bbx:editor}[1]{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{bbx:dashcheck}
       {\bibnamedash}
       {\ifnameundef{shorteditor}
          {\printnames{editor}}
          {\printnames{shorteditor}}
        \setunit{\addcomma\space}%
        \usebibmacro{bbx:savehash}}%
     \usebibmacro{#1}%
     \clearname{editor}%
     \setunit{\addspace}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{date+extrayear}%
  \ifnameundef{shorteditor}
    {}
    {\setunit{\labelnamepunct}\newblock
     \printnames{editor}%
     \printunit{\newunitpunct}\newblock}}
\makeatother


\begin{document}
\cite{companion,iea}
\printbibliography
\end{document}

MWE showing: IEA (2005): International Energy Agency. World Energy Outlook.

moewe
  • 175,683