使用 biblatex 在一年内多次引用

使用 biblatex 在一年内多次引用

我的 biblatex 序言是这样的:

\usepackage[bibstyle=authoryear,
citestyle=authoryear, 
firstinits=true, 
maxbibnames=5,
minbibnames=3, 
maxcitenames=2, 
sorting=nyt, 
url=false, 
isbn=false, 
eprint=false, 
doi=false, 
dashed=false, 
natbib=true]{biblatex}

当我引用同一作者在同一年(\citet{Einstein1905a, Einstein1905b})的两篇论文时,它们显示如下:

爱因斯坦 (1905a); 爱因斯坦 (1905b)

相反,我希望它们显示为:

爱因斯坦(1905a,b)。

我怎样才能做到这一点?

答案1

biblatex没有内置压缩样式仅有的同一作者的论文在同一年。如果您不介意压缩同一作者/不同年份,则只需使用该authoryear-comp样式即可。

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=authoryear-comp,natbib]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@article{one,
author = "Last, First",
title = {Title},
journal = {A Journal},
year = {2011},
}  
@article{two,
author = "Last, First",
title = {Title},
journal = {B Journal},
year = {2012},
}  
@article{three,
author = "Surname, Given",
title = {Title},
journal = {C Journal},
year = {2013},
}  
@article{four,
author = "Surname, Given",
title = {Title},
Journal = {D Journal},
year = {2013},
}  
\end{filecontents}

\begin{document}
\citet{one,two,three,four}
\printbibliography
\end{document}

在此处输入图片描述

答案2

这是一个重新定义的解决方案\textcite

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=authoryear,natbib]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@article{one,
author = "Last, First",
title = {Title},
journal = {A Journal},
year = {2012},
}  
@article{two,
author = "Last, First",
title = {Title},
journal = {B Journal},
year = {2012},
}  
@article{three,
author = "Surname, Given",
title = {Title},
journal = {C Journal},
year = {2013},
}  
@article{four,
author = "Surname, Given",
title = {Title},
Journal = {D Journal},
year = {2013},
}  
\end{filecontents}

\makeatletter
\DeclareCiteCommand{\textcite}
  {}
  {\iffieldequals{namehash}{\cbx@lasthash}
    {\iffieldequals{year}{\cbx@lastyear}
      {\addcomma\printfield{extrayear}}
      {\addcomma\addspace\printfield{labelyear}\printfield{extrayear}}%
      \ifnumequal{\value{citecount}}{\value{citetotal}}
        {\bibcloseparen}
        {}%
    }
    {\ifnumequal{\value{citecount}}{1}
      {}
      {\bibcloseparen\multicitedelim\addspace}%
     \printnames{labelname}
     \bibopenparen\printfield{labelyear}\printfield{extrayear}%
    }%
    \savefield{namehash}{\cbx@lasthash}%
    \savefield{year}{\cbx@lastyear}%
  }
  {}
  {}
\makeatother

\begin{document}
\citet{one,two,three,four}
\printbibliography
\end{document}

制作

在此处输入图片描述

编辑纠正了同一作者不同年份的问题(年份之间缺少逗号和空格)

相关内容