这个问题启发我让打印Url
和Eprint
字段成为条件,这样只有当没有Doi
字段时才会打印。任何指点都会很感激,
如果我使用下面发布的代码,我希望它删除我在这里用红色划掉的内容,
\documentclass{article}
\usepackage[backend=bibtex, style=authoryear-comp, natbib=true]{biblatex} %for digital version
\bibliography{\jobname}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Holland1986,
Author = {Paul W. Holland},
Doi = {10.1080/01621459.1986.10478354},
Eprint = {http://www.tandfonline.com/doi/pdf/10.1080/01621459.1986.10478354},
Journal = {Journal of the American Statistical Association},
Keywords = {Applied_Economics},
Number = {396},
Pages = {945-960},
Title = {Statistics and Causal Inference},
Url = {http://www.tandfonline.com/doi/abs/10.1080/01621459.1986.10478354},
Volume = {81},
Year = {1986}}
@article{Heckman1990,
Author = {James Heckman},
Issn = {00028282},
Journal = {The American Economic Review},
Keywords = {_MSc},
Number = {2},
Pages = {313-318},
Publisher = {American Economic Association},
Title = {Varieties of Selection Bias},
Url = {http://www.jstor.org/stable/2006591},
Volume = {80},
Year = {1990}}
\end{filecontents}
\begin{document}
\citet{Holland1986} and \citet{Heckman1990} went for a swim.
\printbibliography
\end{document}
答案1
要有条件地打印 URL,可以使用以下命令:
\documentclass{article}
\usepackage[backend=bibtex, style=authoryear-comp, natbib=true,url=false]{biblatex} %for digital version
\bibliography{\jobname}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Holland1986,
Author = {Paul W. Holland},
Doi = {10.1080/01621459.1986.10478354},
Journal = {Journal of the American Statistical Association},
Keywords = {Applied_Economics},
Number = {396},
Pages = {945-960},
Title = {Statistics and Causal Inference},
Url = {http://www.tandfonline.com/doi/abs/10.1080/01621459.1986.10478354},
Volume = {81},
Year = {1986}}
@article{Heckman1990,
Author = {James Heckman},
Issn = {00028282},
Journal = {The American Economic Review},
Keywords = {_MSc},
Number = {2},
Pages = {313-318},
Publisher = {American Economic Association},
Title = {Varieties of Selection Bias},
Url = {http://www.jstor.org/stable/2006591},
Volume = {80},
Year = {1990}}
\end{filecontents}
% print url if no doi
\renewbibmacro*{doi+eprint+url}{%
\printfield{doi}%
\newunit\newblock%
\iftoggle{bbx:eprint}{%
\usebibmacro{eprint}%
}{}%
\newunit\newblock%
\iffieldundef{doi}{%
\usebibmacro{url+urldate}}%
{}%
}
\begin{document}
\citet{Holland1986} and \citet{Heckman1990} went for a swim.
\printbibliography
\end{document}
答案2
您的 MWE 使用 BibTeX,但如果您愿意切换到 Biber(您真的应该研究一下,Biber 提供更多功能并且 BibTeX 现在正式被视为遗留后端),您可以使用 Biber 的 sourcemap 功能。
\documentclass{article}
\usepackage[backend=biber, style=authoryear-comp]{biblatex}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map[overwrite]{
\step[fieldsource=doi, final]
\step[fieldset=url, null]
\step[fieldset=eprint, null]
}
}
}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{Holland1986,
Author = {Paul W. Holland},
Doi = {10.1080/01621459.1986.10478354},
Eprint = {http://www.tandfonline.com/doi/pdf/10.1080/01621459.1986.10478354},
Journal = {Journal of the American Statistical Association},
Keywords = {Applied_Economics},
Number = {396},
Pages = {945-960},
Title = {Statistics and Causal Inference},
Url = {http://www.tandfonline.com/doi/abs/10.1080/01621459.1986.10478354},
Volume = {81},
Year = {1986}}
@article{Heckman1990,
Author = {James Heckman},
Issn = {00028282},
Journal = {The American Economic Review},
Keywords = {_MSc},
Number = {2},
Pages = {313-318},
Publisher = {American Economic Association},
Title = {Varieties of Selection Bias},
Url = {http://www.jstor.org/stable/2006591},
Volume = {80},
Year = {1990}}
\end{filecontents}
\begin{document}
\addbibresource{\jobname.bib}
\textcite{Holland1986} and \textcite{Heckman1990} went for a swim.
\printbibliography
\end{document}
答案3
这不是一个真正的tex
解决方案,但如果你正在使用佐特罗和更好的 BibTex您可以打开Preferences
>Better BibTeX
并且只导出一个