我正在尝试设置一个更长的文档并在使用时偶然发现以下问题authoryear-comp
:
如果我设置了uniquelist=minyear
,如果作者列表相同,我会得到带有 NAME YEARa 和 NAME YEARb 的引用。到目前为止一切顺利。
如果我在同一个 cite 命令中引用两篇论文,我会得到YEARa,b
。是否有可能得到 i) , 和 b: 之间的空格YEARa, b
;或 ii) YEARa, YEARb
?
这是一个用于演示的 MWE:
\documentclass{article}
\usepackage[backend=biber,bibencoding=utf8,dashed=false,style=authoryear-comp,uniquename=false,uniquelist=minyear,date=year,maxcitenames=2, useprefix=true,maxbibnames=99,mincrossrefs=99,sorting=ynt,sortcites=true,isbn=false,eprint=false,urldate=long]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{a1,a2}
\end{document}
输出如下所示:
并且 a 后面的逗号和 b 之间没有空格。
答案1
可以通过调整biblatex
宏来添加空间cite:extradate
。这里使用\addthinspace
提供的宏biblatex
\renewbibmacro*{cite:extradate}{%
\iffieldundef{extradate}
{}
{\printtext[bibhyperref]{\addthinspace\printfield{extradate}}}}
请求的第二种形式可以通过重写cite
宏来实现:
\documentclass{article}
\usepackage[backend=biber,bibencoding=utf8,dashed=false,style=authoryear-comp,uniquename=false,uniquelist=minyear,date=year,maxcitenames=2, useprefix=true,maxbibnames=99,mincrossrefs=99,sorting=ynt,sortcites=true,isbn=false,eprint=false,urldate=long]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\renewbibmacro*{cite:extradate}{%
\iffieldundef{extradate}
{}
{\printtext[bibhyperref]{\addthinspace\printfield{extradate}}}}
\begin{document}
\cite{a1,a2}
\makeatletter
\renewbibmacro*{cite}{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}%
\usebibmacro{cite:labeldate+extradate}%
\usebibmacro{cite:reinit}}
{\iffieldequals{namehash}{\cbx@lasthash}
{\ifthenelse{\iffieldequals{labelyear}{\cbx@lastyear}\AND
\(\value{multicitecount}=0\OR\iffieldundef{postnote}\)}
{\setunit{\addcomma\addspace}% <---- punuctation
\usebibmacro{cite:labeldate+extradate}} % <---- instead of cite:extradate
{\setunit{\compcitedelim}%
\usebibmacro{cite:labeldate+extradate}%
\savefield{labelyear}{\cbx@lastyear}}}
{\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}%
\usebibmacro{cite:labeldate+extradate}%
\savefield{namehash}{\cbx@lasthash}%
\savefield{labelyear}{\cbx@lastyear}}}}
{\usebibmacro{cite:shorthand}%
\usebibmacro{cite:reinit}}%
\setunit{\multicitedelim}}
\makeatother
\cite{a1,a2}
\end{document}
您可能需要对其他引用命令执行类似操作。它们的源代码位于 中authoryear-comp.cbx
。请参阅.log
文件以了解系统上的完整路径。
答案2
您可以使用biblatex-ext
的插件替换authoryear-comp
,ext-authoryear-comp
。
然后你只需要extradateonlycompcitedelim
根据自己的喜好重新定义。
\documentclass{article}
\usepackage[
backend=biber,
style=ext-authoryear-comp,
sorting=ynt,
uniquename=false,uniquelist=minyear,
maxbibnames=99, maxcitenames=2,
useprefix=true,
dashed=false,
date=year, urldate=long,
isbn=false, eprint=false,
mincrossrefs=99,
]{biblatex}
\DeclareDelimFormat{extradateonlycompcitedelim}{\addcomma\space}
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{a1,a2}
\end{document}
为了获得“作者年份a,年份b”,重新定义相当复杂的引用宏的一个简单替代方法是\cbx@lastyear
在每个引用键处重置。(当然,更改宏会更有效,但此解决方案在序言中要短得多。)
\documentclass{article}
\usepackage[
backend=biber,
style=authoryear-comp,
sorting=ynt,
uniquename=false,uniquelist=minyear,
maxbibnames=99, maxcitenames=2,
useprefix=true,
dashed=false,
date=year, urldate=long,
isbn=false, eprint=false,
mincrossrefs=99,
]{biblatex}
\makeatletter
\AtEveryCitekey{\global\undef\cbx@lastyear}
\makeatother
\begin{filecontents}{\jobname.bib}
@article{a1,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Awesome Journal},
volume = 3
}
@article{a2,
author={John Smith and Mary Stuart and Peter Pan},
year = 2020,
journal = {Another Journal},
volume = 3
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\cite{a1,a2}
\end{document}
此解决方案也适用于biblatex-ext
样式。