我有一个定义为的biblatex
条目eventdate
:
eventdate = {2012-09-01/2012-09-04}
使用apa
没有定义的样式日期范围,\printeventdate
结果是
2012 年 9 月 1 日至 4 日
我如何格式化它以使其产生:
2012年9月1日至4日
为了
eventdate = {2012-09-01/2012-09-04}
和
2012年9月28日 - 2012年10月3日
为了
eventdate = {2012-09-28/2012-10-03}
?
也就是说,需要将日期和月份反转,并且需要判断月份和年份是否都相同,如果是,则压缩日期字段使得eventday-eventendday eventmonth, eventyear
。否则使用eventday eventmonth, eventyear-eventendday eventendmonth, eventendyear
。
平均能量损失
\documentclass{article}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=apa,sorting=none,backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
%Add eventdate
\DeclareBibliographyDriver{inproceedings}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\ifthenelse{\NOT\iffieldundef{title}\OR\boolean{bbx:titleinauthpos}}{\newunit}{\setunit{\addspace}}\newblock
\usebibmacro{editor+trans}%
\setunit*{\addcomma\addspace}\newblock
\usebibmacro{maintitle+booktitle}%
\setunit{\addcomma\addspace}\newblock
\printeventdate%
\setunit*{\addspace}\newblock
\usebibmacro{addinfo}%
\newunit\newblock
\printfield{series}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\printlist{organization}%
\newunit
\printfield[apacase]{eventtitle}%
\newunit
\printfield{venue}%
\newunit\newblock
\usebibmacro{location+publisher}%
\newunit\newblock
\usebibmacro{origyear}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{related}%
\usebibmacro{apa:pageref}%
\usebibmacro{apa:finpunct}%
\usebibmacro{finentry}}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@INPROCEEDINGS{anon1,
author = {Anon, A. N.},
title = {A very interesting paper},
booktitle = {Proc. {UKACC} International Conference on Control},
date = {2010-09},
eventdate = {2010-09-07/2010-09-10},
venue = {Coventry},
pages = {1--3}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
\printbibliography
\end{document}
Anon, AN (2010 年 9 月)。一篇非常有趣的论文。载于《UKACC 国际控制会议纪要》,2010 年 9 月 7 日至 10 日(第 1-3 页)。考文垂。