[Tex/LaTex] Different style/color for some specific references using Bibtex

bibtexcitingfonts

I need to differentiate some specific references from the others, for both the text and the reference list at the end of the document. Let say I want the "regular" ones in blue and the specific (i.e. mine actually) in orange.

For now, I have something quite standard like this:

in the .tex file:

\usepackage[authoryear,colon,square]{natbib}
\bibliographystyle{dcu}
\begin{document}

Something to say \citep{one_regular_ref01,another_regular_ref02,my_specific01}.

My .bib is normal as I parsed the entrees from journal's website.

This gives me something like this:

Something to say [RegRef et al, 2001; aRegRef et al, 2002; My_paper, 2010].

Everything has the same color. But I'd like my own ref in a different one.

Ok I can edit the bib file but it seems odd to me as I can potentially use the same bib for another document without this very specific need.

I was thinking that adding * (for instance) to the end of the citation call (i.e. \citep{my_specific01*}) could be a way to discriminate the specific citations but now how can I tell bibtex to change the way these references are displayed (again in the text and the reference list) to a different color or potentially any font style.

I did not find anything on the web that treat and solve this very specific task using bibtex but any ideas would be more than appreciated.

thanks

Best Answer

Here there are two preparations the user must make

\preparecolorrefs{integer} where integer is greater or equal to the total number of references in the document

\refcolor{cite-label}{color} to indicate the color for particular citations that aren't black.

EDITED to make a self-compiling example (no external files required).

\documentclass{article}
\usepackage{xcolor,ifthen,filecontents}
\makeatletter
\let\svbibcite\bibcite
\let\svbiblabel\@biblabel
\def\bibcite#1#2{\svbibcite{#1}{%
  \if\relax\csname#1color\endcsname\relax\refcolor{#2}{black}\else%
    \refcolor{#2}{\csname#1color\endcsname}\fi%
  \if\relax\csname#1color\endcsname\relax\textcolor{black}{#2}\else%
    \textcolor{\csname#1color\endcsname}{#2}\fi}}
\def\@biblabel#1{\svbiblabel{\textcolor{\csname#1color\endcsname}{#1}}}
\makeatother
\def\refcolor#1#2{\expandafter\xdef\csname#1color\endcsname{#2}}
\newcounter{refindex}
\def\preparecolorrefs#1{%
  \setcounter{refindex}{0}%
  \whiledo{\value{refindex}<#1}{%
    \stepcounter{refindex}%
    \expandafter\def\csname\therefindex color\endcsname{black}%
  }%
}
\preparecolorrefs{5}% MUST CHOOSE A NUMBER > OR EQUAL TOTAL NUMBER OF REFERENCES
\refcolor{A01}{green}
\refcolor{C03}{red}
\begin{filecontents}{mybib.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha}
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo}
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {Charlie}
}
@misc{D04,
  author = {Duthor, D.},
  year = {2004},
  title = {Delta}
}
\end{filecontents}
\begin{document}
cite \cite{A01, B02, C03, D04}
\bibliographystyle{unsrt}
\bibliography{mybib}
\end{document}

enter image description here