我正在使用以下代码来修改参考书目中作者年份样式的显示方式:
\DeclareBibliographyDriver{article}{%
\usebibmacro{begentry}%
\printnames{author}%
\setunit{\addcomma\space}% Add a comma and a space
\usebibmacro{title}%
\setunit{\addcomma\space}% Add a comma and a space
\usebibmacro{journal}%
\setunit{\addcomma\space}% Add a comma and a space
\printfield{volume}%
\setunit{\addspace}% Add a space
\printfield{parens}{\printfield{year}}%
\setunit{\addcomma\space}% Add a comma and a space
\printfield{pages}%
\setunit{\addperiod\space}% Add a period and a space
\usebibmacro{finentry}%
}
其输出示例如下:
Tversky, Amos and Daniel Kahneman, “Advances in prospect theory: Cumulative representation of uncertainty”, Journal of Risk and Uncertainty, 5( 1992), pp. 297–323.
年份周围的括号是错误的,空格在括号“5(1992)”内,但它应该在括号“5(1992)”之前
我怎样才能解决这个问题?
答案1
我无法使用所示的代码重现您在问题中讨论的确切问题,但我建议进行以下更改。
\printfield{parens}{\printfield{year}}%
不会将年份括在括号中。它将尝试打印一个名为的字段parens
,该字段不存在,然后打印年份。您可能想要类似
\printtext[parens]{\printfield{year}}%
但通常情况下,您不应该使用\printfield{year}
来打印年份。应该使用 来将年份作为日期的一部分进行打印(可以使用 选项或通过修改所选选项的相关日期格式宏来修改 的\printdate
输出)。\printdate
date
\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, style=numeric]{biblatex}
\DeclareBibliographyDriver{article}{%
\usebibmacro{begentry}%
\printnames{author}%
\setunit{\addcomma\space}% Add a comma and a space
\usebibmacro{title}%
\setunit{\addcomma\space}% Add a comma and a space
\usebibmacro{journal}%
\setunit{\addcomma\space}% Add a comma and a space
\printfield{volume}%
\setunit{\addspace}% Add a space
\printtext[parens]{\printfield{year}}%
\setunit{\addcomma\space}% Add a comma and a space
\printfield{pages}%
\setunit{\addperiod\space}% Add a period and a space
\usebibmacro{finentry}%
}
\addbibresource{biblatex-examples.bib}
\begin{document}
Lorem \autocite{sigfridsson}
\printbibliography
\end{document}
无需彻底重新定义驱动程序即可稍微改变输出。通常,仅修改相关的 bibmacros、字段格式或分隔符命令会更有效、更方便、更安全。