Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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

share|improve this answer
    
Amazing! Thank you so much! –  Anand Sarwate Jul 6 at 21:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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