根据 lockstep 的回答这里, 我写
\ifentrytype{book,collection,incollection}{%
}{%
\clearfield{url}%
\clearfield{urldate}%
\clearfield{review}%
\clearfield{series}%
}%
隐藏列出的源类型的 URL 及其日期。问题是,即使我只指定一种条目类型,它现在也会隐藏 @ONLINE 源的 URL。上面的代码是否过时了,还是因为我的设置?
输出
MWE,根据 musicman 的回答制作
\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
显然,规则必须根据每个类型进行定义,所以答案是:不可能。
输出
平均能量损失
\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}
答案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
更新:正如其他答案告诉我们的那样,\ifentrytype
只能使用一个条目类型作为其参数。