5

My BibTeX entries have a keywords field with keywords describing the content. I also have a field called tags with meta information like talk, manuscript, own, etc. Example:

@inproceedings{MalsburgVasishth2007ECEM,
  author = {von der Malsburg, Titus and Vasishth, Shravan},
  title = {A Time-Sensitive Similarity Measure for Scanpaths},
  crossref = {ECEM2007},
  keywords = {eyetracking, scanpaths, method},
  tags = {poster, own}
}

Using printbibliography, I can filter entries with certain keywords

`\printbibliography[keyword=eyetracking]

but I also want to filer entries with certain tags. For example, I'd like to have a section in my CV that lists my posters. How can I achieve this?

I suppose one solution would be to append the content of the tags field to the keywords field using a DeclareSourcemap contraption. Such a solution was given before but it doesn't work as expected. Here is a MWE:

\RequirePackage{filecontents}
\begin{filecontents*}{bibliography.bib}
@article{MalsburgEtAl2014,
  author = {von der Malsburg, Titus and Kliegl, Reinhold and Vasishth, Shravan},
  title = {Determinants of Scanpath Regularity in Reading},
  journal = {Cognitive Science},
  year = {2014},
  keywords = {eyemovements, method, parsing, scanpaths, corpus},
  tags = {article, own}
}
\end{filecontents*}

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{bibliography.bib}
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
       \step[fieldsource=tags, fieldtarget=keywords]
    }
  }
}

\begin{document}
\section{Publications}
\nocite{MalsburgEtAl2014}
\printbibliography[keyword=article,notkeyword=submitted,keyword=own,heading=none]
\end{document}

When I compile this, I get the following error messages:

Package biblatex Warning: Keyword 'article' not found on input line 34.
Package biblatex Warning: Keyword 'own' not found on input line 34.
LaTeX Warning: Empty bibliography on input line 34.

Also, the reference is not shown in the PDF.

6
  • @Ludenticus this looks indeed like the solution but unfortunately it doesn't work. The results I get with the proposed definition of DeclareSourcemap (adapted to my field name) is the same as without it: Keyword 'poster' not found on input line 258. I suppose I should come up with a minimal reproducible example.
    – tmalsburg
    Commented Jan 30, 2015 at 23:24
  • 1
    @tmalsburg I just realized that we actually closed the question while you seem not to be satisfied with the duplicate. Please, could you explain (the best would be a MWE of course) that the solution to the other question doesn't work, and then ping us in the chat room so that we can re-open it if we see it's really not trivial? That would be the easiest way to go now I think :)
    – yo'
    Commented Jan 30, 2015 at 23:29
  • Well, if I knew why it doesn't work, I wouldn't need ask here. In the meantime, I also tried the approach described here but that didn't work either. I'll compile a MWE ...
    – tmalsburg
    Commented Jan 31, 2015 at 1:26
  • @yo' I updated the question and added a MWE. I requested reopening of the question in the chat but didn't get a response. Could you please ...? Thanks.
    – tmalsburg
    Commented Feb 3, 2015 at 19:39
  • @tmalsburg Sorry I wasn't there just now. I have voted for reopening. Your edit triggered the review system, so actually 5 people have voted for reopening and it's open now! :)
    – yo'
    Commented Feb 3, 2015 at 19:52

1 Answer 1

2

(This is a revised solution. Thanks to @moewe for pointing out how to simplify it.)

Basically, what you want to do is copy your tags field to the keywords field, but after also adding a comma so the final keyword is not run together with the first word from the tags field.

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{MalsburgEtAl2014,
  author = {von der Malsburg, Titus and Kliegl, Reinhold and Vasishth, Shravan},
  title = {Determinants of Scanpath Regularity in Reading},
  journal = {Cognitive Science},
  year = {2014},
  keywords = {eyemovements, method, parsing, scanpaths, corpus},
  tags = {article, own},
}
\end{filecontents*}

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
       \step[fieldsource=tags,]
       \step[fieldset=keywords, fieldvalue={,}, append]
       \step[fieldset=keywords, origfieldval, append]
    }
  }
}

\begin{document}
\section{Publications}
\nocite{MalsburgEtAl2014}
\printbibliography[keyword=article, notkeyword=submitted, keyword=own,
heading=none]
\end{document}

Note that Biber and BibTeX will ignore fields they don't recognize. So your tags field is copied, but subsequently 'lost'. (You can 'save' it with a judicious use of the \DeclareDatamodelFields command, but it is not needed for this application.)

2
  • I think the main part is your improved sourcemapping command (i.e. using append), \DeclareDatamodelFields[type=field,datatype=literal]{tags} is not necessary for Biber to be able to perform sourcemappings. If you want to preserve all original keywords the final in the final line ought to be an append I think.
    – moewe
    Commented Feb 4, 2015 at 8:28
  • 2
    @moewe -- You are right, as always. I added that the .dbx part when I was having trouble because I was forgetting to add the stupid comma. Then I forgot to check that it wasn't actually needed! @tmalsburg -- Will do, later today. Note that the tags field will be lost without the .dbx, which is OK if you just want it translated to the keywords field, but may be worth noticing nonetheless.
    – jon
    Commented Feb 4, 2015 at 16:36

You must log in to answer this question.

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