1

I would like to suppress the annotation field from the .bbl file using biblatex. I often use the annotation field to write down notes about a given paper, which can be a problem if I happen to use a LaTeX command such as % in the annotation field. Having something like % in the annotation field does not cause any issues in the .bib file, but having it in the .bbl file causes a failure to compile. I tried to follow the suggestions in Is it possible to suppress a specific field from bibtex .bbl in biblatex?, but these did not work for me.

Here is my minimal working example:

\documentclass[12pt]{article}

\usepackage{biblatex}

\begin{filecontents*}{mwe.bib}
@article{Doe.J-1979a,
    Annote = {10 % strain},
    Author = {John Doe},
    Date-Added = {2020-08-27 10:54:17 -0600},
    Date-Modified = {2020-08-27 12:03:22 -0600},
    Journal = {Journal of LaTeX Issues},
    Title = {Problematic Reference Title},
    Year = {1979}}
\end{filecontents*}

\addbibresource{mwe.bib}

\AtEveryBibitem{\clearfield{annotation}}

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \step[fieldset=annotation, null]
    }
  }
}

\begin{document}
\textcite{Doe.J-1979a}
\printbibliography
\end{document}

This creates the following .bbl file

\begingroup
\makeatletter
\@ifundefined{[email protected]}
  {\@latex@error
     {Missing 'biblatex' package}
     {The bibliography requires the 'biblatex' package.}
      \aftergroup\endinput}
  {}
\endgroup


\refsection{0}
  \datalist[entry]{nty/global//global/global}
    \entry{Doe.J-1979a}{article}{}
      \name{author}{1}{}{%
        {{hash=bd051a2f7a5f377e3a62581b0e0f8577}{%
           family={Doe},
           familyi={D\bibinitperiod},
           given={John},
           giveni={J\bibinitperiod}}}%
      }
      \strng{namehash}{bd051a2f7a5f377e3a62581b0e0f8577}
      \strng{fullhash}{bd051a2f7a5f377e3a62581b0e0f8577}
      \strng{bibnamehash}{bd051a2f7a5f377e3a62581b0e0f8577}
      \strng{authorbibnamehash}{bd051a2f7a5f377e3a62581b0e0f8577}
      \strng{authornamehash}{bd051a2f7a5f377e3a62581b0e0f8577}
      \strng{authorfullhash}{bd051a2f7a5f377e3a62581b0e0f8577}
      \field{sortinit}{D}
      \field{sortinithash}{2ef1bd9a78cc71eb74d7231c635177b8}
      \field{labelnamesource}{author}
      \field{labeltitlesource}{title}
      \field{annotation}{10 % strain}
      \field{journaltitle}{Journal of LaTeX Issues}
      \field{title}{Problematic Reference Title}
      \field{year}{1979}
    \endentry
  \enddatalist
\endrefsection
\endinput

As you can see, the % messes up the closing bracket in \field{annotation}{10 % strain}.

4
  • 1
    in your example you called your field Annote not annotation. Aug 27, 2020 at 20:17
  • @Ulrike Fischer, thanks for your attention to detail, but I believe I did things correctly. The Annote field in the .bib file gets converted to an annotation field in the .bbl file. I have updated my original post to show this.
    – Stretch
    Aug 27, 2020 at 23:02
  • If you replace annotation with annote in the definition of the step of the \DeclareSourcemap instruction, the annotation is ignored (nullified) and it will not appear in the bbl file.
    – Guido
    Aug 27, 2020 at 23:41
  • Hah, that was it! @Guido, if you would submit your suggestion as an answer, I will accept it.
    – Stretch
    Aug 28, 2020 at 0:32

3 Answers 3

2

In the MWE, the .bib file contains the field annote, but in the source map, the step specify annotation as a field. Hence, if in the source map we replace annotation with annote the field containing % will be nullified and it will not appear in the bbl file. Accordingly, the \DeclareSourcemap instruction should look like:

\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \step[fieldset=annote, null]
    }
  }
} 
1

Guido has already given the answer: You need to delete the annote field in your sourcemap. But it may be interesting to know why.

biblatex has some field and type aliases set up for backwards compatibility with some popular BibTeX styles. One such alias relation turns the annote field into annotation. With Biber this alias relation is implemented via a special driver sourcemap defined in biblatex.def (ll. 1305-1337 in v3.15a)

\DeclareDriverSourcemap[datatype=bibtex]{
  <...>
  \map{
    \step[fieldsource=hyphenation,   fieldtarget=langid]
    \step[fieldsource=address,       fieldtarget=location]
    \step[fieldsource=school,        fieldtarget=institution]
    \step[fieldsource=annote,        fieldtarget=annotation]
    \step[fieldsource=archiveprefix, fieldtarget=eprinttype]
    \step[fieldsource=journal,       fieldtarget=journaltitle]
    \step[fieldsource=primaryclass,  fieldtarget=eprintclass]
    \step[fieldsource=key,           fieldtarget=sortkey]
    \step[fieldsource=pdf,           fieldtarget=file]
  }
}

This just says to turn every annote Biber finds into annotation. Indeed you could say that internally for biblatex there is only annotation and no annote field. So it is natural to write all code mentioning only annotation and not annote.

The problem you ran into was timing: This driver sourcemap is executed after your user-level simple \DeclareSourcemap. In particular, when your sourcemap is executed, no field names have been renamed yet and the field is still called annote.

One way to resolve the problem is shown in Guido's answer: Delete the annote field, since that's what it is still called when your sourcemap is executed. You may or may not want to delete annotation as well

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldset=annote,     null]
      \step[fieldset=annotation, null]
    }
  }
}

One other way to get around the issue be to execute the annote->annotation mapping already in your sourcemap: So you first map all annotes to annotation and then delete the annotation.

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=annote,  fieldtarget=annotation]
      \step[fieldset=annotation, null]
    }
  }
}

Note that in any case \AtEveryBibitem{\clearfield{annotation}} won't help because the error you get from the % already occurs when the entry data is read from the .bbl file and not when the field is/could be printed in the bibliography. What's more the standard biblatex styles (except for reading) don't show annotation anyway, so the \clearfield wouldn't do anything useful in the MWE.

0

Add annotation=false to the settings, e.g.: \usepackage[style=apa,annotation=false]{biblatex}

1
  • Welcome to TeX.SE!
    – Mensch
    Oct 28, 2021 at 21:13

You must log in to answer this question.

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