Biblatex 非標準日期

Biblatex 非標準日期

我使用 biblatex 和 biber 來引用歷史課上展示的作品。以世紀為單位的資料記錄(12世紀或12世紀法語)很常見。我曾經在“年份”字段中寫入此類日期,並且自上次升級以來它一直有效:

以下 MWE 使用 TexLive 2015 進行編譯...

\documentclass{article}
\usepackage{biblatex}
\usepackage[utf8]{inputenc}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
    @Thesis{exemple_image,
    Title                    = {Title of the work},
    Author                   = {Artist Name},
    Location                 = {Switzerland},
    Year                     = {{\siecle{15}}},
    }
\end{filecontents}
\addbibresource{\jobname.bib}

\newcommand{\siecle}[1]{%
\textsc{\romannumeral #1}\textsuperscript{e}~siècle
}

\nocite{*}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

參考文獻印刷正確

…但在 TexLive 2016 中就不再這樣了,我遇到了一個錯誤:! Use of /sortlist doesn't match its definition

我猜想 Biblatex 3.5 對「年份」欄位的寬容程度較低。我在文件中進行了搜尋但沒有成功,並且我願意接受所有建議。

答案1

使用 3.10 及更高版本的新 ISO 8601 日期功能,biblatex您可以輸入世紀作為

date = {19XX}

不幸的是,標準日期格式不能透過顯示“20世紀”或類似的輸出來處理這個問題,它們只是寫“1900-1999”,但我們可以啟用世紀處理,如下所示

\documentclass[french]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@thesis{exemple_image,
  title    = {Title of the work},
  author   = {Artist Name},
  location = {Switzerland},
  date     = {16XX},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\NewBibliographyString{century}
\DefineBibliographyStrings{french}{century = {siècle}}

\makeatletter
\renewcommand*{\RNfont}{\textsc}
\DeclareFieldFormat{datecentury}{\RN{#1}\textsuperscript{e}}
\renewrobustcmd*{\mkdaterangetrunc}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {}
      {\printtext[#2date]{%
         \datecircaprint
         % Such a season component can only come from an EDTF 5.1.5 season which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldequalstr{dateunspecified}{yearincentury}
           {\printtext[datecentury]{\number\numexpr\thefield{#2year}/100+1\relax}\setunit{\addnbspace}\bibstring{century}}
           {\iffieldundef{#2season}
              {\iffieldsequal{#2year}{#2endyear}
                 {\iffieldsequal{#2month}{#2endmonth}
                    {\csuse{mkbibdate#1}{}{}{#2day}}
                    {\csuse{mkbibdate#1}{}{#2month}{#2day}}}
                 {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
                  \iffieldsequal{#2dateera}{#2enddateera}{}
                   {\dateeraprint{#2year}}}}
              {\iffieldsequal{#2year}{#2endyear}
                {\csuse{mkbibseasondate#1}{}{#2season}}
                {\csuse{mkbibseasondate#1}{#2year}{#2season}%
                 \iffieldsequal{#2dateera}{#2enddateera}{}
                   {\dateeraprint{#2year}}}}%
            \dateuncertainprint
            \iffieldundef{#2endyear}
              {}
              {\iffieldequalstr{#2endyear}{}
                 {\mbox{\bibdaterangesep}}
                 {\bibdaterangesep
                  \enddatecircaprint
                  \iffieldundef{#2season}
                    {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}
                    {\csuse{mkbibseasondate#1}{#2endyear}{#2endseason}}%
                  \enddateuncertainprint
                  \dateeraprint{#2endyear}}}}}}%
  \endgroup}
\makeatother

\begin{document}
\nocite{*}
\printbibliography
\end{document}

\iffieldequalstr{dateunspecified}{yearincentury}檢查世紀時,格式datecentury控制世紀的輸出,並且 bibstringcentury可用於進一步本地化輸出。

範例輸出

另請參閱96-dates.tex以及§2.3.8日期和時間規範,§4.2.4.1通用字段biblatex文件

答案2

只需更改您定義的方式\siecle

\newrobustcmd{\siecle}[1]{%
  \textsc{\romannumeral #1}\textsuperscript{e}~siècle
}

這樣宏就不會過早擴充。當然,警告

WARN - year field '{\siecle{15}}' in entry 'exemple_image' is not an integer - this will probably not sort properly.

儘管如此,還是會顯示。

在此輸入影像描述

答案3

另一種方法是依靠 Biber 將欄位對應year到另一個欄位。 (本範例使用addendum。)從該範例中不清楚您是否想要或需要將來源對應限制為特定的條目子集,但有多種方法可以做到這一點。 (本範例僅限於特定.bib檔案和entrytype thesis,僅作為範例。)

Biber 將完成,不會出現警告或錯誤。

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
    @Thesis{exemple_image,
    Title                    = {Title of the work},
    Author                   = {Artist Name},
    Location                 = {Switzerland},
    Year                     = {{\siecle{15}}},
    }
\end{filecontents}
\usepackage[backend=biber]{biblatex}
\addbibresource{\jobname.bib}

\newcommand{\siecle}[1]{%
  \textsc{\romannumeral #1}\textsuperscript{e}~siècle
}

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \perdatasource{\jobname.bib}% <-- If you have them in a special bib file
      \pertype{thesis}%             <-- If you want to limit by type
      \step[fieldsource=year]
      \step[fieldset=addendum, origfieldval]
      \step[fieldset=year, null]
    }
  }
}

\nocite{*}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

相關內容