I want to color the brackets of inline citation like: some text[9] where it is written in latex like this some text\cite{9}
. Now hyperref only colors the number "9" without the brackets "[]". Is there any workaround for this?
[Tex/LaTex] How to color citation brackets using hyperref
colorhyperref
Related Solutions
You could either set the colour for the hyperlinks with
\hypersetup{
colorlinks,
citecolor=green,
linkcolor=black
}
(this will only colour the click-able part of the citation) or add the colour manually to the citation commands:
\documentclass[presentation]{beamer}
\usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}
\addbibresource{references.bib}
\DeclareCiteCommand{\cite}
{\color{red}\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\DeclareCiteCommand{\parencite}[\mkcolorbibparens]
{\usebibmacro{prenote}}%
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
\makeatletter
\newrobustcmd{\mkcolorbibparens}[1]{%
\begingroup
\color{red}%
\blx@blxinit
\blx@setsfcodes
\bibopenparen#1\bibcloseparen
\endgroup}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{references.bib}
@Book{bartolini-mair-1990,
author = {Bartolini, Stefano AND Mair, Peter},
title = {Identity, Competition and Electoral Availability. The Stabilization of European Electorates 1885-1985},
publisher = {Cambridge University Press},
year = 1990,
address = {Cambridge},
}
\end{filecontents}
\begin{document}
\begin{frame}
Text \cite{bartolini-mair-1990} text
Text \parencite{bartolini-mair-1990} text
\end{frame}
\begin{frame}
\printbibliography
\end{frame}
\end{document}
Well, I have a workaround for you. Change the definition of \parencite
to
\DeclareCiteCommand{\parencite}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{[\usebibmacro{cite}]}}
% ^ ^
{\multicitedelim}
{\usebibmacro{postnote}}
by adding the missing brackets.
With the following MWE
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[colorlinks=true, citecolor=blue]{hyperref}
%Bibliographie und Quellenverzeichnis
\usepackage[%
backend = biber,
style=authoryear,
citestyle=authoryear-ibid,
sorting=nyt,
autocite=plain,
citereset=none,
url=true, %URL drucken, wenn angegeben
doi=false, %DOI drucken, wenn angegeben
hyperref=true, %Zitationen in klickbare Links
backref=false, %zeige in der Bibl Rücklinks
isbn=false,
maxbibnames=3,
useeditor=true
]{biblatex}
\setlength{\bibitemsep}{1em}
\setlength{\bibhang}{2em}
\renewcommand{\bibfootnotewrapper}[1]{\bibsentence#1}
\DeclareFieldFormat{postnote}{#1}
\renewcommand*{\nameyeardelim}{\space}
\renewcommand*{\postnotedelim}{\addcolon}
\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}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\printtext[bibhyperref]{[\usebibmacro{cite}]}}
{\multicitedelim}
{\usebibmacro{postnote}}
\makeatletter
\newrobustcmd*{\parentexttrack}[1]{%
\begingroup
\blx@blxinit
\blx@setsfcodes
\blx@bibopenparen#1\blx@bibcloseparen
\endgroup}
\AtEveryCite{%
\let\parentext=\parentexttrack%
\let\bibopenparen=\bibopenbracket%
\let\bibcloseparen=\bibclosebracket}
\makeatother
\addbibresource{biblatex-examples.bib}
% here the doc begins
\begin{document}
parencite:\parencite{aksin} cite:\cite{companion} textcite:\textcite{knuth:ct}
\printbibliography
\end{document}
you will get
Best Answer
You can use the
cite
package: