# Modifying citation command

I am using the code provided in this question regarding coloring citations.

The problem is that I don't know how to make (redefine) the cite command to add parentheses around the year

Here is a simple hack, defining a colortextcite command, based on \textcite:

\documentclass[presentation]{beamer}

\usepackage[backend=biber, uniquename=false, maxbibnames=99, maxcitenames=2, citestyle=authoryear, bibstyle=authoryear]{biblatex}

\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,
}
\end{filecontents}

\newcommand{\colortextcite}[1]{\textcolor{red}{\textcite{#1}}}

\begin{document}

\begin{frame}
Text \cite{bartolini-mair-1990} text

Text \parencite{bartolini-mair-1990} text

Text \colortextcite{bartolini-mair-1990} text
\end{frame}

\begin{frame}
\printbibliography
\end{frame}

\end{document}


• i need to learn how to create my own command/macros...the problem is that i don't know where to start and i don't understand their syntax (e.g. in your hack i don't understand the purpose of [1] and #1 – Yorgos Feb 25 at 12:10
• [1] is the number of arguments of the macro, and inside the definition of the macro, #1 denotes this argument (which here is replaced by the biblatex key). This being said, you can find lots of tutorials on tug.org. – Bernard Feb 25 at 12:24