| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2024 Christian Schreinemachers |
| 4 |
% |
| 5 |
% This work may be distributed and/or modified under the conditions |
| 6 |
% of the LaTeX Project Public License, either version 1.3c of this |
| 7 |
% license or (at your option) any later version. The latest version |
| 8 |
% of this license is in |
| 9 |
% |
| 10 |
% http://www.latex-project.org/lppl.txt |
| 11 |
% |
| 12 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 13 |
% version 2008-05-04 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status `maintained'. |
| 16 |
% |
| 17 |
% The current maintainer of this work is Christian Schreinemachers. |
| 18 |
% |
| 19 |
% This work consists of the files |
| 20 |
% README.md |
| 21 |
% bib2qr.dtx |
| 22 |
% bib2qr.ins |
| 23 |
% and the derived files |
| 24 |
% bib2qr.sty |
| 25 |
% bib2qr.pdf |
| 26 |
% |
| 27 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 28 |
% |
| 29 |
% \fi |
| 30 |
% \iffalse |
| 31 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 32 |
%<package>\ProvidesPackage{bib2qr} |
| 33 |
%<package> [2024-07-31 v0.2 Cite BibTeX entries with QR codes] |
| 34 |
% |
| 35 |
%<*driver> |
| 36 |
\documentclass[a4paper]{ltxdoc} |
| 37 |
\usepackage[T1]{fontenc} |
| 38 |
\usepackage[toc]{multitoc} |
| 39 |
\usepackage{geometry} |
| 40 |
\usepackage{fancyvrb} |
| 41 |
% Declare example reference entries |
| 42 |
\begin{filecontents}[overwrite]{example-references.bib} |
| 43 |
@software{bib2qr, |
| 44 |
author = {Schreinemachers, Christian}, |
| 45 |
title = {bib2qr - A LaTeX package for citing BibTeX entries with QR codes}, |
| 46 |
url = {https://codeberg.org/Cs137/bib2qr/releases/tag/v0.2}, |
| 47 |
version = {v0.2}, |
| 48 |
date = {2024-07-31} |
| 49 |
} |
| 50 |
@article{Doe2024, |
| 51 |
author = {Doe, Jane}, |
| 52 |
title = {A comprehensive study on example generation}, |
| 53 |
journal = {Journal of Examples}, |
| 54 |
year = {2024}, |
| 55 |
volume = {42}, |
| 56 |
pages = {1982--2024}, |
| 57 |
doi = {10.1234/example.2024.001} |
| 58 |
} |
| 59 |
@article{Mustermann2023, |
| 60 |
author = {Mustermann, Erika}, |
| 61 |
title = {Limitations in including electronic references in articles}, |
| 62 |
journal = {Journal of Examples}, |
| 63 |
year = {2023}, |
| 64 |
volume = {23}, |
| 65 |
pages = {624--666} |
| 66 |
} |
| 67 |
\end{filecontents} |
| 68 |
\usepackage[style=authoryear,sorting=none]{biblatex} |
| 69 |
\addbibresource{example-references.bib} |
| 70 |
\usepackage[% |
| 71 |
pdfusetitle,% |
| 72 |
hyperindex=false,% |
| 73 |
pdfsubject={LaTeX package documentation},% |
| 74 |
pdfkeywords={bib2qr, biblatex, latex, qrcode, documentation}% |
| 75 |
]{hyperref} |
| 76 |
\usepackage{scrextend} |
| 77 |
\usepackage{cleveref} |
| 78 |
\usepackage[qrwidth=1.25cm]{bib2qr} |
| 79 |
\EnableCrossrefs |
| 80 |
\CodelineIndex |
| 81 |
\RecordChanges |
| 82 |
\DoNotIndex{\begin,\DeclareBibliographyDriver,\DeclareCiteCommand,\DeclareFieldFormat, |
| 83 |
\DeclareKeys,\dimexpr,\edef,\end,\equal,\fullcite,\hspace,\IfBeginWith, |
| 84 |
\ifboolexpr,\iffieldundef,\ifthenelse,\linewidth,\multicitedelim, |
| 85 |
\NewDocumentCommand,\newcommand,\noindent,\par,\parindent,\printfield, |
| 86 |
\ProcessKeyOptions,\qrcode,\RequirePackage,\relax,\SetKeys,\space, |
| 87 |
\thefield,\usebibmacro,\usedriver} |
| 88 |
\setcounter{IndexColumns}{2} |
| 89 |
\setlength{\IndexMin}{40ex} |
| 90 |
\setlength{\columnseprule}{.4pt} |
| 91 |
\addtolength{\oddsidemargin}{2cm} |
| 92 |
\addtolength{\textwidth}{-2cm} |
| 93 |
\begin{document} |
| 94 |
\DocInput{bib2qr.dtx} |
| 95 |
\end{document} |
| 96 |
%</driver> |
| 97 |
% \fi |
| 98 |
% |
| 99 |
% \pagestyle{headings} |
| 100 |
% |
| 101 |
% \newcommand*{\package}[1]{\textsf{#1}} |
| 102 |
% \newcommand*{\ctanpkg}[1]{\href{https://ctan.org/pkg/#1}{\package{#1}}} |
| 103 |
% \newcommand*{\opt}[1]{\texttt{#1}} |
| 104 |
% \newcommand*{\default}[1]{(default: \opt{#1})} |
| 105 |
% |
| 106 |
% |
| 107 |
% ^^A ----------------------------- |
| 108 |
% |
| 109 |
% \changes{v0.2}{2024-07-31}{% |
| 110 |
% Initial release, |
| 111 |
% convert into dtx, |
| 112 |
% add documentation, |
| 113 |
% rename internal macros, |
| 114 |
% add \opt{qrdelimiter} option |
| 115 |
% } |
| 116 |
% \changes{v0.1}{2024/06/16}{Initial version} |
| 117 |
% |
| 118 |
% \GetFileInfo{bib2qr.sty} |
| 119 |
% |
| 120 |
% |
| 121 |
% ^^A ----------------------------- |
| 122 |
% |
| 123 |
% \title{The \package{bib2qr} package} |
| 124 |
% \author{Christian Schreinemachers} |
| 125 |
% \date{% |
| 126 |
% Released \filedate\thanks{% |
| 127 |
% \package{bib2qr}~\fileversion |
| 128 |
% ~(\href{https://codeberg.org/Cs137/bib2qr/releases/tag/\fileversion}{source code})}% |
| 129 |
% } |
| 130 |
% \maketitle |
| 131 |
% |
| 132 |
% |
| 133 |
% ^^A ----------------------------- |
| 134 |
% |
| 135 |
% \begingroup |
| 136 |
% \hypersetup{ |
| 137 |
% linkcolor=., |
| 138 |
% citecolor=., |
| 139 |
% urlcolor=., |
| 140 |
% } |
| 141 |
% \begin{abstract} |
| 142 |
% The \package{bib2qr} package provides functionality to cite BibTeX entries |
| 143 |
% with QR codes for easy sharing and referencing. The target of the QR code |
| 144 |
% is the entry's digital object identifier (DOI), or URL if no DOI exists. |
| 145 |
% It is realised in the \cs{qrcite} macro, via the \LaTeX{} packages |
| 146 |
% \package{biblatex} and \package{qrcode}. In addition to the \cs{qrcite} |
| 147 |
% command, the package contains the \cs{qrfullcite} macro, which requires |
| 148 |
% only a BibTeX key as argument and allows to generate output that might |
| 149 |
% look as follows:\\ |
| 150 |
% \textcolor{red}{\qrfullcite[noindent]{bib2qr}} |
| 151 |
% \end{abstract} |
| 152 |
% \endgroup |
| 153 |
% |
| 154 |
% |
| 155 |
% ^^A ----------------------------- |
| 156 |
% |
| 157 |
% \tableofcontents |
| 158 |
% |
| 159 |
% |
| 160 |
% ^^A ----------------------------- |
| 161 |
% |
| 162 |
% \section{Introduction} |
| 163 |
% ^^A |
| 164 |
% I like to include \href{https://en.wikipedia.org/wiki/QR_code}{quick-response (QR) codes} |
| 165 |
% of references on slides created with \LaTeX{} \ctanpkg{beamer}. Previously, |
| 166 |
% I did this by using the \ctanpkg{qrcode} package and manually declaring the |
| 167 |
% URL of the reference's digital object identifier (DOI). Occasionally, I also |
| 168 |
% add human-readable information generated via \cs{fullcite} from the |
| 169 |
% \ctanpkg{biblatex} package. |
| 170 |
% |
| 171 |
% To avoid manually declaring the URL and calling two separate commands for QR |
| 172 |
% codes and human-readable citations, I developed this \LaTeX{} package. It |
| 173 |
% automates the inclusion of QR codes by a \package{biblatex} bibliography |
| 174 |
% driver\footnote{% |
| 175 |
% \href{http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf\#page=166} |
| 176 |
% {\package{biblatex} documentation p.\,166 (v3.20)}% |
| 177 |
% }, |
| 178 |
% which uses field formats to display QR codes for the entry's \opt{doi} |
| 179 |
% and \opt{url} fields with the \package{qrcode} package. You can cite any |
| 180 |
% reference from your bibliography with this driver by declaring its \meta{key} |
| 181 |
% to the \cs{qrcite} command. The latter is a cite command\footnote{% |
| 182 |
% \href{http://mirrors.ctan.org/macros/latex/contrib/biblatex/doc/biblatex.pdf\#page=186}% |
| 183 |
% {\package{biblatex} documentation p.\,186 (v3.20)}% |
| 184 |
% \label{biblatexCiteCommand}% |
| 185 |
% }, |
| 186 |
% which ensures that any referenced QR code is also listed in the reference list. |
| 187 |
% |
| 188 |
% For the inclusion of both, QR codes and human-readable citation information |
| 189 |
% in a single step, I introduced the \cs{qrfullcite} command. It applies the |
| 190 |
% \cs{qrcite} command and the \cs{fullcite} command from the \package{biblatex} |
| 191 |
% package, ensuring clarity and ease of reference not only on \package{beamer} |
| 192 |
% slides, but in any \LaTeX{} document. |
| 193 |
% |
| 194 |
% |
| 195 |
% ^^A ----------------------------- |
| 196 |
% |
| 197 |
% \section{Usage} |
| 198 |
% ^^A |
| 199 |
% Load the package in your document's preamble and specify any of the |
| 200 |
% options described in the next subsection as follows: |
| 201 |
% |
| 202 |
% \begin{quote} |
| 203 |
% \cs{usepackage}\oarg{option(s)}\{bib2qr\} |
| 204 |
% \end{quote} |
| 205 |
% |
| 206 |
% |
| 207 |
% ^^A ----------------------------- |
| 208 |
% |
| 209 |
% \subsection{Options} |
| 210 |
% ^^A |
| 211 |
% In order to change the default behaviour of this package, declare one |
| 212 |
% or more of the options described in this subsection with your desired |
| 213 |
% value. |
| 214 |
% |
| 215 |
% \begin{description} |
| 216 |
% |
| 217 |
% \item[\opt{doiurlbase=\meta{string}}] \default{https://doi.org/} |
| 218 |
% specifies the prefix to convert a DOI string into its URL. If the DOI |
| 219 |
% string starts with \meta{doiurlbase}, it is used as is to generate a |
| 220 |
% QR code. Otherwise, the DOI string is appended to \meta{doiurlbase} to |
| 221 |
% form the DOI's URL, which is then used to generate the QR code. |
| 222 |
% In normal use cases this option does not require any adjustment. |
| 223 |
% |
| 224 |
% \item[\opt{qrdelimiter=\meta{sepcode}}] \default{\cs{space}} |
| 225 |
% specifies the delimiter of QR codes generated by \cs{qrcite} in multicite |
| 226 |
% mode. It is shown between the individual QR codes of multiple references |
| 227 |
% created by \cs{qrcite}\marg{key1,key2,\dots keyN} and \emph{``\dots is |
| 228 |
% arbitrary code to be executed after each iteration...''}\,\footref{biblatexCiteCommand}. |
| 229 |
% The examples shown in this document were generated considering the |
| 230 |
% default \opt{qrdelimiter}. |
| 231 |
% |
| 232 |
% \item[\opt{qrversion=\meta{version specification}}] \default{0} |
| 233 |
% sets the version of the QR code. Consult the \package{qrcode} documentation |
| 234 |
% for details about the \meta{version specification}\footnote{% |
| 235 |
% \href{http://mirrors.ctan.org/macros/latex/contrib/qrcode/qrcode.pdf\#page=3} |
| 236 |
% {\package{qrcode} documentation p.\,3 (v1.51)}% |
| 237 |
% }. |
| 238 |
% The examples shown in this document were generated considering the |
| 239 |
% default \opt{qrversion}. |
| 240 |
% |
| 241 |
% \item[\opt{qrwidth=\meta{dimen}}] \default{2cm} |
| 242 |
% sets the width of the QR code. The value is used to determine the |
| 243 |
% width for the output of the \cs{fullcite} macro and is passed to |
| 244 |
% \package{qrcode} as \opt{height} option. The default value is quite |
| 245 |
% suitable for usage in \LaTeX{} \package{beamer} slides, but in such |
| 246 |
% documents as this one, a smaller width might be desired. The examples |
| 247 |
% shown in this document were generated using \opt{qrwidth=1.25cm}. |
| 248 |
% |
| 249 |
% \end{description} |
| 250 |
% |
| 251 |
% |
| 252 |
% ^^A ----------------------------- |
| 253 |
% |
| 254 |
% \subsection{Macros} |
| 255 |
% ^^A |
| 256 |
% \subsubsection*{\cs{qrcite}\marg{key(s)}} |
| 257 |
% |
| 258 |
% \DescribeMacro{\qrcite} |
| 259 |
% QR code(s) with a link to the reference's DOI or URL can be generated |
| 260 |
% using the \cs{qrcite} command. The target of the QR code is the entry's |
| 261 |
% DOI converted into a URL, or the URL iteself. In case the BibTeX entry has |
| 262 |
% no DOI and no URL, it does nothing besides raising a warning. |
| 263 |
% ^^A |
| 264 |
% The output for some example entries is shown underneath. If you |
| 265 |
% would like to replicate the examples, you can find the entries |
| 266 |
% sources as \cref{ssec:example_bib}. The colours are defined in the |
| 267 |
% examples, as this functionality is out of scope of the package |
| 268 |
% \package{bib2qr}. Moreover, \package{hyperlink} is configured in such |
| 269 |
% a way that the links in the following examples consider the font colour, |
| 270 |
% usually links would be presented in the colour defined as \opt{linkcolor}. |
| 271 |
% |
| 272 |
% The example displayed in blue was created via \textcolor{blue}{% |
| 273 |
% \cs{qrcite\{bib2qr\}}}. The QR code in red next to it was generated |
| 274 |
% via \textcolor{red}{\cs{qrcite\{Doe2024\}}}. The entry of the latter has a |
| 275 |
% DOI, while the entry of the blue example represents a BibTeX entry without |
| 276 |
% a DOI, but there is a value assigned to its URL field. |
| 277 |
% ^^A |
| 278 |
% The macro \cs{qrcite} is a cite command, thus it can be used to cite multiple |
| 279 |
% references, as shown in black (\cs{qrcite\{bib2qr,Doe2024\}}), and entries |
| 280 |
% cited via \cs{qrcite} are included in the document's bibliography |
| 281 |
% (cf. \cref{ssec:example_ref}). |
| 282 |
% |
| 283 |
% \begingroup |
| 284 |
% \hypersetup{ |
| 285 |
% linkcolor=., |
| 286 |
% citecolor=., |
| 287 |
% urlcolor=., |
| 288 |
% } |
| 289 |
% |
| 290 |
% \par\smallskip% |
| 291 |
% \noindent% |
| 292 |
% \textcolor{blue}{\qrcite{bib2qr}} |
| 293 |
% \textcolor{red}{\qrcite{Doe2024}} |
| 294 |
% \qrcite{bib2qr,Doe2024} |
| 295 |
% \par\medskip% |
| 296 |
% |
| 297 |
% \subsubsection*{\cs{qrfullcite}\marg{key}} |
| 298 |
% |
| 299 |
% \DescribeMacro{\qrfullcite} |
| 300 |
% This command displays the QR code of a BibTeX entry's DOI link or URL and |
| 301 |
% a full citation. The QR code is generated by \cs{qrcite} and the full |
| 302 |
% citation by \cs{fullcite}, provided by the package \package{biblatex}. |
| 303 |
% Each output is presented in individual minipages which are placed next to |
| 304 |
% each other, as shown in the examples underneath |
| 305 |
% (\textcolor{blue}{\cs{qrfullcite\{bib2qr\}}}, |
| 306 |
% \textcolor{red}{\cs{qrfullcite[noindent]\{Doe2024\}}}). |
| 307 |
% |
| 308 |
% Please note that \cs{qrfullcite} does \textbf{not} support group |
| 309 |
% citations and accepts only a single \meta{key} as argument. |
| 310 |
% |
| 311 |
% \textcolor{blue}{\qrfullcite{bib2qr}}% |
| 312 |
% \medskip% |
| 313 |
% \textcolor{red}{\qrfullcite[noindent]{Doe2024}}% |
| 314 |
% \medskip% |
| 315 |
% \endgroup |
| 316 |
% |
| 317 |
% The output of \cs{qrfullcite} is considered as its own paragraph, thus it |
| 318 |
% may be indented, like in this document (see blue example). You can prevent |
| 319 |
% the latter by providing the \opt{noindent} option when calling the macro, |
| 320 |
% as done in the red example. |
| 321 |
% |
| 322 |
% The first minipage has the width of the package option \opt{qrwidth} |
| 323 |
% and displays the output of \cs{qrcite}\marg{key}. The second minipage |
| 324 |
% occupies the remaining width of \cs{linewidth} considering a gap of |
| 325 |
% \opt{0.5em} and \cs{parindent}, if the latter is not deactivated via the |
| 326 |
% \opt{noindent} option. It shows the output of \cs{fullcite}\marg{key}. |
| 327 |
% |
| 328 |
% |
| 329 |
% ^^A ----------------------------- |
| 330 |
% |
| 331 |
% \subsection{Hints} |
| 332 |
% ^^A |
| 333 |
% If the \package{hyperref} package is loaded, not only the DOI/URL strings, |
| 334 |
% but also the QR codes are presented as links. It was modified in this |
| 335 |
% document to allow you to distinguish the output of the individual macro calls |
| 336 |
% in a better way. The previous example without any modifications of the |
| 337 |
% document settings and without deactivating the indentation looks as follows:\\ |
| 338 |
% |
| 339 |
% \qrfullcite{Doe2024}% |
| 340 |
% |
| 341 |
% |
| 342 |
% ^^A ----------------------------- |
| 343 |
% |
| 344 |
% \subsection{Known limitations} |
| 345 |
% ^^A |
| 346 |
% In case no QR code can be generated by \cs{qrcite} called via \cs{qrfullcite}, |
| 347 |
% the output of \cs{fullcite} is nevertheless indented by the width assigned to |
| 348 |
% the \opt{qrwidth} package option and the length of the gap of \opt{0.5em}), |
| 349 |
% as shown in orange below (\textcolor{orange}{\cs{qrcite\{Mustermann2023\}}}). |
| 350 |
% |
| 351 |
% \textcolor{orange}{\qrfullcite{Mustermann2023}}% |
| 352 |
% |
| 353 |
% |
| 354 |
% ^^A ----------------------------- |
| 355 |
% |
| 356 |
% \MaybeStop{ |
| 357 |
% |
| 358 |
% \IndexPrologue{% |
| 359 |
% \section{Index} |
| 360 |
% Numbers written in italic refer to the page where the corresponding entry |
| 361 |
% is described; numbers underlined refer to the code line of the definition; |
| 362 |
% numbers in roman refer to the code lines where the entry is used. |
| 363 |
% } |
| 364 |
% \PrintIndex |
| 365 |
% |
| 366 |
% \GlossaryPrologue{% |
| 367 |
% \section{Change History} |
| 368 |
% The changes listed in this section aim to provide a brief overview of the |
| 369 |
% changes introduced into the package \package{bib2qr}. The |
| 370 |
% \href{https://codeberg.org/Cs137/bib2qr/}{package repository on Codeberg} |
| 371 |
% contains a |
| 372 |
% \href{https://codeberg.org/Cs137/bib2qr/src/branch/main/CHANGELOG.md}{changelog file}, |
| 373 |
% consult it to read a detailed description of the changes introduced into |
| 374 |
% this package. |
| 375 |
% } |
| 376 |
% \PrintChanges |
| 377 |
% |
| 378 |
% ^^A ----------------------------- |
| 379 |
% |
| 380 |
% \newpage |
| 381 |
% \appendix |
| 382 |
% |
| 383 |
% \section{Appendix} |
| 384 |
% |
| 385 |
% The examples presented in this document are based on the |
| 386 |
% BibTeX entries listed in \ref{ssec:example_bib} and result |
| 387 |
% in the bibliography shown as \ref{ssec:example_ref} (\package{biblatex} |
| 388 |
% options: \opt{style=authoryear}, \opt{sorting=none}). |
| 389 |
% |
| 390 |
% \subsection{Example BibTeX entries} |
| 391 |
% \label{ssec:example_bib} |
| 392 |
% \small{% |
| 393 |
% \VerbatimInput[firstline=5]{example-references.bib} |
| 394 |
% } |
| 395 |
% |
| 396 |
% \subsection{Example bibliography} |
| 397 |
% \label{ssec:example_ref} |
| 398 |
% \printbibliography[heading=none] |
| 399 |
% |
| 400 |
% } |
| 401 |
% |
| 402 |
% |
| 403 |
% ^^A ----------------------------- |
| 404 |
% |
| 405 |
% \section{Implementation} |
| 406 |
% ^^A |
| 407 |
% |
| 408 |
% \subsection{Dependencies} |
| 409 |
% ^^A |
| 410 |
% In order to use \package{bib2qr}, the \LaTeX{} packages |
| 411 |
% \ctanpkg{biblatex}, |
| 412 |
% \ctanpkg{ifthen}, |
| 413 |
% \ctanpkg{qrcode}, and |
| 414 |
% \ctanpkg{xstring} |
| 415 |
% are required as package dependencies. |
| 416 |
% \iffalse |
| 417 |
%<*package> |
| 418 |
% \fi |
| 419 |
% \begin{macrocode} |
| 420 |
\RequirePackage{biblatex} |
| 421 |
\RequirePackage{ifthen} |
| 422 |
\RequirePackage{qrcode} |
| 423 |
\RequirePackage{xstring} |
| 424 |
% \end{macrocode} |
| 425 |
% |
| 426 |
% |
| 427 |
% \subsection{Options} |
| 428 |
% ^^A |
| 429 |
% The package options are internally available as \cs{@bibiiqr@}\meta{option}. |
| 430 |
% \begin{macrocode} |
| 431 |
\DeclareKeys[@bibiiqr]{ |
| 432 |
doiurlbase.store = \@bibiiqr@doiurlbase, |
| 433 |
doiurlbase.usage = load, |
| 434 |
qrdelimiter.store = \@bibiiqr@qrdelimiter, |
| 435 |
qrdelimiter.usage = load, |
| 436 |
qrversion.store = \@bibiiqr@qrversion, |
| 437 |
qrversion.usage = load, |
| 438 |
qrwidth.store = \@bibiiqr@qrwidth, |
| 439 |
qrwidth.usage = load, |
| 440 |
}% |
| 441 |
% \end{macrocode} |
| 442 |
% |
| 443 |
% \subsubsection*{Assignement of default values} |
| 444 |
% \begin{macrocode} |
| 445 |
\SetKeys[@bibiiqr]{ |
| 446 |
doiurlbase=https://doi.org/, |
| 447 |
qrdelimiter=\space, |
| 448 |
qrversion=0, |
| 449 |
qrwidth=2cm, |
| 450 |
}% |
| 451 |
% \end{macrocode} |
| 452 |
% |
| 453 |
% \subsubsection*{Processing of package options} |
| 454 |
% \begin{macrocode} |
| 455 |
\ProcessKeyOptions[@bibiiqr]\relax |
| 456 |
% \end{macrocode} |
| 457 |
% |
| 458 |
% \subsection{Macros} |
| 459 |
% |
| 460 |
% \begin{macro}{\@bibiiqr@showqr} |
| 461 |
% \marg{string}\\ |
| 462 |
% Display a string as QR code considering the package options \opt{qrversion} |
| 463 |
% and \opt{qrwidth}. |
| 464 |
% \begin{macrocode} |
| 465 |
\newcommand\@bibiiqr@showqr[1]{% |
| 466 |
\qrcode[height=\@bibiiqr@qrwidth,version=\@bibiiqr@qrversion]{#1}% |
| 467 |
}% |
| 468 |
% \end{macrocode} |
| 469 |
% \end{macro} |
| 470 |
% |
| 471 |
% |
| 472 |
% \subsubsection{Field formats} |
| 473 |
% |
| 474 |
% Custom field formats are defined to display a QR code of an entry's |
| 475 |
% \texttt{doi} and \texttt{url}. |
| 476 |
% |
| 477 |
% \begin{macro}{@bibiiqr@fldFmtDoi} |
| 478 |
% Field format to display a DOI field's value (converted into an URL |
| 479 |
% considering the option \opt{@bibiiqr@doiurlbase}) as QR code using |
| 480 |
% macro \cs{@bibiiqr@showqr}. |
| 481 |
% \begin{macrocode} |
| 482 |
\DeclareFieldFormat{@bibiiqr@fldFmtDoi}{% |
| 483 |
\IfBeginWith{#1}{\@bibiiqr@doiurlbase}% |
| 484 |
{\@bibiiqr@showqr{#1}}% |
| 485 |
{\@bibiiqr@showqr{\@bibiiqr@doiurlbase#1}}% |
| 486 |
}% |
| 487 |
% \end{macrocode} |
| 488 |
% \end{macro} |
| 489 |
% |
| 490 |
% \begin{macro}{@bibiiqr@fldFmtUrl} |
| 491 |
% Field format to display an URL field's value as QR code using \cs{@bibiiqr@showqr}. |
| 492 |
% \begin{macrocode} |
| 493 |
\DeclareFieldFormat{@bibiiqr@fldFmtUrl}{\@bibiiqr@showqr{#1}} |
| 494 |
% \end{macrocode} |
| 495 |
% \end{macro} |
| 496 |
% |
| 497 |
% |
| 498 |
% \subsubsection{Bibliography driver} |
| 499 |
% |
| 500 |
% \begin{macro}{@bibiiqr@bibDrvQR} |
| 501 |
% This bibliography driver |
| 502 |
% allows to display the QR code of an entry's DOI-, or URL field. |
| 503 |
% It applies the \cs{printfield}\oarg{format}\marg{field} macro, which is |
| 504 |
% provided by the \package{biblatex} package to displpay a QR code using the |
| 505 |
% \texttt{@bibiiqr@fldFmtDoi} or \texttt{@bibiiqr@fldFmtUrl} field format and |
| 506 |
% the corresponding field, respectively. |
| 507 |
% |
| 508 |
% The DOI is preferred and the URL is only used if no value is assigned to |
| 509 |
% the DOI field. If neither the DOI, nor the URL field contains a value, a |
| 510 |
% package warning is raised. |
| 511 |
% |
| 512 |
% \begin{macrocode} |
| 513 |
\DeclareBibliographyDriver{@bibiiqr@bibDrvQR}{% |
| 514 |
\usebibmacro{begentry}% |
| 515 |
\ifboolexpr{test{\iffieldundef{doi}}} |
| 516 |
{% |
| 517 |
\ifboolexpr{test{\iffieldundef{url}}}% |
| 518 |
% \end{macrocode} |
| 519 |
% The entry has no DOI and no URL: Raise a warning. |
| 520 |
% \begin{macrocode} |
| 521 |
{% |
| 522 |
\PackageWarning{bib2qr}% |
| 523 |
{BibTeX entry without DOI or URL: \thefield{entrykey}}{}% |
| 524 |
}% |
| 525 |
% \end{macrocode} |
| 526 |
% The entry has no DOI but an URL: Display the \texttt{url} field's |
| 527 |
% value using the \texttt{@bibiiqr@fldFmtUrl} field format. |
| 528 |
% \begin{macrocode} |
| 529 |
{\printfield[@bibiiqr@fldFmtUrl]{url}}% |
| 530 |
}% |
| 531 |
% \end{macrocode} |
| 532 |
% The entry has a DOI: Display the \texttt{doi} field's value using |
| 533 |
% the \texttt{@bibiiqr@fldFmtDoi} field format. |
| 534 |
% \begin{macrocode} |
| 535 |
{\printfield[@bibiiqr@fldFmtDoi]{doi}}% |
| 536 |
\usebibmacro{finentry}% |
| 537 |
} |
| 538 |
% \end{macrocode} |
| 539 |
% \end{macro} |
| 540 |
% |
| 541 |
% \subsubsection{Author commands} |
| 542 |
% |
| 543 |
% \begin{macro}{\qrcite} |
| 544 |
% \marg{key(s)}\\ |
| 545 |
% Display the QR code of a BibTeX entry's DOI link or URL by introducing the |
| 546 |
% cite command \cs{qrcite}\marg{key}, which makes use of the previously |
| 547 |
% defined bibliography driver \texttt{@bibiiqr@bibDrvQR}. It requires at least |
| 548 |
% one BibTeX \marg{key} as argument. |
| 549 |
% \begin{macrocode} |
| 550 |
\DeclareCiteCommand{\qrcite} |
| 551 |
{\usebibmacro{prenote}}% |
| 552 |
{\usedriver{}{@bibiiqr@bibDrvQR}}% |
| 553 |
{\@bibiiqr@qrdelimiter}% |
| 554 |
{\usebibmacro{postnote}}% |
| 555 |
% \end{macrocode} |
| 556 |
% \end{macro} |
| 557 |
% |
| 558 |
% \begin{macro}{\qrfullcite} |
| 559 |
% \changes{v0.2}{2024-07-31}{Add \opt{noindent} option} |
| 560 |
% \oarg{option(s)}\marg{key}\\ |
| 561 |
% Display the QR code of a singe BibTeX entry's DOI link or URL and a full |
| 562 |
% citation of it. Specify \opt{noindent} as option, if the output should not |
| 563 |
% be indented. |
| 564 |
% \begin{macrocode} |
| 565 |
\NewDocumentCommand{\qrfullcite}{O{}m}{% |
| 566 |
\par% |
| 567 |
\ifthenelse{\equal{#1}{noindent}}{% |
| 568 |
\noindent% |
| 569 |
\edef\@bibiiqr@mpiiwidth{\dimexpr\linewidth-\@[email protected]}% |
| 570 |
}{% |
| 571 |
\edef\@bibiiqr@mpiiwidth{% |
| 572 |
\dimexpr\linewidth-\parindent-\@[email protected]}% |
| 573 |
}% |
| 574 |
\begin{minipage}[t]{\@bibiiqr@qrwidth} |
| 575 |
\qrcite{#2}% |
| 576 |
\end{minipage} |
| 577 |
\hspace{0.5em}% |
| 578 |
\begin{minipage}{\@bibiiqr@mpiiwidth} |
| 579 |
\fullcite{#2}% |
| 580 |
\end{minipage} |
| 581 |
\par% |
| 582 |
}% |
| 583 |
% \end{macrocode} |
| 584 |
% \end{macro} |
| 585 |
% |
| 586 |
% \iffalse |
| 587 |
%</package> |
| 588 |
% \fi |
| 589 |
% |
| 590 |
% |
| 591 |
% ^^A ----------------------------- |
| 592 |
% |
| 593 |
% \Finale |
| 594 |
|