I found various ways to remove a field from some entry types. I need to remove the url from some entries but not other of the same type. I try to find in the biblatex manual if it is possible to select entries by their key, but I was unsuccessful. Is there a way to do it at biber or biblatex level?
1 Answer
You can use \iffieldequalstr{entrykey}{<key>}
to select the entry with key <key>
.
\AtEveryBibitem{%
\iffieldequalstr{entrykey}{tric}
{\clearfield{url}\clearfield{urlyear}}
{}%
}
Deletes URL and URL date for an entry called tric
.
If you want to go by type instead use
\AtEveryBibitem{%
\ifentrytype{article}
{\clearfield{url}\clearfield{urlyear}}
{}%
}
This deletes URL and URL date for @article
s.
Alternatively, you can use Biber's sourcemapping. The advantage of sourcemapping is that the data is removed on the input level. So that it is not considered for various extra calculations like labelyear
, labelname
, etc.
You can clear a particular entry by matching the entrykey
\DeclareSourcemap{
\maps{
\map{
\step[fieldsource=entrykey, match=\regexp{\Actan\Z}, final]
\step[fieldset=url, null]
\step[fieldset=urldate, null]
}
}
}
For type-specific mapping use \pertype
.
\DeclareSourcemap{
\maps{
\map{
\pertype{article}
\step[fieldset=url, null]
\step[fieldset=urldate, null]
}
}
}
-
Brilliant! How would I best clear the URL or more than one entry? Is it best to use the full DeclareSourcemap again or can I somehow match on more than one key? Jun 23, 2021 at 19:16
-
1@FrederickNord Depends on what you want to do. If you remove the
\pertype{article}
in the last block, all URLs are cleared. If you leave the\pertype{article}
in, all URLs of@article
entries are cleared. Usually something like this is more semantic and more effective than giving a list of keys to clear, but you can of course also do\step[fieldsource=entrykey, match=\regexp{\A(key1|key2|key3)\Z}, final]
to clear the URLs ofkey1
,key2
andkey3
.– moeweJun 23, 2021 at 20:01 -
yeah, I just want to tweak certain items which take lots of space in the bibliography. The RegEx is not pretty, but handy. Thanks! Oct 15, 2021 at 10:03
\ifthenelse
on some key you define in your.bib
file in the bibliography macro\AtEveryBibitem
.