[Tex/LaTex] biblatex: string manipulation after processing of bibtex @STRING

biblatexbibtexstrings

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.)

Best Answer

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

Related Question