I'm trying to create a DeclareSourcemap to append a string ("Modern publication date ") and a source field value (the value from date) to a target field (addendum). In my biblatex source I have some entries where addendum doesn't exist; and some entries where addendum does exist, with existing text that I don't want to overwrite.

I want to prefix a space to the result appended to addendum, if addendum already contains text. E.g. To end up with something like:

addendum={Existing addendum text. Modern publication date 2015-02-23}

But I don't want to prefix a space to the result appended to 'addendum', if addendum doesn't exist. E.g. To end up with something like:

addendum={Modern publication date 1975-06-15}

I can successfully prefix a space to the string to be appended. But I can't work out how to do this conditionally, depending on whether addendum exists or not (or has a non-zero length string value, or not).

Just to share the deeper motivation: I'm trying to set up a source mapping so that I can readily switch between styles that don't support origdate (e.g. a biblatex native style like authoryear) and those that do (e.g. biblatex-chicago) without having to change my biblatex source file (of bibliographic entries). Also with my in-text citations and bibliographic entries I'm wanting to give prominence to the original date rather than modern date. My Minimum Working Example (MWE) below does all this (the data source mapping is used with biblatex's native style authoryear), except for the conditional prefixing of spaces to appended text ...


  % Entry doesn't have an addendum
    author = {{Plato}},
    date = {2004-09-15},
    origdate = {-0379~},
    title = {Republic},
    translator = {Reeve, C. D. C.},
    publisher = {{Hackett Publishing Company, Inc.}},

  % Entry has an addendum with existing text.
    author = {Hume, David},
    date = {1975-06-12},
    origdate = {1751},
    title = {An {{Enquiry Concerning}} the {{Principles}} of
    addendum = {Previously existing addendum text.},
    editor = {Selby-Bigge, L. A. and Nidditch, P. H.},
    publisher = {{Oxford University Press}},
    booktitle = {Enquiries {{Concerning Human Understanding}}
       and {{Concerning}} the {{Principles}} of {{Morals}}},

%  style=debug,

      %%% addendum to "Modern publication date [datevalue]"
      %%% e.g. addendum={
      %%% [Optional existing text.] Modern publication date 
      %%%  2004-09-15
      %%% }
      % Append some text to the addendum field:
      % - With a leading space of there is text already in 
      %the addendum field (currently works); but
      % - Without a leading space if the addendum field 
      % doesn't exist (currently doesn't work).
      \step[fieldset=addendum, fieldvalue={\ Modern 
      date{ }}, append]
      % The addendum field must exist with at least "Modern 
      % publication date ".
      % Append the date.
      \step[fieldset=addendum, origfieldval, append]
      %%% origdate: origdatevalue to date: origdatevalue 
      %%% e.g. origdate = {1751} to date = {1751}
      \step[fieldset=date, origfieldval]



This give a result of ...


... the Plato entry has two spaces before "Modern publication date ..." (where one space is desired), Hume's entry has one space (as desired) before "Modern publication date ...". Using style=debug makes this more obvious.

I'm not sure if the solution entails one or more of:

  • A better understanding of latex space handling; or
  • Some regexp (which DeclareSourcemap supports);
  • A better understanding of DeclareSourcemap handling;
  • Changes to biblatex source code, of data source mapping, to offer a more powerful append functionality.

One option is to ignore the double space. It is hardly noticeable. But, of course, we coders like to be able to get things exactly as we want them.

I'm using the dev versions of biber (sourceforge link) and biblatex (3.7, sourceforge link). The production versions have been choking for me against the above MWE. I'm using Xelatex.

Edit: Commented out MWE in-text citations so result will appear exactly as posted in image (without backreferences).

Edit: Fixed title capitalisation. "How" to "how".

1 Answer 1


You don't have to put everything into one \map - that makes some things impossible. Try this:

      \step[fieldsource=addendum, final]
      \step[fieldset=addendum, fieldvalue={~}, append]
      % Only suffix "Modern publication date ..." where there is an origdate
      \step[fieldsource=origdate, final] 
      \step[fieldset=addendum, fieldvalue={Modern publication  date{ }}, append]
      \step[fieldset=addendum, origfieldval, append]
      \step[fieldset=date, origfieldval]

This first puts a space at the end of addendum if it exists and then does the actual field modifications. This could be further conditionalised with final \maps to be safer. The point is that you can force \maps to only apply to some entries with final. This is generally how to conditionalise maps.

Edit by John Bentley:

To the above solution, to make it further safer (as PLK suggests), I've added

  % Only suffix "Modern publication date ..." where there is an origdate
  \step[fieldsource=origdate, final] 

... one could also test for this by adding to the MWE ...

    author = {Chalmers, David J.},
    date = {1995},
    title = {Facing up to the Problem of Consciousness},
    pages = {200--19},
    journaltitle = {Journal of Consciousness Studies},
    number = {3},
    timestamp = {2016-06-05T20:09:34Z},
    url = {http://consc.net/papers/facing.html},
    volume = {2},
    addendum={This entry only has a date, not origdate, so no ``Modern publication date" should be output}

You must log in to answer this question.

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