Нестандартная дата 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

С новыми функциями даты ISO 8601 версии biblatex3.10 и выше вы можете ввести столетие как

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управляет выводом столетия, а bibstring centuryможет использоваться для дальнейшей локализации вывода.

пример вывода

См. также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файл и тип записи thesisприводится просто в качестве примера.)

Бибер завершит работу без предупреждений и ошибок.

\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}

Связанный контент