# different name format for a book with shorthand

I'm setting up my own bbx file in biblatex based on authoryear and want it to output the author in another name format when the book has a shorthand. Normally it should output e.g. “Albert E.”, so I defined

\DeclareNameAlias{sortname}{first-last}
\DeclareNameFormat{first-last}{%
\iffirstinits
{\usebibmacro{name:first-last}{#2}{#4}{#5}{#7}}
{\usebibmacro{name:first-last}{#2}{#3}{#5}{#7}}%
\usebibmacro{name:andothers}
}


For books with a shorthand it should in contrast output e.g. “Albert Einstein”, without abbreviating the last name. How can I achieve this?

MWE:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}

\usepackage[backend=biber,style=authoryear-icomp,]{biblatex}
\begin{filecontents}{lit.bib}
@book{regular,
title = {Book's title},
author = {Lastname, Firstname},
location = {The City},
publisher = {Publisher},
date = {2005},
}
@book{withshorthand,
shorthand = {short},
title = {Book's title},
author = {Lastname2, Firstname2},
location = {The City},
publisher = {Publisher},
date = {2005},
}
\end{filecontents}

\DeclareNameAlias{sortname}{first-last}
\DeclareNameFormat{first-last}{%
\iffirstinits
{\usebibmacro{name:first-last}{#2}{#4}{#5}{#7}}
{\usebibmacro{name:first-last}{#2}{#3}{#5}{#7}}%
\usebibmacro{name:andothers}}

\begin{document}
some\parencite{regular} text\parencite{withshorthand}
\printbibliography
\end{document}


Output:

As it has a shorthand, the second bibliography entry should have “Firstname2 Lastname2”, not abbreviating the author's last name as normal entries like #1 do.

• The first step is a complete example. Btw: in biblatex 3.3. your code will no longer work. github.com/plk/biblatex/issues/372 – Ulrike Fischer Mar 14 '16 at 13:07
• Really, a complete example? OK, I'll try my best…Thanks for anouncing the incompatibility! – dessert Mar 14 '16 at 13:59
• I added a MWE and it wasn't half as hard as I thought… ;) – dessert Mar 14 '16 at 14:17

You can use the standard field tests in the declaration, e.g.:

\DeclareNameFormat{first-last}{%
\iffirstinits
{\usebibmacro{name:first-last}{#2}{#4}{#5}{#7}}
{\iffieldundef{shorthand}
{\usebibmacro{name:first-last}{#2}{#3}{#5}{#7}}
{\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}%
\usebibmacro{name:andothers}}


As already mentioned in the comment this definition will not work with biblatex 3.3. where \DeclareNameFormat has a different syntax.

• Thanks a lot, works like a charm! For biblatex 3.3 and newer it therefore should be \DeclareNameAlias{first-last}{given-family} \DeclareNameFormat{given-family}{\nameparts{#1} \ifgiveninits {\usebibmacro{name:given-family}{\namepartfamilyi}{\namepartgiveni}{\namepartprefix}{\namepartsuffix}} {\iffieldundef{shorthand} {\usebibmacro{name:given-family}{\namepartfamilyi}{\namepartgiven}{\namepartprefix}{\namepartsuffix}} {\usebibmacro{name:given-family}{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}}} \usebibmacro{name:andothers}}. – dessert Mar 14 '16 at 17:24