biblatex:authoryear 样式和 \cite 重新定义 = 多次引用错误

biblatex:authoryear 样式和 \cite 重新定义 = 多次引用错误

在一个很好的答案的帮助下https://tex.stackexchange.com/a/50706/13904我能够将\cite命令重新定义为:

\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}}}

但当对同一作者有多次引用时就会出现问题。

\cite{Hembree88,Hembree90}

给出

亨布里 1988亨布里 1990

代替

亨布里 [1988; 1990]

知道如何解决这个问题吗?

这是一个有效的例子:

\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}

答案1

根据您提供的信息,您应该使用命令\textcite而不是\cite。此命令使用括号执行您的请求,()因此您可以在声明中更改它\textcite。年份的分隔由命令设置\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}

结果是

相关内容