Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % File: ifdraft.dtx
4 % Version: 2016/05/16 v1.4
5 % Info: Detect class options draft and final
6 %
7 % Copyright (C)
8 % 1999, 2005, 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 ifdraft.dtx
29 % and the derived files
30 % ifdraft.sty, ifdraft.pdf, ifdraft.ins, ifdraft.drv.
31 %
32 % Distribution:
33 % CTAN:macros/latex/contrib/oberdiek/ifdraft.dtx
34 % CTAN:macros/latex/contrib/oberdiek/ifdraft.pdf
35 %
36 % Unpacking:
37 % (a) If ifdraft.ins is present:
38 % tex ifdraft.ins
39 % (b) Without ifdraft.ins:
40 % tex ifdraft.dtx
41 % (c) If you insist on using LaTeX
42 % latex \let\install=y\input{ifdraft.dtx}
43 % (quote the arguments according to the demands of your shell)
44 %
45 % Documentation:
46 % (a) If ifdraft.drv is present:
47 % latex ifdraft.drv
48 % (b) Without ifdraft.drv:
49 % latex ifdraft.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 ifdraft.dtx
57 % makeindex -s gind.ist ifdraft.idx
58 % pdflatex ifdraft.dtx
59 % makeindex -s gind.ist ifdraft.idx
60 % pdflatex ifdraft.dtx
61 %
62 % Installation:
63 % TDS:tex/latex/oberdiek/ifdraft.sty
64 % TDS:doc/latex/oberdiek/ifdraft.pdf
65 % TDS:source/latex/oberdiek/ifdraft.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: ifdraft 2016/05/16 v1.4 Detect class options draft and final (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: ifdraft
94 Version: 2016/05/16 v1.4
95
96 Copyright (C)
97 1999, 2005, 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 ifdraft.dtx
118 and the derived files
119 ifdraft.sty, ifdraft.pdf, ifdraft.ins, ifdraft.drv.
120
121 \endpreamble
122 \let\MetaPrefix\DoubleperCent
123
124 \generate{%
125 \file{ifdraft.ins}{\from{ifdraft.dtx}{install}}%
126 \file{ifdraft.drv}{\from{ifdraft.dtx}{driver}}%
127 \usedir{tex/latex/oberdiek}%
128 \file{ifdraft.sty}{\from{ifdraft.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{* ifdraft.sty}
139 \Msg{*}
140 \Msg{* To produce the documentation run the file `ifdraft.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{ifdraft.drv}%
155 [2016/05/16 v1.4 Detect class options draft and final (HO)]%
156 \documentclass{ltxdoc}
157 \usepackage{holtxdoc}[2011/11/22]
158 \begin{document}
159 \DocInput{ifdraft.dtx}%
160 \end{document}
161 %</driver>
162 % \fi
163 %
164 %
165 %
166 % \GetFileInfo{ifdraft.drv}
167 %
168 % \title{The \xpackage{ifdraft} package}
169 % \date{2016/05/16 v1.4}
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 % The package provides an interface for selecting code depending
177 % on the options \xoption{draft} and \xoption{final}.
178 % \end{abstract}
179 %
180 % \tableofcontents
181 %
182 % \section{Usage}
183 %
184 % \subsection{Package loading}
185 %
186 % In order to detect the global class options \xoption{draft}
187 % and \xoption{final}, load this package somewhere after
188 % \cs{documentclass} without options:
189 % \begin{quote}
190 % |\usepackage{ifdraft}|
191 % \end{quote}
192 %
193 % \subsection{User macros}
194 %
195 % \begin{declcs}{ifdraft}\ \M{draft case} \M{final case}\\
196 % \SpecialUsageIndex{\ifoptiondraft}^^A
197 % \cs{ifoptiondraft}\ \M{option draft is given}\ ^^A
198 % \M{option draft is not given}\\
199 % \SpecialUsageIndex{\ifoptionfinal}^^A
200 % \cs{ifoptionfinal}\ \M{option final is given}\ ^^A
201 % \M{option final is not given}
202 % \end{declcs}
203 % If none of the options \xoption{draft} or \xoption{final} is used,
204 % then this package assumes \xoption{final} as default setting
205 % for \cs{ifdraft}. All classes that are known to me behave this way.
206 % (Otherwise you can find out with
207 % \cs{ifoptiondraft} and \cs{ifoptionfinal}, whether none of
208 % the options is set.)
209 %
210 % If either \xoption{draft} or \xoption{final} is used, \cs{ifdraft} is
211 % sufficient to distinguish between these cases.
212 %
213 % Both options \xoption{draft} and \xoption{final} should not be used
214 % at the same time. This is contradictionary input.
215 % Which option is more important? The result is
216 % unpredictable in general:
217 % \begin{itemize}
218 % \item
219 % \xclass{article}, \xclass{report}, \xclass{book},
220 % \xclass{scrartcl}, \xclass{scrreprt}, \xclass{scrbook}:\\
221 % \xoption{draft}, \xoption{final}
222 % $\rightarrow$ \xoption{final} is effective.\\
223 % \xoption{final}, \xoption{draft}
224 % $\rightarrow$ \xoption{final} is effective.\\
225 % $\Rightarrow$ \xoption{final} wins, if given.
226 % \item
227 % \xclass{memoir}:\\
228 % \xoption{draft}, \xoption{final}
229 % $\rightarrow$ \xoption{draft} is effective.\\
230 % \xoption{final}, \xoption{draft}
231 % $\rightarrow$ \xoption{draft} is effective.\\
232 % $\Rightarrow$ \xoption{draft} wins if given.
233 % \end{itemize}
234 % These classes evaluates the options in declaration order.
235 % Because the declaration order of these options in this
236 % package is not really interesting, this packages evaluates
237 % the options in the order specified in the calling commands:
238 % \begin{itemize}
239 % \item
240 % \xpackage{ifdraft}:\\
241 % \xoption{draft}, \xoption{final}
242 % $\rightarrow$ \cs{ifdraft} selects \xoption{final} clause.\\
243 % \xoption{final}, \xoption{draft}
244 % $\rightarrow$ \cs{ifdraft} selects \xoption{draft} clause.\\
245 % $\Rightarrow$ latest given option wins.
246 % \end{itemize}
247 % Thus you know with \cs{ifdraft} the latest given option
248 % and you can emulate the behaviour of the different
249 % classes with the help of \cs{ifoptiondraft} and
250 % \cs{ifoptionfinal}.
251 %
252 % Summary: \cs{ifdraft} is sufficient to deal with the
253 % normal use cases: one or none out of \xoption{draft} and \xoption{final}.
254 %
255 % \StopEventually{
256 % }
257 %
258 % \section{Implementation}
259 %
260 % \begin{macrocode}
261 %<*package>
262 % \end{macrocode}
263 % Package identification.
264 % \begin{macrocode}
265 \NeedsTeXFormat{LaTeX2e}
266 \ProvidesPackage{ifdraft}%
267 [2016/05/16 v1.4 Detect class options draft and final (HO)]
268 % \end{macrocode}
269 %
270 % \begin{macrocode}
271 \newif\if@draft
272 \newif\if@option@draft
273 \newif\if@option@final
274 \DeclareOption{draft}{%
275 \@drafttrue
276 \@option@drafttrue
277 }
278 \DeclareOption{final}{%
279 \@draftfalse
280 \@option@finaltrue
281 }
282 \ProcessOptions*\relax
283 % \end{macrocode}
284 % \begin{macro}{\ifdraft}
285 % \begin{macrocode}
286 \newcommand*{\ifdraft}{%
287 \if@draft
288 \expandafter\@firstoftwo
289 \else
290 \expandafter\@secondoftwo
291 \fi
292 }
293 % \end{macrocode}
294 % \end{macro}
295 % \begin{macro}{\ifoptiondraft}
296 % \begin{macrocode}
297 \newcommand*{\ifoptiondraft}{%
298 \if@option@draft
299 \expandafter\@firstoftwo
300 \else
301 \expandafter\@secondoftwo
302 \fi
303 }
304 % \end{macrocode}
305 % \end{macro}
306 % \begin{macro}{\ifoptionfinal}
307 % \begin{macrocode}
308 \newcommand*{\ifoptionfinal}{%
309 \if@option@final
310 \expandafter\@firstoftwo
311 \else
312 \expandafter\@secondoftwo
313 \fi
314 }
315 % \end{macrocode}
316 % \end{macro}
317 % \begin{macrocode}
318 %</package>
319 % \end{macrocode}
320 %
321 % \section{Installation}
322 %
323 % \subsection{Download}
324 %
325 % \paragraph{Package.} This package is available on
326 % CTAN\footnote{\CTANpkg{ifdraft}}:
327 % \begin{description}
328 % \item[\CTAN{macros/latex/contrib/oberdiek/ifdraft.dtx}] The source file.
329 % \item[\CTAN{macros/latex/contrib/oberdiek/ifdraft.pdf}] Documentation.
330 % \end{description}
331 %
332 %
333 % \paragraph{Bundle.} All the packages of the bundle `oberdiek'
334 % are also available in a TDS compliant ZIP archive. There
335 % the packages are already unpacked and the documentation files
336 % are generated. The files and directories obey the TDS standard.
337 % \begin{description}
338 % \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}]
339 % \end{description}
340 % \emph{TDS} refers to the standard ``A Directory Structure
341 % for \TeX\ Files'' (\CTANpkg{tds}). Directories
342 % with \xfile{texmf} in their name are usually organized this way.
343 %
344 % \subsection{Bundle installation}
345 %
346 % \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
347 % TDS tree (also known as \xfile{texmf} tree) of your choice.
348 % Example (linux):
349 % \begin{quote}
350 % |unzip oberdiek.tds.zip -d ~/texmf|
351 % \end{quote}
352 %
353 % \subsection{Package installation}
354 %
355 % \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
356 % \docstrip\ archive. The files are extracted by running the
357 % \xfile{.dtx} through \plainTeX:
358 % \begin{quote}
359 % \verb|tex ifdraft.dtx|
360 % \end{quote}
361 %
362 % \paragraph{TDS.} Now the different files must be moved into
363 % the different directories in your installation TDS tree
364 % (also known as \xfile{texmf} tree):
365 % \begin{quote}
366 % \def\t{^^A
367 % \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
368 % ifdraft.sty & tex/latex/oberdiek/ifdraft.sty\\
369 % ifdraft.pdf & doc/latex/oberdiek/ifdraft.pdf\\
370 % ifdraft.dtx & source/latex/oberdiek/ifdraft.dtx\\
371 % \end{tabular}^^A
372 % }^^A
373 % \sbox0{\t}^^A
374 % \ifdim\wd0>\linewidth
375 % \begingroup
376 % \advance\linewidth by\leftmargin
377 % \advance\linewidth by\rightmargin
378 % \edef\x{\endgroup
379 % \def\noexpand\lw{\the\linewidth}^^A
380 % }\x
381 % \def\lwbox{^^A
382 % \leavevmode
383 % \hbox to \linewidth{^^A
384 % \kern-\leftmargin\relax
385 % \hss
386 % \usebox0
387 % \hss
388 % \kern-\rightmargin\relax
389 % }^^A
390 % }^^A
391 % \ifdim\wd0>\lw
392 % \sbox0{\small\t}^^A
393 % \ifdim\wd0>\linewidth
394 % \ifdim\wd0>\lw
395 % \sbox0{\footnotesize\t}^^A
396 % \ifdim\wd0>\linewidth
397 % \ifdim\wd0>\lw
398 % \sbox0{\scriptsize\t}^^A
399 % \ifdim\wd0>\linewidth
400 % \ifdim\wd0>\lw
401 % \sbox0{\tiny\t}^^A
402 % \ifdim\wd0>\linewidth
403 % \lwbox
404 % \else
405 % \usebox0
406 % \fi
407 % \else
408 % \lwbox
409 % \fi
410 % \else
411 % \usebox0
412 % \fi
413 % \else
414 % \lwbox
415 % \fi
416 % \else
417 % \usebox0
418 % \fi
419 % \else
420 % \lwbox
421 % \fi
422 % \else
423 % \usebox0
424 % \fi
425 % \else
426 % \lwbox
427 % \fi
428 % \else
429 % \usebox0
430 % \fi
431 % \end{quote}
432 % If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
433 % TDS installing feature, then some files can already be in the right
434 % place, see the documentation of \docstrip.
435 %
436 % \subsection{Refresh file name databases}
437 %
438 % If your \TeX~distribution
439 % (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh
440 % these. For example, \TeX\,Live\ users run \verb|texhash| or
441 % \verb|mktexlsr|.
442 %
443 % \subsection{Some details for the interested}
444 %
445 % \paragraph{Unpacking with \LaTeX.}
446 % The \xfile{.dtx} chooses its action depending on the format:
447 % \begin{description}
448 % \item[\plainTeX:] Run \docstrip\ and extract the files.
449 % \item[\LaTeX:] Generate the documentation.
450 % \end{description}
451 % If you insist on using \LaTeX\ for \docstrip\ (really,
452 % \docstrip\ does not need \LaTeX), then inform the autodetect routine
453 % about your intention:
454 % \begin{quote}
455 % \verb|latex \let\install=y\input{ifdraft.dtx}|
456 % \end{quote}
457 % Do not forget to quote the argument according to the demands
458 % of your shell.
459 %
460 % \paragraph{Generating the documentation.}
461 % You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
462 % the documentation. The process can be configured by the
463 % configuration file \xfile{ltxdoc.cfg}. For instance, put this
464 % line into this file, if you want to have A4 as paper format:
465 % \begin{quote}
466 % \verb|\PassOptionsToClass{a4paper}{article}|
467 % \end{quote}
468 % An example follows how to generate the
469 % documentation with pdf\LaTeX:
470 % \begin{quote}
471 %\begin{verbatim}
472 %pdflatex ifdraft.dtx
473 %makeindex -s gind.ist ifdraft.idx
474 %pdflatex ifdraft.dtx
475 %makeindex -s gind.ist ifdraft.idx
476 %pdflatex ifdraft.dtx
477 %\end{verbatim}
478 % \end{quote}
479 %
480 % \begin{History}
481 % \begin{Version}{1999/12/28 v1.0}
482 % \item
483 % First public release, published in newsgroup \xnewsgroup{de.comp.text.tex}:\\
484 % \URL{``\link{Re: auf vorhandensein der option "draft" pruefen}''}^^A
485 % {https://groups.google.com/group/de.comp.text.tex/msg/ccc1ccc9a8c224e9}
486 % \item
487 % LPPL 1.1
488 % \end{Version}
489 % \begin{Version}{2005/10/05 v1.1}
490 % \item
491 % \cs{ifoptiondraft} and \cs{ifoptionfinal} added.
492 % \item
493 % \cs{ProcessOptions} changed to \cs{ProcessOptions*}.
494 % (Order of given class options matters instead
495 % of the order of option declaration in this
496 % package.)
497 % \item
498 % LPPL 1.3
499 % \end{Version}
500 % \begin{Version}{2006/02/20 v1.2}
501 % \item
502 % DTX framework.
503 % \end{Version}
504 % \begin{Version}{2008/08/11 v1.3}
505 % \item
506 % Code is not changed.
507 % \item
508 % URLs updated.
509 % \end{Version}
510 % \begin{Version}{2016/05/16 v1.4}
511 % \item
512 % Documentation updates.
513 % \end{Version}
514 % \end{History}
515 %
516 % \PrintIndex
517 %
518 % \Finale
519 \endinput