4

I am using biblatex 3.1 in conjunction with some BibTeX (.bib) files. These files begin with @STRING macros like

@STRING{CUP="Cambridge University Press"}

and contain entries that have this form:

@BOOK{example,
  AUTHOR       = {John Doe},
  TITLE        = {Leviathan},
  YEAR         = {1992},
  PUBLISHER    = CUP,
  ADDRESS      = {New York},
}

Under ordinary use of biblatex, the "CUP" in the publisher field for this entry will be expanded to "Cambridge University Press." I want it to instead be expanded to "Cambridge Univ Press."

I could make this change just by tweaking the @STRING macro in the .bib file. But that would make the change for every biblatex style, and I want to make this change for just one particular biblatex style. How can I do this?

How to replace a given string in a bibliography with biblatex? shows that it's easy to use \DeclareSourceMap to do arbitrary search–and–replace on bibliography fields when using a particular biblatex style. One need only add the relevant \DeclareSourceMap command to one's biblatex style (.bbx) file. The catch is that these commands don't seem to operate on entries like the PUBLISHER field in the example above. (I don't know why.)

  • 3
    a different solution would be to store the bibtex records and abbreviations in different bibtex file, and to have multiple abbreviation files (for example, one with the full expansion and a second with abbreviated expansions). Then you load the needed files. – Guido Dec 3 '15 at 3:25
  • 1
    @Guido -- Note: I think your comment is a possible solution, and in a way I prefer it to the answer you gave, but there is a "load order" issue with separate @premable files. Generally, the last (re-)definition prevails, but an entry will always (I think) use the @string of its own .bib file ... even if the string is redefined later. Thus the different preamble files need to be handled carefully and the @strings should be rigorously kept separate from the .bib with the actual entries.... (+1 on the answer, by the way.) – jon Dec 4 '15 at 6:41
5

The \DeclareSourceMap should use the value of the string given in @STRING not the abbreviation.

Thus the definition of \DeclareSourceMap should look like:

\DeclareSourcemap{ 
    \maps[datatype=bibtex]{
      \map{
           \step[fieldsource=publisher, match={Cambridge University Press}, replace={Cambridge Univ Press}]
          }
    }      
}

which then produceenter image description here

  • Thank you -- this solution works very nicely. I though that I'd tested it before posting my question, but I must have screwed up the test. – user697473 Dec 3 '15 at 20:01

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.