我引用了同一作者在同一年的两篇文章,引用的键是auth00a
和auth00b
。使用 样式authoryear-comp
,我可以使用,textcite{auth00a,auth00b}
但这会在结果中给出“Author (2000a,b)”。我更希望得到“Author (2000a, 2000b)”;即完整的年份。有没有简单的方法可以做到这一点?谢谢!
答案1
在序言中添加以下几行(xpatch
需要包):
\usepackage{xpatch}
\xpatchbibmacro{textcite}
{\setunit{\addcomma}\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}\usebibmacro{cite:labelyear+extrayear}}
{}
{}
梅威瑟:
\documentclass{article}
\usepackage[backend=biber,style=authoryear-comp]{biblatex}
\usepackage{xpatch}
\xpatchbibmacro{textcite}
{\setunit{\addcomma}\usebibmacro{cite:extrayear}}
{\setunit{\compcitedelim}\usebibmacro{cite:labelyear+extrayear}}
{}
{}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{auth00a,
author = {Author},
title = {MyBook A},
date = {2000}
}
@article{auth00b,
author = {Author},
title = {MyBook B},
date = {2000}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\textcite{auth00a,auth00b}
\end{document}
输出:
答案2
假设您希望所有\...cite
命令都具有这种行为,而不仅仅是\textcite
(问题仅提到\textcite
输出),您可以尝试以下方法。这个想法依赖于这样一个事实:为了隐藏年份并仅打印额外的日期字母,biblatex
需要记住最后一年。如果我们biblatex
忘记最后一年,那么年份将永远不会被省略。
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=authoryear-comp]{biblatex}
\makeatletter
\AtEveryCitekey{\global\undef\cbx@lastyear}
\makeatother
\addbibresource{biblatex-examples.bib}
\begin{document}
Lorem \autocite{knuth:ct:b,knuth:ct:c}
ipsum \autocite{knuth:ct:a,knuth:ct:c}
\printbibliography
\end{document}
答案3
那么,关于xpatch
解决方案。在 Moewe 指出我们应该在宏名称中用 -date 替换 -year 之后,结果如下。但我警告你,这不适用于 ext-authoryear-comp,只适用于 authoryear-comp,这确实应该使 Moewe 的“3 行解决方案”(见上文)成为你最喜欢的选择。
\documentclass{article}
\usepackage[backend=biber,style=authoryear-comp]{biblatex}
\usepackage{xpatch}
\xpatchbibmacro{textcite}
{\setunit{\addcomma}\usebibmacro{cite:extradate}}
{\setunit{\compcitedelim}\usebibmacro{cite:labeldate+extradate}}
{}
{}
\xpatchbibmacro{cite}
{\setunit{\addcomma}\usebibmacro{cite:extradate}}
{\setunit{\compcitedelim}\usebibmacro{cite:labeldate+extradate}}
{}
{}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{auth00a,
author = {Author},
title = {MyBook A},
date = {2000}
}
@article{auth00b,
author = {Author},
title = {MyBook B},
date = {2000}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
\begin{document}
\textcite[cf.][56]{auth00a,auth00b}
\cite[cf.][56]{auth00a,auth00b}
\parencite[cf.][56]{auth00a,auth00b}
\end{document}