1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
%%
%% This is file `bib2qr.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% bib2qr.dtx (with options: `package')
%%
%% Copyright (C) 2024 Christian Schreinemachers
%%
%% This work may be distributed and/or modified under the conditions
%% of the LaTeX Project Public License, either version 1.3c of this
%% license or (at your option) any later version. The latest version
%% of this license is in
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008-05-04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The current maintainer of this work is
%% Christian Schreinemachers.
%%
%% This work consists of the files
%% bib2qr.dtx
%% bib2qr.ins
%% and the derived files
%% bib2qr.sty
%% bib2qr.pdf
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{bib2qr}
[2024-07-31 v0.2 Cite BibTeX entries with QR codes]
\RequirePackage{biblatex}
\RequirePackage{ifthen}
\RequirePackage{qrcode}
\RequirePackage{xstring}
\DeclareKeys[@bibiiqr]{
doiurlbase.store = \@bibiiqr@doiurlbase,
doiurlbase.usage = load,
qrdelimiter.store = \@bibiiqr@qrdelimiter,
qrdelimiter.usage = load,
qrversion.store = \@bibiiqr@qrversion,
qrversion.usage = load,
qrwidth.store = \@bibiiqr@qrwidth,
qrwidth.usage = load,
}%
\SetKeys[@bibiiqr]{
doiurlbase=https://doi.org/,
qrdelimiter=\space,
qrversion=0,
qrwidth=2cm,
}%
\ProcessKeyOptions[@bibiiqr]\relax
\newcommand\@bibiiqr@showqr[1]{%
\qrcode[height=\@bibiiqr@qrwidth,version=\@bibiiqr@qrversion]{#1}%
}%
\DeclareFieldFormat{@bibiiqr@fldFmtDoi}{%
\IfBeginWith{#1}{\@bibiiqr@doiurlbase}%
{\@bibiiqr@showqr{#1}}%
{\@bibiiqr@showqr{\@bibiiqr@doiurlbase#1}}%
}%
\DeclareFieldFormat{@bibiiqr@fldFmtUrl}{\@bibiiqr@showqr{#1}}
\DeclareBibliographyDriver{@bibiiqr@bibDrvQR}{%
\usebibmacro{begentry}%
\ifboolexpr{test{\iffieldundef{doi}}}
{%
\ifboolexpr{test{\iffieldundef{url}}}%
{%
\PackageWarning{bib2qr}%
{BibTeX entry without DOI or URL: \thefield{entrykey}}{}%
}%
{\printfield[@bibiiqr@fldFmtUrl]{url}}%
}%
{\printfield[@bibiiqr@fldFmtDoi]{doi}}%
\usebibmacro{finentry}%
}
\DeclareCiteCommand{\qrcite}
{\usebibmacro{prenote}}%
{\usedriver{}{@bibiiqr@bibDrvQR}}%
{\@bibiiqr@qrdelimiter}%
{\usebibmacro{postnote}}%
\NewDocumentCommand{\qrfullcite}{O{}m}{%
\par%
\ifthenelse{\equal{#1}{noindent}}{%
\noindent%
\edef\@bibiiqr@mpiiwidth{\dimexpr\linewidth-\@bibiiqr@qrwidth-0.5em}%
}{%
\edef\@bibiiqr@mpiiwidth{%
\dimexpr\linewidth-\parindent-\@bibiiqr@qrwidth-0.5em}%
}%
\begin{minipage}[t]{\@bibiiqr@qrwidth}
\qrcite{#2}%
\end{minipage}
\hspace{0.5em}%
\begin{minipage}{\@bibiiqr@mpiiwidth}
\fullcite{#2}%
\end{minipage}
\par%
}%
\endinput
%%
%% End of file `bib2qr.sty'.
|