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?
Responder1
Você poderia simplesmente usar \AtBeginBibliography
e \AtEveryBibitem
para definir o código para colorir apenas as entradas bibliográficas da important
categoria.
PS = Como você não adicionou um exemplo do seu .bib
arquivo, 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}
Editar:
O \ifcategory
comando tem esta sintaxe:
\ifcategory{hcategoryi}{htruei}{hfalsei}
semelhante a muitos outros \if
comandos, consulte biblatex
o manual para. 4.6.2 "Testes Autônomos".
Dentro de htruei
ou hfalsei
você pode aninhar quantos \ifcategory
s (ou outros \if
s) 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}