2

I want to make use of a custom field in my bib file, that is not defined in my BibLaTeX data model. I wish to map this field via the usual \DeclareSourcemap construct, as explained in ยง4.5.3, to one defined in my data model, but also already in use.

Specifically, I have a @Patent entry containing the type field, which I have set to the BibLaTeX-defined patrequs bibstring. I additionally use the custom field appnumber, to encode the USPTO application number (I already use number for the USPTO patent number).

Since appnumber is not defined in my data model, and I wish to obviate having to manually do so, I want to map this to be appended to the end of the interpolated bibstring that my type would otherwise expand to.

It seems that this requires two \step commands. The following works, but appends prior to bibstring interpolation, which is perhaps obvious, but not what I wish to accomplish.

\DeclareSourcemap{
    \maps[datatype=bibtex, overwrite]{
        \map{
            \pertype{patent}
            \step[fieldsource=appnumber]
            \step[fieldset=type, origfieldval, append]
        }
    }
}

This yields, patrequsNN/XXX,XXX instead of the desired, U.S. patent request NN/XXX,XXX.


Please find a sample @Patent entry (adapted from Sandra Mau's webpage, pretending that the US patent has yet to be granted) and an example of desired output below, as a MWE (and available on Overleaf):

@Patent{EHLINGER:2006:biblatex,
 author = {EHLINGER, JR., Philip Charles},
 title = {Device for the treatment of hiccups},
 year = {2006},
 month = {06},
 day = {13},
 number = {7062320},
 kind   = {B2},
 appnumber = {10/684,114},
 type   = {patrequs},
 url = {http://www.patentlens.net/patentlens/patent/US_7062320/},
 IPC_class = {A61N 1/04},
 US_class = {607  2},
}

With the above bib file saved as mwe.bib, the following should (depending upon one's style and other configurations) reproduce output similar to the below:

\documentclass{article}

\usepackage[backend=biber, style=biblatex-cse, autopunct, autocite=superscript, doi=false, url=false, isbn=false]{biblatex}

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
     \map{  % clear patent scope, obviating output of redundant info. for US patents
       \pertype{patent}
       \step[fieldset=location, null]
       \step[fieldset=kind, null]  % we include the USPTO kind codes, but do not use them
       % we use the field "appnumber" to store the USPTO application number
       % we simply map it to be appended to the "type" field, in the standard data model
       % Adapted from: https://tex.stackexchange.com/q/454008/134641
       \step[fieldsource=appnumber]
       \step[fieldset=type, origfieldval, append]
     }
  }
}

\addbibresource{mwe.bib}

\begin{document}

\fullcite{EHLINGER:2006:biblatex}

\end{document}

This yields:

pdfLaTeX-rendered output of the above full citation.

Whereas, I would like something akin to (perhaps also with some better punctuation to demarcate the appnumber from the number):

EHLINGER JR. PC. 2006. Device for the treatment of hiccups. U.S. patent request 10/684,114 7062320.


Might anyone be able to fix this such that (1) the append occurs (or is equivalent to) the result after bibstring interpolation, (2) easily adds a space between the fields (i.e. without my having to modify the underlying style), or (3) suggests some viable alternative to properly encode and typeset the USPTO application number?

Coby Viner
  • 1,939

1 Answers1

2

Why does the map not work?

Biber knows nothing about biblatex's bibstrings. So it does not know that patrequs expands to "U.S. patent request". The bibstring is only 'expanded' by biblatex at the very last minute by virtue of

\DeclareFieldFormat{type}{\ifbibstring{#1}{\bibstring{#1}}{#1}}

That means that biblatex takes the contents of the type field as produced by Biber and checks if it coincides with the name of a bibstring (as patrequs would), if that is the case the corresponding bibstring is printed, if not the text is printed as is.

So type = {patrequs}, expands to 'U.S. patent request'. To all intents and purposes, your mapping turns

type      = {patrequs},
appnumber = {10/684,114},

into

type      = {patrequs10/684,114},

Unfortunately patrequs10/684,114 is not a known bibstring, so the text gets printed verbatim and the bibstring is not expanded.

How can I get it to work?

Just print appnumber

The best solution in my book would be to modify the style you use to print appnumber in the appropriate place and be done with it.

Since appnumber is not a known field in the data model that would necessarily require a custom .dbx file. See Add field "tome" to biblatex entries. I admit that looks like a bit of work.

You could avoid the .dbx file if you remap the field to a reserved special field such as usera, but you would still have to tell the style to use it.

A terrible hack

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
     \map{
       \pertype{patent}
       \step[fieldset=location, null]
     }
     \map{
       \pertype{patent}
       \step[fieldsource=appnumber, final]
       \step[fieldsource=type, match=\regexp{\A(.*)\Z}, replace=\regexp{\\ifbibstring\{$1\}\{\\bibstring\{$1\}\}\{$1\}\x{20}}]
       \step[fieldsource=appnumber]
       \step[fieldset=type, origfieldval, append]
     }
  }
}

Essentially recreates the field format that expands the bibstring in the sourcemap and lets

type      = {patrequs},
appnumber = {10/684,114},

come out as

type = {\ifbibstring{patrequs}{\bibstring{patrequs}}{patrequs} 10/684,114}

But this is truly atrocious.

Coby Viner
  • 1,939
moewe
  • 175,683