2

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.

5
  • 1
    No. Use the 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 field modified, you're going to need to add it yourself or provide clearer details about your requirements (including a MWE). – jon Nov 29 '14 at 20:13
  • One might argue that date should hold the "last modified" bit of a website, but then date could be equally valid to hold the "first published" date. Additional information can always be crammed into the addendum or note 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?. – moewe Apr 6 '15 at 6:11
  • @jon, moewe Thanks for your comments. Both were helpful. Moewe, if you post your comment as a reply, I'll accept it. – Casimir Apr 8 '15 at 11:04
  • @moewe ^^^^ Wanna write up that answer? ;-) – Johannes_B May 7 '15 at 11:33
  • @Johannes_B With pleasure. It took some time, but there you go! – moewe May 10 '15 at 16:19
7

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

enter image description here

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.

1
  • 1
    Very 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. – Johannes_B May 10 '15 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.