3

I'm writing a grant proposal (whee) and I was given a suggestion to make two different citations with two different colors. So it would be something like:

In the PI's prior work~\citeme{mycoolpaper} he proved a cool theorem; 
subsequent follow-up work by others~\cite{otherpaper} provided empirical 
validation on several benchmark data sets.

In the formatting \citeme{} would be colored red, and \cite{} blue, using \hypersetup{} or something like that.

I know that one can do this with \href, but I wasn't sure if you could specify a custom \cite command.

I feel like some combination of the cite and hyperref and maybe biblatex would do it?

7

The following example defines \citeme and changes the citecolor inside a group. Care is taken to support the optional argument of \cite:

\documentclass{article}
\usepackage[colorlinks]{hyperref}

\makeatletter
\newcommand*{\citeme}{%
  \begingroup
  \hypersetup{citecolor=red}%
  \@ifnextchar[\citeme@opt\citeme@
}
\def\citeme@opt[#1]#2{%
  \cite[{#1}]{#2}%
  \endgroup
}
\newcommand*{\citeme@}[1]{%
  \cite{#1}%
  \endgroup
}
\makeatother

\begin{document}

In the PI's prior work~\citeme{mycoolpaper} he proved a cool theorem;
subsequent follow-up work by others~\cite{otherpaper} provided empirical
validation on several benchmark data sets.

\begin{thebibliography}{9}
\bibitem{mycoolpaper}
  Me: Cool Title.

\bibitem{otherpaper}
  Someone else: Hot Title.

\end{thebibliography}
\end{document}

Result

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.