3

Kindly look at the question and the answer given in this link: How to change text color a particular reference in the bibliography in latex? (using ieee transactions bibliography style)

I would like to know how to do this with more than one reference. That is, if I want to color more than one reference in blue?

1 Answers1

5

You could nest several \ifstrequal:

\let\mybibitem\bibitem
\renewcommand{\bibitem}[1]{%
  \ifstrequal{#1}{<BibtexKey1>}
    {\color{blue}\mybibitem{#1}}% IF #1==<BibtexKey1>
    {% ELSE
      \ifstrequal{#1}{<BibtexKey2>}
        {\color{blue}\mybibitem{#1}}% IF #1==<BibtexKey1>
        {\color{black}\mybibitem{#1}}% ELSE
    }%
}

Here is a MWE.

Disclaimer: Note that the last blue references is/are not numbered in the bibliography. I don't understand why.

MWE

\documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{filecontents}
        \begin{filecontents}{jobname.bib}
            @article{greenwade93,
                author  = "George D. Greenwade",
                title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
                year    = "1993",
                journal = "TUGBoat",
                volume  = "14",
                number  = "3",
                pages   = "342--351"
            }
            @book{goossens93,
                author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
                title     = "The LaTeX Companion",
                year      = "1993",
                publisher = "Addison-Wesley",
                address   = "Reading, Massachusetts"
            }
            @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{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", 
                pages = "423-434", 
                doi = "10.1038/nrneurol.2012.117",
            } 
        } 
    \end{filecontents}
    \usepackage{color}
    \usepackage{etoolbox}
    \documentclass{article}
        \usepackage[utf8]{inputenc}
        \usepackage[T1]{fontenc}
        \usepackage{filecontents}
            \begin{filecontents}{jobname.bib}
                @article{greenwade93,
                    author  = "George D. Greenwade",
                    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
                    year    = "1993",
                    journal = "TUGBoat",
                    volume  = "14",
                    number  = "3",
                    pages   = "342--351"
                }
                @book{goossens93,
                    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
                    title     = "The LaTeX Companion",
                    year      = "1993",
                    publisher = "Addison-Wesley",
                    address   = "Reading, Massachusetts"
                }
                @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{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", 
                    pages = "423-434", 
                    doi = "10.1038/nrneurol.2012.117",
                } 
            } 
        \end{filecontents}
        \usepackage{color}
        \usepackage{etoolbox}
        \usepackage{cite}

    \let\mybibitem\bibitem
    \renewcommand{\bibitem}[1]{%
        \ifstrequal{#1}{greenwade93}
        {\color{blue}{\mybibitem{#1}}}% IF #1==<BibtexKey1>
        {% ELSE
            \ifstrequal{#1}{goossens93}
              {\color{blue}{\mybibitem{#1}}}% IF #1==<BibtexKey1>
              {\color{black}\mybibitem{#1}}% ELSE
        }
    }

    \begin{document} 
        This is my document \cite{fuente} and we have another \cite{nature}. We can speak also about \LaTeX! So two more reference: \cite{greenwade93} and \cite{goossens93}

        \bibliographystyle{ieeetr}
        \bibliography{jobname} 
        \let\mybibitem\bibitem
    \end{document}
ebosi
  • 11,692