biblatex-ext-oa

biblatex-ext-oa

为了促进研究成果的开放获取,我想补充一点开放存取徽标在我论文中引用的书目参考文献列表中。只要将“eprint + eprinttype”对(例如 arxiv)与 biblatex 一起使用,就可以自动添加此徽标。也可以手动添加可在出版商网站上公开访问的作品(称为黄金访问)。由于我不知道从哪里开始实现上述目标,因此我没有提供任何 MWE。

编辑根据 moewe 和 gusbrs 的评论,我提供了一个 MWE(url 链接是随机选择的,并且 OA 徽标是为了编译目的而提供的)

\documentclass{article}
\usepackage{graphicx}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{bib:A,
    author={Authors},
    title={Title},
    journal={Journal name},
    year={2018},
}
@article{bib:B,
    author={Authors},
    title={Title},
    journal={Journal name},
    year={2018},
    eprinttype={oai},
    eprint={hal-01917888},
    keywords={OA}
}
@article{bib:C,
    author={Authors},
    title={Title},
    journal={Journal name},
    year={2018},
    eprinttype={arxiv},
    eprint={arXiv:1811.03094},
    keywords={OA}
}
\end{filecontents*}

\usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
\addbibresource{MWEOA.bib}

% new eprinttype
\def\oaitourl#1{http://hal.archives-ouvertes.fr/#1}
\DeclareFieldFormat{eprint:oai}{%
    \ifhyperref
        {\href{\oaitourl#1}{hal:~\nolinkurl{#1}}}
        {hal:~\nolinkurl{#1}}}

% OA logo in the margin  
\newcommand{\impmark}{\strut\vadjust{\domark}}
\newcommand{\domark}{%
  \vbox to 0pt{
    \kern-3\dp\strutbox %manual control of the logo top alignment
    \strut\hfill\rlap{\kern1em\includegraphics[height=10pt]{OA}}
    \vss
  }%
}
\renewbibmacro*{begentry}{\ifkeyword{OA}{\impmark}{}}

\usepackage[hidelinks]{hyperref}

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

看起来像

OA 徽标位于书目边缘

不过,如果能增加两个功能就更好了:

  1. 当 eprinttype(类型arxivoai)字段不为空时,应自动打印 Open Access 徽标(即不使用条目keywordsOA
  2. eprinttype该徽标应可点击,其 URL 地址源自和字段中提供的信息eprint

png OA 徽标

答案1

更新版本 0.6biblatex-extbiblatex-ext-oa附带可用于显示开放存取符号的支持包。biblatex-ext-oa也可以与除来自的样式之外的其他样式一起使用biblatex-ext,它当然应该适用于标准样式,也可能适用于许多贡献的样式。

0.7 版略微改变了选择开放存取符号的界面,并引入了新的包选项来绘制它们(symbolpackage带有值pict2el3drawtikz

biblatex-ext-oa

该软件包biblatex-ext-oa支持两种主要方法来查找与符号链接的最佳知名开放访问 URL:(i)基于文件中给出的数据.bib并由配置命令控制的半自动启发式方法和(ii)全自动 Lua 模块(只能与 LuaLaTeX 一起使用),查询Unpaywall网站使用 DOI。

下面简要介绍了 的最重要部分biblatex-ext-oa,有关更详细的描述,请参阅§7开放存取符号biblatex-ext文档

auto:半自动启发式

启发式方法依赖于.bib文件中的数据和其他配置来识别开放访问链接。此启发式方法(也可以在加载\ExecuteBibliographyOptions{openaccess=auto}后设置)是加载时的默认方法。biblatex-ext-oabiblatex-ext-oa

主要思想是某些字段和eprinttypes 是所谓的“开放访问字段”,这意味着它们可以提供开放访问 URL。此类 URL 可以分为两种类型:要么它们始终是开放访问的(键入“ always”:类似eprinttype = {arxiv}),要么它们仅在某些条件下是开放访问的(键入“ conditional”:类似doi字段或eprinttype = {jstor})。类型为“ ”的字段仅在文件中用字段注释标记conditional时才返回开放访问 URL (请参阅下面的 MWE)。openaccess.bib

如果有多个可能的开放访问 URL,则通过简单的优先级顺序决定哪一个是“最佳开放访问 URL”。如果某个条目有“最佳开放访问 URL”,则页边空白处会显示一个小的开放访问符号,并从那里链接 URL。

默认情况下,、和biblatex-ext-oa具有合理的默认值。如果添加新的,则必须声明其开放访问链接和状态才能使用该类型进行开放访问检测。请参阅以下示例中的定义。如果您想为开放访问 URL 定义一个全新的字段,情况也是如此。urldoieprinttypes arxivjstorhdlpubmedeprinttypehal

这是一个全面的例子,展示了openaccess=auto工作原理

\documentclass[british]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=numeric]{biblatex}
\usepackage[symbolpackage=pict2e, symbol=plos]{biblatex-ext-oa}

\usepackage{kantlipsum}
\usepackage[colorlinks]{hyperref}

\newcommand*{\halurl}[1]{http://hal.archives-ouvertes.fr/#1}
\DeclareFieldFormat{eprint:hal}{%
  \ifhyperref
    {\href{\halurl{#1}}{hal:~\nolinkurl{#1}}}
    {hal:~\nolinkurl{#1}}}
\DeclareFieldAlias{eprint:HAL}{eprint:hal}

% HAL is always open access (I think)
\DeclareOpenAccessEprintUrl[always]{hal}{%
  http://hal.archives-ouvertes.fr/\thefield{eprint}}
\DeclareOpenAccessEprintAlias{HAL}{hal}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
% open access DOIs need to be marked up explicitly
@article{cipriani,
  author  = {Cipriani, Alessandra and Hazra, Rajat Subhra
             and Ruszel, Wioletta M.},
  title   = {Scaling limit of the odometer in divisible sandpiles},
  journal = {Probability Theory and Related Fields},
  date    = {2018},
  volume  = {172},
  number  = {3},
  pages   = {829--868},
  doi     = {10.1007/s00440-017-0821-x},
  doi+an  = {=openaccess},
}
% arXiv is always open access
@online{meckes,
  author      = {Elizabeth Meckes and Kathryn Stewart},
  title       = {On the eigenvalues of truncations
                 of random unitary matrices},
  eprinttype  = {arxiv},
  eprint      = {1811.08340},
  eprintclass = {math.PR},
  date        = {2018-11-20}
}
% DOI is not open access, the arXiv has an open access version
@article{dolan,
  author      = {Matthew J. Dolan and Christoph Englert and Michael Spannowsky},
  title       = {Higgs self-coupling measurements at the {LHC}},
  journal     = {Journal of High Energy Physics},
  volume      = {2012},
  number      = {10},
  doi         = {10.1007/jhep10(2012)112},
  eid         = {112},
  date        = {2012},
  eprint      = {1206.5001},
  eprinttype  = {arxiv},
  eprintclass = {hep-ph},
}
% new eprinttype hal: is always open access, see
% \DeclareOpenAccessEprintUrl[always]{hal}{...}
@online{labbe,
  title      = {New models for the location of \emph{controversial}
                facilities},
  subtitle   = {A bilevel programming approach},
  author     = {Labbé, Martine and Leal, Marina and Puerto, Justo},
  date       = {2018-11},
  eprinttype = {hal},
  eprint     = {hal-01933601},
}
% no open access that I know of
@article{sigfridsson,
  author       = {Sigfridsson, Emma and Ryde, Ulf},
  title        = {Comparison of methods for deriving atomic charges from the
                  electrostatic potential and moments},
  journaltitle = {Journal of Computational Chemistry},
  date         = 1998,
  volume       = 19,
  number       = 4,
  pages        = {377-395},
  doi          = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
% non-open JSTOR
@article{russell:denoting,
  author     = {Bertrand Russell},
  title      = {On Denoting},
  journal    = {Mind},
  series     = {newseries},
  volume     = {14},
  number     = {56},
  date       = {1905-10},
  pages      = {479-493},
  eprinttype = {jstor},
  eprint     = {2248381},
}
% open access JSTOR
@article{russell:atomism,
  author     = {Bertrand Russell},
  title      = {The Philosophy of Logical Atomism},
  subtitle   = {{V}. {General} Propositions and Existence},
  journal    = {The Monist},
  volume     = {29},
  number     = {2},
  date       = {1919-04},
  pages      = {190-222},
  eprinttype = {jstor},
  eprint     = {27900737},
  eprint+an  = {=openaccess},
}
\end{filecontents*}


\addbibresource{\jobname.bib}
\begin{document}
\kant[1]
\nocite{*}
\printbibliography
\end{document}

MWE 书目部分的屏幕截图。除 <code>sigfridsson</code> 之外的所有条目都有一个小型开放获取徽标。

doiapi:全自动开放存取检测,Unpaywall网站

灵感来自艾瑞克·马斯登回答该软件包还具有一个 Lua 模块,可以查询来自Unpaywall网站基于 DOI。

该模块只能与 LuaLaTeX 一起使用,需要通过将选项传递给 来加载doiapi=truebiblatex-ext-oa然后可以使用 启用该选项\ExecuteBibliographyOptions{openaccess=doiapi}。如果doiapi启用,biblatex-ext-oa将从取消付费墙 API。为了减少 API 的负载,结果被缓存在临时.oai文件中。

请注意,只有您提供电子邮件地址才能使用 Unpaywall API。您可以使用 来执行此操作。如果您加载模块并忘记提供电子邮件,\SetDOIAPIMail您将收到警告。如果没有提供邮件地址,查询数据库将是一个致命错误。doiapi

在使用 LuaLaTeX 运行以下 MWE 之前,取消注释\SetDOIAPIMail并提供有效的电子邮件地址。请注意与之前的 MWE 相比不同的符号,如果设置为以下值之一,则该选项允许您在(默认值,上面)和(此处)symbol之间切换,或。plosoanetsymbolpackagepict2el3drawtikz

\documentclass[british]{article}
\usepackage{etoolbox}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[backend=biber, style=numeric]{biblatex}
\usepackage[doiapi=true, symbolpackage=tikz, symbol=oanet]{biblatex-ext-oa}
% symbolpackage=tikz chooses open access symbols drawn in TikZ
% symbol=oanet gives an the open access symbol from
% open-access.net (https://open-access.net/),
% logo by
% Medien + Design
% Center for Digital Systems
% Competence Center for E-Learning and Multimedia
% Freie Universität Berlin
% CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
\ExecuteBibliographyOptions{openaccess=doiapi}

%\SetDOIAPIMail{<your email here>}% <- this MUST be set for doiapi
%\SetDOIAPICacheExpiration{15}% if you like, you can set the expiration period
                              % for the cache here, default is seven days

\usepackage{kantlipsum}
\usepackage[colorlinks]{hyperref}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
% this article is open access at the source
@article{valfort,
  author   = {Valfort, Aurore-Cécile and Launay, Caroline and Sémon, Marie
              and Delattre, Marie},
  title    = {Evolution of mitotic spindle behavior during the first
              asymmetric embryonic division of nematodes},
  journal  = {PLOS Biology},
  date     = {2018-01},
  volume   = {16},
  number   = {1},
  pages    = {1-23},
  doi      = {10.1371/journal.pbio.2005099},
}
% has open access version on Harvard DASH
@article{kucsko,
  author   = {G. Kucsko and P. C. Maurer and N. Y. Yao and M. Kubo
              and H. J. Noh and P. K. Lo and H. Park and M. D. Lukin},
  title    = {Nanometre-scale thermometry in a living cell},
  journal  = {Nature},
  volume   = {500},
  number   = {7460},
  pages    = {54--58},
  doi      = {10.1038/nature12373},
  date     = {2013},
}
% has open access version on the arXiv
@article{randall,
  author   = {Lisa Randall and Raman Sundrum},
  title    = {Large Mass Hierarchy from a Small Extra Dimension},
  journal  = {Physical Review Letters},
  year     = {1999},
  volume   = {83},
  number   = {17},
  pages    = {3370--3373},
  doi      = {10.1103/physrevlett.83.3370},
}
% second open access at HAL
@article{abiakle,
  author     = {Abi Akle, Audrey and Stéphanie Minel and Bernard Yannou},
  title      = {Information visualization for selection in Design by Shopping},
  journal    = {Research in Engineering Design},
  volume     = {28},
  number     = {1},
  year       = {2017},
  pages      = {99--117},
  doi        = {10.1007/s00163-016-0235-2},
}
% no open access that I know of
@article{sigfridsson,
  author       = {Sigfridsson, Emma and Ryde, Ulf},
  title        = {Comparison of methods for deriving atomic charges from the
                  electrostatic potential and moments},
  journaltitle = {Journal of Computational Chemistry},
  date         = 1998,
  volume       = 19,
  number       = 4,
  pages        = {377-395},
  doi          = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
\end{filecontents*}


\addbibresource{\jobname.bib}
\begin{document}
\kant[1]
\nocite{*}
\printbibliography
\end{document}

参考文献部分的截图:除 <code>sigfridsson</code> 之外的所有条目都有一个小小的开放获取符号。


这是答案的旧版本。

旧答案

这是一次可以满足这两个要求的尝试。

OA我选择了 option而不是关键字openaccess,因为我觉得 option 在这里更自然。但更改代码以使用关键字很简单。(您只需将其替换\iftoggle{bbxpluton:openaccess}\ifkeyword{OA})。

不平凡的部分是获取应链接到开放存取符号的 URL。对于某些eprint类型,实际要链接的 URL 仅在处理字段进行打印时组合在一起,完整的 URL 永远不会“知道” biblatex。通过定义宏解决了这个问题\pluton@getoaurl。宏需要为eprinttype您打算使用的每个分支提供一个分支。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage[backend=biber, style=numeric]{biblatex}
\usepackage[hidelinks]{hyperref}

\usepackage{kantlipsum}

\makeatletter
\newtoggle{bbxpluton:openaccess}
\DeclareEntryOption[boolean]{openaccess}[true]{%
  \settoggle{bbxpluton:openaccess}{#1}}


\newcommand*{\pluton@getoaurl}{%
  \undef\bbx@pluton@oaurl
  \iftoggle{bbxpluton:openaccess}
    {% URL and DOI are only open access if indicated
     \iffieldundef{url}
       {}
       {\def\bbx@pluton@oaurl{\thefield{url}}}%
     \iffieldundef{doi}
       {}
       {\def\bbx@pluton@oaurl{%
          https://doi.org/\thefield{doi}}}%
     % the eprinttypes listed here are open access only if indicated
     \iffieldundef{eprint}
       {}
       {\ifboolexpr{   test {\iffieldequalstr{eprinttype}{jstor}}
                    or test {\iffieldequalstr{eprinttype}{JSTOR}}}
          {}
          {\def\bbx@pluton@oaurl{%
             http://www.jstor.org/stable/\thefield{eprint}}}%
        \ifboolexpr{   test {\iffieldequalstr{eprinttype}{hdl}}
                    or test {\iffieldequalstr{eprinttype}{HDL}}}
          {}
          {\def\bbx@pluton@oaurl{%
             http://hdl.handle.net/\thefield{eprint}}}%
        \ifboolexpr{   test {\iffieldequalstr{eprinttype}{pubmed}}
                    or test {\iffieldequalstr{eprinttype}{PubMed}}}
          {}
          {\def\bbx@pluton@oaurl{%
             http://www.ncbi.nlm.nih.gov/pubmed/\thefield{eprint}}}%
       }%
    }
    {}%
  % eprinttype listed here are always open access
  \iffieldundef{eprint}
    {}
    {\ifboolexpr{   test {\iffieldequalstr{eprinttype}{arxiv}}
                 or test {\iffieldequalstr{eprinttype}{arXiv}}}
       {\def\bbx@pluton@oaurl{%
          https://arxiv.org/\abx@arxivpath/\thefield{eprint}}}
       {}%
     \iffieldequalstr{eprinttype}{hal}
       {\def\bbx@pluton@oaurl{%
          http://hal.archives-ouvertes.fr/\thefield{eprint}}}
       {}%
    }%
}

\AtEveryBibitem{\pluton@getoaurl}

\renewbibmacro*{begentry}{%
  \ifundef\bbx@pluton@oaurl
    {}
    {\oamark@link}}

% based on egreg's answer to https://tex.stackexchange.com/a/123451/35864
% originally CC BY-SA 3.0, but dual-licensed under LPPL
% see https://tex.meta.stackexchange.com/a/3333/35864
\newcommand{\oamark@link}{\strut\vadjust{\dooamark@link}}
\newcommand{\dooamark@link}{%
  \vbox to 0pt{
    \kern-3\dp\strutbox
    \strut\hfill\rlap{\kern1em
      \ifhyperref
        {\href{\bbx@pluton@oaurl}{\oasymbol}}
        {\oasymbol}}
    \vss
  }%
}


% PLoS Open Access symbol based on
% https://commons.wikimedia.org/wiki/File:Open_Access_logo_PLoS_white.svg
% public domain/CC0 by PLoS & Wikipedia users Nina, Beao and JakobVoss
\definecolor{oaploscol}{HTML}{f68212}
\newcommand*{\oaplossymbol}{%
  \begin{tikzpicture}[x=.1pt,y=.1pt]
    \fill[oaploscol] (06,73)   arc (180:0:26);
    \fill[white]     (17,72.9) arc (180:-45:15);
    \fill[oaploscol] (47,32) rectangle ++ (11,41.1);
    \fill[oaploscol] (32,32) circle[radius=32];
    \fill[white]     (32,32) circle[radius=21];
    \fill[oaploscol] (32,32) circle[radius= 9];
  \end{tikzpicture}
}

% Open-Acess.net Open Acess symbol
% redrawn with TikZ from
% http://open-access.net/fileadmin/logos/oa.svg
% public domain according to
% https://commons.wikimedia.org/wiki/File:Open_access.svg
% might be covered by open-access.net's overall CC-BY 4.0
% https://creativecommons.org/licenses/by/4.0/
% https://open-access.net/impressum/
% the site states no specific conditions for use of the logo
% other than
%   "Das Logo der Informationsplattform darf nachgenutzt werden,
%    gerne mit einem Link zu open-access.net"
% on https://open-access.net/ueber-uns/
% see also https://open-access.net/community/materialien/
% logo by
% Medien + Design
% Center for Digital Systems
% Competence Center for E-Learning and Multimedia
% Freie Universität Berlin
\definecolor{oanetgreen}{HTML}{356031}
\definecolor{oanetyellow}{HTML}{f9c63a}
\definecolor{oanetintersect}{HTML}{89923a}

\newcommand*{\oanetsymbol}{%
  \begin{tikzpicture}[x=1.1pt,y=1.1pt]
    \fill[oanetgreen] (4,4) circle[radius=4.3];
    \fill[oanetyellow] (11,4) ++ (0:4.3) arc (0:300:4.3)
      -- (11,4) ++ (300:4.3) -- cycle;
    \begin{scope}
      \clip (4,4) circle[radius=4.3];
      \fill[oanetintersect] (11,4) circle[radius=4.3];
    \end{scope}
    \fill[white] (4,4) circle[radius=2.7];
    \fill[white] (11,4) circle[radius=2.7];
    \fill[oanetyellow] (11,4) ++ (2.7,.1) rectangle ++(1.6,-4.1);
  \end{tikzpicture}
}

% reusable box for the symbol, so the image is not
% processed on every use
\newsavebox{\oasymbolbox}
% choose \oaplossymbol or \oanetsymbol here
\sbox{\oasymbolbox}{\oaplossymbol}
\newcommand*{\oasymbol}{\usebox{\oasymbolbox}}

\newcommand*{\halurl}[1]{http://hal.archives-ouvertes.fr/#1}
\DeclareFieldFormat{eprint:hal}{%
  \ifhyperref
    {\href{\halurl{#1}}{hal:~\nolinkurl{#1}}}
    {hal:~\nolinkurl{#1}}}
\makeatother


\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{bib:A,
  author  = {Anne Uthor},
  title   = {Generic Title},
  journal = {Journal},
  year    = {2018},
}
@article{bib:B,
  author     = {Anne Uthor},
  title      = {Open Access Title (HAL)},
  journal    = {Open Journal},
  year       = {2018},
  eprinttype = {hal},
  eprint     = {hal-01917888},
}
@article{bib:C,
  author     = {Anne Uthor},
  title      = {Open Access Title (arXiv)},
  journal    = {Closed Journal},
  year       = {2018},
  eprinttype = {arxiv},
  eprint     = {1811.03094},
}
@article{bib:D,
  author     = {Anne Uthor},
  title      = {Open Access Title (DOI)},
  journal    = {Open Journal},
  year       = {2018},
  doi        = {12345/67898.0},
  options    = {openaccess},
}
@article{bib:E,
  author     = {Anne Uthor},
  title      = {Open Access (URL)},
  journal    = {Open Journal},
  year       = {2018},
  url        = {https://example.com/~author/my_paper.pdf#page20},
  options    = {openaccess},
}
@article{bib:F,
  author     = {Anne Uthor},
  title      = {\emph{Not} Open Access (DOI)},
  journal    = {Closed Journal},
  year       = {2018},
  doi        = {12345/67898.0},
}
\end{filecontents*}

\addbibresource{\jobname.bib}
\begin{document}
\kant[1]
\nocite{*}
\printbibliography
\end{document}

MWE 的参考书目:开放获取文章在右边距标有一个小型链接的开放获取徽标。

编辑:扩展并简化了开放访问 URL 检测(\hyperref可以接受宏中的 URL,即使具有不同的扩展级别)。将 Ti可重复使用的盒子中的 Z 绘制徽标可提高性能。

答案2

arxiv这是部分答案,即自动放置eprinttypes徽标的要求oai,而无需在 bib 文件中手动添加关键字。但我保留了手动添加关键字的可能性,适用于任意条目。

本质上,我们可以执行测试来检查是否eprinttype等于arxivoai

\renewbibmacro*{begentry}{%
  \iffieldequalstr{eprinttype}{arxiv}
  {\impmark}
  {\iffieldequalstr{eprinttype}{oai}
    {\impmark}
    {\ifkeyword{OA}{\impmark}{}}}}

在全:

\documentclass{article}
\usepackage{graphicx}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{bib:A,
    author={Authors},
    title={Title},
    journal={Journal name},
    year={2018},
}
@article{bib:B,
    author={Authors},
    title={Title},
    journal={Journal name},
    year={2018},
    eprinttype={oai},
    eprint={hal-01917888},
}
@article{bib:C,
    author={Authors},
    title={Title},
    journal={Journal name},
    year={2018},
    eprinttype={arxiv},
    eprint={arXiv:1811.03094},
}
\end{filecontents*}

\usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
\addbibresource{\jobname.bib}

% new eprinttype
\def\oaitourl#1{http://hal.archives-ouvertes.fr/#1}
\DeclareFieldFormat{eprint:oai}{%
    \ifhyperref
        {\href{\oaitourl#1}{hal:~\nolinkurl{#1}}}
        {hal:~\nolinkurl{#1}}}

% OA logo in the margin
\newcommand{\impmark}{\strut\vadjust{\domark}}
\newcommand{\domark}{%
  \vbox to 0pt{
    \kern-3\dp\strutbox
    \strut\hfill\rlap{\kern1em\includegraphics[height=10pt]{OA}}
    \vss
  }%
}
\renewbibmacro*{begentry}{%
  \iffieldequalstr{eprinttype}{arxiv}
  {\impmark}
  {\iffieldequalstr{eprinttype}{oai}
    {\impmark}
    {\ifkeyword{OA}{\impmark}{}}}}

\usepackage[hidelinks]{hyperref}

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

在此处输入图片描述

至于第二个要求,相关信息要么在 中,要么在eprinturl字段doi中。通常,您必须将\includegraphics内部内容包装\domark在 中\href。但第一种和第三种情况必须用条件处理,并且链接必须以某种方式用“链接库+字段”构建。

答案3

带有 DOI 的文章也可以开放访问,unpaywall.org 有一个 API,可以告诉我们某个 DOI 是否具有开放访问版本。为了好玩,这里有一个版本可以做到这一点,使用老式 bibtex 和现代 luatex。

在 .bst 文件中,添加函数

FUNCTION {openaccess.check}
{
  doi empty$
    'skip$
    { "\MyMaybeOpenAccess{" doi * "}" * write$ }
  if$
}

并在处理文章的代码中调用它(例如之后)output.bibitem

在文档序言中,定义一个宏

\newcommand{\MyMaybeOpenAccess}[1]{%
  \directlua{
  local http = require('socket.http')
  local url = 'https://api.unpaywall.org/v2/' .. \luastring{#1} .. '?email=your@email'
  body, code, headers, status = http.request(url)
  if code == 200 and body then
     local found = string.match(body, '"is_oa": ([a-z]+)')
     if found == "true" then
        tex.print("\noexpand\\marginpar{\noexpand\\includegraphics[width=0.3cm]{open-access-logo}}")
     end
  end
}}

(对于严肃的用途,还需要处理 isbn 和 eprint 字段、缓存对 API 的访问、在徽标下包含 OA URL 等等。)

相关内容