Bibliography: add a small “open access” logo in the margin
In a desire to promote open access to research results, I would like to add a small open access logo in the list of bibliographic references I cite in my papers. This logo could be added automatically as soon as the pair "eprint + eprinttype" (for instance with arxiv) is used with biblatex. It could also be added manually for works that are openly accessible on publisher's websites (called gold access). Since I do not know where to start to achieve the above goal, I do not provide any MWE.
EDIT Based on the comments by moewe and gusbrs, I am providing an MWE (the url links were chosen randomly and the OA logo is provided for compilation purposes)
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
keywords=OA
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
keywords=OA
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourceMWEOA.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentryifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
which looks like
However, it would be nice to add two features:
- when the eprinttype (of the type
arxiv
oroai
) field is not empty, the Open Access logo should be printed automatically (that is without using thekeywords
entryOA
). - the logo should be clickable with the url address stemming from the information given in the
eprinttype
andeprint
fields.
biblatex
|
show 10 more comments
In a desire to promote open access to research results, I would like to add a small open access logo in the list of bibliographic references I cite in my papers. This logo could be added automatically as soon as the pair "eprint + eprinttype" (for instance with arxiv) is used with biblatex. It could also be added manually for works that are openly accessible on publisher's websites (called gold access). Since I do not know where to start to achieve the above goal, I do not provide any MWE.
EDIT Based on the comments by moewe and gusbrs, I am providing an MWE (the url links were chosen randomly and the OA logo is provided for compilation purposes)
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
keywords=OA
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
keywords=OA
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourceMWEOA.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentryifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
which looks like
However, it would be nice to add two features:
- when the eprinttype (of the type
arxiv
oroai
) field is not empty, the Open Access logo should be printed automatically (that is without using thekeywords
entryOA
). - the logo should be clickable with the url address stemming from the information given in the
eprinttype
andeprint
fields.
biblatex
1
Note thateprint
s need not be freely available by definition, so blindly adding an open access logo when it can not be verified that the article is indeed open access might not be the best idea.
– moewe
Nov 11 '18 at 11:48
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
Nov 11 '18 at 11:53
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
Nov 11 '18 at 12:14
2
Btw, +1 for the open access commitment. :)
– gusbrs
Nov 11 '18 at 12:23
3
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
Nov 11 '18 at 14:36
|
show 10 more comments
In a desire to promote open access to research results, I would like to add a small open access logo in the list of bibliographic references I cite in my papers. This logo could be added automatically as soon as the pair "eprint + eprinttype" (for instance with arxiv) is used with biblatex. It could also be added manually for works that are openly accessible on publisher's websites (called gold access). Since I do not know where to start to achieve the above goal, I do not provide any MWE.
EDIT Based on the comments by moewe and gusbrs, I am providing an MWE (the url links were chosen randomly and the OA logo is provided for compilation purposes)
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
keywords=OA
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
keywords=OA
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourceMWEOA.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentryifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
which looks like
However, it would be nice to add two features:
- when the eprinttype (of the type
arxiv
oroai
) field is not empty, the Open Access logo should be printed automatically (that is without using thekeywords
entryOA
). - the logo should be clickable with the url address stemming from the information given in the
eprinttype
andeprint
fields.
biblatex
In a desire to promote open access to research results, I would like to add a small open access logo in the list of bibliographic references I cite in my papers. This logo could be added automatically as soon as the pair "eprint + eprinttype" (for instance with arxiv) is used with biblatex. It could also be added manually for works that are openly accessible on publisher's websites (called gold access). Since I do not know where to start to achieve the above goal, I do not provide any MWE.
EDIT Based on the comments by moewe and gusbrs, I am providing an MWE (the url links were chosen randomly and the OA logo is provided for compilation purposes)
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
keywords=OA
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
keywords=OA
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourceMWEOA.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentryifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
which looks like
However, it would be nice to add two features:
- when the eprinttype (of the type
arxiv
oroai
) field is not empty, the Open Access logo should be printed automatically (that is without using thekeywords
entryOA
). - the logo should be clickable with the url address stemming from the information given in the
eprinttype
andeprint
fields.
biblatex
biblatex
edited Dec 5 '18 at 16:25
pluton
asked Nov 11 '18 at 11:45
plutonpluton
7,994960133
7,994960133
1
Note thateprint
s need not be freely available by definition, so blindly adding an open access logo when it can not be verified that the article is indeed open access might not be the best idea.
– moewe
Nov 11 '18 at 11:48
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
Nov 11 '18 at 11:53
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
Nov 11 '18 at 12:14
2
Btw, +1 for the open access commitment. :)
– gusbrs
Nov 11 '18 at 12:23
3
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
Nov 11 '18 at 14:36
|
show 10 more comments
1
Note thateprint
s need not be freely available by definition, so blindly adding an open access logo when it can not be verified that the article is indeed open access might not be the best idea.
– moewe
Nov 11 '18 at 11:48
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
Nov 11 '18 at 11:53
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
Nov 11 '18 at 12:14
2
Btw, +1 for the open access commitment. :)
– gusbrs
Nov 11 '18 at 12:23
3
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
Nov 11 '18 at 14:36
1
1
Note that
eprint
s need not be freely available by definition, so blindly adding an open access logo when it can not be verified that the article is indeed open access might not be the best idea.– moewe
Nov 11 '18 at 11:48
Note that
eprint
s need not be freely available by definition, so blindly adding an open access logo when it can not be verified that the article is indeed open access might not be the best idea.– moewe
Nov 11 '18 at 11:48
1
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
Nov 11 '18 at 11:53
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
Nov 11 '18 at 11:53
1
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
Nov 11 '18 at 12:14
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
Nov 11 '18 at 12:14
2
2
Btw, +1 for the open access commitment. :)
– gusbrs
Nov 11 '18 at 12:23
Btw, +1 for the open access commitment. :)
– gusbrs
Nov 11 '18 at 12:23
3
3
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
Nov 11 '18 at 14:36
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
Nov 11 '18 at 14:36
|
show 10 more comments
3 Answers
3
active
oldest
votes
Update Version 0.6 of
biblatex-ext
comes with the support packagebiblatex-ext-oa
that can be used to display open access symbols.biblatex-ext-oa
can be used with styles other than those frombiblatex-ext
as well, it should certainly work for the standard styles and possibly for many contributed styles as well.
biblatex-ext-oa
The package biblatex-ext-oa
supports two main methods for finding the best known open access URL that is linked from the symbol: (i) A semi-automatic heuristic based on the data given in the .bib
file and governed by configuration commands and (ii) a fully automatic Lua module (can only be used with LuaLaTeX) that queries Unpaywall.org using the DOI.
The following gives a short rundown of the most important bits and bobs of biblatex-ext-oa
, for a more detailed description, please consult §7 Open Access Symbols of the biblatex-ext
documentation.
auto
: semi-automatic heuristic
The heuristic relies on data in the .bib
file and additional configuration to identify open access links. This heuristic (which can be also be set with ExecuteBibliographyOptionsopenaccess=auto
after biblatex-ext-oa
has been loaded) is the default when biblatex-ext-oa
is loaded.
The main idea is that certain fields and eprinttype
s are so-called 'open access fields', which means that they can deliver open access URLs. Such URLs can be of two types: Either they are always open access (type 'always
': like eprinttype = arxiv
) or they are only open access under certain conditions (type 'conditional
': like the doi
field or eprinttype = jstor
). Fields of type 'conditional
' only return open access URLs if they are marked with the openaccess
field annotation in the .bib
file (see the MWE below).
If there are several possible open access URLs, a simple priority order decides which one gets to be the 'best open access URL'. If an entry has a 'best open access URL' a little open access symbol is shown in the margin and the URL is linked from there.
By default biblatex-ext-oa
has sensible defaults for url
, doi
and the eprinttypes
arxiv
, jstor
, hdl
and pubmed
. If you add a new eprinttype
, you will have to declare its open access links and state to be able to use that type for open access detection. See the definitions for hal
in the example below. The same holds if you want to define an entirely new field for open access URLs.
This is a comprehensive example that shows how openaccess=auto
works
documentclass[british]article
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[tikzsymbol=plos]biblatex-ext-oa
usepackagekantlipsum
usepackage[colorlinks]hyperref
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
DeclareFieldAliaseprint:HALeprint:hal
% HAL is always open access (I think)
DeclareOpenAccessEprintUrl[always]hal%
http://hal.archives-ouvertes.fr/thefieldeprint
DeclareOpenAccessEprintAliasHALhal
usepackagefilecontents
beginfilecontents*jobname.bib
% open access DOIs need to be marked up explicitly
@articlecipriani,
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
@onlinemeckes,
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
@articledolan,
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...
@onlinelabbe,
title = New models for the location of emphcontroversial
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
@articlesigfridsson,
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
@articlerussell: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
@articlerussell: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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
doiapi
: fully automatic open access detection with Unpaywall.org
Inspired by Eric Marsden's answer the package also features a Lua module that queries open access information from Unpaywall.org based on the DOI.
The module can only be used with LuaLaTeX and needs to be loaded by passing the option doiapi=true
to biblatex-ext-oa
. The option can then be enabled with ExecuteBibliographyOptionsopenaccess=doiapi
. If doiapi
is enabled, biblatex-ext-oa
will query the best open access URL from the Unpaywall API. To reduce load to the API the results are cached in a temporary .oai
file.
Please note that the Unpaywall API can only be used if you supply an email address. You can do this with SetDOIAPIMail
. You will be warned if you load the doiapi
module and forget to give an email. It is a fatal error to query the database if no mail address was given.
Uncomment SetDOIAPIMail
and give a valid email address before you run the following MWE with LuaLaTeX. Note the different symbol compared to the previous MWE, the tikzsymbol
option allows you to switch between plos
(the default, above) and oanet
(here).
documentclass[british]article
usepackageetoolbox
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[doiapi=true, tikzsymbol=oanet]biblatex-ext-oa
% tikzsymbol=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/)
ExecuteBibliographyOptionsopenaccess=doiapi
%SetDOIAPIMail<your email here>% <- this MUST be set for doiapi
%SetDOIAPICacheExpiration15% if you like, you can set the expiration period
% for the cache here, default is seven days
usepackagekantlipsum
usepackage[colorlinks]hyperref
usepackagefilecontents
beginfilecontents*jobname.bib
% this article is open access at the source
@articlevalfort,
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
@articlekucsko,
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
@articlerandall,
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
@articleabiakle,
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
@articlesigfridsson,
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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
This is the old version of the answer.
Old answer
Here is one attempt that should address both requirements.
Instead of a OA
keyword I went with an option openaccess
, since I felt that an option would be more natural here. But it is straightforward to change the code to work with a keyowrd. (You only need to replace iftogglebbxpluton:openaccess
with ifkeywordOA
).
The non-trivial bit was to obtain the URL to which the open access symbol should be linked. For certain eprint
types the actual URL to link is only put together when the field is processed for printing, the full URL is never 'known' to biblatex
. This was solved by defining the macro pluton@getoaurl
. The macro needs a branch for each eprinttype
you intend to use.
documentclassarticle
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagetikz
usepackage[backend=biber, style=numeric]biblatex
usepackage[hidelinks]hyperref
usepackagekantlipsum
makeatletter
newtogglebbxpluton:openaccess
DeclareEntryOption[boolean]openaccess[true]%
settogglebbxpluton:openaccess#1
newcommand*pluton@getoaurl%
undefbbx@pluton@oaurl
iftogglebbxpluton:openaccess
% URL and DOI are only open access if indicated
iffieldundefurl
defbbx@pluton@oaurlthefieldurl%
iffieldundefdoi
defbbx@pluton@oaurl%
https://doi.org/thefielddoi%
% the eprinttypes listed here are open access only if indicated
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypejstor
or test iffieldequalstreprinttypeJSTOR
defbbx@pluton@oaurl%
http://www.jstor.org/stable/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypehdl
or test iffieldequalstreprinttypeHDL
defbbx@pluton@oaurl%
http://hdl.handle.net/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypepubmed
or test iffieldequalstreprinttypePubMed
defbbx@pluton@oaurl%
http://www.ncbi.nlm.nih.gov/pubmed/thefieldeprint%
%
%
% eprinttype listed here are always open access
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypearxiv
or test iffieldequalstreprinttypearXiv
defbbx@pluton@oaurl%
https://arxiv.org/abx@arxivpath/thefieldeprint
%
iffieldequalstreprinttypehal
defbbx@pluton@oaurl%
http://hal.archives-ouvertes.fr/thefieldeprint
%
%
AtEveryBibitempluton@getoaurl
renewbibmacro*begentry%
ifundefbbx@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
newcommandoamark@linkstrutvadjustdooamark@link
newcommanddooamark@link%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1em
ifhyperref
hrefbbx@pluton@oaurloasymbol
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
definecoloroaploscolHTMLf68212
newcommand*oaplossymbol%
begintikzpicture[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];
endtikzpicture
% 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
definecoloroanetgreenHTML356031
definecoloroanetyellowHTMLf9c63a
definecoloroanetintersectHTML89923a
newcommand*oanetsymbol%
begintikzpicture[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;
beginscope
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
endscope
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);
endtikzpicture
% reusable box for the symbol, so the image is not
% processed on every use
newsaveboxoasymbolbox
% choose oaplossymbol or oanetsymbol here
sboxoasymbolboxoaplossymbol
newcommand*oasymboluseboxoasymbolbox
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
makeatother
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author = Anne Uthor,
title = Generic Title,
journal = Journal,
year = 2018,
@articlebib:B,
author = Anne Uthor,
title = Open Access Title (HAL),
journal = Open Journal,
year = 2018,
eprinttype = hal,
eprint = hal-01917888,
@articlebib:C,
author = Anne Uthor,
title = Open Access Title (arXiv),
journal = Closed Journal,
year = 2018,
eprinttype = arxiv,
eprint = 1811.03094,
@articlebib:D,
author = Anne Uthor,
title = Open Access Title (DOI),
journal = Open Journal,
year = 2018,
doi = 12345/67898.0,
options = openaccess,
@articlebib:E,
author = Anne Uthor,
title = Open Access (URL),
journal = Open Journal,
year = 2018,
url = https://example.com/~author/my_paper.pdf#page20,
options = openaccess,
@articlebib:F,
author = Anne Uthor,
title = emphNot Open Access (DOI),
journal = Closed Journal,
year = 2018,
doi = 12345/67898.0,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
edit: Extended and simplified the open access URL detection (hyperref
can accept the URLs in a macro even with different levels of expansion). Place the TikZ-drawn logos in a reusable box to improve performance.
This looks quite sophisticated!! Thanks! I'll try to digest this in the coming days. Maybe this idea of a logo could become an option of biblatex :) oalogo=true !
– pluton
Nov 11 '18 at 17:05
1
@pluton Not sure if it really is something for the core. It is a bit of a gimmick, but I thought about including it inbiblatex-ext
when it has matured a bit.
– moewe
Nov 11 '18 at 17:07
Sounds very good!
– pluton
Nov 11 '18 at 17:15
2
Nice! A pity I can't upvote again...
– gusbrs
Nov 25 '18 at 15:23
add a comment |
This is a partial answer, namely to the requirement of automatically placing the logo for arxiv
and oai
eprinttypes, without requiring adding the keyword manually in the bib file. But I've kept the possibility of manually adding the keyword, for any arbitrary entry.
Essentially, we can perform a test to check whether eprinttype
is equal to arxiv
or oai
:
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
In full:
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourcejobname.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
As for the second requirement, the relevant information would be either in eprint
or url
or doi
fields. In general, you would have to wrap the includegraphics
inside domark
in a href
. But the first and third of these cases would have to be dealt with conditionals, and the links built with a "linkbase+field" somehow.
add a comment |
Articles with a DOI can be open access too, and unpaywall.org has an API that can tell us whether a DOI is known to have an open access version. Just for fun, here's a version that does just that, using oldschool bibtex and modern luatex.
In your .bst file, add the function
FUNCTION openaccess.check
doi empty$
'skip$
"MyMaybeOpenAccess" doi * "" * write$
if$
and call it in the code that handles an article (just after output.bibitem
for example.
In your document preamble, define a macro
newcommandMyMaybeOpenAccess[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\marginparnoexpand\includegraphics[width=0.3cm]open-access-logo")
end
end
(For serious use, would also need to handle isbn and eprint fields, cache accesses to the API, include the OA URL under the logo, and so on.)
2
I'm planning on including a similar functionality in the next version ofbiblatex-ext
(github.com/moewew/biblatex-ext/blob/master/blxextdoiapi.lua). Would it be OK if I credit you and and this answer as inspiration in the documentation (github.com/moewew/biblatex-ext/blob/…)?
– moewe
Nov 23 '18 at 11:01
3
Sure, that's fine.
– Eric Marsden
Nov 23 '18 at 13:26
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459449%2fbibliography-add-a-small-open-access-logo-in-the-margin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Update Version 0.6 of
biblatex-ext
comes with the support packagebiblatex-ext-oa
that can be used to display open access symbols.biblatex-ext-oa
can be used with styles other than those frombiblatex-ext
as well, it should certainly work for the standard styles and possibly for many contributed styles as well.
biblatex-ext-oa
The package biblatex-ext-oa
supports two main methods for finding the best known open access URL that is linked from the symbol: (i) A semi-automatic heuristic based on the data given in the .bib
file and governed by configuration commands and (ii) a fully automatic Lua module (can only be used with LuaLaTeX) that queries Unpaywall.org using the DOI.
The following gives a short rundown of the most important bits and bobs of biblatex-ext-oa
, for a more detailed description, please consult §7 Open Access Symbols of the biblatex-ext
documentation.
auto
: semi-automatic heuristic
The heuristic relies on data in the .bib
file and additional configuration to identify open access links. This heuristic (which can be also be set with ExecuteBibliographyOptionsopenaccess=auto
after biblatex-ext-oa
has been loaded) is the default when biblatex-ext-oa
is loaded.
The main idea is that certain fields and eprinttype
s are so-called 'open access fields', which means that they can deliver open access URLs. Such URLs can be of two types: Either they are always open access (type 'always
': like eprinttype = arxiv
) or they are only open access under certain conditions (type 'conditional
': like the doi
field or eprinttype = jstor
). Fields of type 'conditional
' only return open access URLs if they are marked with the openaccess
field annotation in the .bib
file (see the MWE below).
If there are several possible open access URLs, a simple priority order decides which one gets to be the 'best open access URL'. If an entry has a 'best open access URL' a little open access symbol is shown in the margin and the URL is linked from there.
By default biblatex-ext-oa
has sensible defaults for url
, doi
and the eprinttypes
arxiv
, jstor
, hdl
and pubmed
. If you add a new eprinttype
, you will have to declare its open access links and state to be able to use that type for open access detection. See the definitions for hal
in the example below. The same holds if you want to define an entirely new field for open access URLs.
This is a comprehensive example that shows how openaccess=auto
works
documentclass[british]article
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[tikzsymbol=plos]biblatex-ext-oa
usepackagekantlipsum
usepackage[colorlinks]hyperref
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
DeclareFieldAliaseprint:HALeprint:hal
% HAL is always open access (I think)
DeclareOpenAccessEprintUrl[always]hal%
http://hal.archives-ouvertes.fr/thefieldeprint
DeclareOpenAccessEprintAliasHALhal
usepackagefilecontents
beginfilecontents*jobname.bib
% open access DOIs need to be marked up explicitly
@articlecipriani,
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
@onlinemeckes,
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
@articledolan,
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...
@onlinelabbe,
title = New models for the location of emphcontroversial
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
@articlesigfridsson,
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
@articlerussell: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
@articlerussell: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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
doiapi
: fully automatic open access detection with Unpaywall.org
Inspired by Eric Marsden's answer the package also features a Lua module that queries open access information from Unpaywall.org based on the DOI.
The module can only be used with LuaLaTeX and needs to be loaded by passing the option doiapi=true
to biblatex-ext-oa
. The option can then be enabled with ExecuteBibliographyOptionsopenaccess=doiapi
. If doiapi
is enabled, biblatex-ext-oa
will query the best open access URL from the Unpaywall API. To reduce load to the API the results are cached in a temporary .oai
file.
Please note that the Unpaywall API can only be used if you supply an email address. You can do this with SetDOIAPIMail
. You will be warned if you load the doiapi
module and forget to give an email. It is a fatal error to query the database if no mail address was given.
Uncomment SetDOIAPIMail
and give a valid email address before you run the following MWE with LuaLaTeX. Note the different symbol compared to the previous MWE, the tikzsymbol
option allows you to switch between plos
(the default, above) and oanet
(here).
documentclass[british]article
usepackageetoolbox
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[doiapi=true, tikzsymbol=oanet]biblatex-ext-oa
% tikzsymbol=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/)
ExecuteBibliographyOptionsopenaccess=doiapi
%SetDOIAPIMail<your email here>% <- this MUST be set for doiapi
%SetDOIAPICacheExpiration15% if you like, you can set the expiration period
% for the cache here, default is seven days
usepackagekantlipsum
usepackage[colorlinks]hyperref
usepackagefilecontents
beginfilecontents*jobname.bib
% this article is open access at the source
@articlevalfort,
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
@articlekucsko,
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
@articlerandall,
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
@articleabiakle,
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
@articlesigfridsson,
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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
This is the old version of the answer.
Old answer
Here is one attempt that should address both requirements.
Instead of a OA
keyword I went with an option openaccess
, since I felt that an option would be more natural here. But it is straightforward to change the code to work with a keyowrd. (You only need to replace iftogglebbxpluton:openaccess
with ifkeywordOA
).
The non-trivial bit was to obtain the URL to which the open access symbol should be linked. For certain eprint
types the actual URL to link is only put together when the field is processed for printing, the full URL is never 'known' to biblatex
. This was solved by defining the macro pluton@getoaurl
. The macro needs a branch for each eprinttype
you intend to use.
documentclassarticle
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagetikz
usepackage[backend=biber, style=numeric]biblatex
usepackage[hidelinks]hyperref
usepackagekantlipsum
makeatletter
newtogglebbxpluton:openaccess
DeclareEntryOption[boolean]openaccess[true]%
settogglebbxpluton:openaccess#1
newcommand*pluton@getoaurl%
undefbbx@pluton@oaurl
iftogglebbxpluton:openaccess
% URL and DOI are only open access if indicated
iffieldundefurl
defbbx@pluton@oaurlthefieldurl%
iffieldundefdoi
defbbx@pluton@oaurl%
https://doi.org/thefielddoi%
% the eprinttypes listed here are open access only if indicated
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypejstor
or test iffieldequalstreprinttypeJSTOR
defbbx@pluton@oaurl%
http://www.jstor.org/stable/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypehdl
or test iffieldequalstreprinttypeHDL
defbbx@pluton@oaurl%
http://hdl.handle.net/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypepubmed
or test iffieldequalstreprinttypePubMed
defbbx@pluton@oaurl%
http://www.ncbi.nlm.nih.gov/pubmed/thefieldeprint%
%
%
% eprinttype listed here are always open access
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypearxiv
or test iffieldequalstreprinttypearXiv
defbbx@pluton@oaurl%
https://arxiv.org/abx@arxivpath/thefieldeprint
%
iffieldequalstreprinttypehal
defbbx@pluton@oaurl%
http://hal.archives-ouvertes.fr/thefieldeprint
%
%
AtEveryBibitempluton@getoaurl
renewbibmacro*begentry%
ifundefbbx@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
newcommandoamark@linkstrutvadjustdooamark@link
newcommanddooamark@link%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1em
ifhyperref
hrefbbx@pluton@oaurloasymbol
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
definecoloroaploscolHTMLf68212
newcommand*oaplossymbol%
begintikzpicture[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];
endtikzpicture
% 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
definecoloroanetgreenHTML356031
definecoloroanetyellowHTMLf9c63a
definecoloroanetintersectHTML89923a
newcommand*oanetsymbol%
begintikzpicture[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;
beginscope
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
endscope
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);
endtikzpicture
% reusable box for the symbol, so the image is not
% processed on every use
newsaveboxoasymbolbox
% choose oaplossymbol or oanetsymbol here
sboxoasymbolboxoaplossymbol
newcommand*oasymboluseboxoasymbolbox
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
makeatother
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author = Anne Uthor,
title = Generic Title,
journal = Journal,
year = 2018,
@articlebib:B,
author = Anne Uthor,
title = Open Access Title (HAL),
journal = Open Journal,
year = 2018,
eprinttype = hal,
eprint = hal-01917888,
@articlebib:C,
author = Anne Uthor,
title = Open Access Title (arXiv),
journal = Closed Journal,
year = 2018,
eprinttype = arxiv,
eprint = 1811.03094,
@articlebib:D,
author = Anne Uthor,
title = Open Access Title (DOI),
journal = Open Journal,
year = 2018,
doi = 12345/67898.0,
options = openaccess,
@articlebib:E,
author = Anne Uthor,
title = Open Access (URL),
journal = Open Journal,
year = 2018,
url = https://example.com/~author/my_paper.pdf#page20,
options = openaccess,
@articlebib:F,
author = Anne Uthor,
title = emphNot Open Access (DOI),
journal = Closed Journal,
year = 2018,
doi = 12345/67898.0,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
edit: Extended and simplified the open access URL detection (hyperref
can accept the URLs in a macro even with different levels of expansion). Place the TikZ-drawn logos in a reusable box to improve performance.
This looks quite sophisticated!! Thanks! I'll try to digest this in the coming days. Maybe this idea of a logo could become an option of biblatex :) oalogo=true !
– pluton
Nov 11 '18 at 17:05
1
@pluton Not sure if it really is something for the core. It is a bit of a gimmick, but I thought about including it inbiblatex-ext
when it has matured a bit.
– moewe
Nov 11 '18 at 17:07
Sounds very good!
– pluton
Nov 11 '18 at 17:15
2
Nice! A pity I can't upvote again...
– gusbrs
Nov 25 '18 at 15:23
add a comment |
Update Version 0.6 of
biblatex-ext
comes with the support packagebiblatex-ext-oa
that can be used to display open access symbols.biblatex-ext-oa
can be used with styles other than those frombiblatex-ext
as well, it should certainly work for the standard styles and possibly for many contributed styles as well.
biblatex-ext-oa
The package biblatex-ext-oa
supports two main methods for finding the best known open access URL that is linked from the symbol: (i) A semi-automatic heuristic based on the data given in the .bib
file and governed by configuration commands and (ii) a fully automatic Lua module (can only be used with LuaLaTeX) that queries Unpaywall.org using the DOI.
The following gives a short rundown of the most important bits and bobs of biblatex-ext-oa
, for a more detailed description, please consult §7 Open Access Symbols of the biblatex-ext
documentation.
auto
: semi-automatic heuristic
The heuristic relies on data in the .bib
file and additional configuration to identify open access links. This heuristic (which can be also be set with ExecuteBibliographyOptionsopenaccess=auto
after biblatex-ext-oa
has been loaded) is the default when biblatex-ext-oa
is loaded.
The main idea is that certain fields and eprinttype
s are so-called 'open access fields', which means that they can deliver open access URLs. Such URLs can be of two types: Either they are always open access (type 'always
': like eprinttype = arxiv
) or they are only open access under certain conditions (type 'conditional
': like the doi
field or eprinttype = jstor
). Fields of type 'conditional
' only return open access URLs if they are marked with the openaccess
field annotation in the .bib
file (see the MWE below).
If there are several possible open access URLs, a simple priority order decides which one gets to be the 'best open access URL'. If an entry has a 'best open access URL' a little open access symbol is shown in the margin and the URL is linked from there.
By default biblatex-ext-oa
has sensible defaults for url
, doi
and the eprinttypes
arxiv
, jstor
, hdl
and pubmed
. If you add a new eprinttype
, you will have to declare its open access links and state to be able to use that type for open access detection. See the definitions for hal
in the example below. The same holds if you want to define an entirely new field for open access URLs.
This is a comprehensive example that shows how openaccess=auto
works
documentclass[british]article
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[tikzsymbol=plos]biblatex-ext-oa
usepackagekantlipsum
usepackage[colorlinks]hyperref
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
DeclareFieldAliaseprint:HALeprint:hal
% HAL is always open access (I think)
DeclareOpenAccessEprintUrl[always]hal%
http://hal.archives-ouvertes.fr/thefieldeprint
DeclareOpenAccessEprintAliasHALhal
usepackagefilecontents
beginfilecontents*jobname.bib
% open access DOIs need to be marked up explicitly
@articlecipriani,
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
@onlinemeckes,
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
@articledolan,
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...
@onlinelabbe,
title = New models for the location of emphcontroversial
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
@articlesigfridsson,
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
@articlerussell: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
@articlerussell: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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
doiapi
: fully automatic open access detection with Unpaywall.org
Inspired by Eric Marsden's answer the package also features a Lua module that queries open access information from Unpaywall.org based on the DOI.
The module can only be used with LuaLaTeX and needs to be loaded by passing the option doiapi=true
to biblatex-ext-oa
. The option can then be enabled with ExecuteBibliographyOptionsopenaccess=doiapi
. If doiapi
is enabled, biblatex-ext-oa
will query the best open access URL from the Unpaywall API. To reduce load to the API the results are cached in a temporary .oai
file.
Please note that the Unpaywall API can only be used if you supply an email address. You can do this with SetDOIAPIMail
. You will be warned if you load the doiapi
module and forget to give an email. It is a fatal error to query the database if no mail address was given.
Uncomment SetDOIAPIMail
and give a valid email address before you run the following MWE with LuaLaTeX. Note the different symbol compared to the previous MWE, the tikzsymbol
option allows you to switch between plos
(the default, above) and oanet
(here).
documentclass[british]article
usepackageetoolbox
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[doiapi=true, tikzsymbol=oanet]biblatex-ext-oa
% tikzsymbol=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/)
ExecuteBibliographyOptionsopenaccess=doiapi
%SetDOIAPIMail<your email here>% <- this MUST be set for doiapi
%SetDOIAPICacheExpiration15% if you like, you can set the expiration period
% for the cache here, default is seven days
usepackagekantlipsum
usepackage[colorlinks]hyperref
usepackagefilecontents
beginfilecontents*jobname.bib
% this article is open access at the source
@articlevalfort,
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
@articlekucsko,
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
@articlerandall,
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
@articleabiakle,
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
@articlesigfridsson,
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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
This is the old version of the answer.
Old answer
Here is one attempt that should address both requirements.
Instead of a OA
keyword I went with an option openaccess
, since I felt that an option would be more natural here. But it is straightforward to change the code to work with a keyowrd. (You only need to replace iftogglebbxpluton:openaccess
with ifkeywordOA
).
The non-trivial bit was to obtain the URL to which the open access symbol should be linked. For certain eprint
types the actual URL to link is only put together when the field is processed for printing, the full URL is never 'known' to biblatex
. This was solved by defining the macro pluton@getoaurl
. The macro needs a branch for each eprinttype
you intend to use.
documentclassarticle
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagetikz
usepackage[backend=biber, style=numeric]biblatex
usepackage[hidelinks]hyperref
usepackagekantlipsum
makeatletter
newtogglebbxpluton:openaccess
DeclareEntryOption[boolean]openaccess[true]%
settogglebbxpluton:openaccess#1
newcommand*pluton@getoaurl%
undefbbx@pluton@oaurl
iftogglebbxpluton:openaccess
% URL and DOI are only open access if indicated
iffieldundefurl
defbbx@pluton@oaurlthefieldurl%
iffieldundefdoi
defbbx@pluton@oaurl%
https://doi.org/thefielddoi%
% the eprinttypes listed here are open access only if indicated
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypejstor
or test iffieldequalstreprinttypeJSTOR
defbbx@pluton@oaurl%
http://www.jstor.org/stable/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypehdl
or test iffieldequalstreprinttypeHDL
defbbx@pluton@oaurl%
http://hdl.handle.net/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypepubmed
or test iffieldequalstreprinttypePubMed
defbbx@pluton@oaurl%
http://www.ncbi.nlm.nih.gov/pubmed/thefieldeprint%
%
%
% eprinttype listed here are always open access
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypearxiv
or test iffieldequalstreprinttypearXiv
defbbx@pluton@oaurl%
https://arxiv.org/abx@arxivpath/thefieldeprint
%
iffieldequalstreprinttypehal
defbbx@pluton@oaurl%
http://hal.archives-ouvertes.fr/thefieldeprint
%
%
AtEveryBibitempluton@getoaurl
renewbibmacro*begentry%
ifundefbbx@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
newcommandoamark@linkstrutvadjustdooamark@link
newcommanddooamark@link%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1em
ifhyperref
hrefbbx@pluton@oaurloasymbol
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
definecoloroaploscolHTMLf68212
newcommand*oaplossymbol%
begintikzpicture[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];
endtikzpicture
% 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
definecoloroanetgreenHTML356031
definecoloroanetyellowHTMLf9c63a
definecoloroanetintersectHTML89923a
newcommand*oanetsymbol%
begintikzpicture[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;
beginscope
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
endscope
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);
endtikzpicture
% reusable box for the symbol, so the image is not
% processed on every use
newsaveboxoasymbolbox
% choose oaplossymbol or oanetsymbol here
sboxoasymbolboxoaplossymbol
newcommand*oasymboluseboxoasymbolbox
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
makeatother
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author = Anne Uthor,
title = Generic Title,
journal = Journal,
year = 2018,
@articlebib:B,
author = Anne Uthor,
title = Open Access Title (HAL),
journal = Open Journal,
year = 2018,
eprinttype = hal,
eprint = hal-01917888,
@articlebib:C,
author = Anne Uthor,
title = Open Access Title (arXiv),
journal = Closed Journal,
year = 2018,
eprinttype = arxiv,
eprint = 1811.03094,
@articlebib:D,
author = Anne Uthor,
title = Open Access Title (DOI),
journal = Open Journal,
year = 2018,
doi = 12345/67898.0,
options = openaccess,
@articlebib:E,
author = Anne Uthor,
title = Open Access (URL),
journal = Open Journal,
year = 2018,
url = https://example.com/~author/my_paper.pdf#page20,
options = openaccess,
@articlebib:F,
author = Anne Uthor,
title = emphNot Open Access (DOI),
journal = Closed Journal,
year = 2018,
doi = 12345/67898.0,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
edit: Extended and simplified the open access URL detection (hyperref
can accept the URLs in a macro even with different levels of expansion). Place the TikZ-drawn logos in a reusable box to improve performance.
This looks quite sophisticated!! Thanks! I'll try to digest this in the coming days. Maybe this idea of a logo could become an option of biblatex :) oalogo=true !
– pluton
Nov 11 '18 at 17:05
1
@pluton Not sure if it really is something for the core. It is a bit of a gimmick, but I thought about including it inbiblatex-ext
when it has matured a bit.
– moewe
Nov 11 '18 at 17:07
Sounds very good!
– pluton
Nov 11 '18 at 17:15
2
Nice! A pity I can't upvote again...
– gusbrs
Nov 25 '18 at 15:23
add a comment |
Update Version 0.6 of
biblatex-ext
comes with the support packagebiblatex-ext-oa
that can be used to display open access symbols.biblatex-ext-oa
can be used with styles other than those frombiblatex-ext
as well, it should certainly work for the standard styles and possibly for many contributed styles as well.
biblatex-ext-oa
The package biblatex-ext-oa
supports two main methods for finding the best known open access URL that is linked from the symbol: (i) A semi-automatic heuristic based on the data given in the .bib
file and governed by configuration commands and (ii) a fully automatic Lua module (can only be used with LuaLaTeX) that queries Unpaywall.org using the DOI.
The following gives a short rundown of the most important bits and bobs of biblatex-ext-oa
, for a more detailed description, please consult §7 Open Access Symbols of the biblatex-ext
documentation.
auto
: semi-automatic heuristic
The heuristic relies on data in the .bib
file and additional configuration to identify open access links. This heuristic (which can be also be set with ExecuteBibliographyOptionsopenaccess=auto
after biblatex-ext-oa
has been loaded) is the default when biblatex-ext-oa
is loaded.
The main idea is that certain fields and eprinttype
s are so-called 'open access fields', which means that they can deliver open access URLs. Such URLs can be of two types: Either they are always open access (type 'always
': like eprinttype = arxiv
) or they are only open access under certain conditions (type 'conditional
': like the doi
field or eprinttype = jstor
). Fields of type 'conditional
' only return open access URLs if they are marked with the openaccess
field annotation in the .bib
file (see the MWE below).
If there are several possible open access URLs, a simple priority order decides which one gets to be the 'best open access URL'. If an entry has a 'best open access URL' a little open access symbol is shown in the margin and the URL is linked from there.
By default biblatex-ext-oa
has sensible defaults for url
, doi
and the eprinttypes
arxiv
, jstor
, hdl
and pubmed
. If you add a new eprinttype
, you will have to declare its open access links and state to be able to use that type for open access detection. See the definitions for hal
in the example below. The same holds if you want to define an entirely new field for open access URLs.
This is a comprehensive example that shows how openaccess=auto
works
documentclass[british]article
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[tikzsymbol=plos]biblatex-ext-oa
usepackagekantlipsum
usepackage[colorlinks]hyperref
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
DeclareFieldAliaseprint:HALeprint:hal
% HAL is always open access (I think)
DeclareOpenAccessEprintUrl[always]hal%
http://hal.archives-ouvertes.fr/thefieldeprint
DeclareOpenAccessEprintAliasHALhal
usepackagefilecontents
beginfilecontents*jobname.bib
% open access DOIs need to be marked up explicitly
@articlecipriani,
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
@onlinemeckes,
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
@articledolan,
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...
@onlinelabbe,
title = New models for the location of emphcontroversial
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
@articlesigfridsson,
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
@articlerussell: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
@articlerussell: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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
doiapi
: fully automatic open access detection with Unpaywall.org
Inspired by Eric Marsden's answer the package also features a Lua module that queries open access information from Unpaywall.org based on the DOI.
The module can only be used with LuaLaTeX and needs to be loaded by passing the option doiapi=true
to biblatex-ext-oa
. The option can then be enabled with ExecuteBibliographyOptionsopenaccess=doiapi
. If doiapi
is enabled, biblatex-ext-oa
will query the best open access URL from the Unpaywall API. To reduce load to the API the results are cached in a temporary .oai
file.
Please note that the Unpaywall API can only be used if you supply an email address. You can do this with SetDOIAPIMail
. You will be warned if you load the doiapi
module and forget to give an email. It is a fatal error to query the database if no mail address was given.
Uncomment SetDOIAPIMail
and give a valid email address before you run the following MWE with LuaLaTeX. Note the different symbol compared to the previous MWE, the tikzsymbol
option allows you to switch between plos
(the default, above) and oanet
(here).
documentclass[british]article
usepackageetoolbox
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[doiapi=true, tikzsymbol=oanet]biblatex-ext-oa
% tikzsymbol=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/)
ExecuteBibliographyOptionsopenaccess=doiapi
%SetDOIAPIMail<your email here>% <- this MUST be set for doiapi
%SetDOIAPICacheExpiration15% if you like, you can set the expiration period
% for the cache here, default is seven days
usepackagekantlipsum
usepackage[colorlinks]hyperref
usepackagefilecontents
beginfilecontents*jobname.bib
% this article is open access at the source
@articlevalfort,
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
@articlekucsko,
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
@articlerandall,
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
@articleabiakle,
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
@articlesigfridsson,
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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
This is the old version of the answer.
Old answer
Here is one attempt that should address both requirements.
Instead of a OA
keyword I went with an option openaccess
, since I felt that an option would be more natural here. But it is straightforward to change the code to work with a keyowrd. (You only need to replace iftogglebbxpluton:openaccess
with ifkeywordOA
).
The non-trivial bit was to obtain the URL to which the open access symbol should be linked. For certain eprint
types the actual URL to link is only put together when the field is processed for printing, the full URL is never 'known' to biblatex
. This was solved by defining the macro pluton@getoaurl
. The macro needs a branch for each eprinttype
you intend to use.
documentclassarticle
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagetikz
usepackage[backend=biber, style=numeric]biblatex
usepackage[hidelinks]hyperref
usepackagekantlipsum
makeatletter
newtogglebbxpluton:openaccess
DeclareEntryOption[boolean]openaccess[true]%
settogglebbxpluton:openaccess#1
newcommand*pluton@getoaurl%
undefbbx@pluton@oaurl
iftogglebbxpluton:openaccess
% URL and DOI are only open access if indicated
iffieldundefurl
defbbx@pluton@oaurlthefieldurl%
iffieldundefdoi
defbbx@pluton@oaurl%
https://doi.org/thefielddoi%
% the eprinttypes listed here are open access only if indicated
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypejstor
or test iffieldequalstreprinttypeJSTOR
defbbx@pluton@oaurl%
http://www.jstor.org/stable/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypehdl
or test iffieldequalstreprinttypeHDL
defbbx@pluton@oaurl%
http://hdl.handle.net/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypepubmed
or test iffieldequalstreprinttypePubMed
defbbx@pluton@oaurl%
http://www.ncbi.nlm.nih.gov/pubmed/thefieldeprint%
%
%
% eprinttype listed here are always open access
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypearxiv
or test iffieldequalstreprinttypearXiv
defbbx@pluton@oaurl%
https://arxiv.org/abx@arxivpath/thefieldeprint
%
iffieldequalstreprinttypehal
defbbx@pluton@oaurl%
http://hal.archives-ouvertes.fr/thefieldeprint
%
%
AtEveryBibitempluton@getoaurl
renewbibmacro*begentry%
ifundefbbx@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
newcommandoamark@linkstrutvadjustdooamark@link
newcommanddooamark@link%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1em
ifhyperref
hrefbbx@pluton@oaurloasymbol
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
definecoloroaploscolHTMLf68212
newcommand*oaplossymbol%
begintikzpicture[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];
endtikzpicture
% 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
definecoloroanetgreenHTML356031
definecoloroanetyellowHTMLf9c63a
definecoloroanetintersectHTML89923a
newcommand*oanetsymbol%
begintikzpicture[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;
beginscope
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
endscope
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);
endtikzpicture
% reusable box for the symbol, so the image is not
% processed on every use
newsaveboxoasymbolbox
% choose oaplossymbol or oanetsymbol here
sboxoasymbolboxoaplossymbol
newcommand*oasymboluseboxoasymbolbox
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
makeatother
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author = Anne Uthor,
title = Generic Title,
journal = Journal,
year = 2018,
@articlebib:B,
author = Anne Uthor,
title = Open Access Title (HAL),
journal = Open Journal,
year = 2018,
eprinttype = hal,
eprint = hal-01917888,
@articlebib:C,
author = Anne Uthor,
title = Open Access Title (arXiv),
journal = Closed Journal,
year = 2018,
eprinttype = arxiv,
eprint = 1811.03094,
@articlebib:D,
author = Anne Uthor,
title = Open Access Title (DOI),
journal = Open Journal,
year = 2018,
doi = 12345/67898.0,
options = openaccess,
@articlebib:E,
author = Anne Uthor,
title = Open Access (URL),
journal = Open Journal,
year = 2018,
url = https://example.com/~author/my_paper.pdf#page20,
options = openaccess,
@articlebib:F,
author = Anne Uthor,
title = emphNot Open Access (DOI),
journal = Closed Journal,
year = 2018,
doi = 12345/67898.0,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
edit: Extended and simplified the open access URL detection (hyperref
can accept the URLs in a macro even with different levels of expansion). Place the TikZ-drawn logos in a reusable box to improve performance.
Update Version 0.6 of
biblatex-ext
comes with the support packagebiblatex-ext-oa
that can be used to display open access symbols.biblatex-ext-oa
can be used with styles other than those frombiblatex-ext
as well, it should certainly work for the standard styles and possibly for many contributed styles as well.
biblatex-ext-oa
The package biblatex-ext-oa
supports two main methods for finding the best known open access URL that is linked from the symbol: (i) A semi-automatic heuristic based on the data given in the .bib
file and governed by configuration commands and (ii) a fully automatic Lua module (can only be used with LuaLaTeX) that queries Unpaywall.org using the DOI.
The following gives a short rundown of the most important bits and bobs of biblatex-ext-oa
, for a more detailed description, please consult §7 Open Access Symbols of the biblatex-ext
documentation.
auto
: semi-automatic heuristic
The heuristic relies on data in the .bib
file and additional configuration to identify open access links. This heuristic (which can be also be set with ExecuteBibliographyOptionsopenaccess=auto
after biblatex-ext-oa
has been loaded) is the default when biblatex-ext-oa
is loaded.
The main idea is that certain fields and eprinttype
s are so-called 'open access fields', which means that they can deliver open access URLs. Such URLs can be of two types: Either they are always open access (type 'always
': like eprinttype = arxiv
) or they are only open access under certain conditions (type 'conditional
': like the doi
field or eprinttype = jstor
). Fields of type 'conditional
' only return open access URLs if they are marked with the openaccess
field annotation in the .bib
file (see the MWE below).
If there are several possible open access URLs, a simple priority order decides which one gets to be the 'best open access URL'. If an entry has a 'best open access URL' a little open access symbol is shown in the margin and the URL is linked from there.
By default biblatex-ext-oa
has sensible defaults for url
, doi
and the eprinttypes
arxiv
, jstor
, hdl
and pubmed
. If you add a new eprinttype
, you will have to declare its open access links and state to be able to use that type for open access detection. See the definitions for hal
in the example below. The same holds if you want to define an entirely new field for open access URLs.
This is a comprehensive example that shows how openaccess=auto
works
documentclass[british]article
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[tikzsymbol=plos]biblatex-ext-oa
usepackagekantlipsum
usepackage[colorlinks]hyperref
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
DeclareFieldAliaseprint:HALeprint:hal
% HAL is always open access (I think)
DeclareOpenAccessEprintUrl[always]hal%
http://hal.archives-ouvertes.fr/thefieldeprint
DeclareOpenAccessEprintAliasHALhal
usepackagefilecontents
beginfilecontents*jobname.bib
% open access DOIs need to be marked up explicitly
@articlecipriani,
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
@onlinemeckes,
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
@articledolan,
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...
@onlinelabbe,
title = New models for the location of emphcontroversial
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
@articlesigfridsson,
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
@articlerussell: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
@articlerussell: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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
doiapi
: fully automatic open access detection with Unpaywall.org
Inspired by Eric Marsden's answer the package also features a Lua module that queries open access information from Unpaywall.org based on the DOI.
The module can only be used with LuaLaTeX and needs to be loaded by passing the option doiapi=true
to biblatex-ext-oa
. The option can then be enabled with ExecuteBibliographyOptionsopenaccess=doiapi
. If doiapi
is enabled, biblatex-ext-oa
will query the best open access URL from the Unpaywall API. To reduce load to the API the results are cached in a temporary .oai
file.
Please note that the Unpaywall API can only be used if you supply an email address. You can do this with SetDOIAPIMail
. You will be warned if you load the doiapi
module and forget to give an email. It is a fatal error to query the database if no mail address was given.
Uncomment SetDOIAPIMail
and give a valid email address before you run the following MWE with LuaLaTeX. Note the different symbol compared to the previous MWE, the tikzsymbol
option allows you to switch between plos
(the default, above) and oanet
(here).
documentclass[british]article
usepackageetoolbox
usepackagebabel
usepackagecsquotes
usepackage[backend=biber, style=numeric]biblatex
usepackage[doiapi=true, tikzsymbol=oanet]biblatex-ext-oa
% tikzsymbol=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/)
ExecuteBibliographyOptionsopenaccess=doiapi
%SetDOIAPIMail<your email here>% <- this MUST be set for doiapi
%SetDOIAPICacheExpiration15% if you like, you can set the expiration period
% for the cache here, default is seven days
usepackagekantlipsum
usepackage[colorlinks]hyperref
usepackagefilecontents
beginfilecontents*jobname.bib
% this article is open access at the source
@articlevalfort,
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
@articlekucsko,
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
@articlerandall,
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
@articleabiakle,
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
@articlesigfridsson,
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,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
This is the old version of the answer.
Old answer
Here is one attempt that should address both requirements.
Instead of a OA
keyword I went with an option openaccess
, since I felt that an option would be more natural here. But it is straightforward to change the code to work with a keyowrd. (You only need to replace iftogglebbxpluton:openaccess
with ifkeywordOA
).
The non-trivial bit was to obtain the URL to which the open access symbol should be linked. For certain eprint
types the actual URL to link is only put together when the field is processed for printing, the full URL is never 'known' to biblatex
. This was solved by defining the macro pluton@getoaurl
. The macro needs a branch for each eprinttype
you intend to use.
documentclassarticle
usepackage[utf8]inputenc
usepackage[T1]fontenc
usepackagelmodern
usepackagetikz
usepackage[backend=biber, style=numeric]biblatex
usepackage[hidelinks]hyperref
usepackagekantlipsum
makeatletter
newtogglebbxpluton:openaccess
DeclareEntryOption[boolean]openaccess[true]%
settogglebbxpluton:openaccess#1
newcommand*pluton@getoaurl%
undefbbx@pluton@oaurl
iftogglebbxpluton:openaccess
% URL and DOI are only open access if indicated
iffieldundefurl
defbbx@pluton@oaurlthefieldurl%
iffieldundefdoi
defbbx@pluton@oaurl%
https://doi.org/thefielddoi%
% the eprinttypes listed here are open access only if indicated
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypejstor
or test iffieldequalstreprinttypeJSTOR
defbbx@pluton@oaurl%
http://www.jstor.org/stable/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypehdl
or test iffieldequalstreprinttypeHDL
defbbx@pluton@oaurl%
http://hdl.handle.net/thefieldeprint%
ifboolexpr test iffieldequalstreprinttypepubmed
or test iffieldequalstreprinttypePubMed
defbbx@pluton@oaurl%
http://www.ncbi.nlm.nih.gov/pubmed/thefieldeprint%
%
%
% eprinttype listed here are always open access
iffieldundefeprint
ifboolexpr test iffieldequalstreprinttypearxiv
or test iffieldequalstreprinttypearXiv
defbbx@pluton@oaurl%
https://arxiv.org/abx@arxivpath/thefieldeprint
%
iffieldequalstreprinttypehal
defbbx@pluton@oaurl%
http://hal.archives-ouvertes.fr/thefieldeprint
%
%
AtEveryBibitempluton@getoaurl
renewbibmacro*begentry%
ifundefbbx@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
newcommandoamark@linkstrutvadjustdooamark@link
newcommanddooamark@link%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1em
ifhyperref
hrefbbx@pluton@oaurloasymbol
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
definecoloroaploscolHTMLf68212
newcommand*oaplossymbol%
begintikzpicture[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];
endtikzpicture
% 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
definecoloroanetgreenHTML356031
definecoloroanetyellowHTMLf9c63a
definecoloroanetintersectHTML89923a
newcommand*oanetsymbol%
begintikzpicture[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;
beginscope
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
endscope
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);
endtikzpicture
% reusable box for the symbol, so the image is not
% processed on every use
newsaveboxoasymbolbox
% choose oaplossymbol or oanetsymbol here
sboxoasymbolboxoaplossymbol
newcommand*oasymboluseboxoasymbolbox
newcommand*halurl[1]http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:hal%
ifhyperref
hrefhalurl#1hal:~nolinkurl#1
hal:~nolinkurl#1
makeatother
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author = Anne Uthor,
title = Generic Title,
journal = Journal,
year = 2018,
@articlebib:B,
author = Anne Uthor,
title = Open Access Title (HAL),
journal = Open Journal,
year = 2018,
eprinttype = hal,
eprint = hal-01917888,
@articlebib:C,
author = Anne Uthor,
title = Open Access Title (arXiv),
journal = Closed Journal,
year = 2018,
eprinttype = arxiv,
eprint = 1811.03094,
@articlebib:D,
author = Anne Uthor,
title = Open Access Title (DOI),
journal = Open Journal,
year = 2018,
doi = 12345/67898.0,
options = openaccess,
@articlebib:E,
author = Anne Uthor,
title = Open Access (URL),
journal = Open Journal,
year = 2018,
url = https://example.com/~author/my_paper.pdf#page20,
options = openaccess,
@articlebib:F,
author = Anne Uthor,
title = emphNot Open Access (DOI),
journal = Closed Journal,
year = 2018,
doi = 12345/67898.0,
endfilecontents*
addbibresourcejobname.bib
begindocument
kant[1]
nocite*
printbibliography
enddocument
edit: Extended and simplified the open access URL detection (hyperref
can accept the URLs in a macro even with different levels of expansion). Place the TikZ-drawn logos in a reusable box to improve performance.
edited Nov 30 '18 at 12:22
answered Nov 11 '18 at 16:55
moewemoewe
89.6k10110339
89.6k10110339
This looks quite sophisticated!! Thanks! I'll try to digest this in the coming days. Maybe this idea of a logo could become an option of biblatex :) oalogo=true !
– pluton
Nov 11 '18 at 17:05
1
@pluton Not sure if it really is something for the core. It is a bit of a gimmick, but I thought about including it inbiblatex-ext
when it has matured a bit.
– moewe
Nov 11 '18 at 17:07
Sounds very good!
– pluton
Nov 11 '18 at 17:15
2
Nice! A pity I can't upvote again...
– gusbrs
Nov 25 '18 at 15:23
add a comment |
This looks quite sophisticated!! Thanks! I'll try to digest this in the coming days. Maybe this idea of a logo could become an option of biblatex :) oalogo=true !
– pluton
Nov 11 '18 at 17:05
1
@pluton Not sure if it really is something for the core. It is a bit of a gimmick, but I thought about including it inbiblatex-ext
when it has matured a bit.
– moewe
Nov 11 '18 at 17:07
Sounds very good!
– pluton
Nov 11 '18 at 17:15
2
Nice! A pity I can't upvote again...
– gusbrs
Nov 25 '18 at 15:23
This looks quite sophisticated!! Thanks! I'll try to digest this in the coming days. Maybe this idea of a logo could become an option of biblatex :) oalogo=true !
– pluton
Nov 11 '18 at 17:05
This looks quite sophisticated!! Thanks! I'll try to digest this in the coming days. Maybe this idea of a logo could become an option of biblatex :) oalogo=true !
– pluton
Nov 11 '18 at 17:05
1
1
@pluton Not sure if it really is something for the core. It is a bit of a gimmick, but I thought about including it in
biblatex-ext
when it has matured a bit.– moewe
Nov 11 '18 at 17:07
@pluton Not sure if it really is something for the core. It is a bit of a gimmick, but I thought about including it in
biblatex-ext
when it has matured a bit.– moewe
Nov 11 '18 at 17:07
Sounds very good!
– pluton
Nov 11 '18 at 17:15
Sounds very good!
– pluton
Nov 11 '18 at 17:15
2
2
Nice! A pity I can't upvote again...
– gusbrs
Nov 25 '18 at 15:23
Nice! A pity I can't upvote again...
– gusbrs
Nov 25 '18 at 15:23
add a comment |
This is a partial answer, namely to the requirement of automatically placing the logo for arxiv
and oai
eprinttypes, without requiring adding the keyword manually in the bib file. But I've kept the possibility of manually adding the keyword, for any arbitrary entry.
Essentially, we can perform a test to check whether eprinttype
is equal to arxiv
or oai
:
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
In full:
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourcejobname.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
As for the second requirement, the relevant information would be either in eprint
or url
or doi
fields. In general, you would have to wrap the includegraphics
inside domark
in a href
. But the first and third of these cases would have to be dealt with conditionals, and the links built with a "linkbase+field" somehow.
add a comment |
This is a partial answer, namely to the requirement of automatically placing the logo for arxiv
and oai
eprinttypes, without requiring adding the keyword manually in the bib file. But I've kept the possibility of manually adding the keyword, for any arbitrary entry.
Essentially, we can perform a test to check whether eprinttype
is equal to arxiv
or oai
:
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
In full:
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourcejobname.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
As for the second requirement, the relevant information would be either in eprint
or url
or doi
fields. In general, you would have to wrap the includegraphics
inside domark
in a href
. But the first and third of these cases would have to be dealt with conditionals, and the links built with a "linkbase+field" somehow.
add a comment |
This is a partial answer, namely to the requirement of automatically placing the logo for arxiv
and oai
eprinttypes, without requiring adding the keyword manually in the bib file. But I've kept the possibility of manually adding the keyword, for any arbitrary entry.
Essentially, we can perform a test to check whether eprinttype
is equal to arxiv
or oai
:
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
In full:
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourcejobname.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
As for the second requirement, the relevant information would be either in eprint
or url
or doi
fields. In general, you would have to wrap the includegraphics
inside domark
in a href
. But the first and third of these cases would have to be dealt with conditionals, and the links built with a "linkbase+field" somehow.
This is a partial answer, namely to the requirement of automatically placing the logo for arxiv
and oai
eprinttypes, without requiring adding the keyword manually in the bib file. But I've kept the possibility of manually adding the keyword, for any arbitrary entry.
Essentially, we can perform a test to check whether eprinttype
is equal to arxiv
or oai
:
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
In full:
documentclassarticle
usepackagegraphicx
usepackagefilecontents
beginfilecontents*jobname.bib
@articlebib:A,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
@articlebib:B,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=oai,
eprint=hal-01917888,
@articlebib:C,
author=Authors,
title=Title,
journal=Journal name,
year=2018,
eprinttype=arxiv,
eprint=arXiv:1811.03094,
endfilecontents*
usepackage[backend=bibtex,style=numeric,eprint=true]biblatex
addbibresourcejobname.bib
% new eprinttype
defoaitourl#1http://hal.archives-ouvertes.fr/#1
DeclareFieldFormateprint:oai%
ifhyperref
hrefoaitourl#1hal:~nolinkurl#1
hal:~nolinkurl#1
% OA logo in the margin
newcommandimpmarkstrutvadjustdomark
newcommanddomark%
vbox to 0pt
kern-3dpstrutbox
struthfillrlapkern1emincludegraphics[height=10pt]OA
vss
%
renewbibmacro*begentry%
iffieldequalstreprinttypearxiv
impmark
iffieldequalstreprinttypeoai
impmark
ifkeywordOAimpmark
usepackage[hidelinks]hyperref
begindocument
nocite*
printbibliography
enddocument
As for the second requirement, the relevant information would be either in eprint
or url
or doi
fields. In general, you would have to wrap the includegraphics
inside domark
in a href
. But the first and third of these cases would have to be dealt with conditionals, and the links built with a "linkbase+field" somehow.
edited Nov 11 '18 at 14:29
answered Nov 11 '18 at 14:19
gusbrsgusbrs
7,7112840
7,7112840
add a comment |
add a comment |
Articles with a DOI can be open access too, and unpaywall.org has an API that can tell us whether a DOI is known to have an open access version. Just for fun, here's a version that does just that, using oldschool bibtex and modern luatex.
In your .bst file, add the function
FUNCTION openaccess.check
doi empty$
'skip$
"MyMaybeOpenAccess" doi * "" * write$
if$
and call it in the code that handles an article (just after output.bibitem
for example.
In your document preamble, define a macro
newcommandMyMaybeOpenAccess[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\marginparnoexpand\includegraphics[width=0.3cm]open-access-logo")
end
end
(For serious use, would also need to handle isbn and eprint fields, cache accesses to the API, include the OA URL under the logo, and so on.)
2
I'm planning on including a similar functionality in the next version ofbiblatex-ext
(github.com/moewew/biblatex-ext/blob/master/blxextdoiapi.lua). Would it be OK if I credit you and and this answer as inspiration in the documentation (github.com/moewew/biblatex-ext/blob/…)?
– moewe
Nov 23 '18 at 11:01
3
Sure, that's fine.
– Eric Marsden
Nov 23 '18 at 13:26
add a comment |
Articles with a DOI can be open access too, and unpaywall.org has an API that can tell us whether a DOI is known to have an open access version. Just for fun, here's a version that does just that, using oldschool bibtex and modern luatex.
In your .bst file, add the function
FUNCTION openaccess.check
doi empty$
'skip$
"MyMaybeOpenAccess" doi * "" * write$
if$
and call it in the code that handles an article (just after output.bibitem
for example.
In your document preamble, define a macro
newcommandMyMaybeOpenAccess[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\marginparnoexpand\includegraphics[width=0.3cm]open-access-logo")
end
end
(For serious use, would also need to handle isbn and eprint fields, cache accesses to the API, include the OA URL under the logo, and so on.)
2
I'm planning on including a similar functionality in the next version ofbiblatex-ext
(github.com/moewew/biblatex-ext/blob/master/blxextdoiapi.lua). Would it be OK if I credit you and and this answer as inspiration in the documentation (github.com/moewew/biblatex-ext/blob/…)?
– moewe
Nov 23 '18 at 11:01
3
Sure, that's fine.
– Eric Marsden
Nov 23 '18 at 13:26
add a comment |
Articles with a DOI can be open access too, and unpaywall.org has an API that can tell us whether a DOI is known to have an open access version. Just for fun, here's a version that does just that, using oldschool bibtex and modern luatex.
In your .bst file, add the function
FUNCTION openaccess.check
doi empty$
'skip$
"MyMaybeOpenAccess" doi * "" * write$
if$
and call it in the code that handles an article (just after output.bibitem
for example.
In your document preamble, define a macro
newcommandMyMaybeOpenAccess[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\marginparnoexpand\includegraphics[width=0.3cm]open-access-logo")
end
end
(For serious use, would also need to handle isbn and eprint fields, cache accesses to the API, include the OA URL under the logo, and so on.)
Articles with a DOI can be open access too, and unpaywall.org has an API that can tell us whether a DOI is known to have an open access version. Just for fun, here's a version that does just that, using oldschool bibtex and modern luatex.
In your .bst file, add the function
FUNCTION openaccess.check
doi empty$
'skip$
"MyMaybeOpenAccess" doi * "" * write$
if$
and call it in the code that handles an article (just after output.bibitem
for example.
In your document preamble, define a macro
newcommandMyMaybeOpenAccess[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\marginparnoexpand\includegraphics[width=0.3cm]open-access-logo")
end
end
(For serious use, would also need to handle isbn and eprint fields, cache accesses to the API, include the OA URL under the logo, and so on.)
answered Nov 11 '18 at 23:01
Eric MarsdenEric Marsden
68137
68137
2
I'm planning on including a similar functionality in the next version ofbiblatex-ext
(github.com/moewew/biblatex-ext/blob/master/blxextdoiapi.lua). Would it be OK if I credit you and and this answer as inspiration in the documentation (github.com/moewew/biblatex-ext/blob/…)?
– moewe
Nov 23 '18 at 11:01
3
Sure, that's fine.
– Eric Marsden
Nov 23 '18 at 13:26
add a comment |
2
I'm planning on including a similar functionality in the next version ofbiblatex-ext
(github.com/moewew/biblatex-ext/blob/master/blxextdoiapi.lua). Would it be OK if I credit you and and this answer as inspiration in the documentation (github.com/moewew/biblatex-ext/blob/…)?
– moewe
Nov 23 '18 at 11:01
3
Sure, that's fine.
– Eric Marsden
Nov 23 '18 at 13:26
2
2
I'm planning on including a similar functionality in the next version of
biblatex-ext
(github.com/moewew/biblatex-ext/blob/master/blxextdoiapi.lua). Would it be OK if I credit you and and this answer as inspiration in the documentation (github.com/moewew/biblatex-ext/blob/…)?– moewe
Nov 23 '18 at 11:01
I'm planning on including a similar functionality in the next version of
biblatex-ext
(github.com/moewew/biblatex-ext/blob/master/blxextdoiapi.lua). Would it be OK if I credit you and and this answer as inspiration in the documentation (github.com/moewew/biblatex-ext/blob/…)?– moewe
Nov 23 '18 at 11:01
3
3
Sure, that's fine.
– Eric Marsden
Nov 23 '18 at 13:26
Sure, that's fine.
– Eric Marsden
Nov 23 '18 at 13:26
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459449%2fbibliography-add-a-small-open-access-logo-in-the-margin%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Note that
eprint
s need not be freely available by definition, so blindly adding an open access logo when it can not be verified that the article is indeed open access might not be the best idea.– moewe
Nov 11 '18 at 11:48
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
Nov 11 '18 at 11:53
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
Nov 11 '18 at 12:14
2
Btw, +1 for the open access commitment. :)
– gusbrs
Nov 11 '18 at 12:23
3
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
Nov 11 '18 at 14:36