4

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

1 Answer 1

6

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

9
  • Actually I realized that this does not work with natbib. I need to change a lot of stuffs but this helpful anyways. thks
    – Adakite
    Commented Jan 23, 2015 at 16:23
  • 1
    @Adakite That is why you should be specific in your question. Your question title used BibTeX and bibtex (not natbib) was the category tag. I myself have no experience with natbib. Commented Jan 23, 2015 at 16:26
  • this is because I did not realized that natbib is totaly disconnected to bibtex. I thought natbib was just a specific package for bibtex . My bad. But again, your answer is relevant so thanks again.
    – Adakite
    Commented Jan 23, 2015 at 16:35
  • 1
    @Adakite - what makes you think that natbib and BibTeX are "totally disconnected"? The natbib package is a citation management package that's compatible with many bibliography styles; it doesn't take over, replace, or otherwise conflict with any of BibTeX's tasks.
    – Mico
    Commented Jan 23, 2015 at 17:20
  • 1
    @cartoonist Glad you could figure it out an make it work for your application. Commented Sep 3, 2017 at 15:22

You must log in to answer this question.

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