5

I would like to use Biber sourcemaps to add a default value to bibliography items' hyphenation field if there isn't any (I want the default hyphenation for bibliography entries be different from the document's main language). This is the best I could come up with:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldset=needs-hyphenation,fieldvalue=true]
      \step[fieldsource=hyphenation,fieldset=needs-hyphenation,null]
      \step[fieldsource=needs-hyphenation,fieldset=hyphenation,fieldvalue=british]
      \step[fieldset=needs-hyphenation,null]
    }
  }
}

Unfortunately, I can't seem to find a way to conditionally process entries in a sourcemap based on the absence of a key. The fieldsource in itself can be used to make a step conditional on the presence of a field, which I (ab)use to bring a "flag" field into existence then conditionally delete it.

Is there a better way to conditionally run a step if a field is not present?

  • 1
    How about \step[fieldsource=hyphenation, notmatch=".", final]? This will only continue if the field is blank. – PLK Nov 16 '14 at 15:22
5

Sorry guys, the realisation came to me the second I posted this question! :-)

\map without [overwrite] will not overwrite any fields, therefore one can just say

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldset=hyphenation,fieldvalue=british]
    }
  }
}

and not worry about overwriting anything. However, I do wonder if this "flag field" method of programming is of any use in some other situation...

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.