This is a follow-up question from here. One of the examples in the top solution work well with the plainnat style, but when I used the aea style, it threw an error.
Here is the aea style with a MWE that does not involve acronyms.
\begin{filecontents*}{\jobname.bib}
@article{oasis,
author={{Organization for the Advancement of Structured Information Standards}},
title={Some title},
journal={J. Something},
year={2012},
}
\end{filecontents*}
\documentclass{article}
\usepackage[authoryear]{natbib}
\begin{document}
Here it is \citep{oasis}
A second time \citep{oasis}
\bibliographystyle{aea}
\bibliography{\jobname}
\end{document}
The output is very good:
However, with the acronym, TexStudio won't compile:
\begin{filecontents*}{\jobname.bib}
@article{oasis,
author={{\acroauthor{Organization for the Advancement of Structured Information Standards}{OASIS}}},
title={Some title},
journal={J. Something},
year={2012},
}
\end{filecontents*}
\documentclass{article}
\usepackage[authoryear]{natbib}
\usepackage{etoolbox}
\newif\ifabbreviation
\pretocmd{\thebibliography}{\abbreviationfalse}{}{}
\AtBeginDocument{\abbreviationtrue}
\DeclareRobustCommand\acroauthor[2]{%
\ifabbreviation
\ifcsname acroused@#2\endcsname
#2%
\else
#1%
%~(\mbox{#2})% <----
\expandafter\gdef\csname acroused@#2\endcsname{}%
\fi
\else
#1
(\mbox{#2})%
\fi
}
\begin{document}
Here it is \citep{oasis}
A second time \citep{oasis}
\bibliographystyle{aea}
\bibliography{\jobname}
\end{document}
Instead, it throws three errors along with two warnings:
Something's wrong--perhaps a missing \item. ...nformation Standards}{OASIS}}}{2012}{oasis}
Something's wrong--perhaps a missing \item. ...nformation Standards}{OASIS}}}{2012}{oasis}
Something's wrong--perhaps a missing \item. ...nformation Standards}{OASIS}}}{2012}{oasis}
File `document.bib' already exists on the system.
Empty `thebibliography' environment
For reference, aea.bst can be obtained here, in the zip file called LaTeX templates.


\defcitealias, but I had not thought to use a combination of\defcitealias,\newcommand, and\citeyear. This answer works well for me for my current needs. – Life is Good Apr 23 '21 at 19:24