I'm trying to recreate the \cite behaviour for multiple authors using a custom citing format. Essentially I want to have the author's name in black text, while the year is a colored hyperlink. Would anyone know how to accomplish this?
My current attempt is to recursively build the citation by feeding in the last author (#1 in addcite) and the remaining list of works to be cited (#2,#3). The first work to be cited is popped off from the remaining list (\citeauthor{#2}) and compared to the reported last author (#1), then the behavior is decided based on if it is the same author or not. However, I cannot get the comparison to work (I think it has to do with the comparison not comparing the literal text, but maybe differing because they have different hyperrefs, being the same author but different works). And for some reason the first work is always lost (but works fine when given a single citation).
\newcommand{\mycite}[1]{(\addcite(,#1,))}
\def\addcite(#1,#2,#3){%
\def\temp{\citeauthor{#2}}%
\ifx\temp#1%
\citeyear{#2}%
\else{\hypersetup{citecolor=black}\citeauthor{#2}}~\citeyear{#2}%
\fi%
\def\tempA{\citeauthor{#2}}%
\ifx\relax#3%
\relax%
\else; \addcite(\tempA,#3)%
\fi
}
Ideal working solution would take
\mycite{AuthorA_Year1,AuthorA_Year2,AuthorB_Year1,AuthorB_Year3}
and return (punctuation not important):
AuthorA (Year1; Year2); AuthorB (Year1; Year3)
Where AuthorA and AuthorB are in black, and the years are in whatever the citecolor is defined as from hyperref.
authoryearstyle inbiblatexplushyperrefwith thecolorlinksoption, and as a gift, the year will be a also a link to the reference. See the last example form here but in the second line add\usepackage[colorlinks]{hyperref}– Fran Jun 26 '20 at 15:13backrefto have back references! Anway,natbibalso can usehyperrefto link the cite, although including also the author part in the link, that I think that is better than link only the year, but If you are picky about this, see here. – Fran Jun 27 '20 at 01:29