1

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?

3
  • 1
    An example would be really helpful here. Anyhow, I would assume you could somehow work with an \ifthenelse on some key you define in your .bib file in the bibliography macro \AtEveryBibitem.
    – Timm
    Mar 16, 2017 at 11:45
  • It is possible to do that per key. But it seems more elegant to do it by some other way. Either by type, some option in the bib file, or something else entirely. It really depends on your situation. So it would be really helpful if you could give more details about your specific use case as well as an MWE so we can get started more quickly and make sure that our solutions work for you.
    – moewe
    Mar 16, 2017 at 11:59
  • @moewe Thanks for caring. The work in this is progressing slowly. I am thinking that it may work just clearing the field 'per' entry type. But still have to check all the entries I have.
    – TeXtnik
    Mar 20, 2017 at 12:05

1 Answer 1

4

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 @articles.


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]
    }
  }
}
3
  • 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 of key1, key2 and key3.
    – moewe
    Jun 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

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.