7

In a comment to the question Notes after bibliography entry with Biber and BibLaTeX Marco Daniel suggested to use \DeclareSourcemap to add notes to specific entries.

The most immediate solution would be to have a definition of source map like, where we search entries based on they BibTeX key, thus using something like:

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=entrykey, match={key1},
            fieldset=note, fieldvalue={This is a note}]
    }
  }
}

However, it does not work: the note field is not inserted for the appropriate entry. However, if a different field is used, e.g., author

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=author, match={Author},
            fieldset=note, fieldvalue={This is a note}]
    }
  }
}

then, the note is inserted.

I think that an MWE in this case would not be required, but since somebody is going to ask for it, here it is:

\documentclass{article}
\usepackage{filecontents}
\usepackage[style=numeric]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@article{key1,
author = {Author, John},
title  = {Title},
journal =  {A Journal},
year = 2012,
}
@article{key2,
author = {Author2, John},
title  = {Title},
journal =  {A Journal},
year = 2012,
}
\end{filecontents}
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=entrykey, match={key1},
            fieldset=note, fieldvalue={This is a note}]
    }
    \map{
      \step[fieldsource=author, match={Author2},
            fieldset=note, fieldvalue={This is a note}]
      }
  }
}
\begin{document}
\nocite{*}
\printbibliography
\end{document}

So, the question is whether it is possible to use the BibTeX key (entrykey) in a biber mapsource specification, or what is the field that can be used and uniquely identifies a bibentry?

0
6

I don't think that you can match the entrykey field (but it would be perhaps worth a feature request). But actually you probably don't need it. You could do something like this instead:

\documentclass{article}
\usepackage{filecontents}

\usepackage[style=numeric]{biblatex}
\addbibresource{\jobname.bib}
\begin{filecontents}{\jobname.bib}
@article{key1,
author = {Author, John},
title  = {Title},
journal =  {A Journal},
year = 2012,
}
@article{key2,
author = {Author2, John},
title  = {Title},
journal =  {A Journal},
year = 2012,
}
@article{key3,
author = {Author3, John},
title  = {Title},
journal =  {A Journal},
year = 2012,
}
\end{filecontents}

\makeatletter
\@namedef{key1note}{This is note 1}
\@namedef{key2note}{This is note 2}
% key3 has no note 
\makeatother

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldset=note, 
            fieldvalue=\unexpanded{\csname\thefield{entrykey}note\endcsname}
            ]
      }
  }
}



\begin{document}
\nocite{*}
\printbibliography
\end{document}
3
  • Nice suggestion ;-) -- However I think this should be a request. Nov 17 '12 at 10:20
  • Nice suggestion indeed. I'll create a feature request for biber.
    – Guido
    Nov 17 '12 at 10:56
  • This is implemented in biber 1.4 DEV beta as the "entrykey" pseudo-field, just like in your first example. You will also need biblatex 2.4 DEV beta from SF to try this. This is documented in the biber and biblatex PDF manuals. Of course you can't change this field with a map, it would make a real mess ...
    – PLK
    Nov 19 '12 at 9:13

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.