9

Is there a possiblity to add a second URL to @online entries?

I would like to display 1. the original URL and 2. an entry in an archiving service (archive.org or webcitation.org) in case the original Site goes down

Related, i also would like to add the name of the Website (e.g. name of the newspaper, Media outlet) similar to Booktitle from @incollection

2

1 Answer 1

7

You can define a new archiveurl field with accompanying archivedate.

This is done via a .dbx file, we can also add internationalisation. You can read more about this in How can I create entirely new data types with BibLaTeX/Biber? and Add field “tome” to biblatex entries. The .dbx needs to placed somewhere TeX can find it and its name must be given to biblatex in the datamodel option at loading time. In the MWE the file is created automatically using filecontents.

The .dbx contains

\DeclareDatamodelFields[type=field, datatype=uri]{archiveurl}
\DeclareDatamodelEntryfields{archiveurl}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
  archivedate,
}
\DeclareDatamodelEntryfields{archivedate}

and thus defines two new fields: archiveurl and archivedate. The former is a URI-type field (a URL) while the latter is a date field.

Then we define the needed strings, internationalisation can also be done in an .lbx file.

\NewBibliographyString{archivedat,archivedon}
\DefineBibliographyStrings{english}{%
  archivedat = {archived at},
  archivedon = {on},
}

We can define the formats and new macros

\DeclareFieldFormat{archiveurl}{\bibstring{archivedat}\space\url{#1}}
\DeclareFieldFormat{archivedate}{\bibstring{archivedon}\space#1}

\newbibmacro*{archiveurl}{\printfield{archiveurl}}
\newbibmacro*{archivedate}{\printarchivedate}

Finally, we modify the URL macro to also print the archive URL.

\renewbibmacro*{url+urldate}{%
  \usebibmacro{url}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\addspace}%
     \usebibmacro{urldate}}%
  \setunit{\addcomma\space}%
  \usebibmacro{archiveurl}%
  \iffieldundef{archiveyear}
    {}
    {\setunit*{\addspace}%
     \usebibmacro{archivedate}}}

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .