TeX - LaTeX Asked by paulswanson on August 2, 2021
I’m trying to use Bibtool to exclude (filter out) a range of entries from a bibliography, based on some field criteria.
Bibtool offers the select.by.non.string
rule which will cause a bibliographic entry to be excluded if it contains a certain string in one of its fields.
For example, for a given bib file with the following entries:
@misc{foo19,
author = {Foo, John},
title = {Travel Diary},
year = {2019},
publisher = {Bar Publishing}
}
@misc{smith20,
author = {Smith, Mary},
title = {New Years Resolutions},
year = {2020}
publisher = {Bar Publishing}
}
@misc{foo20,
author = {Foo, John},
title = {Isolation},
year = {2020}
publisher = {Pandemic Press}
}
and calling bibtool with the following resource file:
select.by.string.ignored {"{}"}
select.case.sensitive {off}
select.by.non.string { title "Travel Diary" }
will result in a the output excluding any entries with a title of “Travel Diary”, in this case a resulting bibliography of:
@misc{smith20,
author = {Smith, Mary},
title = {New Years Resolutions},
year = {2020}
publisher = {Bar Publishing}
}
@misc{foo20,
author = {Foo, John},
title = {Isolation},
year = {2020}
publisher = {Pandemic Press}
}
So far, so good. But the behaviour becomes problematic once multiple such rules are included in the resource file. On page 34 (Section A.9.2) of the current Bibtool manual it states that
If several rules are supplied then any entry matching one of the rules is selected. Thus different rules act as alternatives.
What I expected to happen, was that whichever rule is first matched applies to that given entry, however this is not the case. If a second rule is added to the resource file, as such:
select.by.string.ignored {"{}"}
select.case.sensitive {off}
select.by.non.string { title "Travel Diary" }
select.by.non.string { title "Isolation" }
Instead of filtering out both entries containing “Travel Diary” and “Isolation” titles, it filters out NO bibliographic entries at all; the full, original input bibliography is returned with no Bibtool errors.
Furthermore, I get the same results when specifying multiple fields within even a single select.by.non.string
rule.
All I want is to exclude various entries based on a list of criteria, should be a fairly trivial exercise. Is this the wrong rule / tool, am I doing it wrong … how do others get this task done without resorting to cut and paste?
You can use regular expressions for this. Similar to the options for strings, there is select
to include entries that match the regular expression and select.non
to exclude entries that match the expression.
In regular expressions the bar |
is used as the 'or' operator. In Bibtool this character needs to be escaped by a backslash, as noted in the manual on page 32.
Resource file:
select.by.string.ignored {"{}"}
select.case.sensitive {off}
select.non { title "Travel Diary|Isolation" }
Answered by Marijn on August 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP