Como posso colorir totalmente as entradas da bibliografia com o biblatex?

Como posso colorir totalmente as entradas da bibliografia com o biblatex?

Gostaria de colorir certas entradas bibliográficas, por exemplo, artigos "importantes" e "premiados". O que tenho no momento:

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

No entanto, apenas o bibentry em si é laranja (ou azul, não mostrado abaixo), e não o número de referência próximo a ele. Como posso conseguir isso?

insira a descrição da imagem aqui

Responder1

Você poderia simplesmente usar \AtBeginBibliographye \AtEveryBibitempara definir o código para colorir apenas as entradas bibliográficas da importantcategoria.

PS = Como você não adicionou um exemplo do seu .bibarquivo, usei 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}

insira a descrição da imagem aqui

Editar:

O \ifcategorycomando tem esta sintaxe:

\ifcategory{hcategoryi}{htruei}{hfalsei}

semelhante a muitos outros \ifcomandos, consulte biblatexo manual para. 4.6.2 "Testes Autônomos".

Dentro de htrueiou hfalseivocê pode aninhar quantos \ifcategorys (ou outros \ifs) quiser, basta prestar atenção combinando todos os colchetes.

Aqui está um exemplo com três cores diferentes para três categorias diferentes:

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

insira a descrição da imagem aqui

informação relacionada