Search code examples
latexbiblatex

How to colour reference brackets in Latex? All methods I tried, are incompatible with biblatex so I get reference outputted as [?]


To make reference list, I am using biblatex package:

\usepackage[ natbib=true, style=numeric,sorting=none]{biblatex}
\addbibresource{name.bib}

I found a way to colour the reference brackets:

\usepackage{color}
\usepackage{hyperref}
\usepackage{cite}
\renewcommand{\citeleft}{\textcolor{red}{[}}
\renewcommand{\citeright}{\textcolor{red}{]}}

I do get the brackets coloured, but the reference shows as [?]. I read that cite package is incompatible with biblatex, but I cannot find how to do it using biblatex. How do I do it?


Solution

  • The biblatex-ext package has the handy \DeclareOuterCiteDelims macro:

    \documentclass{article}
    
    \usepackage[natbib=true,style=ext-numeric,sorting=none]{biblatex}
    \addbibresource{biblatex-examples.bib}
    \usepackage{color}
    
    \DeclareOuterCiteDelims{cite}{\textcolor{green}{\bibopenbracket}}{\textcolor{red}{\bibclosebracket}}
    
    \begin{document}
    
    \cite{knuth:ct}
    
    \printbibliography
    
    \end{document}
    

    enter image description here