参考文献内の特定の参照を色分けする

参考文献内の特定の参照を色分けする

原稿の改訂版では、通常、新しい変更点を色付きのテキストでマークします。この質問は、ファイル内の特定の参照に対してこれを行うさまざまな方法に関するものです.bib。これについては以前にも解決策がありましたが、私には満足のいくものではありません。これです1 つの参照に対してのみ作業を実行します。ここは、複数のネストされた を使用することで、複数の参照に対応する前の の拡張ですifstreqal。ただし、色付きの参照の数が増えると、これはまったく役に立たなくなる可能性があります。

私が考えているのは、ネストされた構造の作成にユーザーを関与させることなく、色付きの参照のラベルをすべて取得するコードを用意することです。

その他の新しいソリューションも歓迎します。

まず最初に MWE を紹介します。

\documentclass{article}
\usepackage{filecontents}
\usepackage{color}
\usepackage{etoolbox}

\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}

\let\mybibitem\bibitem
\renewcommand{\bibitem}[1]{%
    \ifstrequal{#1}{greenwade93}
    {\color{blue}\mybibitem{#1}}
    {\color{black}\mybibitem{#1}}%
}

\begin{document}

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

\bibliographystyle{ieeetr}
\bibliography{jobname}

\end{document}

答え1

biblatex/biber を使用すると、参照をマークするのは非常に簡単です。

 \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xcolor}
\usepackage[style=ieee]{biblatex}
\addbibresource{biblatex-examples.bib}
\DeclareBibliographyCategory{changed}
\addtocategory{changed}{doody,angenendt}
\AtEveryBibitem{\ifcategory{changed}{\color{red}}{}}
\DeclareFieldFormat{labelnumberwidth}{\ifcategory{changed}{\textcolor{green}{\mkbibbrackets{#1}}}{\mkbibbrackets{#1}}}
\begin{document}
\cite{doody,herrmann,angenendt}
\printbibliography

\end{document}

ここに画像の説明を入力してください

関連情報