在bibtex中为多个参考文献着色

在bibtex中为多个参考文献着色

请查看此链接中的问题和答案: 如何更改乳胶中参考书目中特定参考文献的文本颜色?(使用 IEEE 交易书目样式)

我想知道如何使用多个参考来实现这一点。也就是说,如果我想将多个参考标记为蓝色?

答案1

你可以嵌套多个\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
    }%
}

这是一个 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}

相关内容