![书目中出版商和地点后面未显示年份](https://linux22.com/image/400660/%E4%B9%A6%E7%9B%AE%E4%B8%AD%E5%87%BA%E7%89%88%E5%95%86%E5%92%8C%E5%9C%B0%E7%82%B9%E5%90%8E%E9%9D%A2%E6%9C%AA%E6%98%BE%E7%A4%BA%E5%B9%B4%E4%BB%BD.png)
我正在撰写的一篇论文要求我使用自定义引用样式。该样式与标准哈佛样式类似,因此我决定biblatex-bath
根据自己的需要调整样式。
除其他事项外,引用书籍时,必须注明出版商和地点
Publisher; Location; Year.
publisher+location+date
我找到了由 biblatex 定义的标准bibmacro,bbx/standard.bbx
并决定覆盖它,如下所示:
\renewbibmacro*{publisher+location+date}{%
\printlist{publisher}%
\setunit*{\addsemicolon\space}%
\printlist{location}%
\setunit*{\addsemicolon\space}%
\printfield{year}%
\newunit%
}
出版商和地点都显示正常,但缺少年份。以下是完整的 MWE:
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8
\begin{filecontents*}{biblatextest2.bib}
@Book{Gali2015,
author = {Gal{\'\i}, Jordi},
title = {Monetary policy, inflation, and the business cycle: an introduction to the new Keynesian framework and its applications},
year = {2015},
edition = {2},
publisher = {Princeton University Press},
location = {Princeton and Oxford},
}
\end{filecontents*}
\documentclass{article}
\usepackage[style=bath,sorting=ynt]{biblatex}
\assignrefcontextentries[]{*}
\renewbibmacro*{publisher+location+date}{%
\printlist{publisher}%
\setunit*{\addsemicolon\space}%
\printlist{location}%
\setunit*{\addsemicolon\space}%
\printfield{year}%
\newunit%
}
\addbibresource{biblatextest2.bib}
\begin{document}
\noindent Here is a citation. Compare \cite[p.~123]{Gali2015}.
\appendix
\newrefcontext[sorting=nyt]%
\printbibliography
\end{document}
得出:
如您所见,缺少出版商和地点后的年份。在那里打印另一个字段(例如\printfield{title}
而不是\printfield{year}
)是可行的;该问题特定于\printfield{year}
。(实际上,这并不完全正确:\printfield{name}
也不起作用。)
和往常一样,我非常感激任何帮助。(也可以随意提出完全不同的解决方案;我不会纠结于修改这个特定的 biblatex 样式,或者修改任何特定的样式。如果有更好的方法来制作自定义的 biblatex 样式,我愿意洗耳恭听。)
答案1
您可以将该选项添加mergedate=false
到您的biblatex
选项中。
我可能倾向于使用\usebibmacro{date}
而不是以\printfield{year}
与默认宏更加一致并允许更多的灵活性。
\RequirePackage{filecontents}
\begin{filecontents*}{biblatextest2.bib}
@Book{Gali2015,
author = {Galí, Jordi},
title = {Monetary policy, inflation, and the business cycle: an introduction to the new Keynesian framework and its applications},
year = {2015},
edition = {2},
publisher = {Princeton University Press},
location = {Princeton and Oxford},
}
\end{filecontents*}
\documentclass{article}
\usepackage[style=bath,mergedate=false,sorting=ynt]{biblatex}
\assignrefcontextentries[]{*}
\renewbibmacro*{publisher+location+date}{%
\printlist{publisher}%
\setunit*{\addsemicolon\space}%
\printlist{location}%
\setunit*{\addsemicolon\space}%
\usebibmacro{date}%
\newunit%
}
\addbibresource{biblatextest2.bib}
\begin{document}
\noindent Here is a citation. Compare \cite[p.~123]{Gali2015}.
\appendix
\newrefcontext[sorting=nyt]%
\printbibliography
\end{document}