I want to change the output format of \citeauthor{} so that full names ("givenname familyname") instead of just family names are displayed. Therefore, I have to define a special format and change \citeauthor so that it uses this format for its output routine.
Like shown in the example in the biblatex manual (section 4.2.3, page 146; biblatex version 3.9), I use \ifblank{\namepartgiven} to check whether the current name has a non-empty field namepartgiven. The logic seems simple enough: If the test succeeds, \namepartgiven\space will be printed just before \namepartfamily; if the field is empty, \namepartfamily should be printed immediately, without any preceding \space. However, I wonder when \ifblank is supposed to trigger.
Consider the following example:
\documentclass{article}
\usepackage[backend=biber,bibstyle=authoryear, citestyle=authoryear-icomp]{biblatex}
\addbibresource{test.bib}
\usepackage{filecontents}
\begin{filecontents*}{test.bib}
@book{test,
author = {John Doe and Smith},
title = {How to write an extraordinary book},
date = {2018}
}%
\end{filecontents*}
\DeclareNameFormat{citeauthor}{%
% \iffieldundef{\namepartgiven}{}%
{\ifblank{\namepartgiven}{}{\namepartgiven\space}}%
\namepartfamily%
\ifnumgreater{\value{liststop}}{\value{listcount}}%
{\ifnumgreater{\value{liststop}-1}{\value{listcount}}%
{\multinamedelim}%
{\finalnamedelim}%
}%
{\ifmorenames{\usebibmacro{name:andothers}}{}}%
}
\DeclareCiteCommand{\citeauthor}
{\boolfalse{citetracker}%
\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\printnames[citeauthor]{author}}%
{}
{\midsentence*}
\begin{document}
\printbibliography
\citeauthor{test}\par\cite{test}
\end{document}
This code works as expected if \namepartgiven is not empty. However, the database contains no given name for the second author (Smith). Apparently, \ifblank doesn't trigger because the field is not present; consequently, it branches off to print the non-existent given name, followed by a space:
So, how about checking first whether the field namepartgiven is used at all before checking whether it is empty? Just activate the first line after \DeclareNameFormat{citeauthor} and compile the document again! This is what you will see:
Not surprisingly, the erroneous space right before "Smith" has disappeared. But wait, what happened to John Doe? Why has "John" gone as well?
Does anybody know what is happening here? There must be something I haven't understood correctly -- or could this be a bug in biblatex?




\ifblank{\namepartgiven}never returns true. – egreg Mar 06 '18 at 10:48\ifdefvoidinstead of\ifblank. The example in the docs need tweaking. I'll have a look later, but maybe there is a simpler solution altogether. – moewe Mar 06 '18 at 10:53{\midsentence*}for? The standard is\DeclareCiteCommand{\citeauthor} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\ifciteindex {\indexnames{labelname}} {}% \printnames{labelname}} {\multicitedelim} {\usebibmacro{postnote}}so I assume you want\DeclareCiteCommand{\citeauthor} {\boolfalse{citetracker}% \boolfalse{pagetracker}% \usebibmacro{prenote}} {\ifciteindex {\indexnames[citeauthor]{labelname}} {}% \printnames{labelname}} {\multicitedelim} {\usebibmacro{postnote}}– moewe Mar 06 '18 at 11:13\midsentence*: I have one peculiar entry in my database where the name corresponds to\namepartgiven \namepartfamilyi; the author used his family name's initial as a pseudonym.\citeauthorwill end with\adddotfor this author, so I thought it would make sense to indicate that this is no end-of-sentence mark. If I understand you correctly,\midsentencewill only be honored in the bibliography, not in such citations, and should be removed as redundant? – Andreas Mar 06 '18 at 12:24biblatex? :-) – Andreas Mar 06 '18 at 12:28\adddotis already an abbreviation dot and not a sentence-ending full stop, so\midsentenceshould not be needed, I would have thought. – moewe Mar 06 '18 at 12:36