# Inconsistent bracket color with citet and citep

I am using biblatex:

\usepackage[style=authoryear,
natbib=true,
hyperref=true,
url=false,
doi=false,
isbn=false,
sorting=nyt,
bibstyle=numeric,
backend=bibtex]{biblatex}
\usepackage{hyperref}


and the hyperref workaround:

\DeclareCiteCommand{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{citeyear}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{ \usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{cite}}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
{\boolfalse{cbx:parens}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{\usebibmacro{textcite}}}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}%
\multicitedelim}
{\usebibmacro{textcite:postnote}}


The color of the hyperref is green. If I use \citet, I get this result, where the end bracket is not green.

for \citep the same thing happen:

and \cite:

how can I change the color of the bracket so that it is consistent?

• Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Skillmon Apr 7 '18 at 6:49

Full linking is hard with biblatex. Additionally, there could be confusion about the target of links with certain styles. That is why the defaults only link the year/title. Nevertheless, full links seem to be high up many people's wish lists.

The style authoryear is fortunately fairly unproblematic conceptually. But we still have to re-implement all citation commands.

Normally, parts of the citation are typeset when the entry/entries processed are not yet known or not known any more or where grouping makes things a bit awkward, this is true for the parentheses as well as post- and pre-notes. We have to bring the typesetting of these elements into a context where it is known what entry they "belong" to and where the links can easily be applied.

This is going to be much harder with other more intricate styles such as authoryear-icomp that use the punctuation tracker between entries. The punctuation tracker makes text and punctuation typesetting asynchronous leading to edge cases where it can be much more complicated to get the link right around punctuation marks.

Note that the code uses internal macros of hyperref that are only available if that package is loaded. No error checking is done to prevent errors from not loading hyperref.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\makeatletter

\DeclareCiteCommand{\cite}
{}%
{\DeclareFieldFormat{bibhyperref}{####1}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeindex}%
\usebibmacro{cite}%
\ifnumequal{\value{citecount}}{\value{citetotal}}
{\usebibmacro{postnote}}
{}%
\iflastcitekey{}{\multicitedelim}%
{}
{}

\DeclareCiteCommand*{\cite}
{}%
{\DeclareFieldFormat{bibhyperref}{####1}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeindex}%
\usebibmacro{citeyear}%
\ifnumequal{\value{citecount}}{\value{citetotal}}
{\usebibmacro{postnote}}
{}%
\iflastcitekey{}{\multicitedelim}%
{}
{}

\DeclareCiteCommand{\parencite}
{}%
{\DeclareFieldFormat{bibhyperref}{####1}%
\iffirstcitekey{\bibopenparen}{}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeindex}%
\usebibmacro{cite}%
\ifnumequal{\value{citecount}}{\value{citetotal}}
{\usebibmacro{postnote}}
{}%
\iflastcitekey{\bibcloseparen}{\multicitedelim}%
{}
{}

\DeclareCiteCommand*{\parencite}
{}%
{\DeclareFieldFormat{bibhyperref}{####1}%
\iffirstcitekey{\bibopenparen}{}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeindex}%
\usebibmacro{citeyear}%
\ifnumequal{\value{citecount}}{\value{citetotal}}
{\usebibmacro{postnote}}
{}%
\iflastcitekey{\bibcloseparen}{\multicitedelim}%
{}
{}

\DeclareCiteCommand{\textcite}
{\boolfalse{cbx:parens}}
{\DeclareFieldFormat{bibhyperref}{####1}%
\usebibmacro{citeindex}%
\iffirstcitekey
{\setcounter{textcitetotal}{1}}
{\stepcounter{textcitetotal}%
\textcitedelim}%
\usebibmacro{textcite}%
\iflastcitekey
{}
{\ifbool{cbx:parens}
{\bibcloseparen\global\boolfalse{cbx:parens}}
{}}%
\ifnumequal{\value{citecount}}{\value{citetotal}}
{\usebibmacro{textcite:postnote}}
{}%
{}
{}

\DeclareMultiCiteCommand{\parencites}{\parencite}{}
\makeatother

\begin{document}
A\cite{sigfridsson}B

\parencite{sigfridsson}

\textcite{sigfridsson}

\parencite[cf.][380]{sigfridsson}

\parencite{sigfridsson,worman,geer}

\parencite[cf.][1]{sigfridsson,worman,geer}

\printbibliography
\end{document}


• I know the question only asked about the colour of the brackets, but this is really at its heart a question about the links and their 'scope'. – moewe Apr 7 '18 at 7:34
• "full links seem to be high up many people's wish lists" --> I think this comes from people being used to Elsevier's style of making the whole citation blue and clickable. People seem to like that. I guess it has to do with the possibility to read the text skipping the blue parts entirely and just sucking in the information in the text flow. Then, it's also easier to spot the sources in the text when more of them (not in numbers, but in percentage of each item) is colored. – thymaro Apr 23 '18 at 7:30
• If I don't want to read who wrote what, I don't have to look for the closing parenthesis, I can just skip the colored part of the text, which is much more convenient for the eyes to do. cf. e.g. the last line in your examples. ;) – thymaro Apr 23 '18 at 7:32