7

My university requires online sources to include three different dates per entry:

  1. Date of original publication
  2. Date of last edit
  3. date of visiting the website

Well, the first and third date are easy, but what biblatex field corresponds to the second date?

  1. date
  2. ???
  3. urldate

In the end, an entry should look something like

Uthor, A. (1996): A Stackexchange question. <https://tex.stackexchange.com/questions/ask>. (Last edited: 2008-04-36) (Last checked: 2018-01-29)

where the dates correspond to the above definitions as

  1. 1996
  2. 2008-04-36
  3. 2018-01-29

How do I approach this? Right now, I just use the note field, but, of course, this is not exactly desirable, since it is not very "clean".

EDIT: just found some other similar questions. I need to work on that, although I have not much knowledge as to which bibmacro I need to edit or, actually, about adding custom fields to entries and incorporating them in macros. I'll see what I can do.

I shall investigate them further.

  • Are you using biblatex as your tagging suggests? Would you be OK with a biblatex-specific solution? – moewe Jan 29 '18 at 10:35
  • @moewe Yes, I am using biblatex. I would indeed. Gosh, you're even faster in seeing this question as I am adding information. – thymaro Jan 29 '18 at 10:38
  • Not really related to your question, but it might be nice to include an archived version of the page as well. :) – Andrea Lazzarotto Jan 29 '18 at 14:50
  • @AndreaLazzarotto I don't understand. What page are you referring to? – thymaro Jan 29 '18 at 16:00
  • 1
    @AndreaLazzarotto now I see. I don't know why they need all those dates, but I just figured it's to get a rough frame of reference of how much a page could have changed since my referencing it. Of course, I could make PDFs of those pages and put them in the annex, but in general, pages are pretty stable and don't change much, so they can still be counter checked for veracity of my referencing their content. Of course, pages that do change their content more often, I should consider freezing. I'll talk to my advisor. Thanks for the input. – thymaro Jan 29 '18 at 19:49
5

Similar to Biblatex: Custom date fields. We need to define a .dbx file to make the new lasteditdate known to Biber. Then we only need to add a call to \printlasteditdate to the URL/URL date macro.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@online{elk,
  author       = {Anne Elk},
  title        = {On the Theory of Brontosauruses},
  url          = {https://example.edu/~elk/bronto.html},
  lasteditdate = {2018-01-15},
  urldate      = {2018-01-29},
}
\end{filecontents*}


\begin{filecontents*}{lastedit.dbx}
\DeclareDatamodelFields[type=field, datatype=date, skipout]{
  lasteditdate,
}
\DeclareDatamodelEntryfields{
  lasteditday,
  lasteditendday,
  lasteditendhour,
  lasteditendminute,
  lasteditendmonth,
  lasteditendsecond,
  lasteditendtimezone,
  lasteditendyear,
  lastedithour,
  lasteditminute,
  lasteditmonth,
  lasteditsecond,
  lastedittimezone,
  lastedityear,
}
\end{filecontents*}

\documentclass[british]{article}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber, datamodel=lastedit, lasteditdate=short]{biblatex}
\usepackage{hyperref}
\addbibresource{\jobname.bib}

\NewBibliographyString{lastchanged}
\DefineBibliographyStrings{english}{
  lastchanged = {last changed},
}

\DeclareFieldFormat{lasteditdate}{\mkbibparens{\bibstring{lastchanged}\space#1}}

\renewbibmacro*{url+urldate}{%
  \usebibmacro{url}%
  \iffieldundef{lastedityear}
    {}
    {\setunit*{\addspace}%
     \printlasteditdate}%
  \iffieldundef{urlyear}
    {}
    {\setunit*{\addspace}%
     \usebibmacro{urldate}}}

\begin{document}
\nocite{*}

\printbibliography
\end{document}

enter image description here

  • Splendid. You know, it makes so much sense when I'm reading it, but I can't even guess how much time it would take me to find out how to do all this on my own. I'll have to check against the documentation and other similar questions to figure out where to get the information myself for future alterations of the same type. +1 for "On the Theory of Brontosauruses" :D – thymaro Jan 29 '18 at 11:18
  • I get WARN - Datamodel: Entry 'AsbestosNetwor.2013.ProductsContai' (REF/SiSS_final_report.bib): Invalid field 'lasteditday' for entrytype 'online' from biber 2.10. Same for lasteditmonth and lastedityear. I use biber with--validate_datamodel and I don't use anything else than yyyy-mm-dd. The document compiles as wished, but should I worry about the three warnings per entry? – thymaro Jan 29 '18 at 23:26
  • 1
    @thymaro You don't need to worry, but I have edited the answer so that the warning should be removed. I adapted the code from an earlier answer which was for an older biblatex version. – moewe Jan 30 '18 at 8:26
  • fyi, it works without warnings on my system, now. thanks again. – thymaro Jan 31 '18 at 21:09
0

I can't comment yet, but it should be noted that the .dbx file @moewe created in the TeX should be named the same as the datamodel attribute given to biblatex. It will throw the following error (or something alike) when you try to run the biber %.bcf command: ! Package xkeyval Error: `lasteditdate' undefined in families `blx@opt@pre'.

Hope this saves someone the hour of debugging I just spent on it.

Note to the mods: I am aware this should be a comment on the accepted answer. I simply can't make comments yet :-)

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.