| 1 |
%% $Id: hvqrurl.tex 901 2024-05-26 07:18:06Z herbert $ |
| 2 |
\listfiles |
| 3 |
\errorcontextlines=100 |
| 4 |
\documentclass[twoside=on,usegeometry]{scrartcl} |
| 5 |
\usepackage{libertinus-otf} |
| 6 |
\setmonofont[Scale=MatchLowercase,FakeStretch=0.85]{DejaVu Sans Mono} |
| 7 |
\usepackage{microtype} |
| 8 |
\usepackage[english]{babel} |
| 9 |
\usepackage[automark]{scrlayer-scrpage} |
| 10 |
\pagestyle{scrheadings} |
| 11 |
|
| 12 |
\usepackage[showframe=false]{geometry} |
| 13 |
\usepackage{listings} |
| 14 |
\usepackage[imakeidx]{xindex} |
| 15 |
\makeindex |
| 16 |
% |
| 17 |
\lstset{% |
| 18 |
language=[LaTeX]TeX,% |
| 19 |
showstringspaces=false,% |
| 20 |
tabsize=5,% |
| 21 |
frame=single,% |
| 22 |
% lineskip=-1pt,% |
| 23 |
extendedchars=true,% |
| 24 |
basicstyle={\small\ttfamily},% |
| 25 |
% numbers=left,% |
| 26 |
% stepnumber=1,% |
| 27 |
% numberstyle=\tiny,% |
| 28 |
% xleftmargin=2em,% |
| 29 |
breaklines=true} |
| 30 |
% |
| 31 |
|
| 32 |
\usepackage{ragged2e} |
| 33 |
\usepackage{hvqrurl} |
| 34 |
\usepackage{hvdoctools} |
| 35 |
|
| 36 |
\usepackage{hyperref} |
| 37 |
\hypersetup{%urlcolor=blue, |
| 38 |
linktocpage, colorlinks=true}% |
| 39 |
|
| 40 |
\begin{document} |
| 41 |
\title{Package \texttt{hvqrurl}\\Creating a QR-code of an URL in the margin \\\small ver 0.09} |
| 42 |
\author{Herbert Voß\thanks{\protect\url{[email protected]}}} |
| 43 |
\date{\today} |
| 44 |
\maketitle |
| 45 |
|
| 46 |
|
| 47 |
\begin{abstract} |
| 48 |
This package allows to draw an URL as a QR code into the margin of a one- or twosided |
| 49 |
document. The following packages are loaded by default: |
| 50 |
\LPack{qrcode}, \LPack{marginnote}, \LPack{url}, \LPack{xcolor}, |
| 51 |
and |
| 52 |
\LPack{xkeyval}. |
| 53 |
\end{abstract} |
| 54 |
|
| 55 |
|
| 56 |
\section{Package option} |
| 57 |
There is only one package option \Lkeyword{forget}. If it is used, then all |
| 58 |
qrcodes are always created new and the already existing codes in the \Lext{aux} file |
| 59 |
are not used. The deafult is not to use this option. For example: 100 qrcodes needs |
| 60 |
about 30 seconds with option \Lkeyword{forget}, but only 4 seconds without it. It is obvious |
| 61 |
that for the first \LaTeX\ run the codes will allways be created new. |
| 62 |
If a qrcode is |
| 63 |
created, e.g. for \hvqrurl{https://pkks.de}, then there is something like |
| 64 |
|
| 65 |
\begin{verbatim} |
| 66 |
\qr@savematrix{https://pkks.de}{2}{3}{11111110001010011011111111000001001110110101000001101110100 |
| 67 |
0000011101011101101110101010001000101110110111010001111110010111011000001011010001001000001111111 |
| 68 |
1010101010101111111000000001111001110000000001100010000011101011010000000010011010110001101011001 |
| 69 |
0011100111001010111101101011001011110011100100011110010100001011010000010010010100101101101100011 |
| 70 |
1101111011111111110001101001010000001010011111100011100011000101011111100100000000011101110100010 |
| 71 |
0011111111001100110101010001100000100101100110001001110111010001010011111100001011101000110010110 |
| 72 |
010100101110101010010000011101110000010101110101001100001111111001001011100001001} |
| 73 |
\end{verbatim} |
| 74 |
|
| 75 |
in the \Lext{aux} file (all in one line!). This is always used in following |
| 76 |
\LaTeX\ runs and created only new if the URL changes or the option \Lkeyword{forget} |
| 77 |
is used. |
| 78 |
|
| 79 |
\section{The macros} |
| 80 |
|
| 81 |
\begin{BDef} |
| 82 |
\Lcs{hvqrset}\Largb{key=value, \ldots}\\ |
| 83 |
\Lcs{hvqrurl}\OptArg{key=value, \ldots}\Largb{URL}\\ |
| 84 |
\Lcs{hvqrurl*}\OptArg{key=value, \ldots}\Largb{URL} |
| 85 |
\end{BDef} |
| 86 |
|
| 87 |
With the default macro \Lcs{hvqrurl} the URL is printed as as QR code into the margin and |
| 88 |
in the the text as usual with the macro \Lcs{url}, for example \hvqrurl{https://mirror.ctan.org/pkg/hvqrurl}. |
| 89 |
With \LPack{hyperref} you'll get the the same color for the QR code as for the URL link and, of course, |
| 90 |
it is also a link. This example shows the output of the QR code with the default setting and |
| 91 |
an active \LPack{hyppref}. |
| 92 |
The star version of the command |
| 93 |
prints only the QR code but not the URL in the text. |
| 94 |
|
| 95 |
With \Lcs{hvqrset} one can set the optional arguments globally. For example if one do not want all |
| 96 |
QR codes not as a link when using \LPack{hyperref}: |
| 97 |
|
| 98 |
\begin{lstlisting} |
| 99 |
\hvqrset{qrlink=nolink} |
| 100 |
\end{lstlisting} |
| 101 |
|
| 102 |
|
| 103 |
\section{Optional arguments} |
| 104 |
|
| 105 |
\subsection{No link with \LPack{hyperref}} |
| 106 |
|
| 107 |
This needs package hyperref, which is loaded by default. With the optional argument |
| 108 |
\Lkeyword{nohyperref} you can prevent the loading of this package. |
| 109 |
|
| 110 |
\begin{lstlisting} |
| 111 |
With qrlink=nolink the QR code is no link: \hvqrurl[qrlink=nolink]{https://mirror.ctan.org/pkg/hvqrurl}. |
| 112 |
The default setting is qrlink=link. |
| 113 |
\end{lstlisting} |
| 114 |
With \Lkeyset{qrlink=nolink} the QR code is no link: \hvqrurl[qrlink=nolink]{https://mirror.ctan.org/pkg/hvqrurl}. |
| 115 |
The default setting is \Lkeyset{qrlink=link}. Without using \LPack{hyperref} this optional argument |
| 116 |
has no meaning. The optional argument \Lkeyword{linktext} is also only valid, |
| 117 |
if hyperref is aktive. |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
\subsection{Color of the QR code} |
| 125 |
The default color is \Lkeyval{black}. It can be changed by |
| 126 |
the optional argument \Lkeyword{qrcolor}. The package |
| 127 |
\LPack{xcolor}\hvqrurl*[qrlink=nolink,qrcolor=red!40!white]{https://mirror.ctan.org/pkg/xcolor} |
| 128 |
is loaded by default, |
| 129 |
the reason why an extended color definition is possible. For this example we used |
| 130 |
|
| 131 |
\begin{lstlisting} |
| 132 |
The package xcolor\hvqrurl*[qrcolor=red!40!white]{https://mirror.ctan.org/pkg/xcolor} |
| 133 |
is loaded by default, ... |
| 134 |
\end{lstlisting} |
| 135 |
|
| 136 |
\subsection{Vertical position of the QR code} |
| 137 |
By default the baseline of the QR code is nearly at the same height as the baseline of the text. |
| 138 |
However, when changing the size of the QR code it may be nessesary to move up or down the QR code. |
| 139 |
The default value of \Lkeyword{qradjust} is \verb|-1.5\normalbaselineskip|. Setting the value |
| 140 |
to 0pt the QR code |
| 141 |
\hvqrurl[qrlink=nolink,qradjust=0pt]{https://latex.texnik.de/tutorials/packages/#header-footer} |
| 142 |
is moved down which is the default |
| 143 |
setting without a vertical adjustment. |
| 144 |
|
| 145 |
\begin{lstlisting} |
| 146 |
The default value of qradjust is \verb|-1.5\normalbaselineskip|. Setting the value |
| 147 |
to 0pt the QR code |
| 148 |
\hvqrurl[qradjust=0pt]{https://latex.texnik.de/tutorials/packages/#header-footer} |
| 149 |
is moved down which is the default setting without a vertical adjustment. |
| 150 |
\end{lstlisting} |
| 151 |
|
| 152 |
|
| 153 |
\subsection{Size of the QR code} |
| 154 |
By default the QR code is a square with height and width of 1cm. |
| 155 |
it can be changed by setting \Lkeyword{qrheight} to another value, for example to 2cm: |
| 156 |
\hvqrurl*[qrlink=nolink,qrheight=2cm]{https://identity.fu-berlin.de/idp-fub/profile/SAML2/Redirect/SSO;jsessionid=71C984647E3B8F2E716CA067CB13387E?execution=e1s1} |
| 157 |
This is an extremely long url where it may make sense to use a larger QR code. |
| 158 |
|
| 159 |
\begin{lstlisting} |
| 160 |
it can be changed by setting qrheight to another value, for example to 2cm: |
| 161 |
\hvqrurl*[qrheight=2cm]{https://identity.fu-berlin.de/idp-fub/profile/SAML2/Redirect/SSO;jsessionid=71C984647E3B8F2E716CA067CB13387E?execution=e1s1} |
| 162 |
This is an extremely long url where it may make sense to use a larger QR code. |
| 163 |
\end{lstlisting} |
| 164 |
|
| 165 |
|
| 166 |
\subsection{QR code level} |
| 167 |
The QR code specification includes four levels of encoding: |
| 168 |
Low (L) (\hvqrurl[qrlink=nolink]{https://www.tug.org/}), Medium (M), Quality (Q), |
| 169 |
and High (H) (\hvqrurl[qrlink=nolink,qradjust=0pt,qrlevel=H]{https://www.tug.org/}), |
| 170 |
in increasing order of error-correction capability. |
| 171 |
In general, for a given text a higher error-correction level requires |
| 172 |
more bits of information in the QR code. |
| 173 |
|
| 174 |
\begin{lstlisting} |
| 175 |
The QR code specification includes four levels of encoding: |
| 176 |
Low (L) (\hvqrurl{https://www.tug.org/}), Medium (M), Quality (Q), |
| 177 |
and High (H) (\hvqrurl[qradjust=0pt,qrlevel=H]{https://www.tug.org/}), |
| 178 |
in increasing order of error-correction capability. |
| 179 |
\end{lstlisting} |
| 180 |
|
| 181 |
The first QR code has the default level \Lkeyval{M} and the last one the |
| 182 |
level \Lkeyval{H}. In general the user has not to set this keyword it will be |
| 183 |
controlled internally by the package. |
| 184 |
|
| 185 |
|
| 186 |
\subsection{Inner or outer margin for the QR code} |
| 187 |
By default the QR code is set in the right (oneside document) or outer margin (twoside) of the |
| 188 |
document. This one (\hvqrurl{https://hvoss.org}) is at the default position. |
| 189 |
With the optional argument \Lkeyword{qrreverse} it can be placed in the left or inner margin. |
| 190 |
This one (\hvqrurl[qrreverse]{https://latex.texnik.de}) is in the other margin. |
| 191 |
|
| 192 |
\begin{lstlisting} |
| 193 |
This one (\hvqrurl{https://hvoss.org}) is at the default position. |
| 194 |
With the optional argument \Lkeyword{qrreverse} it can be placed in the left or inner margin. |
| 195 |
This one (\hvqrurl[qrreverse]{https://latex.texnik.de}) is in the other margin. |
| 196 |
\end{lstlisting} |
| 197 |
|
| 198 |
\subsection{Alternative link text} |
| 199 |
By default the QR code is set with the given text. If the link is too long, one |
| 200 |
can use a short link with the optional argument \Lkeyword{linktext} for the text and |
| 201 |
the long link for the qrcode, like |
| 202 |
this one: \hvqrurl[linktext=https://www.uni-bonn.de]% |
| 203 |
{https://www.uni-bonn.de/de/studium/studienangebot/studiengaenge-a-z/kunstgeschichte-bazf?set_language=de}. |
| 204 |
|
| 205 |
|
| 206 |
\begin{lstlisting} |
| 207 |
By default the QR code is set with the given text. If the link is too long, one |
| 208 |
can use a short link with the optional argument \Lkeyword{linktext} for the text and |
| 209 |
the long link for the qrcode, like |
| 210 |
this one: \hvqrurl[linktext=https://www.uni-bonn.de]% |
| 211 |
{https://www.uni-bonn.de/de/studium/studienangebot/studiengaenge-a-z/kunstgeschichte-bazf?set_language=de}. |
| 212 |
\end{lstlisting} |
| 213 |
|
| 214 |
It makes no sense to use the star version \Lcs{hvqrurl*} together with the optional argument |
| 215 |
\Lkeyword{linktext}! |
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
\printindex |
| 220 |
|
| 221 |
|
| 222 |
\section{The Package Source} |
| 223 |
\lstinputlisting[basicstyle=\ttfamily\footnotesize,tabsize=3,numbers=left,numberstyle=\tiny]{hvqrurl.sty} |
| 224 |
|
| 225 |
|
| 226 |
\end{document} |
| 227 |
|