How to change text color a particular reference in the bibliography in latex? (using ieee transactions bibliography style)
I found a simple - and totally hackish - way to color specific items.
Just find in the resulting file the last thing written in the reference you want to color and put a \color{black}
after it, so everything after the reference will not be painted by a different color.
There are two versions of this trick:
Put
\color{blue}
after the first subitem of your reference and\color{black}
after the last one. In your case, the first subitem is the author and the last is the year, so your bibfile will looks like this (P.s.: I added another reference to test the effect):@article{fuente, author = {D. de la Fuente and J.G. Castaño and M. Morcillo}, title = {Long-term atmospheric corrosion of zinc}, journal = {Corrosion Science}, volume = {49}, year = {2007}, pages = {1420–1436}, } @article{test2, author = {Zhu Zimmermann}, title = {The glory of the letter Z}, journal = {Alphanumeric Characters}, volume = {99}, year = {1999}, pages = {199-299}, } @article{nature, author = {\color{blue}Rosa Rademakers and Manuela Neumann and Ian R. Mackenzie}, title = {Advances in understanding the molecular basis of frontotemporal dementia - elongated title}, journal = {Nature Reviews Neurology}, volume = {8}, year = {2012\color{black}}, pages = {423-434}, doi = {10.1038/nrneurol.2012.117}, }
And your result will be this:
- Advantages: you don't need to test for the string content, so you can easily apply in many unrelated items.
- Drawbacks: the numbering will NOT be painted along with the reference
If you need the number to have the same color, you can try this:
Don't put the
\color{blue}
in the first subitem of the reference you want to color, but instead in the last subitem of the reference immediately above your reference - in the resulting file, NOT in the bib file. This way, the number will be painted together with the text. This will be your bibfile:@article{fuente, author = {D. de la Fuente and J.G. Castaño and M. Morcillo}, title = {Long-term atmospheric corrosion of zinc}, journal = {Corrosion Science}, volume = {49}, year = {2007\color{blue}}, pages = {1420–1436}, } @article{test2, author = {Zhu Zimmermann}, title = {The glory of the letter Z}, journal = {Alphanumeric Characters}, volume = {99}, year = {1999}, pages = {199-299}, } @article{nature, author = {Rosa Rademakers and Manuela Neumann and Ian R. Mackenzie}, title = {Advances in understanding the molecular basis of frontotemporal dementia - elongated title}, journal = {Nature Reviews Neurology}, volume = {8}, year = {2012\color{black}}, pages = {423-434}, doi = {10.1038/nrneurol.2012.117}, }
And here is the result:
- Advantages: the numbering will be painted along with the reference
- Drawbacks: items are not independent of the others, so if you add another item you may need to change where you put the
\color{blue}
.
\color{xxx}
is a switch that change the color of the text, and it applies to the text following it (in a group). However, \bibitem
does not set a group. This is way the color is propagated to the item following the entry where the color is set.
Here is a simple hack to that achieve the result of the OP (it uses the toolbox
package, i.e., \usepackage{etoolbox}
)
\let\mybibitem\bibitem
\renewcommand{\bibitem}[1]{%
\ifstrequal{#1}{nature}
{\color{blue}\mybibitem{#1}}
{\color{black}\mybibitem{#1}}%
}