Bibliography: add a small “open access” logo in the margin
up vote
7
down vote
favorite
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)
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
keywords={OA}
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
keywords={OA}
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{MWEOA.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{ifkeyword{OA}{impmark}{}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
which looks like
However, it would not 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
up vote
7
down vote
favorite
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)
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
keywords={OA}
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
keywords={OA}
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{MWEOA.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{ifkeyword{OA}{impmark}{}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
which looks like
However, it would not 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
2 days ago
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
2 days ago
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
2 days ago
2
Btw, +1 for the open access commitment. :)
– gusbrs
2 days ago
2
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
2 days ago
|
show 10 more comments
up vote
7
down vote
favorite
up vote
7
down vote
favorite
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)
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
keywords={OA}
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
keywords={OA}
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{MWEOA.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{ifkeyword{OA}{impmark}{}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
which looks like
However, it would not 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)
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
keywords={OA}
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
keywords={OA}
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{MWEOA.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox %manual control of the logo top alignment
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{ifkeyword{OA}{impmark}{}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
which looks like
However, it would not 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 2 days ago
asked 2 days ago
pluton
7,834960128
7,834960128
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
2 days ago
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
2 days ago
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
2 days ago
2
Btw, +1 for the open access commitment. :)
– gusbrs
2 days ago
2
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
2 days ago
|
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
2 days ago
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
2 days ago
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
2 days ago
2
Btw, +1 for the open access commitment. :)
– gusbrs
2 days ago
2
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
2 days ago
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
2 days ago
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
2 days ago
1
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
2 days ago
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
2 days ago
1
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
2 days ago
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
2 days ago
2
2
Btw, +1 for the open access commitment. :)
– gusbrs
2 days ago
Btw, +1 for the open access commitment. :)
– gusbrs
2 days ago
2
2
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
2 days ago
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
2 days ago
|
show 10 more comments
3 Answers
3
active
oldest
votes
up vote
5
down vote
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}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
In full:
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{jobname.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
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 |
up vote
5
down vote
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 iftoggle{bbxpluton:openaccess}
with ifkeyword{OA}
).
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.
documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{tikz}
usepackage[backend=biber, style=numeric]{biblatex}
usepackage[hidelinks]{hyperref}
usepackage{kantlipsum}
makeatletter
newtoggle{bbxpluton:openaccess}
DeclareEntryOption[boolean]{openaccess}[true]{%
settoggle{bbxpluton:openaccess}{#1}}
newcommand*{pluton@getoaurl}{%
undefbbx@pluton@oaurl
iftoggle{bbxpluton:openaccess}
{% URL and DOI are only open access if indicated
iffieldundef{url}
{}
{defbbx@pluton@oaurl{thefield{url}}}%
iffieldundef{doi}
{}
{defbbx@pluton@oaurl{%
https://doi.org/thefield{doi}}}%
% the eprinttypes listed here are open access only if indicated
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{jstor}}
or test {iffieldequalstr{eprinttype}{JSTOR}}}
{}
{defbbx@pluton@oaurl{%
http://www.jstor.org/stable/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{hdl}}
or test {iffieldequalstr{eprinttype}{HDL}}}
{}
{defbbx@pluton@oaurl{%
http://hdl.handle.net/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{pubmed}}
or test {iffieldequalstr{eprinttype}{PubMed}}}
{}
{defbbx@pluton@oaurl{%
http://www.ncbi.nlm.nih.gov/pubmed/thefield{eprint}}}%
}%
}
{}%
% eprinttype listed here are always open access
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{arxiv}}
or test {iffieldequalstr{eprinttype}{arXiv}}}
{defbbx@pluton@oaurl{%
https://arxiv.org/abx@arxivpath/thefield{eprint}}}
{}%
iffieldequalstr{eprinttype}{hal}
{defbbx@pluton@oaurl{%
http://hal.archives-ouvertes.fr/thefield{eprint}}}
{}%
}%
}
AtEveryBibitem{pluton@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
newcommand{oamark@link}{strutvadjust{dooamark@link}}
newcommand{dooamark@link}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1em
ifhyperref
{href{bbx@pluton@oaurl}{oasymbol}}
{oasymbol}}
vss
}%
}
% PLoS Open Access symbol based on
% https://commons.wikimedia.org/wiki/File:Open_Access_logo_PLoS_white.svg
% public domain/CC0 by PLoS & Wikipedia users Nina, Beao and JakobVoss
definecolor{oaploscol}{HTML}{f68212}
newcommand*{oaplossymbol}{%
begin{tikzpicture}[x=.1pt,y=.1pt]
fill[oaploscol] (06,73) arc (180:0:26);
fill[white] (17,72.9) arc (180:-45:15);
fill[oaploscol] (47,32) rectangle ++ (11,41.1);
fill[oaploscol] (32,32) circle[radius=32];
fill[white] (32,32) circle[radius=21];
fill[oaploscol] (32,32) circle[radius= 9];
end{tikzpicture}
}
% Open-Acess.net Open Acess symbol
% redrawn with TikZ from
% http://open-access.net/fileadmin/logos/oa.svg
% public domain according to
% https://commons.wikimedia.org/wiki/File:Open_access.svg
% might be covered by open-access.net's overall CC-BY 4.0
% https://creativecommons.org/licenses/by/4.0/
% https://open-access.net/impressum/
% the site states no specific conditions for use of the logo
% other than
% "Das Logo der Informationsplattform darf nachgenutzt werden,
% gerne mit einem Link zu open-access.net"
% on https://open-access.net/ueber-uns/
% see also https://open-access.net/community/materialien/
% logo by
% Medien + Design
% Center for Digital Systems
% Competence Center for E-Learning and Multimedia
% Freie Universität Berlin
definecolor{oanetgreen}{HTML}{356031}
definecolor{oanetyellow}{HTML}{f9c63a}
definecolor{oanetintersect}{HTML}{89923a}
newcommand*{oanetsymbol}{%
begin{tikzpicture}[x=1.1pt,y=1.1pt]
fill[oanetgreen] (4,4) circle[radius=4.3];
fill[oanetyellow] (11,4) ++ (0:4.3) arc (0:300:4.3)
-- (11,4) ++ (300:4.3) -- cycle;
begin{scope}
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
end{scope}
fill[white] (4,4) circle[radius=2.7];
fill[white] (11,4) circle[radius=2.7];
fill[oanetyellow] (11,4) ++ (2.7,.1) rectangle ++(1.6,-4.1);
end{tikzpicture}
}
% reusable box for the symbol, so the image is not
% processed on every use
newsavebox{oasymbolbox}
% choose oaplossymbol or oanetsymbol here
sbox{oasymbolbox}{oaplossymbol}
newcommand*{oasymbol}{usebox{oasymbolbox}}
newcommand*{halurl}[1]{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:hal}{%
ifhyperref
{href{halurl{#1}}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
makeatother
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author = {Anne Uthor},
title = {Generic Title},
journal = {Journal},
year = {2018},
}
@article{bib:B,
author = {Anne Uthor},
title = {Open Access Title (HAL)},
journal = {Open Journal},
year = {2018},
eprinttype = {hal},
eprint = {hal-01917888},
}
@article{bib:C,
author = {Anne Uthor},
title = {Open Access Title (arXiv)},
journal = {Closed Journal},
year = {2018},
eprinttype = {arxiv},
eprint = {1811.03094},
}
@article{bib:D,
author = {Anne Uthor},
title = {Open Access Title (DOI)},
journal = {Open Journal},
year = {2018},
doi = {12345/67898.0},
options = {openaccess},
}
@article{bib:E,
author = {Anne Uthor},
title = {Open Access (URL)},
journal = {Open Journal},
year = {2018},
url = {https://example.com/~author/my_paper.pdf#page20},
options = {openaccess},
}
@article{bib:F,
author = {Anne Uthor},
title = {emph{Not} Open Access (DOI)},
journal = {Closed Journal},
year = {2018},
doi = {12345/67898.0},
}
end{filecontents*}
addbibresource{jobname.bib}
begin{document}
kant[1]
nocite{*}
printbibliography
end{document}
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
2 days ago
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
2 days ago
Sounds very good!
– pluton
2 days ago
add a comment |
up vote
4
down vote
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
newcommand{MyMaybeOpenAccess}[1]{%
directlua{
local http = require('socket.http')
local url = 'https://api.unpaywall.org/v2/' .. luastring{#1} .. '?email=your@email'
body, code, headers, status = http.request(url)
if code == 200 and body then
local found = string.match(body, '"is_oa": ([a-z]+)')
if found == "true" then
tex.print("noexpand\marginpar{noexpand\includegraphics[width=0.3cm]{open-access-logo}}")
end
end
}}
(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.)
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
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}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
In full:
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{jobname.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
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 |
up vote
5
down vote
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}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
In full:
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{jobname.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
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 |
up vote
5
down vote
up vote
5
down vote
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}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
In full:
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{jobname.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
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}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
In full:
documentclass{article}
usepackage{graphicx}
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
}
@article{bib:B,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={oai},
eprint={hal-01917888},
}
@article{bib:C,
author={Authors},
title={Title},
journal={Journal name},
year={2018},
eprinttype={arxiv},
eprint={arXiv:1811.03094},
}
end{filecontents*}
usepackage[backend=bibtex,style=numeric,eprint=true]{biblatex}
addbibresource{jobname.bib}
% new eprinttype
defoaitourl#1{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:oai}{%
ifhyperref
{href{oaitourl#1}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
% OA logo in the margin
newcommand{impmark}{strutvadjust{domark}}
newcommand{domark}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1emincludegraphics[height=10pt]{OA}}
vss
}%
}
renewbibmacro*{begentry}{%
iffieldequalstr{eprinttype}{arxiv}
{impmark}
{iffieldequalstr{eprinttype}{oai}
{impmark}
{ifkeyword{OA}{impmark}{}}}}
usepackage[hidelinks]{hyperref}
begin{document}
nocite{*}
printbibliography
end{document}
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 2 days ago
answered 2 days ago
gusbrs
5,8692838
5,8692838
add a comment |
add a comment |
up vote
5
down vote
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 iftoggle{bbxpluton:openaccess}
with ifkeyword{OA}
).
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.
documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{tikz}
usepackage[backend=biber, style=numeric]{biblatex}
usepackage[hidelinks]{hyperref}
usepackage{kantlipsum}
makeatletter
newtoggle{bbxpluton:openaccess}
DeclareEntryOption[boolean]{openaccess}[true]{%
settoggle{bbxpluton:openaccess}{#1}}
newcommand*{pluton@getoaurl}{%
undefbbx@pluton@oaurl
iftoggle{bbxpluton:openaccess}
{% URL and DOI are only open access if indicated
iffieldundef{url}
{}
{defbbx@pluton@oaurl{thefield{url}}}%
iffieldundef{doi}
{}
{defbbx@pluton@oaurl{%
https://doi.org/thefield{doi}}}%
% the eprinttypes listed here are open access only if indicated
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{jstor}}
or test {iffieldequalstr{eprinttype}{JSTOR}}}
{}
{defbbx@pluton@oaurl{%
http://www.jstor.org/stable/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{hdl}}
or test {iffieldequalstr{eprinttype}{HDL}}}
{}
{defbbx@pluton@oaurl{%
http://hdl.handle.net/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{pubmed}}
or test {iffieldequalstr{eprinttype}{PubMed}}}
{}
{defbbx@pluton@oaurl{%
http://www.ncbi.nlm.nih.gov/pubmed/thefield{eprint}}}%
}%
}
{}%
% eprinttype listed here are always open access
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{arxiv}}
or test {iffieldequalstr{eprinttype}{arXiv}}}
{defbbx@pluton@oaurl{%
https://arxiv.org/abx@arxivpath/thefield{eprint}}}
{}%
iffieldequalstr{eprinttype}{hal}
{defbbx@pluton@oaurl{%
http://hal.archives-ouvertes.fr/thefield{eprint}}}
{}%
}%
}
AtEveryBibitem{pluton@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
newcommand{oamark@link}{strutvadjust{dooamark@link}}
newcommand{dooamark@link}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1em
ifhyperref
{href{bbx@pluton@oaurl}{oasymbol}}
{oasymbol}}
vss
}%
}
% PLoS Open Access symbol based on
% https://commons.wikimedia.org/wiki/File:Open_Access_logo_PLoS_white.svg
% public domain/CC0 by PLoS & Wikipedia users Nina, Beao and JakobVoss
definecolor{oaploscol}{HTML}{f68212}
newcommand*{oaplossymbol}{%
begin{tikzpicture}[x=.1pt,y=.1pt]
fill[oaploscol] (06,73) arc (180:0:26);
fill[white] (17,72.9) arc (180:-45:15);
fill[oaploscol] (47,32) rectangle ++ (11,41.1);
fill[oaploscol] (32,32) circle[radius=32];
fill[white] (32,32) circle[radius=21];
fill[oaploscol] (32,32) circle[radius= 9];
end{tikzpicture}
}
% Open-Acess.net Open Acess symbol
% redrawn with TikZ from
% http://open-access.net/fileadmin/logos/oa.svg
% public domain according to
% https://commons.wikimedia.org/wiki/File:Open_access.svg
% might be covered by open-access.net's overall CC-BY 4.0
% https://creativecommons.org/licenses/by/4.0/
% https://open-access.net/impressum/
% the site states no specific conditions for use of the logo
% other than
% "Das Logo der Informationsplattform darf nachgenutzt werden,
% gerne mit einem Link zu open-access.net"
% on https://open-access.net/ueber-uns/
% see also https://open-access.net/community/materialien/
% logo by
% Medien + Design
% Center for Digital Systems
% Competence Center for E-Learning and Multimedia
% Freie Universität Berlin
definecolor{oanetgreen}{HTML}{356031}
definecolor{oanetyellow}{HTML}{f9c63a}
definecolor{oanetintersect}{HTML}{89923a}
newcommand*{oanetsymbol}{%
begin{tikzpicture}[x=1.1pt,y=1.1pt]
fill[oanetgreen] (4,4) circle[radius=4.3];
fill[oanetyellow] (11,4) ++ (0:4.3) arc (0:300:4.3)
-- (11,4) ++ (300:4.3) -- cycle;
begin{scope}
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
end{scope}
fill[white] (4,4) circle[radius=2.7];
fill[white] (11,4) circle[radius=2.7];
fill[oanetyellow] (11,4) ++ (2.7,.1) rectangle ++(1.6,-4.1);
end{tikzpicture}
}
% reusable box for the symbol, so the image is not
% processed on every use
newsavebox{oasymbolbox}
% choose oaplossymbol or oanetsymbol here
sbox{oasymbolbox}{oaplossymbol}
newcommand*{oasymbol}{usebox{oasymbolbox}}
newcommand*{halurl}[1]{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:hal}{%
ifhyperref
{href{halurl{#1}}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
makeatother
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author = {Anne Uthor},
title = {Generic Title},
journal = {Journal},
year = {2018},
}
@article{bib:B,
author = {Anne Uthor},
title = {Open Access Title (HAL)},
journal = {Open Journal},
year = {2018},
eprinttype = {hal},
eprint = {hal-01917888},
}
@article{bib:C,
author = {Anne Uthor},
title = {Open Access Title (arXiv)},
journal = {Closed Journal},
year = {2018},
eprinttype = {arxiv},
eprint = {1811.03094},
}
@article{bib:D,
author = {Anne Uthor},
title = {Open Access Title (DOI)},
journal = {Open Journal},
year = {2018},
doi = {12345/67898.0},
options = {openaccess},
}
@article{bib:E,
author = {Anne Uthor},
title = {Open Access (URL)},
journal = {Open Journal},
year = {2018},
url = {https://example.com/~author/my_paper.pdf#page20},
options = {openaccess},
}
@article{bib:F,
author = {Anne Uthor},
title = {emph{Not} Open Access (DOI)},
journal = {Closed Journal},
year = {2018},
doi = {12345/67898.0},
}
end{filecontents*}
addbibresource{jobname.bib}
begin{document}
kant[1]
nocite{*}
printbibliography
end{document}
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
2 days ago
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
2 days ago
Sounds very good!
– pluton
2 days ago
add a comment |
up vote
5
down vote
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 iftoggle{bbxpluton:openaccess}
with ifkeyword{OA}
).
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.
documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{tikz}
usepackage[backend=biber, style=numeric]{biblatex}
usepackage[hidelinks]{hyperref}
usepackage{kantlipsum}
makeatletter
newtoggle{bbxpluton:openaccess}
DeclareEntryOption[boolean]{openaccess}[true]{%
settoggle{bbxpluton:openaccess}{#1}}
newcommand*{pluton@getoaurl}{%
undefbbx@pluton@oaurl
iftoggle{bbxpluton:openaccess}
{% URL and DOI are only open access if indicated
iffieldundef{url}
{}
{defbbx@pluton@oaurl{thefield{url}}}%
iffieldundef{doi}
{}
{defbbx@pluton@oaurl{%
https://doi.org/thefield{doi}}}%
% the eprinttypes listed here are open access only if indicated
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{jstor}}
or test {iffieldequalstr{eprinttype}{JSTOR}}}
{}
{defbbx@pluton@oaurl{%
http://www.jstor.org/stable/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{hdl}}
or test {iffieldequalstr{eprinttype}{HDL}}}
{}
{defbbx@pluton@oaurl{%
http://hdl.handle.net/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{pubmed}}
or test {iffieldequalstr{eprinttype}{PubMed}}}
{}
{defbbx@pluton@oaurl{%
http://www.ncbi.nlm.nih.gov/pubmed/thefield{eprint}}}%
}%
}
{}%
% eprinttype listed here are always open access
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{arxiv}}
or test {iffieldequalstr{eprinttype}{arXiv}}}
{defbbx@pluton@oaurl{%
https://arxiv.org/abx@arxivpath/thefield{eprint}}}
{}%
iffieldequalstr{eprinttype}{hal}
{defbbx@pluton@oaurl{%
http://hal.archives-ouvertes.fr/thefield{eprint}}}
{}%
}%
}
AtEveryBibitem{pluton@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
newcommand{oamark@link}{strutvadjust{dooamark@link}}
newcommand{dooamark@link}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1em
ifhyperref
{href{bbx@pluton@oaurl}{oasymbol}}
{oasymbol}}
vss
}%
}
% PLoS Open Access symbol based on
% https://commons.wikimedia.org/wiki/File:Open_Access_logo_PLoS_white.svg
% public domain/CC0 by PLoS & Wikipedia users Nina, Beao and JakobVoss
definecolor{oaploscol}{HTML}{f68212}
newcommand*{oaplossymbol}{%
begin{tikzpicture}[x=.1pt,y=.1pt]
fill[oaploscol] (06,73) arc (180:0:26);
fill[white] (17,72.9) arc (180:-45:15);
fill[oaploscol] (47,32) rectangle ++ (11,41.1);
fill[oaploscol] (32,32) circle[radius=32];
fill[white] (32,32) circle[radius=21];
fill[oaploscol] (32,32) circle[radius= 9];
end{tikzpicture}
}
% Open-Acess.net Open Acess symbol
% redrawn with TikZ from
% http://open-access.net/fileadmin/logos/oa.svg
% public domain according to
% https://commons.wikimedia.org/wiki/File:Open_access.svg
% might be covered by open-access.net's overall CC-BY 4.0
% https://creativecommons.org/licenses/by/4.0/
% https://open-access.net/impressum/
% the site states no specific conditions for use of the logo
% other than
% "Das Logo der Informationsplattform darf nachgenutzt werden,
% gerne mit einem Link zu open-access.net"
% on https://open-access.net/ueber-uns/
% see also https://open-access.net/community/materialien/
% logo by
% Medien + Design
% Center for Digital Systems
% Competence Center for E-Learning and Multimedia
% Freie Universität Berlin
definecolor{oanetgreen}{HTML}{356031}
definecolor{oanetyellow}{HTML}{f9c63a}
definecolor{oanetintersect}{HTML}{89923a}
newcommand*{oanetsymbol}{%
begin{tikzpicture}[x=1.1pt,y=1.1pt]
fill[oanetgreen] (4,4) circle[radius=4.3];
fill[oanetyellow] (11,4) ++ (0:4.3) arc (0:300:4.3)
-- (11,4) ++ (300:4.3) -- cycle;
begin{scope}
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
end{scope}
fill[white] (4,4) circle[radius=2.7];
fill[white] (11,4) circle[radius=2.7];
fill[oanetyellow] (11,4) ++ (2.7,.1) rectangle ++(1.6,-4.1);
end{tikzpicture}
}
% reusable box for the symbol, so the image is not
% processed on every use
newsavebox{oasymbolbox}
% choose oaplossymbol or oanetsymbol here
sbox{oasymbolbox}{oaplossymbol}
newcommand*{oasymbol}{usebox{oasymbolbox}}
newcommand*{halurl}[1]{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:hal}{%
ifhyperref
{href{halurl{#1}}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
makeatother
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author = {Anne Uthor},
title = {Generic Title},
journal = {Journal},
year = {2018},
}
@article{bib:B,
author = {Anne Uthor},
title = {Open Access Title (HAL)},
journal = {Open Journal},
year = {2018},
eprinttype = {hal},
eprint = {hal-01917888},
}
@article{bib:C,
author = {Anne Uthor},
title = {Open Access Title (arXiv)},
journal = {Closed Journal},
year = {2018},
eprinttype = {arxiv},
eprint = {1811.03094},
}
@article{bib:D,
author = {Anne Uthor},
title = {Open Access Title (DOI)},
journal = {Open Journal},
year = {2018},
doi = {12345/67898.0},
options = {openaccess},
}
@article{bib:E,
author = {Anne Uthor},
title = {Open Access (URL)},
journal = {Open Journal},
year = {2018},
url = {https://example.com/~author/my_paper.pdf#page20},
options = {openaccess},
}
@article{bib:F,
author = {Anne Uthor},
title = {emph{Not} Open Access (DOI)},
journal = {Closed Journal},
year = {2018},
doi = {12345/67898.0},
}
end{filecontents*}
addbibresource{jobname.bib}
begin{document}
kant[1]
nocite{*}
printbibliography
end{document}
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
2 days ago
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
2 days ago
Sounds very good!
– pluton
2 days ago
add a comment |
up vote
5
down vote
up vote
5
down vote
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 iftoggle{bbxpluton:openaccess}
with ifkeyword{OA}
).
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.
documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{tikz}
usepackage[backend=biber, style=numeric]{biblatex}
usepackage[hidelinks]{hyperref}
usepackage{kantlipsum}
makeatletter
newtoggle{bbxpluton:openaccess}
DeclareEntryOption[boolean]{openaccess}[true]{%
settoggle{bbxpluton:openaccess}{#1}}
newcommand*{pluton@getoaurl}{%
undefbbx@pluton@oaurl
iftoggle{bbxpluton:openaccess}
{% URL and DOI are only open access if indicated
iffieldundef{url}
{}
{defbbx@pluton@oaurl{thefield{url}}}%
iffieldundef{doi}
{}
{defbbx@pluton@oaurl{%
https://doi.org/thefield{doi}}}%
% the eprinttypes listed here are open access only if indicated
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{jstor}}
or test {iffieldequalstr{eprinttype}{JSTOR}}}
{}
{defbbx@pluton@oaurl{%
http://www.jstor.org/stable/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{hdl}}
or test {iffieldequalstr{eprinttype}{HDL}}}
{}
{defbbx@pluton@oaurl{%
http://hdl.handle.net/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{pubmed}}
or test {iffieldequalstr{eprinttype}{PubMed}}}
{}
{defbbx@pluton@oaurl{%
http://www.ncbi.nlm.nih.gov/pubmed/thefield{eprint}}}%
}%
}
{}%
% eprinttype listed here are always open access
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{arxiv}}
or test {iffieldequalstr{eprinttype}{arXiv}}}
{defbbx@pluton@oaurl{%
https://arxiv.org/abx@arxivpath/thefield{eprint}}}
{}%
iffieldequalstr{eprinttype}{hal}
{defbbx@pluton@oaurl{%
http://hal.archives-ouvertes.fr/thefield{eprint}}}
{}%
}%
}
AtEveryBibitem{pluton@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
newcommand{oamark@link}{strutvadjust{dooamark@link}}
newcommand{dooamark@link}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1em
ifhyperref
{href{bbx@pluton@oaurl}{oasymbol}}
{oasymbol}}
vss
}%
}
% PLoS Open Access symbol based on
% https://commons.wikimedia.org/wiki/File:Open_Access_logo_PLoS_white.svg
% public domain/CC0 by PLoS & Wikipedia users Nina, Beao and JakobVoss
definecolor{oaploscol}{HTML}{f68212}
newcommand*{oaplossymbol}{%
begin{tikzpicture}[x=.1pt,y=.1pt]
fill[oaploscol] (06,73) arc (180:0:26);
fill[white] (17,72.9) arc (180:-45:15);
fill[oaploscol] (47,32) rectangle ++ (11,41.1);
fill[oaploscol] (32,32) circle[radius=32];
fill[white] (32,32) circle[radius=21];
fill[oaploscol] (32,32) circle[radius= 9];
end{tikzpicture}
}
% Open-Acess.net Open Acess symbol
% redrawn with TikZ from
% http://open-access.net/fileadmin/logos/oa.svg
% public domain according to
% https://commons.wikimedia.org/wiki/File:Open_access.svg
% might be covered by open-access.net's overall CC-BY 4.0
% https://creativecommons.org/licenses/by/4.0/
% https://open-access.net/impressum/
% the site states no specific conditions for use of the logo
% other than
% "Das Logo der Informationsplattform darf nachgenutzt werden,
% gerne mit einem Link zu open-access.net"
% on https://open-access.net/ueber-uns/
% see also https://open-access.net/community/materialien/
% logo by
% Medien + Design
% Center for Digital Systems
% Competence Center for E-Learning and Multimedia
% Freie Universität Berlin
definecolor{oanetgreen}{HTML}{356031}
definecolor{oanetyellow}{HTML}{f9c63a}
definecolor{oanetintersect}{HTML}{89923a}
newcommand*{oanetsymbol}{%
begin{tikzpicture}[x=1.1pt,y=1.1pt]
fill[oanetgreen] (4,4) circle[radius=4.3];
fill[oanetyellow] (11,4) ++ (0:4.3) arc (0:300:4.3)
-- (11,4) ++ (300:4.3) -- cycle;
begin{scope}
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
end{scope}
fill[white] (4,4) circle[radius=2.7];
fill[white] (11,4) circle[radius=2.7];
fill[oanetyellow] (11,4) ++ (2.7,.1) rectangle ++(1.6,-4.1);
end{tikzpicture}
}
% reusable box for the symbol, so the image is not
% processed on every use
newsavebox{oasymbolbox}
% choose oaplossymbol or oanetsymbol here
sbox{oasymbolbox}{oaplossymbol}
newcommand*{oasymbol}{usebox{oasymbolbox}}
newcommand*{halurl}[1]{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:hal}{%
ifhyperref
{href{halurl{#1}}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
makeatother
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author = {Anne Uthor},
title = {Generic Title},
journal = {Journal},
year = {2018},
}
@article{bib:B,
author = {Anne Uthor},
title = {Open Access Title (HAL)},
journal = {Open Journal},
year = {2018},
eprinttype = {hal},
eprint = {hal-01917888},
}
@article{bib:C,
author = {Anne Uthor},
title = {Open Access Title (arXiv)},
journal = {Closed Journal},
year = {2018},
eprinttype = {arxiv},
eprint = {1811.03094},
}
@article{bib:D,
author = {Anne Uthor},
title = {Open Access Title (DOI)},
journal = {Open Journal},
year = {2018},
doi = {12345/67898.0},
options = {openaccess},
}
@article{bib:E,
author = {Anne Uthor},
title = {Open Access (URL)},
journal = {Open Journal},
year = {2018},
url = {https://example.com/~author/my_paper.pdf#page20},
options = {openaccess},
}
@article{bib:F,
author = {Anne Uthor},
title = {emph{Not} Open Access (DOI)},
journal = {Closed Journal},
year = {2018},
doi = {12345/67898.0},
}
end{filecontents*}
addbibresource{jobname.bib}
begin{document}
kant[1]
nocite{*}
printbibliography
end{document}
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.
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 iftoggle{bbxpluton:openaccess}
with ifkeyword{OA}
).
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.
documentclass{article}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage{lmodern}
usepackage{tikz}
usepackage[backend=biber, style=numeric]{biblatex}
usepackage[hidelinks]{hyperref}
usepackage{kantlipsum}
makeatletter
newtoggle{bbxpluton:openaccess}
DeclareEntryOption[boolean]{openaccess}[true]{%
settoggle{bbxpluton:openaccess}{#1}}
newcommand*{pluton@getoaurl}{%
undefbbx@pluton@oaurl
iftoggle{bbxpluton:openaccess}
{% URL and DOI are only open access if indicated
iffieldundef{url}
{}
{defbbx@pluton@oaurl{thefield{url}}}%
iffieldundef{doi}
{}
{defbbx@pluton@oaurl{%
https://doi.org/thefield{doi}}}%
% the eprinttypes listed here are open access only if indicated
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{jstor}}
or test {iffieldequalstr{eprinttype}{JSTOR}}}
{}
{defbbx@pluton@oaurl{%
http://www.jstor.org/stable/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{hdl}}
or test {iffieldequalstr{eprinttype}{HDL}}}
{}
{defbbx@pluton@oaurl{%
http://hdl.handle.net/thefield{eprint}}}%
ifboolexpr{ test {iffieldequalstr{eprinttype}{pubmed}}
or test {iffieldequalstr{eprinttype}{PubMed}}}
{}
{defbbx@pluton@oaurl{%
http://www.ncbi.nlm.nih.gov/pubmed/thefield{eprint}}}%
}%
}
{}%
% eprinttype listed here are always open access
iffieldundef{eprint}
{}
{ifboolexpr{ test {iffieldequalstr{eprinttype}{arxiv}}
or test {iffieldequalstr{eprinttype}{arXiv}}}
{defbbx@pluton@oaurl{%
https://arxiv.org/abx@arxivpath/thefield{eprint}}}
{}%
iffieldequalstr{eprinttype}{hal}
{defbbx@pluton@oaurl{%
http://hal.archives-ouvertes.fr/thefield{eprint}}}
{}%
}%
}
AtEveryBibitem{pluton@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
newcommand{oamark@link}{strutvadjust{dooamark@link}}
newcommand{dooamark@link}{%
vbox to 0pt{
kern-3dpstrutbox
struthfillrlap{kern1em
ifhyperref
{href{bbx@pluton@oaurl}{oasymbol}}
{oasymbol}}
vss
}%
}
% PLoS Open Access symbol based on
% https://commons.wikimedia.org/wiki/File:Open_Access_logo_PLoS_white.svg
% public domain/CC0 by PLoS & Wikipedia users Nina, Beao and JakobVoss
definecolor{oaploscol}{HTML}{f68212}
newcommand*{oaplossymbol}{%
begin{tikzpicture}[x=.1pt,y=.1pt]
fill[oaploscol] (06,73) arc (180:0:26);
fill[white] (17,72.9) arc (180:-45:15);
fill[oaploscol] (47,32) rectangle ++ (11,41.1);
fill[oaploscol] (32,32) circle[radius=32];
fill[white] (32,32) circle[radius=21];
fill[oaploscol] (32,32) circle[radius= 9];
end{tikzpicture}
}
% Open-Acess.net Open Acess symbol
% redrawn with TikZ from
% http://open-access.net/fileadmin/logos/oa.svg
% public domain according to
% https://commons.wikimedia.org/wiki/File:Open_access.svg
% might be covered by open-access.net's overall CC-BY 4.0
% https://creativecommons.org/licenses/by/4.0/
% https://open-access.net/impressum/
% the site states no specific conditions for use of the logo
% other than
% "Das Logo der Informationsplattform darf nachgenutzt werden,
% gerne mit einem Link zu open-access.net"
% on https://open-access.net/ueber-uns/
% see also https://open-access.net/community/materialien/
% logo by
% Medien + Design
% Center for Digital Systems
% Competence Center for E-Learning and Multimedia
% Freie Universität Berlin
definecolor{oanetgreen}{HTML}{356031}
definecolor{oanetyellow}{HTML}{f9c63a}
definecolor{oanetintersect}{HTML}{89923a}
newcommand*{oanetsymbol}{%
begin{tikzpicture}[x=1.1pt,y=1.1pt]
fill[oanetgreen] (4,4) circle[radius=4.3];
fill[oanetyellow] (11,4) ++ (0:4.3) arc (0:300:4.3)
-- (11,4) ++ (300:4.3) -- cycle;
begin{scope}
clip (4,4) circle[radius=4.3];
fill[oanetintersect] (11,4) circle[radius=4.3];
end{scope}
fill[white] (4,4) circle[radius=2.7];
fill[white] (11,4) circle[radius=2.7];
fill[oanetyellow] (11,4) ++ (2.7,.1) rectangle ++(1.6,-4.1);
end{tikzpicture}
}
% reusable box for the symbol, so the image is not
% processed on every use
newsavebox{oasymbolbox}
% choose oaplossymbol or oanetsymbol here
sbox{oasymbolbox}{oaplossymbol}
newcommand*{oasymbol}{usebox{oasymbolbox}}
newcommand*{halurl}[1]{http://hal.archives-ouvertes.fr/#1}
DeclareFieldFormat{eprint:hal}{%
ifhyperref
{href{halurl{#1}}{hal:~nolinkurl{#1}}}
{hal:~nolinkurl{#1}}}
makeatother
usepackage{filecontents}
begin{filecontents*}{jobname.bib}
@article{bib:A,
author = {Anne Uthor},
title = {Generic Title},
journal = {Journal},
year = {2018},
}
@article{bib:B,
author = {Anne Uthor},
title = {Open Access Title (HAL)},
journal = {Open Journal},
year = {2018},
eprinttype = {hal},
eprint = {hal-01917888},
}
@article{bib:C,
author = {Anne Uthor},
title = {Open Access Title (arXiv)},
journal = {Closed Journal},
year = {2018},
eprinttype = {arxiv},
eprint = {1811.03094},
}
@article{bib:D,
author = {Anne Uthor},
title = {Open Access Title (DOI)},
journal = {Open Journal},
year = {2018},
doi = {12345/67898.0},
options = {openaccess},
}
@article{bib:E,
author = {Anne Uthor},
title = {Open Access (URL)},
journal = {Open Journal},
year = {2018},
url = {https://example.com/~author/my_paper.pdf#page20},
options = {openaccess},
}
@article{bib:F,
author = {Anne Uthor},
title = {emph{Not} Open Access (DOI)},
journal = {Closed Journal},
year = {2018},
doi = {12345/67898.0},
}
end{filecontents*}
addbibresource{jobname.bib}
begin{document}
kant[1]
nocite{*}
printbibliography
end{document}
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 yesterday
answered 2 days ago
moewe
82.2k7102314
82.2k7102314
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
2 days ago
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
2 days ago
Sounds very good!
– pluton
2 days ago
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
2 days ago
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
2 days ago
Sounds very good!
– pluton
2 days ago
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
2 days ago
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
2 days ago
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
2 days ago
@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
2 days ago
Sounds very good!
– pluton
2 days ago
Sounds very good!
– pluton
2 days ago
add a comment |
up vote
4
down vote
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
newcommand{MyMaybeOpenAccess}[1]{%
directlua{
local http = require('socket.http')
local url = 'https://api.unpaywall.org/v2/' .. luastring{#1} .. '?email=your@email'
body, code, headers, status = http.request(url)
if code == 200 and body then
local found = string.match(body, '"is_oa": ([a-z]+)')
if found == "true" then
tex.print("noexpand\marginpar{noexpand\includegraphics[width=0.3cm]{open-access-logo}}")
end
end
}}
(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.)
add a comment |
up vote
4
down vote
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
newcommand{MyMaybeOpenAccess}[1]{%
directlua{
local http = require('socket.http')
local url = 'https://api.unpaywall.org/v2/' .. luastring{#1} .. '?email=your@email'
body, code, headers, status = http.request(url)
if code == 200 and body then
local found = string.match(body, '"is_oa": ([a-z]+)')
if found == "true" then
tex.print("noexpand\marginpar{noexpand\includegraphics[width=0.3cm]{open-access-logo}}")
end
end
}}
(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.)
add a comment |
up vote
4
down vote
up vote
4
down vote
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
newcommand{MyMaybeOpenAccess}[1]{%
directlua{
local http = require('socket.http')
local url = 'https://api.unpaywall.org/v2/' .. luastring{#1} .. '?email=your@email'
body, code, headers, status = http.request(url)
if code == 200 and body then
local found = string.match(body, '"is_oa": ([a-z]+)')
if found == "true" then
tex.print("noexpand\marginpar{noexpand\includegraphics[width=0.3cm]{open-access-logo}}")
end
end
}}
(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
newcommand{MyMaybeOpenAccess}[1]{%
directlua{
local http = require('socket.http')
local url = 'https://api.unpaywall.org/v2/' .. luastring{#1} .. '?email=your@email'
body, code, headers, status = http.request(url)
if code == 200 and body then
local found = string.match(body, '"is_oa": ([a-z]+)')
if found == "true" then
tex.print("noexpand\marginpar{noexpand\includegraphics[width=0.3cm]{open-access-logo}}")
end
end
}}
(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 2 days ago
Eric Marsden
42625
42625
add a comment |
add a comment |
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
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
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
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
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
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
2 days ago
1
Related tex.stackexchange.com/q/402765/35864, tex.stackexchange.com/q/156706/35864
– moewe
2 days ago
1
This one may also be of interest: tex.stackexchange.com/a/411050/105447
– gusbrs
2 days ago
2
Btw, +1 for the open access commitment. :)
– gusbrs
2 days ago
2
Off-topic: this logo you included in the question looks very much like "restricted access" to me.
– gusbrs
2 days ago