biblatex で参考文献のエントリを完全にカラー化するにはどうすればいいですか

biblatex で参考文献のエントリを完全にカラー化するにはどうすればいいですか

「重要」論文や「受賞」論文など、特定の参考文献のエントリをカラー化したいと考えています。現時点では次のものがあります。

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[backend=biber,
        isbn=true,
        giveninits=true,
        style=numeric,
        maxnames=99,
        sorting=ydnt,
        defernumbers=true,
        autocite=superscript]{biblatex}
\defbibheading{bibliography}[\refname]{}
\addbibresource{references.bib}
\renewbibmacro{in:}{}

\usepackage[usenames,dvipsnames]{xcolor}

\DeclareBibliographyCategory{important}
\DeclareBibliographyCategory{award}

\addtocategory{important}{small}
\addtocategory{award}{big}

\AtEveryBibitem{
\ifcategory{award}%
    {\color{blue}}%
    {}%
\ifcategory{important}%
    {\color{orange}}%
    {}%
}

\begin{document}

\section{Main text}

\cite{small}

\cite{big}

\section{Bibliography}
\printbibliography

\end{document}

しかし、bibentry 自体だけがオレンジ色 (または青色、以下には示されていません) で、その横にある参照番号はオレンジ色ではありません。どうすればこれを実現できますか?

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

答え1

と を使用するだけで\AtBeginBibliography\AtEveryBibitemカテゴリの参考文献エントリのみを色分けするコードを設定できますimportant

PS = ファイルの例を追加しなかったため.bib、 を使用しましたbiblatex-examples.bib

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[backend=biber,
isbn=true,
giveninits=true,
style=numeric,
maxnames=99,
sorting=ydnt,
defernumbers=true,
autocite=superscript]{biblatex}
\defbibheading{bibliography}[\refname]{}
\addbibresource{biblatex-examples.bib}
\renewbibmacro{in:}{}

\usepackage[usenames,dvipsnames]{xcolor}

\DeclareBibliographyCategory{important}
\addtocategory{important}{knuth:ct:a}
\addtocategory{important}{knuth:ct:c}

\AtBeginBibliography{%
    \DeclareFieldFormat{labelnumberwidth}{\ifcategory{important}%
        {\color{orange}\mkbibbrackets{#1}}%
        {\mkbibbrackets{#1}}%
    }}
\AtEveryBibitem{\ifcategory{important}
    {\color{orange}}
    {}}

\begin{document}

    \section{Main text}

    \cite{knuth:ct}
    \cite{knuth:ct:a}
    \cite{knuth:ct:b}       
    \cite{knuth:ct:c}       
    \cite{companion}

    \section{Bibliography}

    \printbibliography

\end{document}

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

編集:

コマンド\ifcategoryの構文は次のとおりです。

\ifcategory{hcategoryi}{htruei}{hfalsei}

\if他の多くのs コマンドと同様に、biblatexマニュアルの 4.6.2 項「スタンドアロン テスト」を参照してください。

htrueior内では、 (または他の)を必要なhfalsei数だけネストできます。注意する必要があるのは、すべての中括弧が一致することだけです。\ifcategory\if

以下は、3 つの異なるカテゴリに 3 つの異なる色を使用した例です。

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage[backend=biber,
isbn=true,
giveninits=true,
style=numeric,
maxnames=99,
sorting=ydnt,
defernumbers=true,
autocite=superscript]{biblatex}
\defbibheading{bibliography}[\refname]{}
\addbibresource{biblatex-examples.bib}
\renewbibmacro{in:}{}

\usepackage[usenames,dvipsnames]{xcolor}

\DeclareBibliographyCategory{important}
\addtocategory{important}{knuth:ct:a}
\addtocategory{important}{knuth:ct:c}
\DeclareBibliographyCategory{awards}
\addtocategory{awards}{knuth:ct:b}
\DeclareBibliographyCategory{ducks}
\addtocategory{ducks}{companion}

\AtBeginBibliography{%
    \DeclareFieldFormat{labelnumberwidth}%
        {\ifcategory{important}% if
            {\color{orange}\mkbibbrackets{#1}}% then
            {\ifcategory{awards}% else if
                {\color{blue}\mkbibbrackets{#1}}% then
                {\ifcategory{ducks}% else if
                    {\color{green}\mkbibbrackets{#1}}% then
                    {{\mkbibbrackets{#1}}%else
                }% end if
            }% end if
        }% end if
}}
\AtEveryBibitem%
    {\ifcategory{important}% if
        {\color{orange}}% then
        {\ifcategory{awards}% else if
            {\color{blue}}% then
            {\ifcategory{ducks}% else if
                {\color{green}}% then
                {}%else
            }% end if
        }% end if
    }% end if

\begin{document}

    \section{Main text}

    \cite{knuth:ct}
    \cite{knuth:ct:a}
    \cite{knuth:ct:b}       
    \cite{knuth:ct:c}       
    \cite{companion}

    \section{Bibliography}

    \printbibliography

\end{document}

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

関連情報