禁止从 Zotero 导出的 biblatex 报纸文章中的 URL

禁止从 Zotero 导出的 biblatex 报纸文章中的 URL

我正在使用 Zotero + Better BibTex 并使用 biblatex 包生成 APA 引用样式的参考书目。我想从学术期刊 @articles 中排除 url 和 urldate,但保留它们用于报纸 @articles。我已成功使用找到的代码从所有文章中隐藏 url这里,但我不知道如何在 Zotero 中向项目添加 entrysubtype 字段,以便我可以仅从学术文章中排除 URL。有没有办法在 Zotero 中输入 entrysubtype,或者我是否可以基于现有的 @article 字段使用其他 LaTex 技巧?

答案1

如果你使用报纸上的entrysubtype = {newspaper}那些@article

@article{frie2002,
  author  = {Jonathan Friedland},
  title   = {Across the Divide},
  journal = {Guardian}, 
  pages   = {10-11},
  date    = {2002-01-15},
  entrysubtype = {newspaper},
  url     = {https://www.theguardian.com/uk},
  urldate = {2016-09-16},
}

你只需要

\AtEveryBibitem{%
  \ifboolexpr{test {\ifentrytype{article}} and not test {\iffieldequalstr{entrysubtype}{newspaper}}}
    {\clearfield{url}%
     \clearfield{urlyear}}
    {}%
}

删除非报纸的url和。urldate@article

biblatex-apa但是,也有一个@newsarticle条目类型

@newsarticle{frie2002,
  author    = {Jonathan Friedland},
  title     = {Across the Divide},
  newspaper = {Guardian}, 
  pages     = {10-11},
  date      = {2002-01-15},
  url       = {https://www.theguardian.com/uk},
  urldate   = {2016-09-16},
}

在这种情况下你想要

\AtEveryBibitem{%
  \ifentrytype{newsarticle}
    {\clearfield{url}%
     \clearfield{urlyear}}
    {}%
}

答案2

您可以保留有关参考文献的所有信息,将其从 Zotero 复制到您的文档,并且仍然可以删除参考文献列表中不必要的字段。

biblatex有一个选项可以声明映射,该选项可以格式化引用中出现的项。可以将两组类型或单个类型包含在映射中。这在动态修改数据(见第 199 页文档)。就我个人而言,我使用它来删除 URL,但我认为你可以做更多。

在下面的解决方案中,URL仅出现在类似在线的引用类型中,因此我声明了以下映射

\DeclareSourcemap{%
  \maps{%
    % remove URLs for non-online types
    \map{%
      \pernottype{www}
      \pernottype{online}
      % Do not show urls, eprints, and urldates
      \step[fieldset=url, null]
      \step[fieldset=urldate, null]
      \step[fieldset=eprint, null]
    }%
  }%
}

这是输出:

在此处输入图片描述

观察文章和书籍条目仍然包含url


完整代码

\begin{filecontents*}[overwrite]{example.bib}
@article{frie2002,
    author  = {Jonathan Friedland},
    title   = {Across the Divide},
    journal = {Guardian}, 
    pages   = {10-11},
    date    = {2002-01-15},
    entrysubtype = {newspaper},
    url     = {https://www.theguardian.com/uk},
    urldate = {2016-09-16},
}
@book{ref:murphy2012,
  title = {Machine Learning: A Probabilistic Perspective},
  author = {Murphy, Kevin P.},
  date = {2012},
  series = {Adaptive {{Computation}} and {{Machine Learning}} Series},
  publisher = {{The MIT Press}},
  abstract = {A comprehensive introduction to machine learning that uses probabilistic models and inference as a unifying approach.},
  isbn = {978-0-262-01802-9},
  url = {http://www.example.url.address},
  file = {/home/ziko/Documents/research/papers/pdfs/Murphy/2012/murphy_2012_machine learning.pdf}
}
@www{GoogleWWW,
  title        = {Google website},
  author       = {Google},
  url = {https://www.google,com},
  year         = 2022,
  note         = {Accessed:2022-07-23},
}
@online{CitekeyMiscAudio,
  title        = {Audio: The 'Other' Red Planet},
  author       = {NASA},
  url = {https://www.nasa.gov/nh/pluto-the-other-red-planet},
  year         = 2015,
  note         = {Accessed: 2018-12-06},
}
@online{CitekeyMiscVideo,
  title        = {Video: The 'Other' Red Planet},
  author       = {NASA},
  url = {https://www.nasa.gov/nh/pluto-the-other-red-planet},
  year         = 2015,
  note         = {Accessed: 2018-12-06},
}
\end{filecontents*}
%%%
\documentclass{article}
\usepackage[backend=biber,style=numeric]{biblatex}
    \addbibresource{example.bib}
    \DeclareSourcemap{%
      \maps{%
        \map{%
          % remove URLs from non-internet types
          \pernottype{www}
          \pernottype{online}
          % Do not show urls, eprints, and urldates
          \step[fieldset=url, null]
          \step[fieldset=urldate, null]
          \step[fieldset=eprint, null]
        }%
      }%
    }
\usepackage[colorlinks]{hyperref}


\begin{document}
\nocite{*}
\printbibliography[title=References]
\end{document}

相关内容