Me gustaría colorear ciertas entradas de la bibliografía, por ejemplo, artículos "importantes" y "premiados". Lo que tengo en este 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}
Sin embargo, sólo el bibentry en sí es naranja (o azul, no se muestra a continuación), no el número de referencia al lado. ¿Cómo puedo lograr eso?
Respuesta1
Simplemente puede usar \AtBeginBibliography
y \AtEveryBibitem
para configurar el código para colorear las entradas de bibliografía solo de la important
categoría.
PD = Como no agregaste un ejemplo de tu .bib
archivo, usé 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:
El \ifcategory
comando tiene esta sintaxis:
\ifcategory{hcategoryi}{htruei}{hfalsei}
similar a muchos otros \if
comandos, consulte biblatex
el manual párr. 4.6.2 "Pruebas independientes".
Dentro de htruei
o hfalsei
puedes anidar tantas \ifcategory
s (u otras \if
) que quieras, sólo tienes que prestar atención a hacer coincidir todas las llaves.
Aquí hay un ejemplo con tres colores diferentes para tres categorías 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}