5

Does anyone know know how to change the color of the cite number in the bibliography?

\documentclass{book}  
\usepackage[square, numbers, comma, sort&compress]{natbib}  % Use the "Natbib" 

\begin{document}
How can I change the cite count number to blue~\cite{ref1}?

\label{References}
\bibliographystyle{unsrtnat}  % Use the "unsrtnat" BibTeX style for formatting 
\bibliography{Bibliography} 

\end{document}

And here is the content of the bib file

@article{ref1,
             author = {John Clark},
             title = {Learn to use Latex},
             journal = {Latex Journal},
             volume = {1},
             number = {1}, 
             year = {2014},
             pages = {1-2}  
} 

How can I change the "[1]" to blue

enter image description here

  • 2
    Please show a MWE of your code for see what are you using for work with bibliographies: bibtex or biblatex. – Aradnix Aug 21 '14 at 7:28
  • 1
    Sorry, I'm a noob. What is MWE? I am using natbib – wererabit Aug 21 '14 at 9:21
6
+50

I don't know why you'd want to do it, but here it is:

\begin{filecontents*}{\jobname.bib}
@article{ref1,
  author = {John Clark},
  title = {Learn to use {\LaTeX}},
  journal = {{\LaTeX} Journal},
  volume = {1},
  number = {1},
  year = {2014},
  pages = {1-2},
}
\end{filecontents*}

\documentclass{book}  
\usepackage[square, numbers, comma, sort&compress]{natbib}
\usepackage{xcolor,xpatch}

\makeatletter
\xpatchcmd{\@lbibitem}
 {\item[\hfil}
 {\item[\hfil\color{red}}
 {}{}
\makeatother
\begin{document}


How can I change the cite count number to blue~\cite{ref1}?

\bibliographystyle{unsrtnat}  % Use the "unsrtnat" BibTeX style for formatting 
\bibliography{\jobname}

\end{document}

The filecontents* environment is just to avoid clobbering my files, use the external .bib file as usual. Change red into whatever color you prefer, using the features provided by xcolor.

enter image description here

  • Redefine biblabel also work! \def\@biblabel#1{\textcolor{red}{[#1]}} – Say OL Oct 8 '17 at 15:57
  • Is it possible to do the same for some specific entry, not all of them? I'm using biber. – Sigur Mar 16 at 0:11
5

It's not clear to me if you want the citation call-out number to be set in blue or, instead, you wish to have the number that precedes the corresponding bibliographic entry set in blue.

If it's the former you want, an easy solution involves loading the hyperref package, setting its option colorlinks to true, and specifying the additional option citecolor=blue. As a separate (and probably quite important) benefit, the citation callouts will be made into hyperlinks to the corresponding entries.

(In the MWE below I've changed the document class from book to article purely to enable all output to be typeset on the same page.)

enter image description here

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{Bibliography.bib}
@article{ref1,
             author = {John Clark},
             title = {Learn to use {\LaTeX}},
             journal = {LaTeX Journal},
             volume = {1},
             number = {1}, 
             year = {2014},
             pages = {1-2}  
} 
\end{filecontents*}  
\usepackage[square, numbers, comma, sort&compress]{natbib}  
\bibliographystyle{unsrtnat}  % Use "unsrtnat" BibTeX style 
\usepackage[colorlinks=true,citecolor=blue]{hyperref}

\begin{document}
Now the cite count numbers are typeset in blue in the body of the text: \cite{ref1}

\bibliography{Bibliography}
\end{document}

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.