I am trying to get alternate background color for bibliography, with AtBeginBebliography, as shown(Please note, \IF_COUNTER_IS_ODD does not have any meaning, it is just to show, I want orange \colorbox for odd number item, and the normal white background for even item.). This is a mwe
\documentclass[a4paper]{scrartcl}
\usepackage[dvipsnames, table]{xcolor}
\usepackage[
defernumbers=true,
sorting=ydnt,
maxbibnames=99,
citestyle=numeric
]{biblatex}
\addbibresource{mwe.bib}
\AtBeginBibliography{%
\DeclareFieldFormat{labelnumberwidth}{\IF_COUNTER_IS_ODD%
{\colorbox{orange}\mkbibbrackets{#1}}%
{\mkbibbrackets{#1}}%
}}
\AtEveryBibitem{\IF_COUNTER_IS_ODD
{\colorbox{orange}}
{}}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
mwe.bib
@article{einstein,
author = "Albert Einstein",
title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004"
}
@book{latexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The \LaTeX\ Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
\colorboxare doomed, because the waybiblatexproduces bibliography entries does not lend itself to absorbing the entry as an argument of a macro. But there is https://tex.stackexchange.com/q/457084/35864. An alternative if you don't like that might be possible withlua-ulbut will need you to compile your document with LuaLaTeX (which may or may not be an issue for you). – moewe Sep 06 '20 at 15:26lua-ulsolution will look more like https://tex.stackexchange.com/q/547414/35864, which is probably not quite what you have in mind. – moewe Sep 06 '20 at 15:31