Debian Codegraph @

texmf-dist/source/latex/kvdefinekeys/kvdefinekeys.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: kvdefinekeys.dtx
4 % Version: 2019-12-19 v1.6
5 % Info: Define keys
6 %
7 % Copyright (C)
8 % 2010, 2011 Heiko Oberdiek
9 % 2016-2019 Oberdiek Package Support Group
10 % https://github.com/ho-tex/kvdefinekeys/issues
11 %
12 % This work may be distributed and/or modified under the
13 % conditions of the LaTeX Project Public License, either
14 % version 1.3c of this license or (at your option) any later
15 % version. This version of this license is in
16 % https://www.latex-project.org/lppl/lppl-1-3c.txt
17 % and the latest version of this license is in
18 % https://www.latex-project.org/lppl.txt
19 % and version 1.3 or later is part of all distributions of
20 % LaTeX version 2005/12/01 or later.
21 %
22 % This work has the LPPL maintenance status "maintained".
23 %
24 % The Current Maintainers of this work are
25 % Heiko Oberdiek and the Oberdiek Package Support Group
26 % https://github.com/ho-tex/kvdefinekeys/issues
27 %
28 % The Base Interpreter refers to any `TeX-Format',
29 % because some files are installed in TDS:tex/generic//.
30 %
31 % This work consists of the main source file kvdefinekeys.dtx
32 % and the derived files
33 % kvdefinekeys.sty, kvdefinekeys.pdf, kvdefinekeys.ins, kvdefinekeys.drv,
34 % kvdefinekeys-test1.tex.
35 %
36 % Distribution:
37 % CTAN:macros/latex/contrib/kvdefinekeys/kvdefinekeys.dtx
38 % CTAN:macros/latex/contrib/kvdefinekeys/kvdefinekeys.pdf
39 %
40 % Unpacking:
41 % (a) If kvdefinekeys.ins is present:
42 % tex kvdefinekeys.ins
43 % (b) Without kvdefinekeys.ins:
44 % tex kvdefinekeys.dtx
45 % (c) If you insist on using LaTeX
46 % latex \let\install=y\input{kvdefinekeys.dtx}
47 % (quote the arguments according to the demands of your shell)
48 %
49 % Documentation:
50 % (a) If kvdefinekeys.drv is present:
51 % latex kvdefinekeys.drv
52 % (b) Without kvdefinekeys.drv:
53 % latex kvdefinekeys.dtx; ...
54 % The class ltxdoc loads the configuration file ltxdoc.cfg
55 % if available. Here you can specify further options, e.g.
56 % use A4 as paper format:
57 % \PassOptionsToClass{a4paper}{article}
58 %
59 % Programm calls to get the documentation (example):
60 % pdflatex kvdefinekeys.dtx
61 % makeindex -s gind.ist kvdefinekeys.idx
62 % pdflatex kvdefinekeys.dtx
63 % makeindex -s gind.ist kvdefinekeys.idx
64 % pdflatex kvdefinekeys.dtx
65 %
66 % Installation:
67 % TDS:tex/generic/kvdefinekeys/kvdefinekeys.sty
68 % TDS:doc/latex/kvdefinekeys/kvdefinekeys.pdf
69 % TDS:source/latex/kvdefinekeys/kvdefinekeys.dtx
70 %
71 %<*ignore>
72 \begingroup
73 \catcode123=1 %
74 \catcode125=2 %
75 \def\x{LaTeX2e}%
76 \expandafter\endgroup
77 \ifcase 0\ifx\install y1\fi\expandafter
78 \ifx\csname processbatchFile\endcsname\relax\else1\fi
79 \ifx\fmtname\x\else 1\fi\relax
80 \else\csname fi\endcsname
81 %</ignore>
82 %<*install>
83 \input docstrip.tex
84 \Msg{************************************************************************}
85 \Msg{* Installation}
86 \Msg{* Package: kvdefinekeys 2019-12-19 v1.6 Define keys (HO)}
87 \Msg{************************************************************************}
88
89 \keepsilent
90 \askforoverwritefalse
91
92 \let\MetaPrefix\relax
93 \preamble
94
95 This is a generated file.
96
97 Project: kvdefinekeys
98 Version: 2019-12-19 v1.6
99
100 Copyright (C)
101 2010, 2011 Heiko Oberdiek
102 2016-2019 Oberdiek Package Support Group
103
104 This work may be distributed and/or modified under the
105 conditions of the LaTeX Project Public License, either
106 version 1.3c of this license or (at your option) any later
107 version. This version of this license is in
108 https://www.latex-project.org/lppl/lppl-1-3c.txt
109 and the latest version of this license is in
110 https://www.latex-project.org/lppl.txt
111 and version 1.3 or later is part of all distributions of
112 LaTeX version 2005/12/01 or later.
113
114 This work has the LPPL maintenance status "maintained".
115
116 The Current Maintainers of this work are
117 Heiko Oberdiek and the Oberdiek Package Support Group
118 https://github.com/ho-tex/kvdefinekeys/issues
119
120
121 The Base Interpreter refers to any `TeX-Format',
122 because some files are installed in TDS:tex/generic//.
123
124 This work consists of the main source file kvdefinekeys.dtx
125 and the derived files
126 kvdefinekeys.sty, kvdefinekeys.pdf, kvdefinekeys.ins, kvdefinekeys.drv,
127 kvdefinekeys-test1.tex.
128
129 \endpreamble
130 \let\MetaPrefix\DoubleperCent
131
132 \generate{%
133 \file{kvdefinekeys.ins}{\from{kvdefinekeys.dtx}{install}}%
134 \file{kvdefinekeys.drv}{\from{kvdefinekeys.dtx}{driver}}%
135 \usedir{tex/generic/kvdefinekeys}%
136 \file{kvdefinekeys.sty}{\from{kvdefinekeys.dtx}{package}}%
137 }
138
139 \catcode32=13\relax% active space
140 \let =\space%
141 \Msg{************************************************************************}
142 \Msg{*}
143 \Msg{* To finish the installation you have to move the following}
144 \Msg{* file into a directory searched by TeX:}
145 \Msg{*}
146 \Msg{* kvdefinekeys.sty}
147 \Msg{*}
148 \Msg{* To produce the documentation run the file `kvdefinekeys.drv'}
149 \Msg{* through LaTeX.}
150 \Msg{*}
151 \Msg{* Happy TeXing!}
152 \Msg{*}
153 \Msg{************************************************************************}
154
155 \endbatchfile
156 %</install>
157 %<*ignore>
158 \fi
159 %</ignore>
160 %<*driver>
161 \NeedsTeXFormat{LaTeX2e}
162 \ProvidesFile{kvdefinekeys.drv}%
163 [2019-12-19 v1.6 Define keys (HO)]%
164 \documentclass{ltxdoc}
165 \usepackage{holtxdoc}[2011/11/22]
166 \begin{document}
167 \DocInput{kvdefinekeys.dtx}%
168 \end{document}
169 %</driver>
170 % \fi
171 %
172 %
173 %
174 % \GetFileInfo{kvdefinekeys.drv}
175 %
176 % \title{The \xpackage{kvdefinekeys} package}
177 % \date{2019-12-19 v1.6}
178 % \author{Heiko Oberdiek\thanks
179 % {Please report any issues at \url{https://github.com/ho-tex/kvdefinekeys/issues}}}
180 %
181 % \maketitle
182 %
183 % \begin{abstract}
184 % Package \xpackage{kvdefinekeys} provides \cs{kv@define@key} to define
185 % keys the same way as \xpackage{keyval}'s \cs{define@key}. However, it
186 % works also using \iniTeX.
187 % \end{abstract}
188 %
189 % \tableofcontents
190 %
191 % \def\M#1{\texttt{\{}\meta{#1}\texttt{\}}}
192 %
193 % \section{Documentation}
194 %
195 % \subsection{Motivation}
196 %
197 % \cs{kvsetkeys} serves as replacement for \xpackage{keyval}'s
198 % \cs{setkeys}. This package adds macros to define keys, closing
199 % the gap \cs{kvsetkeys} leaves.
200 %
201 % \begin{declcs}{kv@define@key}\,\M{family}\,\M{key}\,[\meta{default}]\,^^A
202 % \M{definition}
203 % \end{declcs}
204 % Macro \cs{kv@define@key} reimplements \xpackage{keyval}'s
205 % \cs{define@key}. Differences to the original:
206 % \begin{itemize}
207 % \item The defined keys also allow \cs{par} inside values.
208 % \item Shorthands of package \xpackage{babel} are supported in
209 % family and key names.
210 % \item Macro \cs{kv@define@key} is made robust if
211 % \hologo{eTeX}'s \cs{protected} or \hologo{LaTeX}'s
212 % \cs{DeclareRobustCommand} are found.
213 % \end{itemize}
214 %
215 % \StopEventually{
216 % }
217 %
218 % \section{Implementation}
219 %
220 % \subsection{Identification}
221 %
222 % \begin{macrocode}
223 %<*package>
224 % \end{macrocode}
225 % Reload check, especially if the package is not used with \LaTeX.
226 % \begin{macrocode}
227 \begingroup\catcode61\catcode48\catcode32=10\relax%
228 \catcode13=5 % ^^M
229 \endlinechar=13 %
230 \catcode35=6 % #
231 \catcode39=12 % '
232 \catcode44=12 % ,
233 \catcode45=12 % -
234 \catcode46=12 % .
235 \catcode58=12 % :
236 \catcode64=11 % @
237 \catcode123=1 % {
238 \catcode125=2 % }
239 \expandafter\let\expandafter\x\csname [email protected]\endcsname
240 \ifx\x\relax % plain-TeX, first loading
241 \else
242 \def\empty{}%
243 \ifx\x\empty % LaTeX, first loading,
244 % variable is initialized, but \ProvidesPackage not yet seen
245 \else
246 \expandafter\ifx\csname PackageInfo\endcsname\relax
247 \def\x#1#2{%
248 \immediate\write-1{Package #1 Info: #2.}%
249 }%
250 \else
251 \def\x#1#2{\PackageInfo{#1}{#2, stopped}}%
252 \fi
253 \x{kvdefinekeys}{The package is already loaded}%
254 \aftergroup\endinput
255 \fi
256 \fi
257 \endgroup%
258 % \end{macrocode}
259 % Package identification:
260 % \begin{macrocode}
261 \begingroup\catcode61\catcode48\catcode32=10\relax%
262 \catcode13=5 % ^^M
263 \endlinechar=13 %
264 \catcode35=6 % #
265 \catcode39=12 % '
266 \catcode40=12 % (
267 \catcode41=12 % )
268 \catcode44=12 % ,
269 \catcode45=12 % -
270 \catcode46=12 % .
271 \catcode47=12 % /
272 \catcode58=12 % :
273 \catcode64=11 % @
274 \catcode91=12 % [
275 \catcode93=12 % ]
276 \catcode123=1 % {
277 \catcode125=2 % }
278 \expandafter\ifx\csname ProvidesPackage\endcsname\relax
279 \def\x#1#2#3[#4]{\endgroup
280 \immediate\write-1{Package: #3 #4}%
281 \xdef#1{#4}%
282 }%
283 \else
284 \def\x#1#2[#3]{\endgroup
285 #2[{#3}]%
286 \ifx#1\@undefined
287 \xdef#1{#3}%
288 \fi
289 \ifx#1\relax
290 \xdef#1{#3}%
291 \fi
292 }%
293 \fi
294 \expandafter\x\csname [email protected]\endcsname
295 \ProvidesPackage{kvdefinekeys}%
296 [2019-12-19 v1.6 Define keys (HO)]%
297 % \end{macrocode}
298 %
299 % \begin{macrocode}
300 \begingroup\catcode61\catcode48\catcode32=10\relax%
301 \catcode13=5 % ^^M
302 \endlinechar=13 %
303 \catcode123=1 % {
304 \catcode125=2 % }
305 \catcode64=11 % @
306 \def\x{\endgroup
307 \expandafter\edef\csname KVD@AtEnd\endcsname{%
308 \endlinechar=\the\endlinechar\relax
309 \catcode13=\the\catcode13\relax
310 \catcode32=\the\catcode32\relax
311 \catcode35=\the\catcode35\relax
312 \catcode61=\the\catcode61\relax
313 \catcode64=\the\catcode64\relax
314 \catcode123=\the\catcode123\relax
315 \catcode125=\the\catcode125\relax
316 }%
317 }%
318 \x\catcode61\catcode48\catcode32=10\relax%
319 \catcode13=5 % ^^M
320 \endlinechar=13 %
321 \catcode35=6 % #
322 \catcode64=11 % @
323 \catcode123=1 % {
324 \catcode125=2 % }
325 \def\TMP@EnsureCode#1#2{%
326 \edef\KVD@AtEnd{%
327 \KVD@AtEnd
328 \catcode#1=\the\catcode#1\relax
329 }%
330 \catcode#1=#2\relax
331 }
332 \TMP@EnsureCode{42}{12}% *
333 \TMP@EnsureCode{46}{12}% .
334 \TMP@EnsureCode{47}{12}% /
335 \TMP@EnsureCode{91}{12}% [
336 \TMP@EnsureCode{93}{12}% ]
337 \edef\KVD@AtEnd{\KVD@AtEnd\noexpand\endinput}
338 % \end{macrocode}
339 %
340 % \subsection{Package loading}
341 %
342 % \begin{macrocode}
343 \begingroup\expandafter\expandafter\expandafter\endgroup
344 \expandafter\ifx\csname RequirePackage\endcsname\relax
345 \def\TMP@RequirePackage#1[#2]{%
346 \begingroup\expandafter\expandafter\expandafter\endgroup
347 \expandafter\ifx\csname ver@#1.sty\endcsname\relax
348 \input #1.sty\relax
349 \fi
350 }%
351 \TMP@RequirePackage{ltxcmds}[2010/03/01]%
352 \let\@ifundefined\ltx@IfUndefined
353 \let\@ifnextchar\ltx@ifnextchar
354 \long\def\@firstoftwo#1#2{#1}
355 \long\def\@secondoftwo#1#2{#2}
356 \else
357 \fi
358 % \end{macrocode}
359 %
360 %
361 % \subsection{Provide key defining macro}
362 %
363 % \begin{macro}{\kv@define@key}
364 % \begin{macrocode}
365 \@ifundefined{protected}{%
366 \@ifundefined{DeclareRobustCommand}{%
367 \def\kv@define@key#1#2%
368 }{%
369 \DeclareRobustCommand*{\kv@define@key}[2]%
370 }%
371 }{%
372 \protected\def\kv@define@key#1#2%
373 }%
374 {%
375 \begingroup
376 \csname @safe@activestrue\endcsname
377 \let\ifincsname\iftrue
378 \edef\KVD@temp{\endgroup
379 \noexpand\KVD@DefineKey{#1}{#2}%
380 }%
381 \KVD@temp
382 }
383 % \end{macrocode}
384 % \end{macro}
385 % \begin{macro}{\KVD@DefineKey}
386 % \begin{macrocode}
387 \def\KVD@DefineKey#1#2{%
388 \begingroup
389 \toks\z@{\endgroup\KVD@DefineKeyWithDefault{#1}{#2}}%
390 \toks\tw@{\endgroup\long\expandafter\def\csname KV@#1@#2\endcsname##1}%
391 \@ifnextchar[{\the\toks\z@}{\the\toks\tw@}%
392 }
393 % \end{macrocode}
394 % \end{macro}
395 % \begin{macro}{\KVD@DefineKeyWithDefault}
396 % \begin{macrocode}
397 \long\def\KVD@DefineKeyWithDefault#1#2[#3]{%
398 \expandafter\def\csname KV@#1@#2@default\expandafter\endcsname
399 \expandafter{%
400 \csname KV@#1@#2\endcsname{#3}%
401 }%
402 \long\expandafter\def\csname KV@#1@#2\endcsname##1%
403 }
404 % \end{macrocode}
405 % \end{macro}
406 %
407 % \begin{macrocode}
408 \KVD@AtEnd%
409 %</package>
410 % \end{macrocode}
411 % \section{Installation}
412 %
413 % \subsection{Download}
414 %
415 % \paragraph{Package.} This package is available on
416 % CTAN\footnote{\CTANpkg{kvdefinekeys}}:
417 % \begin{description}
418 % \item[\CTAN{macros/latex/contrib/kvdefinekeys/kvdefinekeys.dtx}] The source file.
419 % \item[\CTAN{macros/latex/contrib/kvdefinekeys/kvdefinekeys.pdf}] Documentation.
420 % \end{description}
421 %
422 %
423 % \paragraph{Bundle.} All the packages of the bundle `kvdefinekeys'
424 % are also available in a TDS compliant ZIP archive. There
425 % the packages are already unpacked and the documentation files
426 % are generated. The files and directories obey the TDS standard.
427 % \begin{description}
428 % \item[\CTANinstall{install/macros/latex/contrib/kvdefinekeys.tds.zip}]
429 % \end{description}
430 % \emph{TDS} refers to the standard ``A Directory Structure
431 % for \TeX\ Files'' (\CTANpkg{tds}). Directories
432 % with \xfile{texmf} in their name are usually organized this way.
433 %
434 % \subsection{Bundle installation}
435 %
436 % \paragraph{Unpacking.} Unpack the \xfile{kvdefinekeys.tds.zip} in the
437 % TDS tree (also known as \xfile{texmf} tree) of your choice.
438 % Example (linux):
439 % \begin{quote}
440 % |unzip kvdefinekeys.tds.zip -d ~/texmf|
441 % \end{quote}
442 %
443 % \subsection{Package installation}
444 %
445 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
446 % \docstrip\ archive. The files are extracted by running the
447 % \xfile{.dtx} through \plainTeX:
448 % \begin{quote}
449 % \verb|tex kvdefinekeys.dtx|
450 % \end{quote}
451 %
452 % \paragraph{TDS.} Now the different files must be moved into
453 % the different directories in your installation TDS tree
454 % (also known as \xfile{texmf} tree):
455 % \begin{quote}
456 % \def\t{^^A
457 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
458 % kvdefinekeys.sty & tex/generic/kvdefinekeys/kvdefinekeys.sty\\
459 % kvdefinekeys.pdf & doc/latex/kvdefinekeys/kvdefinekeys.pdf\\
460 % kvdefinekeys.dtx & source/latex/kvdefinekeys/kvdefinekeys.dtx\\
461 % \end{tabular}^^A
462 % }^^A
463 % \sbox0{\t}^^A
464 % \ifdim\wd0>\linewidth
465 % \begingroup
466 % \advance\linewidth by\leftmargin
467 % \advance\linewidth by\rightmargin
468 % \edef\x{\endgroup
469 % \def\noexpand\lw{\the\linewidth}^^A
470 % }\x
471 % \def\lwbox{^^A
472 % \leavevmode
473 % \hbox to \linewidth{^^A
474 % \kern-\leftmargin\relax
475 % \hss
476 % \usebox0
477 % \hss
478 % \kern-\rightmargin\relax
479 % }^^A
480 % }^^A
481 % \ifdim\wd0>\lw
482 % \sbox0{\small\t}^^A
483 % \ifdim\wd0>\linewidth
484 % \ifdim\wd0>\lw
485 % \sbox0{\footnotesize\t}^^A
486 % \ifdim\wd0>\linewidth
487 % \ifdim\wd0>\lw
488 % \sbox0{\scriptsize\t}^^A
489 % \ifdim\wd0>\linewidth
490 % \ifdim\wd0>\lw
491 % \sbox0{\tiny\t}^^A
492 % \ifdim\wd0>\linewidth
493 % \lwbox
494 % \else
495 % \usebox0
496 % \fi
497 % \else
498 % \lwbox
499 % \fi
500 % \else
501 % \usebox0
502 % \fi
503 % \else
504 % \lwbox
505 % \fi
506 % \else
507 % \usebox0
508 % \fi
509 % \else
510 % \lwbox
511 % \fi
512 % \else
513 % \usebox0
514 % \fi
515 % \else
516 % \lwbox
517 % \fi
518 % \else
519 % \usebox0
520 % \fi
521 % \end{quote}
522 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
523 % TDS installing feature, then some files can already be in the right
524 % place, see the documentation of \docstrip.
525 %
526 % \subsection{Refresh file name databases}
527 %
528 % If your \TeX~distribution
529 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
530 % these. For example, \TeX\,Live\ users run \verb|texhash| or
531 % \verb|mktexlsr|.
532 %
533 % \subsection{Some details for the interested}
534 %
535 % \paragraph{Unpacking with \LaTeX.}
536 % The \xfile{.dtx} chooses its action depending on the format:
537 % \begin{description}
538 % \item[\plainTeX:] Run \docstrip\ and extract the files.
539 % \item[\LaTeX:] Generate the documentation.
540 % \end{description}
541 % If you insist on using \LaTeX\ for \docstrip\ (really,
542 % \docstrip\ does not need \LaTeX), then inform the autodetect routine
543 % about your intention:
544 % \begin{quote}
545 % \verb|latex \let\install=y\input{kvdefinekeys.dtx}|
546 % \end{quote}
547 % Do not forget to quote the argument according to the demands
548 % of your shell.
549 %
550 % \paragraph{Generating the documentation.}
551 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
552 % the documentation. The process can be configured by the
553 % configuration file \xfile{ltxdoc.cfg}. For instance, put this
554 % line into this file, if you want to have A4 as paper format:
555 % \begin{quote}
556 % \verb|\PassOptionsToClass{a4paper}{article}|
557 % \end{quote}
558 % An example follows how to generate the
559 % documentation with pdf\LaTeX:
560 % \begin{quote}
561 %\begin{verbatim}
562 %pdflatex kvdefinekeys.dtx
563 %makeindex -s gind.ist kvdefinekeys.idx
564 %pdflatex kvdefinekeys.dtx
565 %makeindex -s gind.ist kvdefinekeys.idx
566 %pdflatex kvdefinekeys.dtx
567 %\end{verbatim}
568 % \end{quote}
569 %
570 % \begin{thebibliography}{9}
571 % \bibitem{keyval}
572 % David Carlisle:
573 % \textit{The \xpackage{keyval} package};
574 % 1999/03/16 v1.13;
575 % \CTAN{macros/latex/required/graphics/keyval.dtx}.
576 %
577 % \end{thebibliography}
578 %
579 % \begin{History}
580 % \begin{Version}{2010/03/01 v1.0}
581 % \item
582 % First version.
583 % \end{Version}
584 % \begin{Version}{2010/08/19 v1.1}
585 % \item
586 % Documentation fix, no code change.
587 % \end{Version}
588 % \begin{Version}{2011/01/30 v1.2}
589 % \item
590 % Already loaded package files are not input in \hologo{plainTeX}.
591 % \end{Version}
592 % \begin{Version}{2011/04/07 v1.3}
593 % \item
594 % Support for package \xpackage{babel}'s shorthands added.
595 % \item
596 % \cs{kv@define@key} is made robust if available.
597 % \end{Version}
598 % \begin{Version}{2016/05/16 v1.4}
599 % \item
600 % Documentation updates.
601 % \end{Version}
602 % \begin{Version}{2019/12/15 v1.5}
603 % \item
604 % Documentation updates.
605 % \end{Version}
606 % \begin{Version}{2019-12-19 v1.6}
607 % \item Fix definition of \cs{KVD@DefineKey} for gh issue embedfile/2
608 % \end{Version}
609 % \end{History}
610 %
611 % \PrintIndex
612 %
613 % \Finale
614 \endinput