# Getting the name from another field indexed in biblatex

This is the solution to getting the author into the index rather than the shortauthor: Getting the authors to show in the index while using shortauthor and biblatex

But I want to extend on this and have a special field for the value that should appear in the index. The package authorindex suggests the field authauthor for this (authentical author). The aim is to have one index entry for "Elisabet Engdahl" rather than two:

So the second entry should not be there.

This is what I cam up with, but it seems to ignore my authauthor field:

\documentclass[english]{scrartcl}
\listfiles
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

@misc{FreyTappe1991,
Author = {Frey, Werner and Tappe, Hans Thilo},
Howpublished = {Manuskript 30. Januar 1991},
Shortauthor = {F/T},
authautor = {Frey, Werner and Tappe, Hans Thilo},
Title = {{Zur Interpretation der X-bar-Theorie und zur Syntax des Mittelfeldes}},
Year = {1991}}

@phdthesis{Engdahl1980,
Author = {Engdahl, Elisabet Britt},
authauthor = {Engdahl, Elisabet},
Title = {The Syntax and Semantics of Questions in {Swedish}},
Type = {{PhD} dissertation},
School = {University of Massachusetts},
Note = {[Reproduced by GLSA, University of Massachusetts. Amherst, Ma. 1980]},
Year = {1980}}

@book{Engdahl1986,
Author = {Engdahl, Elisabet},
Publisher = {Reidel},
Title = {Constituent questions. {The} syntax and semantics of questions with special reference to {Swedish}},
Year = {1986}}

\end{filecontents}

\begin{filecontents}{authauthor.dbx}
\DeclareDatamodelFields[type=list, datatype=name]{
authauthor}
\DeclareDatamodelEntryfields{authauthor}
\end{filecontents}

\usepackage[
style=authoryear,
indexing=cite,
datamodel=authauthor
]{biblatex}
\bibliography{\jobname}

\usepackage{makeidx}
\makeindex

%% \renewbibmacro*{citeindex}{%
%%   \ifciteindex
%%     {\iffieldequalstr{labelnamesource}{shortauthor}
%%        {\indexnames{author}}
%%        {\iffieldequalstr{labelnamesource}{shorteditor}
%%           {\indexnames{editor}}
%%           {\indexnames{labelname}}}}
%%     {}}

\renewbibmacro*{citeindex}{%
\ifciteindex
{\iffieldequalstr{labelnamesource}{shortauthor}
{\iffieldundef{authauthor}
{\indexnames{author}}
{\indexnames{authauthor}}}
{\iffieldequalstr{labelnamesource}{author}
{\iffieldundef{authauthor}% if defined use authauthor
{\indexnames{author}}
{\indexnames{authauthor}}} % if defined use this field
{\iffieldequalstr{labelnamesource}{shorteditor}
{\iffieldundef{autheditor}
{\indexnames{editor}}
{\indexnames{autheditor}}}
{\indexnames{labelname}}}}}
{}}

\begin{document}
Some text \cite{FreyTappe1991}
\clearpage
Some text \cite{FreyTappe1991}

\clearpage
Some text \cite{FreyTappe1991}

\clearpage
Some text \cite{FreyTappe1991} and \cite{Engdahl1980,Engdahl1986}

\clearpage
\printbibliography
\printindex
\end{document}


authauthor is a name list, so you cannot use \iffieldundef you need to use \ifnameundef

\renewbibmacro*{citeindex}{%
\ifciteindex
{\iffieldequalstr{labelnamesource}{shortauthor}
{\ifnameundef{authauthor}
{\indexnames{author}}
{\indexnames{authauthor}}}
{\iffieldequalstr{labelnamesource}{author}
{\ifnameundef{authauthor}% if defined use authauthor
{\indexnames{author}}
{\indexnames{authauthor}}} % if defined use this field
{\iffieldequalstr{labelnamesource}{shorteditor}
{\ifnameundef{autheditor}
{\indexnames{editor}}
{\indexnames{autheditor}}}
{\indexnames{labelname}}}}}
{}}


You also need to declare autheditor if you want to use it

\begin{filecontents}{authauthor.dbx}
\DeclareDatamodelFields[type=list, datatype=name]{
authauthor,
autheditor}
\DeclareDatamodelEntryfields{authauthor,autheditor}
\end{filecontents}