Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

With the help of a great answer to http://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}
share|improve this question
    
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 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
This is perfect. Thanks a lot. –  Sébastien Apr 30 '12 at 22:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.