
biblatex
我希望在我的風格 ( )中使用澳洲風格的日期和日期範圍,biblatex-sbl
即使未載入 babel 或 polyglossia。對於範圍在一個月內的情況,以下程式碼將會失敗。我想要“2016 年 1 月 1 日至 5 日”,但我得到的是“1 月 1 日至 52016 年”。有人可以幫忙嗎? (FWIW,biblatex-chicago
在這種情況下也會失敗。)
\documentclass{article}
\usepackage[backend=biber,dateabbrev=false]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{a,
title = {TitleA},
date = {2016-01-02}
}
@book{b,
title = {TitleB},
date = {2016-01-02/2016-02-05}
}
@book{c,
title = {TitleC},
date = {2016-01-01/2016-01-05}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DefineBibliographyExtras{english}{%
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\stripzeros{\thefield{#3}}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%
}
\begin{document}
\cite{a}, \cite{b}, \cite{c}
\printbibliography
\end{document}
答案1
啊——明白了。我需要這個:
\DefineBibliographyExtras{english}{%
\restorecommand\mkdaterangecomp
\restorecommand\mkdaterangecompextra
\restorecommand\mkdaterangeterse
\restorecommand\mkdaterangeterseextra
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\stripzeros{\thefield{#3}}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}{\bibstring{\thefield{#1}}}{\stripzeros{\thefield{#1}}}}%
}
編輯
其實,以上這些還不夠。為了為這個問題提供正確的答案,我實際上需要以下內容。這也考慮到了biblatex
擴展日期/時間功能。
\DefineBibliographyExtras{english}{%
\protected\def\mkdaterangecomp{%
\mkdaterangetrunc{long}}%
\protected\def\mkdaterangeterse{%
\mkdaterangetrunc{short}}%
\protected\def\mkdaterangecompextra{%
\mkdaterangetruncextra{long}}%
\protected\def\mkdaterangeterseextra{%
\mkdaterangetruncextra{short}}%
\protected\def\mkbibdatelong#1#2#3{%
\iffieldundef{#3}
{}
{\thefield{#3}%
\iffieldundef{#2}{}{\nobreakspace}}%
\iffieldundef{#2}
{}
{\mkbibmonth{\thefield{#2}}%
\iffieldundef{#1}{}{\space}}%
\iffieldbibstring{#1}
{\bibstring{\thefield{#1}}}
{\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}}%
}
答案2
有一個簡單的方法(用 xelatex 和 pdflatex 測試)...
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{a,
title = {TitleA},
date = {2016-01-02}
}
@book{b,
title = {TitleB},
date = {2016-01-02/2016-02-05}
}
@book{c,
title = {TitleC},
date = {2016-01-01/2016-01-05}
}
\end{filecontents}
\usepackage[australian]{babel}
% Polyglossia variants don't quite work with biblatex at the moment
%\usepackage{polyglossia}
%\setdefaultlanguage[variant=british]{english}
\usepackage[%
%
% Basics
%
style=authoryear,
alldates=long,
dateabbrev=false,
%alldates=ymd, % ISO like, but customizable format (Recommended)
%
% Unecessary to set
%
% [default] autobib=try to get main document
% language from babel/polyglossia
%language=autobib,
%autolang=langname, % Don't worry about this.
%
% Other (new) settings you might like to play with
%
% alldatesusetime=true,
% alltimes=24h,
% seconds=true,
% timezones=true,
% datezeros=true,
% dateera=secular,
% datecirca=true,
% dateuncertain=true,
]{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
Current language: \currentlang\\
\autocite{a}\\
\autocite{b}\\
\autocite{c}\\
\printbibliography
\end{document}
在參考書目/參考文獻部分中,得出:
標題A(2016 年 1 月 2 日)。
標題B(2016年1月2日至2016年2月5日)。
TitleC(2016年1月1日至2016年1月5日)。
總之你:
- 設定
australian
為你的 babel 變體\usepackage[australian]{babel}
- 使用 biblatex 選項
alldates=long
- 根據需要設定其他選項(您已選擇
dateabbrev=false
)。
這將為您提供“2016 年 1 月 1 日至 2016 年 1 月 5 日”,而不是“2016 年 1 月 1 日至 5 日”。但我建議前者更好,因為像「2016 年 12 月 31 日至 2016 年 1 月 5 日」這樣的日期範圍將沒有您指定的排序的壓縮和可讀等效項。
這似乎也為您提供了您在回覆 @Ross 時所表達的內容。
Biblatex 對 Polyglossia 的支援目前是一個問題(特別是對於 Polyglossia 語言變體設定)。解決方案是暫時使用 babel,而不是 polyglossia。詳情請參閱http://tex.stackexchange.com > 我們如何讓 Polyglossia 語言變體與 Biblatex 參考書目一起使用?。
不過,我向您推薦alldates=ymd
它為您提供類似 ISO 的格式(但具有 ISO 不允許的自訂選項)。在網路時代,讓你的約會變得全球友好是正確的。在這種情況下,當使用 時alldates=ymd
,該命令\usepackage[australian]{babel}
變得無關緊要,可以刪除(出於 biblatex 目的)。這會產生:
標題A (2016-01-02)。
標題B (2016-01-02/2016-02-05)。
標題C (2016-01-01/2016-01-05)。
警告 Biblatex 最近引入了大量日期時間功能來支援 EDTF 輸入日期(例如 2016-07-22T22:12+10:00; 2016?; 1875~; -0379~)。儘管發布的 biblatex 相當強大,但仍在測試中(我至少確保您的乳膠包是最新的)。