两个带有不同颜色链接的 \cite 命令?

两个带有不同颜色链接的 \cite 命令?

我正在写一份拨款提案(哇),有人建议我用两种不同的颜色制作两个不同的引文。所以它会是这样的:

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.

在格式化时\citeme{}\cite{}用红色、蓝色\hypersetup{}或类似的颜色。

我知道可以用\href,但我不确定您是否可以指定自定义\cite命令。

我觉得将citehyperref和进行某种组合也许biblatex可以做到这一点?

答案1

以下示例定义\citeme并更改了citecolor组内的。注意支持可选参数\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}

结果

相关内容