如果 biblatex-chicago 中存在 DOI,则隐藏 URL

如果 biblatex-chicago 中存在 DOI,则隐藏 URL

对于那些比我更了解 biblatex 工作原理的人来说,这个问题可能是一个本垒打...无论如何,我想实现已经解决的问题这里这里,但使用biblatex-chicago而不是biblatex。这意味着只要参考文献中存在 DOI,URL 就应该被隐藏。注意:在原始问题中,情况恰恰相反。

卡尔科勒的 MWE一旦我替换,它将不起作用biblatex

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[backend=biber]{biblatex-chicago}

\addbibresource{\jobname.bib}

\renewbibmacro*{doi+eprint+url}{%
  \iftoggle{bbx:doi}
    {\iffieldundef{url}{\printfield{doi}}{}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{kastenholz1,
  hyphenation = {american},
  author = {Kastenholz, M. A. and H{\"u}nenberger, Philippe H.},
  indextitle = {Computation of ionic solvation free energies},
  title = {Computation of methodology\hyphen independent ionic solvation free
    energies from molecular simulations},
  subtitle = {I. The electrostatic potential in molecular liquids},
  journaltitle = jchph,
  volume = {124},
  eid = {124106},
  date = {2006},
  url = {http://dx.doi.org/10.1063/1.2172593},
  urldate = {2006-10-01},
  doi = {10.1063/1.2172593},
}
@article{kastenholz2,
  hyphenation = {american},
  author = {Kastenholz, M. A. and H{\"u}nenberger, Philippe H.},
  indextitle = {Computation of ionic solvation free energies},
  title = {Computation of methodology\hyphen independent ionic solvation free
    energies from molecular simulations},
  subtitle = {I. The electrostatic potential in molecular liquids},
  journaltitle = jchph,
  volume = {124},
  eid = {124106},
  date = {2006},
  doi = {10.1063/1.2172593},
}
\end{filecontents}


\begin{document}
  \nocite{*}
  \printbibliography
\end{document}

输出:

不好

请问谁能帮忙?

答案1

除非我误解了这个问题,否则不会添加选项

\usepackage[doi=only]{biblatex-chicago}

或者

\usepackage[url=false]{biblatex-chicago}

工作(后者会抑制全部请参阅 4.4.2biblatex-chicago

答案2

您可以修补负责打印和的两个宏,doiurl清除该url字段(如果已定义)doi

\usepackage{biblatex-chicago}
\usepackage{xpatch}

% patch macro used in bibliography
\xpretobibmacro{bib+doi+url}
  {\iffieldundef{doi}
     {}
     {\clearfield{url}}}
  {}{}

% patch macro used in notes
\xpretobibmacro{cite+doi+url}
  {\iffieldundef{doi}
     {}
     {\clearfield{url}}}
  {}{}

相关内容