Biblatex urldate 设置为今天

Biblatex urldate 设置为今天

在撰写文档时,我希望将urldate在线书目条目的(访问日期)设置为编撰日期。考虑以下 MWE:

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\begin{filecontents}{references.bib}
@online{abc,
title = {This is a Title},
author = {Author, Some},
url = {http://www.somesite.com},
date = {2013-10-10},
urldate = {\year-\month-\day} % this does not work. Also urldate = {\today} doesn't.
}
\end{filecontents}

\addbibresource{references.bib}
\begin{document}
\cite{abc}.
\printbibliography
\end{document}

不幸的是,这不起作用。文本中有连字符,因为biblatex日期应为 的形式yyyy-mm-dd。关于如何解决这个问题,您有什么想法吗?

答案1

您可以通过以下方式实现此目的:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
       \pertype{online}
       \step[fieldset=urldate,fieldvalue={\the\year-\the\month-\the\day}]
    } 
 }
}

此定义覆盖urldate在线类型的每个字段并使用当前日期。

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\usepackage{filecontents}
\begin{filecontents}{references.bib}
@online{abc,
title = {This is a Title},
author = {Author, Some},
url = {http://www.somesite.com},
date = {2013-10-10},
urldate = {xxxx} % this does not work. Also urldate = {\today} doesn't.
}
\end{filecontents}


\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
       \pertype{online}
       \step[fieldset=urldate,fieldvalue={\the\year-\the\month-\the\day}]
    } 
 }
}
\addbibresource{references.bib}
\begin{document}
\cite{abc}.


\printbibliography
\end{document}

在此处输入图片描述

答案2

这不是你要求的,但考虑到@Seamus 的评论。我将特定日期(如果您愿意,可以是今天)存储在一个字符串中,并在单个条目中引用该字符串。

\documentclass{article}
\usepackage[backend=biber]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@string{today = {2013-12-11}}

@online{abc,
title = {This is a Title},
author = {Author, Some},
url = {http://www.somesite.com},
date = {2013-10-10},
urldate = today,
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
\cite{abc}.
\printbibliography
\end{document}

输出

相关内容