# hyperlink in amsrefs package miss the last parenthesis

It seems like a bug, I want to fix it but fails. I will describe the problem by the following MME:

\documentclass{amsart}
\usepackage[author-year]{amsrefs}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
AUTHOR = {Motazedifard, Ali and Dalafi, A. and Naderi, M. H. and
TITLE = {Controllable generation of photons and phonons in a coupled
{B}ose--{E}instein condensate-optomechanical cavity via the
parametric dynamical {C}asimir effect},
JOURNAL = {Ann. Physics},
FJOURNAL = {Annals of Physics},
VOLUME = {396},
YEAR = {2018},
PAGES = {202--219},
ISSN = {0003-4916},
MRCLASS = {81},
MRNUMBER = {3853390},
DOI = {10.1016/j.aop.2018.07.013},
URL = {https://doi.org/10.1016/j.aop.2018.07.013},
}
\end{filecontents}
\begin{document}
\bibliography{\jobname}
\end{document}


The compile result looks like: It is wired that the color is only for "In Motazedifard et al. (2018", why the last ")" is out of color?

I think I have seen this wrong coloring in some textbooks and now I am convinced that this is a bug in the amsrefs package. However (I could be wrong though), it is worth pointing out that rather than “missing the last right parenthesis”, the intended behavior should be “using black/normal colored parentheses while the authors and year are colored”. You can check this by typing

\cite{MotazedifardDalafiNaderiRoknizadeh2018Controllable}


which will produce a pair of black parentheses.

I can offer a fix which forces the left parenthesis to be black.

\documentclass{amsart}
\usepackage[author-year]{amsrefs}

\makeatletter
\renewcommand*\citesel@object[5]{\PrintCiteNames{#3} \textcolor{black}{\citeleft}#4}
% The original definition is
% \def\citesel@object#1#2#3#4#5{\PrintCiteNames{#3} \citeleft#4}
% which misses the possible color change by hyperref
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
AUTHOR = {Motazedifard, Ali and Dalafi, A. and Naderi, M. H. and
TITLE = {Controllable generation of photons and phonons in a coupled
{B}ose--{E}instein condensate-optomechanical cavity via the
parametric dynamical {C}asimir effect},
JOURNAL = {Ann. Physics},
FJOURNAL = {Annals of Physics},
VOLUME = {396},
YEAR = {2018},
PAGES = {202--219},
ISSN = {0003-4916},
MRCLASS = {81},
MRNUMBER = {3853390},
DOI = {10.1016/j.aop.2018.07.013},
URL = {https://doi.org/10.1016/j.aop.2018.07.013},
}
\end{filecontents}
\begin{document}
\bibliography{\jobname}
\end{document}


One could also force the right parenthesis to be cyan, like this:

\documentclass{amsart}
\usepackage[author-year]{amsrefs}

\usepackage{etoolbox}
\makeatletter
\patchcmd\cite@cj
{\citeright}
{\textcolor{cyan}\citeright}
{}{}
\makeatother

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
AUTHOR = {Motazedifard, Ali and Dalafi, A. and Naderi, M. H. and
TITLE = {Controllable generation of photons and phonons in a coupled
{B}ose--{E}instein condensate-optomechanical cavity via the
parametric dynamical {C}asimir effect},
JOURNAL = {Ann. Physics},
FJOURNAL = {Annals of Physics},
VOLUME = {396},
YEAR = {2018},
PAGES = {202--219},
ISSN = {0003-4916},
MRCLASS = {81},
MRNUMBER = {3853390},
DOI = {10.1016/j.aop.2018.07.013},
URL = {https://doi.org/10.1016/j.aop.2018.07.013},
}
\end{filecontents}
\begin{document}

• This fix seems work for the colorlinks setting of hyperref, but fails when I use ocgcolorlinks. – user19832 Sep 18 '18 at 13:35