I am writing a report in which I cite several webpages. I would like to supply the dates on which these websites were last revised. Is there a field called last modified
(or something similar) for the online
entry or any other entry type for that matter? A quick search of the Biblatex documentation turned nothing up but perhaps I was searching for the wrong terms.
1 Answer
I would argue that a "last modified" field for websites is not really necessary. The date
field will contain this information. If you cite a book you always use the year of your print version for the year
field, not the year of some other edition (be it the first or just one you like, if you insist on giving information like this there is origdate
).
You can add information like "last modified" in the note
or addendum
fields, which are designed to hold miscellaneous information.
There is also the urldate
for last visited (which is not exactly what you seem to want, but deserves a mention anyway).
But who am I to deny you the joy of having a lastmodifieddate
field. It won't come for free though. We will follow the more complex example in How can I create entirely new data types with BibLaTeX/Biber?.
We will need a new data model for this.
Save the following in a file called lastmod.dbx
(in the MWE below this file is automatically created via filecontents
).
\DeclareDatamodelFields[type=field, datatype=datepart]{
lastmodifiedyear,
lastmodifiedmonth,
lastmodifiedday,
lastmodifiedhour,
lastmodifiedminute,
lastmodifiedsecond,
lastmodifiedtimezone,
lastmodifiedseason,
}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
lastmodifieddate}
\DeclareDatamodelEntryfields{
lastmodifieddate}
Note that we will later load biblatex
with the option datamodel=lastmod
.
Now Biber knows lastmodifieddate
.
We can even have localisation features (save this in english-lastmod.lbx
)
\ProvidesFile{english-lastmod.lbx}[2015/05/10 english with edditions for last modified]
\InheritBibliographyExtras{english}
\NewBibliographyString{lastmodified}
\DeclareBibliographyStrings{%
inherit = {english},
lastmodified = {{last modified}{last mod\adddot}},
}
Finally, we enable printing the new date via
\DeclareFieldFormat{lastmodifieddate}{\bibstring{lastmodified}\space#1}
\newbibmacro*{lastmodifieddate}{\printlastmodifieddate}
\renewbibmacro*{url+urldate}{%
\usebibmacro{url}%
\iffieldundef{lastmodifiedyear}
{}
{\setunit*{\addcomma\space}%
\usebibmacro{lastmodifieddate}}
\iffieldundef{urlyear}
{}
{\setunit*{\addspace}%
\usebibmacro{urldate}}}
The MWE
\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{webs,
author = {Anne Uthor},
title = {A Website from the Future},
url = {https://example.com},
urldate = {2014-12-12},
lastmodifieddate = {2015-06-06},
}
\end{filecontents*}
\begin{filecontents}{lastmod.dbx}
\DeclareDatamodelFields[type=field, datatype=datepart]{
lastmodifiedyear,
lastmodifiedmonth,
lastmodifiedday,
lastmodifiedhour,
lastmodifiedminute,
lastmodifiedsecond,
lastmodifiedtimezone,
lastmodifiedseason,
}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
lastmodifieddate}
\DeclareDatamodelEntryfields{
lastmodifieddate}
\end{filecontents}
\documentclass[english]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[datamodel=lastmod,backend=biber]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}
\begin{filecontents*}{english-lastmod.lbx}
\ProvidesFile{english-lastmod.lbx}[2015/05/10 english with edditions for last modified]
\InheritBibliographyExtras{english}
\NewBibliographyString{lastmodified}
\DeclareBibliographyStrings{%
inherit = {english},
lastmodified = {{last modified}{last mod\adddot}},
}
\end{filecontents*}
\DeclareLanguageMapping{english}{english-lastmod}
\ExecuteBibliographyOptions{lastmodifieddate=short}
\DeclareFieldFormat{lastmodifieddate}{\bibstring{lastmodified}\space#1}
\newbibmacro*{lastmodifieddate}{\printlastmodifieddate}
\renewbibmacro*{url+urldate}{%
\usebibmacro{url}%
\iffieldundef{lastmodifiedyear}
{}
{\setunit*{\addcomma\space}%
\usebibmacro{lastmodifieddate}}
\iffieldundef{urlyear}
{}
{\setunit*{\addspace}%
\usebibmacro{urldate}}}
\begin{document}
\cite{webs}
\printbibliography
\end{document}
gives
The answer was updated to reflect changes in biblatex
's internals that make defining date fields easier. If you are using a very old version of biblatex
you may have to check the edit history.
-
1Very good, thanks. @pacificorion I have one non-TeXnical question. Would a more recent modified date imply that the site was visted that day as well? If not, if a change of contents is known, why is there no check for updates or corrections, making the last visited field match up once again. If the last modified information is known, doesn't that mean any date later than that will have the exact same information available on page, making the visited field redundant? Just my two cents on the topic. May 10, 2015 at 16:55
addendum
field if you just want it at the end of the entry. If you want it to appear somewhere specific in the entry and/or if you want a special fieldmodified
, you're going to need to add it yourself or provide clearer details about your requirements (including a MWE).date
should hold the "last modified" bit of a website, but thendate
could be equally valid to hold the "first published" date. Additional information can always be crammed into theaddendum
ornote
fields. With Biber you can create your own new fields see Add field “tome” to biblatex entries, dates need special handling though, see How can I create entirely new data types with BibLaTeX/Biber?.