5

With the help of a great answer to https://tex.stackexchange.com/a/50706/13904 I was able to redefine the \cite command as:

\renewbibmacro*{cite}{%
  \iffieldundef{shorthand}
    {\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
       {\usebibmacro{cite:label}%
        \setunit{\addspace}}
       {\printnames{labelname}%
        \setunit{\nameyeardelim}}%
%     \usebibmacro{cite:labelyear+extrayear}}% DELETED
     \printtext[brackets]{\usebibmacro{cite:labelyear+extrayear}}}% ADDED
    {\usebibmacro{cite:shorthand}}}

But a problem appears when one has multiple citations of a same author.

\cite{Hembree88,Hembree90}

gives

HEMBREE 1988HEMBREE 1990

instead of

HEMBREE [1988; 1990]

Any idea how to solve this?

Here is a working example:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[style=authoryear-icomp]{biblatex}
\makeatletter
\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\addspace}}
\printnames{labelname}%
\setunit{\nameyeardelim}}%
\printtext[brackets]{\usebibmacro{cite:labelyear+extrayear}}}% ADDED
{\usebibmacro{cite:shorthand}}}
\makeatother
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{A02,
author = {Author, A.},
year = {2002},
title = {Alpha},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{A01,A02}
\printbibliography
\end{document}
Sébastien
  • 53
  • 3
  • You're using the authoryear-icomp citation style, but the code snipppet from the linked answer is suited for the authoryear style. But more important, you didn't describe in detail the results you want to achieve. Do you just want to replace parentheses with brackets, or is it something more complex? – lockstep Apr 30 '12 at 22:33

1 Answers1

5

Based on your given information you should use the command \textcite instead of \cite. This command does your request with the parentheses () So you can change this inside the declaration of \textcite. The separation of the years is set by the command \compcitedelim.

\documentclass{article}
\usepackage[english]{babel}
\usepackage[style=authoryear-icomp]{biblatex}
\DeclareCiteCommand{\textcite}
  {\usebibmacro{cite:init}}
  {%
   \let\bibopenparen\bibopenbracket%
   \let\bibcloseparen\bibclosebracket%
   \usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:postnote}}

\renewcommand*\compcitedelim{\addsemicolon\space}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
author = {Author, A.},
year = {2001},
title = {Alpha},
}
@misc{A02,
author = {Author, A.},
year = {2002},
title = {Alpha},
}

@misc{A03,
author = {Author, A.},
year = {2003},
title = {Alpha},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\textcite{A01,A02,A03}
\printbibliography
\end{document}

The result will be

Marco Daniel
  • 95,681