# String to sort index of authors generated with biblatex

I have an index of cited authors generated with biblatex and imakeidx. How can I have this index sorted by the sortkey field in the bib-file, if defined.

For indexing titles there is a indexsorttitle field (biblatex manual p. 26), but there is no parallel for authors.

My idea was to use the sortstring@printed name syntax in the \index commend via the bibmacro, but I dont know how to make this work. Something like \iffieldundef{sortkey}{}{\thefield{sortkey}@} inserted in the macro, perhaps?

In the example below, al-Xalil should be sorted after Brutus in the index.

\documentclass{book}
\usepackage{imakeidx}
\usepackage{filecontents}
\usepackage[indexing=cite]{biblatex}

\makeindex[title=Index of Authors, name=author]
\renewbibmacro*{citeindex}{%
{\indexnames{labelname}}{}}

\DeclareIndexNameFormat{default}{%
\usebibmacro{index:name}{\index[author]}
{#1}{#3}{#5}{#7}}

\begin{filecontents}{general.bib}
@misc{A01,
author = {Arabicname al-Xalil},
year = {2001},
sortkey = {xalil},
title = {Alpha}
}
@misc{B02,
author = {Alex Brutus},
year = {2002},
title = {Bravo}
}
\end{filecontents}

\begin{document}

\cite{A01}
\cite{B02}

\printindex[author]
\end{document}


Accorindg to the biblatex documentation the field sortkey is not written to the .bbl file and thus not available for use in the document (p. 27).

We will have to use another field, because I'm lazy I used usera below. One could of course create a new indexsortname field via a .dbx file.

Then we simply use as you yourself suggested

\renewbibmacro*{index:name}[5]{%
\usebibmacro{index:entry}{#1}
{\iffieldundef{usera}{}{\thefield{usera}\actualoperator}\mkbibindexname{#2}{#3}{#4}{#5}}}


MWE

\documentclass{article}
\usepackage{imakeidx}
\usepackage{filecontents}
\usepackage[indexing=cite]{biblatex}

\makeindex[title=Index of Authors, name=author]
\renewbibmacro*{citeindex}{%
{\indexnames{labelname}}{}}

\renewbibmacro*{index:name}[5]{%
\usebibmacro{index:entry}{#1}
{\iffieldundef{usera}{}{\thefield{usera}\actualoperator}\mkbibindexname{#2}{#3}{#4}{#5}}}

\DeclareIndexNameFormat{default}{%
\usebibmacro{index:name}{\index[author]}
{#1}{#3}{#5}{#7}}

\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Arabicname al-Xalil},
year = {2001},
usera = {xalil},
sortkey = {xalil},
title = {Alpha}
}
@misc{B02,
author = {Alex Brutus},
year = {2002},
title = {Bravo}
}
\end{filecontents}

• I am trying to implement this solution while using a name field (instead of usera). Would you know how to write the index:name macro so that it prints the name field into the index, e.g. with "last name, given name" (instead of \thefield{usera})? Thanks Jan 6 '18 at 23:11
• @ienissei The field usera here is only for sorting. It is not printed. The printing is done by \mkbibindexname and that is indeed applied to a name field (as you can see in the output). I'm not quite sure what you need. Can you give more details? (If necessary in a new question?) Jan 7 '18 at 7:35