# The 'inverted' attribute is not recognized if a \DefineName abbreviation is used in an AMSRefs \bib entry

In Section 8.1 of the AMSRefs package documentation, it is explained that to properly typeset author names that are to be written with the family name first, one should set the attribute inverted on that name; for example: author={Li, Lian Jie}*{inverted={yes}} will typeset correctly as 'Li Lian Jie' (and not as 'Li, Lian Jie' or 'Lian Jie Li'). Trying to use author={Li Lian Jie} to force the correct name will not work if, for instance, the option initials or the option alphabetic is called.

In Section 8.4, it is explained that one can write \DefineName{dmj}{Jones, David M.} and then use the abbreviation as author={dmj} in any \bib entry.

However, when I use an abbreviation in a \bib entry, the inverted attribute is not recognized. This happens even if there are multiple authors in a \bib entry and any one name is entered using an abbreviation, and even if that name is not the one to which the inverted attribute is being passed. Here's an MCVE:

\documentclass{amsart}

\usepackage{amsrefs}

\DefineName{aut-f}{Author, First}
\DefineName{aut-s}{Author, Second}

\begin{document}

\begin{bibdiv}
\begin{biblist}

\raggedright

\bib{art1}{article}{
author={Author, First}*{inverted={yes}},
author={Author, Second}*{inverted={yes}},
title={Title of the paper},
journal={Journal of interesting results},
volume={10},
date={2021},
number={3},
pages={8\ndash 11},
review={\MR{12345}},
}

\end{biblist}
\end{bibdiv}

\end{document}


The output for the above example looks like this:

Author First and Author Second, Title of the paper, Journal of interesting results 10 (2021), no. 3, 8–11. MR12345

Now, if I write author={aut-f} instead of author={Author, First}, the output changes to:

First Author and Second Author, Title of the paper, Journal of interesting results 10 (2021), no. 3, 8–11. MR12345

That is, it behaves as if the inverted attribute is not passed to any of the entries. The output remains as above regardless of how I mix and match the inverted attributes with the abbreviations.

I also tried adding *{inverted={yes}} to the \DefineName commands, but that throws out LaTeX Error: Missing \begin{document}.

Question: How can I get the inverted attribute to work with the \DefineName abbreviations?

I tried looking at the documented source, but I was not really able to gather anything of use on my own. I noticed that \DefineSimpleKey{prop}{inverted} is defined on line 236, and we have on lines 2450–2461:

\def\set@name@a#1{%
\begingroup
\get@current@properties
\select@auxlanguage
\def\@tempa{yes}%
\ifx\@tempa\prop’inverted
\setbib@nameBE
\else
#1%
\fi
\endgroup
}


But, I'm not sure how to relate this to the definition of \DefineName given on lines 1244–1246:

\newcommand{\DefineName}[2]{%
\bib*{#1}{name}{name={#2}}%
}


I also looked at the documentation for the rkeyval package to find out whether the key value option *{inverted={yes}} needs to somehow be added to the definition of the command \DefineName, but once again I didn't get much out of it (being far too much of a novice). For instance, on page 3 of the rkeyval documentation the following is mentioned:

Test for a trailing option marked by a star. Usage:

\newcommand{\blub}[1]{\star@{\blubaux{#1}}{default}}


Arg 1 of \star@ is the code to be run, arg 2 is the default value of the option (could be empty). If arg 1 is \moo, this test discards a star and expands to \moo if a star is found, or expands to \moo{#2} if not. As the example shows, arg 1 need not be a single token.

10 \def\star@#1#2{%
11     \def\star@a##1{#1}%
12     \def\star@b{#1{#2}}%
13     \futurelet\@let@token\star@test
14 }
15
16 \def\star@test{\ifx*\@let@token \let\star@b\star@a\fi \star@b}


Perhaps this is relevant? I'm honestly quite lost.

I also noticed that if I define a command called \DefineInvertedName analogously to \DefineName as

\newcommand{\DefineInvertedName}[2]{%
\bib*{#1}{name}{name={#2}*{inverted={yes}}}%
}


\DefineInvertedName{aut-f1}{Author, First}

to the preamble in the MCVE above, and using author={aut-f1} and author={aut-s1} in the \bib entry, gives this as the output:
That is, only the last author entry is inverted. The same happens when I create a \bib entry with more than two authors: only the last author entry is inverted. This is possibly a byproduct of the way multiple author entries are strung together by AMSRefs, but I'm not able to pinpoint exactly why it is so.