6

This question is apparently the same as this one, where the author did not follow up by providing a working example.

I would like to make the color of \citeauthor links to be black and the color of \cite to be blue. In the example that follows, both the author and the number citation are colored blue, and there is apparently not a citeauthorcolor keyword for hyperref. How can I produce different colors?

main.tex

\documentclass[12pt]{article}

\usepackage[colorlinks=true, citecolor=blue]{hyperref}
\usepackage[numbers]{natbib}

\begin{document}

The work by \citeauthor{myref} was a fancy read~\cite{myref}.

\bibliographystyle{plainnat}
\bibliography{main}

\end{document}

main.bib

@article{myref,
    title = {Fancy title},
    journal = {Journal of Fancy Publications},
    author = {Jane Dee and John Doe},
    year = {2017},
    pages = {293--311},
}

Compile: pdflatex main; bibtex main; pdflatex main; pdflatex main;

1
  • I would vote to close the other question as a duplicate of a non existed when asked :P
    – koleygr
    Sep 23, 2017 at 0:50

1 Answer 1

1

Here is a "hack":

\documentclass[12pt]{article}

\usepackage[colorlinks=true, citecolor=blue]{hyperref}
\usepackage[numbers]{natbib}
\usepackage{filecontents}

\let\oldciteauthor=\citeauthor
\def\citeauthor#1{\hypersetup{citecolor=blue}\oldciteauthor{#1}}
\let\oldcite=\cite
\def\cite#1{\hypersetup{citecolor=red}\oldcite{#1}}
\begin{filecontents}{main.bib}
@article{myref,
    title = {Fancy title},
    journal = {Journal of Fancy Publications},
    author = {Jane Dee and John Doe},
    year = {2017},
    pages = {293--311},
}
\end{filecontents}

\begin{document}

The work by \citeauthor{myref} was a fancy read~\cite{myref}.

\bibliographystyle{plainnat}
\bibliography{main}

\end{document}

Output:

enter image description here

1
  • This answer shows how it can be done with citet and citep, in combination with pre- and suffixes.
    – Bram
    Jun 1, 2019 at 15:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .