Debian Codegraph @

texmf-dist/source/latex/oberdiek/twoopt.dtx

raw
1 % \iffalse meta-comment
2 %
3 % File: twoopt.dtx
4 % Version: 2016/05/16 v1.6
5 % Info: Definitions with two optional arguments
6 %
7 % Copyright (C)
8 % 1999, 2006, 2008 Heiko Oberdiek
9 % 2016-2019 Oberdiek Package Support Group
10 % https://github.com/ho-tex/oberdiek/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/oberdiek/issues
27 %
28 % This work consists of the main source file twoopt.dtx
29 % and the derived files
30 % twoopt.sty, twoopt.pdf, twoopt.ins, twoopt.drv.
31 %
32 % Distribution:
33 % CTAN:macros/latex/contrib/oberdiek/twoopt.dtx
34 % CTAN:macros/latex/contrib/oberdiek/twoopt.pdf
35 %
36 % Unpacking:
37 % (a) If twoopt.ins is present:
38 % tex twoopt.ins
39 % (b) Without twoopt.ins:
40 % tex twoopt.dtx
41 % (c) If you insist on using LaTeX
42 % latex \let\install=y\input{twoopt.dtx}
43 % (quote the arguments according to the demands of your shell)
44 %
45 % Documentation:
46 % (a) If twoopt.drv is present:
47 % latex twoopt.drv
48 % (b) Without twoopt.drv:
49 % latex twoopt.dtx; ...
50 % The class ltxdoc loads the configuration file ltxdoc.cfg
51 % if available. Here you can specify further options, e.g.
52 % use A4 as paper format:
53 % \PassOptionsToClass{a4paper}{article}
54 %
55 % Program calls to get the documentation (example):
56 % pdflatex twoopt.dtx
57 % makeindex -s gind.ist twoopt.idx
58 % pdflatex twoopt.dtx
59 % makeindex -s gind.ist twoopt.idx
60 % pdflatex twoopt.dtx
61 %
62 % Installation:
63 % TDS:tex/latex/oberdiek/twoopt.sty
64 % TDS:doc/latex/oberdiek/twoopt.pdf
65 % TDS:source/latex/oberdiek/twoopt.dtx
66 %
67 %<*ignore>
68 \begingroup
69 \catcode123=1 %
70 \catcode125=2 %
71 \def\x{LaTeX2e}%
72 \expandafter\endgroup
73 \ifcase 0\ifx\install y1\fi\expandafter
74 \ifx\csname processbatchFile\endcsname\relax\else1\fi
75 \ifx\fmtname\x\else 1\fi\relax
76 \else\csname fi\endcsname
77 %</ignore>
78 %<*install>
79 \input docstrip.tex
80 \Msg{************************************************************************}
81 \Msg{* Installation}
82 \Msg{* Package: twoopt 2016/05/16 v1.6 Definitions with two optional arguments (HO)}
83 \Msg{************************************************************************}
84
85 \keepsilent
86 \askforoverwritefalse
87
88 \let\MetaPrefix\relax
89 \preamble
90
91 This is a generated file.
92
93 Project: twoopt
94 Version: 2016/05/16 v1.6
95
96 Copyright (C)
97 1999, 2006, 2008 Heiko Oberdiek
98 2016-2019 Oberdiek Package Support Group
99
100 This work may be distributed and/or modified under the
101 conditions of the LaTeX Project Public License, either
102 version 1.3c of this license or (at your option) any later
103 version. This version of this license is in
104 https://www.latex-project.org/lppl/lppl-1-3c.txt
105 and the latest version of this license is in
106 https://www.latex-project.org/lppl.txt
107 and version 1.3 or later is part of all distributions of
108 LaTeX version 2005/12/01 or later.
109
110 This work has the LPPL maintenance status "maintained".
111
112 The Current Maintainers of this work are
113 Heiko Oberdiek and the Oberdiek Package Support Group
114 https://github.com/ho-tex/oberdiek/issues
115
116
117 This work consists of the main source file twoopt.dtx
118 and the derived files
119 twoopt.sty, twoopt.pdf, twoopt.ins, twoopt.drv.
120
121 \endpreamble
122 \let\MetaPrefix\DoubleperCent
123
124 \generate{%
125 \file{twoopt.ins}{\from{twoopt.dtx}{install}}%
126 \file{twoopt.drv}{\from{twoopt.dtx}{driver}}%
127 \usedir{tex/latex/oberdiek}%
128 \file{twoopt.sty}{\from{twoopt.dtx}{package}}%
129 }
130
131 \catcode32=13\relax% active space
132 \let =\space%
133 \Msg{************************************************************************}
134 \Msg{*}
135 \Msg{* To finish the installation you have to move the following}
136 \Msg{* file into a directory searched by TeX:}
137 \Msg{*}
138 \Msg{* twoopt.sty}
139 \Msg{*}
140 \Msg{* To produce the documentation run the file `twoopt.drv'}
141 \Msg{* through LaTeX.}
142 \Msg{*}
143 \Msg{* Happy TeXing!}
144 \Msg{*}
145 \Msg{************************************************************************}
146
147 \endbatchfile
148 %</install>
149 %<*ignore>
150 \fi
151 %</ignore>
152 %<*driver>
153 \NeedsTeXFormat{LaTeX2e}
154 \ProvidesFile{twoopt.drv}%
155 [2016/05/16 v1.6 Definitions with two optional arguments (HO)]%
156 \documentclass{ltxdoc}
157 \usepackage{holtxdoc}[2011/11/22]
158 \begin{document}
159 \DocInput{twoopt.dtx}%
160 \end{document}
161 %</driver>
162 % \fi
163 %
164 %
165 %
166 % \GetFileInfo{twoopt.drv}
167 %
168 % \title{The \xpackage{twoopt} package}
169 % \date{2016/05/16 v1.6}
170 % \author{Heiko Oberdiek\thanks
171 % {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}}
172 %
173 % \maketitle
174 %
175 % \begin{abstract}
176 % This package provides commands to define macros with two
177 % optional arguments.
178 % \end{abstract}
179 %
180 % \tableofcontents
181 %
182 % \newenvironment{param}{^^A
183 % \newcommand{\entry}[1]{\meta{\###1}:&}^^A
184 % \begin{tabular}[t]{@{}l@{ }l@{}}^^A
185 % }{^^A
186 % \end{tabular}^^A
187 % }
188 %
189 % \section{Usage}
190 % \DescribeMacro{\newcommandtwoopt}
191 % \DescribeMacro{\renewcommandtwoopt}
192 % \DescribeMacro{\providecommandtwoopt}
193 % Similar to \cmd{\newcommand}, \cmd{\renewcommand}
194 % and \cmd{\providecommand} this package provides commands
195 % to define macros with two optional arguments.
196 % The names of the commands are built by appending the
197 % package name to the \LaTeX-pendants:
198 % \begingroup
199 % \def\x{\marg{cmd} \oarg{num} \oarg{default1}^^A
200 % \oarg{default2} \marg{def.}}^^A
201 % \begin{tabbing}
202 % \cmd{\providecommandtwoopt} \=\kill
203 % \cmd{\newcommandtwoopt}\>\x\\
204 % \cmd{\renewcommandtwoopt}\>\x\\
205 % \cmd{\providecommandtwoopt}\>\x\\
206 % \end{tabbing}
207 % \endgroup
208 %
209 % Also the |*|-forms are supported. Indeed it is better to
210 % use this ones, unless it is intended to hold
211 % whole paragraphs in some of the arguments. If the macro
212 % is defined with the |*|-form, missing braces
213 % can be detected earlier.
214 %
215 % Example:
216 % \begin{quote}
217 % |\newcommandtwoopt{\bsp}[3][AA][BB]{%|\\
218 % | \typeout{\string\bsp: #1,#2,#3}%|\\
219 % |}|\\
220 % \begin{tabular}{@{}l@{\quad$\rightarrow$\quad}l@{}}
221 % |\bsp[aa][bb]{cc}|&|\bsp: aa,bb,cc|\\
222 % |\bsp[aa]{cc}|&|\bsp: aa,BB,cc|\\
223 % |\bsp{cc}|&|\bsp: AA,BB,cc|\\
224 % \end{tabular}
225 % \end{quote}
226 %
227 % \StopEventually{
228 % }
229 %
230 % \section{Implementation}
231 % \begin{macrocode}
232 %<*package>
233 \NeedsTeXFormat{LaTeX2e}
234 \ProvidesPackage{twoopt}
235 [2016/05/16 v1.6 Definitions with two optional arguments (HO)]%
236 % \end{macrocode}
237 % \begin{macro}{\newcommandtwoopt}
238 % \begin{macrocode}
239 \newcommand{\newcommandtwoopt}{%
240 \@ifstar{\@newcommandtwoopt*}{\@newcommandtwoopt{}}%
241 }
242 % \end{macrocode}
243 % \end{macro}
244 %
245 % \begin{macro}{\@newcommandtwoopt}
246 % \begin{param}
247 % \entry1 star\\
248 % \entry2 macro name to be defined
249 % \end{param}
250 % \begin{macrocode}
251 \newcommand{\@newcommandtwoopt}{}
252 \long\def\@newcommandtwoopt#1#2{%
253 \expandafter\@@newcommandtwoopt
254 \csname2\string#2\endcsname{#1}{#2}%
255 }
256 % \end{macrocode}
257 % \end{macro}
258 %
259 % \begin{macro}{\@@newcommandtwoopt}
260 % \begin{param}
261 % \entry1 help command to be defined
262 % (\expandafter\cmd\csname 2\bslash<name>\endcsname)\\
263 % \entry2 star\\
264 % \entry3 macro name to be defined\\
265 % \entry4 number of total arguments\\
266 % \entry5 default for optional argument one\\
267 % \entry6 default for optional argument two
268 % \end{param}
269 % \begin{macrocode}
270 \newcommand{\@@newcommandtwoopt}{}
271 \long\def\@@newcommandtwoopt#1#2#3[#4][#5][#6]{%
272 \newcommand#2#3[1][{#5}]{%
273 \to@ScanSecondOptArg#1{##1}{#6}%
274 }%
275 \newcommand#2#1[{#4}]%
276 }
277 % \end{macrocode}
278 % \end{macro}
279 %
280 % \begin{macro}{\renewcommandtwoopt}
281 % \begin{macrocode}
282 \newcommand{\renewcommandtwoopt}{%
283 \@ifstar{\@renewcommandtwoopt*}{\@renewcommandtwoopt{}}%
284 }
285 % \end{macrocode}
286 % \end{macro}
287 %
288 % \begin{macro}{\@renewcommandtwoopt}
289 % \begin{param}
290 % \entry1 star\\
291 % \entry2 command name to be defined
292 % \end{param}
293 % \begin{macrocode}
294 \newcommand{\@renewcommandtwoopt}{}
295 \long\def\@renewcommandtwoopt#1#2{%
296 \begingroup
297 \escapechar\m@ne
298 \xdef\@gtempa{{\string#2}}%
299 \endgroup
300 \expandafter\@ifundefined\@gtempa{%
301 \@latex@error{\noexpand#2undefined}\@ehc
302 }{}%
303 \let#2\@undefined
304 \expandafter\let\csname2\string#2\endcsname\@undefined
305 \expandafter\@@newcommandtwoopt
306 \csname2\string#2\endcsname{#1}{#2}%
307 }
308 % \end{macrocode}
309 % \end{macro}
310 %
311 % \begin{macro}{\providecommandtwoopt}
312 % \begin{macrocode}
313 \newcommand{\providecommandtwoopt}{%
314 \@ifstar{\@providecommandtwoopt*}{\@providecommandtwoopt{}}%
315 }
316 % \end{macrocode}
317 % \end{macro}
318 %
319 % \begin{macro}{\@providecommandtwoopt}
320 % \begin{param}
321 % \entry1 star\\
322 % \entry2 command name to be defined
323 % \end{param}
324 % \begin{macrocode}
325 \newcommand{\@providecommandtwoopt}{}
326 \long\def\@providecommandtwoopt#1#2{%
327 \begingroup
328 \escapechar\m@ne
329 \xdef\@gtempa{{\string#2}}%
330 \endgroup
331 \expandafter\@ifundefined\@gtempa{%
332 \expandafter\@@newcommandtwoopt
333 \csname2\string#2\endcsname{#1}{#2}%
334 }{%
335 \let\to@dummyA\@undefined
336 \let\to@dummyB\@undefined
337 \@@newcommandtwoopt\to@dummyA{#1}\to@dummyB
338 }%
339 }
340 % \end{macrocode}
341 % \end{macro}
342 %
343 % \begin{macro}{\to@ScanSecondOptArg}
344 % \begin{param}
345 % \entry1 help command to be defined
346 % (\expandafter\cmd\csname 2\bslash<name>\endcsname)\\
347 % \entry2 first arg of command to be defined\\
348 % \entry3 default for second opt. arg.
349 % \end{param}
350 % \begin{macrocode}
351 \newcommand{\to@ScanSecondOptArg}[3]{%
352 \@ifnextchar[{%
353 \expandafter#1\to@ArgOptToArgArg{#2}%
354 }{%
355 #1{#2}{#3}%
356 }%
357 }
358 % \end{macrocode}
359 % \end{macro}
360 %
361 % \begin{macro}{\to@ArgOptToArgArg}
362 % \begin{macrocode}
363 \newcommand{\to@ArgOptToArgArg}{}
364 \long\def\to@ArgOptToArgArg#1[#2]{{#1}{#2}}
365 % \end{macrocode}
366 % \end{macro}
367 %
368 % \begin{macrocode}
369 %</package>
370 % \end{macrocode}
371 %
372 % \section{Installation}
373 %
374 % \subsection{Download}
375 %
376 % \paragraph{Package.} This package is available on
377 % CTAN\footnote{\CTANpkg{twoopt}}:
378 % \begin{description}
379 % \item[\CTAN{macros/latex/contrib/oberdiek/twoopt.dtx}] The source file.
380 % \item[\CTAN{macros/latex/contrib/oberdiek/twoopt.pdf}] Documentation.
381 % \end{description}
382 %
383 %
384 % \paragraph{Bundle.} All the packages of the bundle `oberdiek'
385 % are also available in a TDS compliant ZIP archive. There
386 % the packages are already unpacked and the documentation files
387 % are generated. The files and directories obey the TDS standard.
388 % \begin{description}
389 % \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}]
390 % \end{description}
391 % \emph{TDS} refers to the standard ``A Directory Structure
392 % for \TeX\ Files'' (\CTANpkg{tds}). Directories
393 % with \xfile{texmf} in their name are usually organized this way.
394 %
395 % \subsection{Bundle installation}
396 %
397 % \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
398 % TDS tree (also known as \xfile{texmf} tree) of your choice.
399 % Example (linux):
400 % \begin{quote}
401 % |unzip oberdiek.tds.zip -d ~/texmf|
402 % \end{quote}
403 %
404 % \subsection{Package installation}
405 %
406 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
407 % \docstrip\ archive. The files are extracted by running the
408 % \xfile{.dtx} through \plainTeX:
409 % \begin{quote}
410 % \verb|tex twoopt.dtx|
411 % \end{quote}
412 %
413 % \paragraph{TDS.} Now the different files must be moved into
414 % the different directories in your installation TDS tree
415 % (also known as \xfile{texmf} tree):
416 % \begin{quote}
417 % \def\t{^^A
418 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
419 % twoopt.sty & tex/latex/oberdiek/twoopt.sty\\
420 % twoopt.pdf & doc/latex/oberdiek/twoopt.pdf\\
421 % twoopt.dtx & source/latex/oberdiek/twoopt.dtx\\
422 % \end{tabular}^^A
423 % }^^A
424 % \sbox0{\t}^^A
425 % \ifdim\wd0>\linewidth
426 % \begingroup
427 % \advance\linewidth by\leftmargin
428 % \advance\linewidth by\rightmargin
429 % \edef\x{\endgroup
430 % \def\noexpand\lw{\the\linewidth}^^A
431 % }\x
432 % \def\lwbox{^^A
433 % \leavevmode
434 % \hbox to \linewidth{^^A
435 % \kern-\leftmargin\relax
436 % \hss
437 % \usebox0
438 % \hss
439 % \kern-\rightmargin\relax
440 % }^^A
441 % }^^A
442 % \ifdim\wd0>\lw
443 % \sbox0{\small\t}^^A
444 % \ifdim\wd0>\linewidth
445 % \ifdim\wd0>\lw
446 % \sbox0{\footnotesize\t}^^A
447 % \ifdim\wd0>\linewidth
448 % \ifdim\wd0>\lw
449 % \sbox0{\scriptsize\t}^^A
450 % \ifdim\wd0>\linewidth
451 % \ifdim\wd0>\lw
452 % \sbox0{\tiny\t}^^A
453 % \ifdim\wd0>\linewidth
454 % \lwbox
455 % \else
456 % \usebox0
457 % \fi
458 % \else
459 % \lwbox
460 % \fi
461 % \else
462 % \usebox0
463 % \fi
464 % \else
465 % \lwbox
466 % \fi
467 % \else
468 % \usebox0
469 % \fi
470 % \else
471 % \lwbox
472 % \fi
473 % \else
474 % \usebox0
475 % \fi
476 % \else
477 % \lwbox
478 % \fi
479 % \else
480 % \usebox0
481 % \fi
482 % \end{quote}
483 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
484 % TDS installing feature, then some files can already be in the right
485 % place, see the documentation of \docstrip.
486 %
487 % \subsection{Refresh file name databases}
488 %
489 % If your \TeX~distribution
490 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
491 % these. For example, \TeX\,Live\ users run \verb|texhash| or
492 % \verb|mktexlsr|.
493 %
494 % \subsection{Some details for the interested}
495 %
496 % \paragraph{Unpacking with \LaTeX.}
497 % The \xfile{.dtx} chooses its action depending on the format:
498 % \begin{description}
499 % \item[\plainTeX:] Run \docstrip\ and extract the files.
500 % \item[\LaTeX:] Generate the documentation.
501 % \end{description}
502 % If you insist on using \LaTeX\ for \docstrip\ (really,
503 % \docstrip\ does not need \LaTeX), then inform the autodetect routine
504 % about your intention:
505 % \begin{quote}
506 % \verb|latex \let\install=y\input{twoopt.dtx}|
507 % \end{quote}
508 % Do not forget to quote the argument according to the demands
509 % of your shell.
510 %
511 % \paragraph{Generating the documentation.}
512 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
513 % the documentation. The process can be configured by the
514 % configuration file \xfile{ltxdoc.cfg}. For instance, put this
515 % line into this file, if you want to have A4 as paper format:
516 % \begin{quote}
517 % \verb|\PassOptionsToClass{a4paper}{article}|
518 % \end{quote}
519 % An example follows how to generate the
520 % documentation with pdf\LaTeX:
521 % \begin{quote}
522 %\begin{verbatim}
523 %pdflatex twoopt.dtx
524 %makeindex -s gind.ist twoopt.idx
525 %pdflatex twoopt.dtx
526 %makeindex -s gind.ist twoopt.idx
527 %pdflatex twoopt.dtx
528 %\end{verbatim}
529 % \end{quote}
530 %
531 % \begin{History}
532 % \begin{Version}{1998/10/30 v1.0}
533 % \item
534 % The first version was built as a response to a question
535 % of \NameEmail{Rebecca and Rowland}{[email protected]},
536 % published in the newsgroup
537 % \href{news:comp.text.tex}{comp.text.tex}:\\
538 % \URL{``Re: [Q] LaTeX command with two optional arguments?''}^^A
539 % {https://groups.google.com/group/comp.text.tex/msg/0ab1afde7b172d37}
540 % \end{Version}
541 % \begin{Version}{1998/10/30 v1.1}
542 % \item
543 % Improvements added in response to
544 % \NameEmail{Stefan Ulrich}{[email protected]}
545 % in the same thread:\\
546 % \URL{``Re: [Q] LaTeX command with two optional arguments?''}^^A
547 % {https://groups.google.com/group/comp.text.tex/msg/b8d84d4336f302c4}
548 % \end{Version}
549 % \begin{Version}{1998/11/04 v1.2}
550 % \item
551 % Fixes for LaTeX bugs 2896, 2901, 2902 added.
552 % \end{Version}
553 % \begin{Version}{1999/04/12 v1.3}
554 % \item
555 % Fixes removed because of LaTeX [1998/12/01].
556 % \item
557 % Documentation in dtx format.
558 % \item
559 % Copyright: LPPL (\CTAN{macros/latex/base/lppl.txt})
560 % \item
561 % First CTAN release.
562 % \end{Version}
563 % \begin{Version}{2006/02/20 v1.4}
564 % \item
565 % Code is not changed.
566 % \item
567 % New DTX framework.
568 % \item
569 % LPPL 1.3
570 % \end{Version}
571 % \begin{Version}{2008/08/11 v1.5}
572 % \item
573 % Code is not changed.
574 % \item
575 % URLs updated from \texttt{www.dejanews.com}
576 % to \texttt{groups.google.com}.
577 % \end{Version}
578 % \begin{Version}{2016/05/16 v1.6}
579 % \item
580 % Documentation updates.
581 % \end{Version}
582 % \end{History}
583 %
584 % \PrintIndex
585 %
586 % \Finale
587 \endinput