是否有可能为@online 条目添加第二个 URL?
我希望显示 1. 原始 URL 和 2. 存档服务(archive.org 或 webcitation.org)中的条目,以防原始网站瘫痪
相关,我还想添加类似于@incollection 的书名的网站名称(例如报纸名称、媒体机构名称)
答案1
您可以定义一个archiveurl
带有随附的新字段archivedate
。
这是通过 .dbx
文件完成的,我们还可以添加国际化。您可以在此阅读更多相关信息如何使用 BibLaTeX/Biber 创建全新的数据类型?和将字段“tome”添加到 biblatex 条目。需要将其放置在 TeX 可以找到的地方,并且必须在加载时在选项中.dbx
指定其名称。在 MWE 中,使用 会自动创建文件。biblatex
datamodel
filecontents
包含.dbx
\DeclareDatamodelFields[type=field, datatype=uri]{archiveurl}
\DeclareDatamodelEntryfields{archiveurl}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
archivedate,
}
\DeclareDatamodelEntryfields{archivedate}
从而定义了两个新字段:archiveurl
和archivedate
。前者是URI类型字段(URL),而后者是日期字段。
然后我们定义所需的字符串,国际化也可以在文件中完成.lbx
。
\NewBibliographyString{archivedat,archivedon}
\DefineBibliographyStrings{english}{%
archivedat = {archived at},
archivedon = {on},
}
我们可以定义格式和新的宏
\DeclareFieldFormat{archiveurl}{\bibstring{archivedat}\space\url{#1}}
\DeclareFieldFormat{archivedate}{\bibstring{archivedon}\space#1}
\newbibmacro*{archiveurl}{\printfield{archiveurl}}
\newbibmacro*{archivedate}{\printarchivedate}
最后,我们修改 URL 宏以打印档案 URL。
\renewbibmacro*{url+urldate}{%
\usebibmacro{url}%
\iffieldundef{urlyear}
{}
{\setunit*{\addspace}%
\usebibmacro{urldate}}%
\setunit{\addcomma\space}%
\usebibmacro{archiveurl}%
\iffieldundef{archiveyear}
{}
{\setunit*{\addspace}%
\usebibmacro{archivedate}}}
完整 MWE
\documentclass{article}
\usepackage{filecontents}
\usepackage[british]{babel}
\begin{filecontents*}{archiving.dbx}
\DeclareDatamodelFields[type=field, datatype=uri]{archiveurl}
\DeclareDatamodelEntryfields{archiveurl}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
archivedate,
}
\DeclareDatamodelEntryfields{archivedate}
\end{filecontents*}
\usepackage[backend=biber,style=authortitle, datamodel=archiving]{biblatex}
\begin{filecontents*}{\jobname.bib}
@article{panic,
author = {Plunkett, John},
title = {Sorrell accuses Murdoch of panic buying},
journal = {The Guardian},
date = {2005-10-27},
url = {http://media.guardian.co.uk/site/story/0,14173,1601858,00.html},
archiveurl = {http://www.webcitation.org/5Kt3PxfFl},
archivedate = {2006-12-04},
}
\end{filecontents*}
\NewBibliographyString{archivedat,archivedon}
\DefineBibliographyStrings{english}{%
archivedat = {archived at},
archivedon = {on},
}
\DeclareFieldFormat{archiveurl}{\bibstring{archivedat}\space\url{#1}}
\DeclareFieldFormat{archivedate}{\bibstring{archivedon}\space#1}
\newbibmacro*{archiveurl}{\printfield{archiveurl}}
\newbibmacro*{archivedate}{\printarchivedate}
\renewbibmacro*{url+urldate}{%
\usebibmacro{url}%
\iffieldundef{urlyear}
{}
{\setunit*{\addspace}%
\usebibmacro{urldate}}%
\setunit{\addcomma\space}%
\usebibmacro{archiveurl}%
\iffieldundef{archiveyear}
{}
{\setunit*{\addspace}%
\usebibmacro{archivedate}}}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{panic}
\printbibliography
\end{document}