biblatex 条件打印额外日期

biblatex 条件打印额外日期

这是biblatex 格式用于在线资源。我有以下 biblatex 配置文件。感谢 Guido 提供的信息。我还\MakeSentenceCase从 Audrey 的回答中获取了一些代码biblatex 中标题的句子大小写。

\ProvidesFile{biblatex.cfg}

\ExecuteBibliographyOptions{
firstinits=true,
isbn=true,
dashed=false,
eprint=true,
maxbibnames=99,
alldates=long,
doi=true,
uniquename=init
}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=medium, fieldtarget=usera]
      \step[fieldsource=urlupdate, fieldtarget=extradate]
    }
  }
}


\DefineBibliographyStrings{english}{%
  references = {Cited References},
}
\DefineBibliographyStrings{english}{% 
january = {Jan},
february = {Feb},
march = {Mar},
april = {Apr},
may = {May},
june = {Jun},
july = {Jul},
august = {Aug},
september = {Sep},
october = {Oct},
november = {Nov},
december = {Dec}
}

\NewBibliographyString{available}
\NewBibliographyString{cited}

\DefineBibliographyStrings{english}{%
  available = {Available from},
}


% Redefined url+urldate macro

\DeclareFieldFormat{url}{\bibstring{available}\addcolon\space\url{#1}}
\DeclareFieldFormat{urldate}{#1}
\DeclareFieldFormat{urlday}{#1}

\renewbibmacro*{url+urldate}{%
    \iffieldundef{urlyear}
    {}
%    {\setunit*{\addspace}%
%     }
  {\printtext{[}%
  \printtext{cited}\addcolon\space%
  \printfield{urlyear}
    \mkbibmonth{\thefield{urlmonth}}
    \stripzeros{\thefield{urlday}}%
  \printtext{].}\space%
  \printfield{url}%
  }
}
% Change how the publisher, location and dates are printed

\renewbibmacro{publisher+location+date}{
  \iflistundef{publisher}
    {}
    {\printtext{}%
    \iflistundef{location}
        {}
        {\printlist{location}}%
        \printtext{\addcolon\space}%
     \printlist{publisher}%
            \printtext{\addsemicolon\space}
    }
}

% Remove parentheses around dates

\renewbibmacro*{date+extrayear}{%
    \iffieldundef{year}
      {}
      {\printtext{%
     \addperiod\space\printfield{labelyear}%
     \printfield{extrayear}}}}

% Print last name first before first name

\renewbibmacro*{title}{%
  \ifboolexpr{
    test {\iffieldundef{title}}
    and
    test {\iffieldundef{subtitle}}
  }
    {}
    {\printtext[title]{%
       \printfield[titlecase]{title}%
       \setunit{\subtitlepunct}%
       \printfield[titlecase]{subtitle}
       \setunit{}%
       \iffieldundef{usera}
          {}
    {\printtext{[}\printfield{usera}\printtext{]}}}%
     \newunit}%
  \printfield{titleaddon}}

\DeclareNameAlias{sortname}{last-first}
\DeclareNameAlias{default}{last-first} % for good measure, changes that of the editor and others
\renewcommand{\bibinitperiod}{}
\renewcommand{\bibinitdelim}{}
\DeclareFieldFormat{title}{#1}

\DeclareFieldFormat{titlecase}{\MakeTitleCase{#1}}

\newrobustcmd{\MakeTitleCase}[1]{%
  \ifthenelse{\ifcurrentfield{booktitle}\OR\ifcurrentfield{booksubtitle}%
    \OR\ifcurrentfield{maintitle}\OR\ifcurrentfield{mainsubtitle}%
    \OR\ifcurrentfield{journaltitle}\OR\ifcurrentfield{journalsubtitle}%
    \OR\ifcurrentfield{issuetitle}\OR\ifcurrentfield{issuesubtitle}%
    \OR\ifentrytype{book}\OR\ifentrytype{mvbook}\OR\ifentrytype{bookinbook}%
    \OR\ifentrytype{booklet}\OR\ifentrytype{suppbook}%
    \OR\ifentrytype{collection}\OR\ifentrytype{mvcollection}%
    \OR\ifentrytype{suppcollection}\OR\ifentrytype{manual}%
    \OR\ifentrytype{periodical}\OR\ifentrytype{suppperiodical}%
    \OR\ifentrytype{proceedings}\OR\ifentrytype{mvproceedings}%
    \OR\ifentrytype{reference}\OR\ifentrytype{mvreference}%
    \OR\ifentrytype{report}\OR\ifentrytype{thesis}}
    {#1}
    {\MakeSentenceCase{#1}}}

%% What actually prints the bibliography entry.

\DeclareBibliographyDriver{online}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{bytranslator+others}%
  \newunit\newblock
  \printfield{version}%
  \newunit\newblock
    \usebibmacro{publisher+location+date}
    \newunit\newblock
    \usebibmacro{url+urldate}
  \usebibmacro{finentry}}

\endinput

现在,考虑以下 MWE:

\documentclass[10pt]{article}

\usepackage[style=authoryear,backend=biber]{biblatex}
\usepackage{lipsum}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@online{kruse,
author = {John S. Kruse},
title = {Framework for Sustainable Soil Management: Literature Review and Synthesis},
year = {2007},
url = {http://www.swcs.org/documents/filelibrary/BeyondTliteraturereview.pdf},
publisher= {Soil and Water Conservation Society},
location={Ankeny (IA)},
urldate = {2008-08-03},
medium = {Internet},
}

@online{cois,
author={},
title = {Canadian Soil Information Service},
medium = {Internet},
location = {Ottawa (ON)},
publisher = {Agriculture and Agri-Food Canada},
urldate = {2010-06-30},
url = {http://sis.agr.gc.ca/cansis/},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\lipsum[1]
\nocite{*}
\printbibliography

\end{document}

在此处输入图片描述

对于第一个参考书目条目,我希望能够urlupdate在我的.bib文件中放置一个映射到额外日期字段的字段。我希望能够使用额外日期字段得出类似

加拿大土壤信息服务 [互联网]。2010 年。渥太华 (ON):加拿大农业和农业食品部;[2010 年 5 月 19 日更新;2010 年 6 月 30 日引用]。可从以下网址获取:http://sis.agr.gc.ca/cansis/

当声明 urlupdate 时

加拿大土壤信息服务 [互联网]。2010 年。渥太华 (ON):加拿大农业和农业食品部;[2010 年 6 月 30 日引用]。可从以下网址获取:http://sis.agr.gc.ca/cansis/

但事实并非如此。

答案肯定在 biblatex 手册的某个地方,但很难找到。我已经在这个问题上呆了 2 个小时了。

答案1

使用 biblatex 2.0/biber 1.0,您可以更改数据模型。只需将其添加到 latex 可以找到的文件“biblatex-dm.cfg”中:

\DeclareDatamodelFields[type=field, datatype=date, skipout]{urlupdate}
\DeclareDatamodelFields[type=field, datatype=integer]{
  urlupday,
  urlupendday,
  urlupendmonth,
  urlupendyear,
  urlupmonth,
  urlupyear}

\DeclareDatamodelEntryfields{
  urlupday,
  urlupendday,
  urlupendmonth,
  urlupendyear,
  urlupmonth,
  urlupyear}

然后,您可以像使用其他日期字段一样,在 .bib 文件中使用字段“urlupdate”,拆分字段“urlupday”等将位于 .bbl 中,您可以像检查其他字段一样,在 biblatex 格式中检查这些字段。

答案2

一种可能性是使用urldate范围值,即YYYY-MM-dd/YYYY-MM-dd第一个日期是必填项,用于值cited,第二个日期用于updated值。然后,您可以使用字段urlendyear, urlendmonth,urlendday来引用更新值。

相关内容