10

Based on lockstep's answer here, I wrote

\ifentrytype{book,collection,incollection}{%
}{%
\clearfield{url}%
\clearfield{urldate}%
\clearfield{review}%
\clearfield{series}%
}%

to suppress the URL and its date for the listed source types. The catch is, it even suppresses the URL for @ONLINE sources now, even if I only specify one entry type. Is the code above outdated or is it due to my settings?

Output

enter image description here

MWE, made after musicman's answer

\documentclass{article}

\usepackage[
style=authoryear-icomp
]{biblatex}

\AtEveryBibitem{%
\ifentrytype{book,collection,incollection}{
    \clearfield{url}%
    \clearfield{urldate}%
    \clearfield{review}%
    \clearfield{series}%%
}{}
}

\usepackage{filecontents}

\begin{filecontents}{test-lit.bib}
@book{Abook,
  author = {AAAAbook, A.},
  year = {2001},
  title = {Alpha},
  url = {tex.stackexchange.com},
}
@online{Bonline,
  author = {BBBBonline, B.},
  year = {2002},
  title = {Bravo},
  url = {tex.stackexchange.com},
}
@collection{Ccollection,
    editor = {CCCCColletionEditor, C.},
    year = {2002},
    title = {Charlie},
    url = {tex.stackexchange.com},
}
@incollection{Dincollection,
    author = {DDDDincollection, D.},
    year = {2002},
    crossref = {Ccollection},
    title = {Delta},
    url = {tex.stackexchange.com},
}
\end{filecontents}

\addbibresource{test-lit.bib}

\nocite{*}

\listfiles

\begin{document}

Abc.

\printbibliography

\end{document}
1
  • look at the synthax: if {} else {your commands} - it's applicated only on entrytypes which are not book,collection,incollection, so @online of course, too.
    – musicman
    Jul 2, 2014 at 15:29

2 Answers 2

12

Apparently the rules have to be defined on an per-type-basis so the answer is: not possible.

Output

enter image description here

MWE

    \documentclass{article}

\usepackage[
style=authoryear-icomp
]{biblatex}

\AtEveryBibitem{%
\ifentrytype{book}{
    \clearfield{url}%
    \clearfield{urldate}%
    \clearfield{review}%
    \clearfield{series}%%
}{}
\ifentrytype{collection}{
    \clearfield{url}%
    \clearfield{urldate}%
    \clearfield{review}%
    \clearfield{series}%%
}{}
\ifentrytype{incollection}{
    \clearfield{url}%
    \clearfield{urldate}%
    \clearfield{review}%
    \clearfield{series}%%
}{}
}

%%%%not working:
%%%\AtEveryBibitem{%
%%%\ifentrytype{book,collection,incollection}{%supresses the fields for those entrytypes
%%% \clearfield{url}%
%%% \clearfield{urldate}%
%%% \clearfield{review}%
%%% \clearfield{series}%
%%%}{}%the other entrytypes are nore affected
%%%}

\usepackage{filecontents}

\begin{filecontents}{test-lit.bib}
@book{Abook,
  author = {AAAAbook, A.},
  year = {2001},
  title = {Alpha},
  url = {tex.stackexchange.com},
}
@online{Bonline,
  author = {BBBBonline, B.},
  year = {2002},
  title = {Bravo},
  url = {tex.stackexchange.com},
}
@collection{Ccollection,
    editor = {CCCCColletionEditor, C.},
    year = {2002},
    title = {Charlie},
    url = {tex.stackexchange.com},
}
@incollection{Dincollection,
    author = {DDDDincollection, D.},
    year = {2002},
    crossref = {Ccollection},
    title = {Delta},
    url = {tex.stackexchange.com},
}
\end{filecontents}

\addbibresource{test-lit.bib}

\nocite{*}

\listfiles

\begin{document}

Abc.

\printbibliography

\end{document}
3
  • 8
    you are right. shorter way using the already included ifthen-package: \AtEveryBibitem{\ifthenelse{\ifentrytype{book}\OR\ifentrytype{collection}\OR\ifentrytype{incollection}}{ \clearfield{url}\clearfield{urldate}\clearfield{review}\clearfield{series}}{}}
    – musicman
    Jul 3, 2014 at 11:03
  • 3
    I just came across this answer because of Biblatex: Surpessing urldate does not work (\clearfield) and it seems that with the current version \clearfield{urldate} doesn't work any more, now \clearfield{urlyear} is needed.
    – moewe
    Nov 18, 2015 at 18:02
  • To suppress the issue from the \cite in apa author-year style, to ensure you get Author (date) and not Author (date, issue), this does it: \AtEveryCitekey{\clearfield{issue}}.
    – PatrickT
    Jul 9, 2018 at 19:30
2
\ifentrytype{book,collection,incollection}{%supresses the fields for those entrytypes
\clearfield{url}%
\clearfield{urldate}%
\clearfield{review}%
\clearfield{series}%
}{}%the other entrytypes are nore affected

UPDATE: as the other answer tells us, \ifentrytype only works with ONE entrytype as its argument.

3
  • 1
    Would love to say it works for me, and I fully understand your first comment... but I still get the URL for an incollection entry printed out. I don't get it. It probably needs a real MWE. I'll get back to you on that. Thank you for your effort.
    – henry
    Jul 2, 2014 at 15:38
  • Ok, it doesn't work. Updated my op with real MWE and a picture. :)
    – henry
    Jul 3, 2014 at 8:08
  • 2
    I just came across this answer because of Biblatex: Surpessing urldate does not work (\clearfield) and it seems that with the current version \clearfield{urldate} doesn't work any more, now \clearfield{urlyear} is needed.
    – moewe
    Nov 18, 2015 at 18:02

You must log in to answer this question.

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