Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % extract package by Hendri Adriaens.
4 %
5 % Extract package files and examples and create documentation:
6 % latex extract.dtx
7 % latex extract.dtx
8 % bibtex extract
9 % makeindex -s gglo.ist -o extract.gls extract.glo
10 % makeindex -s gind.ist -o extract.ind extract.idx
11 % latex extract.dtx
12 % latex extract.dtx
13 %
14 % To finish the installation you have to move the following
15 % file into a directory searched by LaTeX:
16 % extract.sty
17 %
18 %% ---------------------------------------
19 %% Copyright (C) 2004-2019 Hendri Adriaens
20 %% ---------------------------------------
21 %%
22 %% This work may be distributed and/or modified under the
23 %% conditions of the LaTeX Project Public License, either version 1.3
24 %% of this license or (at your option) any later version.
25 %% The latest version of this license is in
26 %% http://www.latex-project.org/lppl.txt
27 %% and version 1.3 or later is part of all distributions of LaTeX
28 %% version 2003/12/01 or later.
29 %%
30 %% This work has the LPPL maintenance status "maintained".
31 %%
32 %% This Current Maintainer of this work is Hendri Adriaens.
33 %%
34 %% This work consists of the file extract.dtx and the derived files
35 %% extract.sty, xtrex1.tex, xtrex2.tex, xtrex3.tex, xtrex4.tex,
36 %% xtrex5.tex, xtrex6.tex and xtrex7.tex.
37 %%
38 %% The following files constitute the extract package and must be
39 %% distributed as a whole: readme, extract.dtx, extract.pdf and
40 %% extract.sty.
41 %%
42 %<*batchfile>
43 \begingroup
44 \input docstrip
45 \keepsilent
46 \preamble
47 \endpreamble
48 \askforoverwritefalse
49 \generate{
50 \file{extract.sty}{\from{extract.dtx}{extract}}
51 \file{xtrex1.tex}{\from{extract.dtx}{xtrex1}}
52 \file{xtrex2.tex}{\from{extract.dtx}{xtrex2}}
53 \file{xtrex3.tex}{\from{extract.dtx}{xtrex3}}
54 \file{xtrex4.tex}{\from{extract.dtx}{xtrex4}}
55 \file{xtrex5.tex}{\from{extract.dtx}{xtrex5}}
56 \file{xtrex6.tex}{\from{extract.dtx}{xtrex6}}
57 \file{xtrex7.tex}{\from{extract.dtx}{xtrex7}}
58 \file{xtrpream.ble}{\from{extract.dtx}{preamble}}
59 \file{extract.bib}{\from{extract.dtx}{bib}}
60 }
61 \endgroup
62 %</batchfile>
63 %<*driver>
64 \documentclass[a4paper]{ltxdoc}
65 \input{xtrpream.ble}
66 \begin{document}
67 \DocInput{extract.dtx}
68 \let\Section\section\def\section*#1{\Section*{#1}\addcontentsline{toc}{section}{#1}}
69 \bibliographystyle{plain}
70 \bibliography{extract}
71 \section*{Acknowledgements}
72 Thanks go to David Carlisle for proposing the technique implemented
73 in this package to solve my initial problem.\footnote{See
74 section~\ref{sec:intro}.} Thanks also go to Michael Kohlhase and
75 Johannes Luber for reporting bugs and providing ideas for extensions
76 of the package.
77 \PrintChangesX\PrintIndexX
78 \end{document}
79 %</driver>
80 % \fi
81 %
82 % \changes{v1.0}{2004/12/19}{Initial release}
83 % \changes{v1.1}{2005/01/01}{Added conditional extraction using labels}
84 % \changes{v1.1}{2005/01/01}{Revised documentation}
85 % \changes{v1.2}{2005/01/06}{Fixed \cs{AfterEndEnv} hook for nested environments}
86 % \changes{v1.2}{2005/01/06}{Simplified optional argument check for \texttt{extract} environment}
87 % \changes{v1.2}{2005/01/06}{Increased efficiency of the package}
88 % \changes{v1.3}{2005/01/12}{Removed some input checks for more flexibility}
89 % \changes{v1.3}{2005/01/12}{Added \cs{extractline}}
90 % \changes{v1.3}{2005/01/12}{Added line extraction method for commands}
91 % \changes{v1.3}{2005/01/12}{Simplified package}
92 % \changes{v1.3}{2005/01/12}{Added \texttt{document-handles} option}
93 % \changes{v1.3}{2005/01/12}{Added examples and documentation}
94 % \changes{v1.3}{2005/01/12}{Updated license information}
95 % \changes{v1.4}{2005/02/06}{Adjusted options section for \pf{xkeyval} (\cs{XKV@tkey} not defined anymore)}
96 % \changes{v1.4}{2005/02/06}{Added \texttt{extractskip} environment}
97 % \changes{v1.4}{2005/02/06}{Allow for any filename}
98 % \changes{v1.4}{2005/02/06}{Changed temp extension to \texttt{.xtr}}
99 % \changes{v1.5}{2005/02/08}{Solved bug in options section}
100 % \changes{v1.5}{2005/02/08}{Avoid using counters for conditional extraction with numbers}
101 % \changes{v1.6}{2005/02/14}{Improved options section}
102 % \changes{v1.6}{2005/02/14}{Added optional header for extracted files}
103 % \changes{v1.7}{2005/03/31}{Solved small bug with `no-header' option}
104 % \changes{v1.7}{2005/03/31}{Revised documentation}
105 % \changes{v1.8}{2005/05/07}{Added \texttt{copydocumentclass} option}
106 % \changes{v1.8}{2005/05/07}{Changed name of option \texttt{no-header} to \texttt{header}}
107 % \changes{v1.8}{2005/05/07}{Changed name of option \texttt{document-handles} to \texttt{handles}}
108 % \changes{v1.8}{2005/05/07}{Revised documentation and examples}
109 %
110 % \GetFileInfo{extract.sty}
111 %
112 % \CheckSum{1069}
113 %
114 % \DoNotIndex{\@backslashchar,\@bsphack,\@checkend,\@currenvir,
115 % \@currenvline,\@doendpe,\@eha,\@ehc,\@empty,\@endpefalse,\@esphack,
116 % \@expandtwoargs,\@ifundefined,\@ignorefalse,\@latex@error,\do,
117 % \@makeother,\@namedef,\@ne,\@nil,\@nnil,\@temptokena,\@testopt,
118 % \active,\advance,\AtBeginDocument,\AtEndDocument,\begin,\begingroup,
119 % \catcode,\closeout,\csname,\CurrentOption,\DeclareOptionX,\def,
120 % \dospecials,\edef,\else,\end,\endcsname,\endgroup,\expandafter,\fi,
121 % \g@addto@macro,\global,\if@endpe,\if@ignore,\ifcat,\ifin@,\ifnum,\ifx,
122 % \ignorespaces,\immediate,\in@,\input,\jobname,\lccode,\let,\lowercase,
123 % \m@ne,\NeedsTeXFormat,\newcount,\newif,\newwrite,\noexpand,\on@line,
124 % \openout,\ProcessOptionsX,\ProvidesPackage,\relax,\RequirePackage,
125 % \reserved@a,\romannumeral,\string,\the,\write,\XTR@activefalse,
126 % \XTR@activetrue,\XTR@handlestrue,\XTR@resa,\XTR@tempa,\XTR@tempb,\z@,
127 % \PackageError,\gdef,\count@,\day,\divide,\month,\multiply,\space,
128 % \time,\xdef,\year,\@nameuse,\@tempcnta,\@tempcntb,\\,\!,\(,\),
129 % \define@boolkey,\XTR@sttrue,\XTR@stfalse,\documentclass,\filename@base,
130 % \filename@ext,\filename@parse,\KV@@sp@def,\XKV@afterelsefi,\XKV@afterfi,
131 % \XKV@classoptionslist,\XKV@documentclass,\XKV@for@n,\XKV@for@o,
132 % \XKV@ifstar,\XKV@ifundefined,\XKV@sp@deflist,\XKV@tkey,\chapter}
133 %
134 % \CharacterTable
135 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
136 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
137 % Digits \0\1\2\3\4\5\6\7\8\9
138 % Exclamation \! Double quote \" Hash (number) \#
139 % Dollar \$ Percent \% Ampersand \&
140 % Acute accent \' Left paren \( Right paren \)
141 % Asterisk \* Plus \+ Comma \,
142 % Minus \- Point \. Solidus \/
143 % Colon \: Semicolon \; Less than \<
144 % Equals \= Greater than \> Question mark \?
145 % Commercial at \@ Left bracket \[ Backslash \\
146 % Right bracket \] Circumflex \^ Underscore \_
147 % Grave accent \` Left brace \{ Vertical bar \|
148 % Right brace \} Tilde \~}
149 %
150 %\title{The \pf{extract} package
151 %\thanks{This package can be downloaded from the CTAN mirrors:
152 %\texttt{/macros/latex/contrib/extract}. See \texttt{extract.dtx} for
153 %information on installing \pf{extract} into your \LaTeX\
154 %distribution and for the license of this package.}}
155 %\author{\mktitledecor Hendri Adriaens}
156 %\date{\fileversion\ (\filedate)}
157 %\maketitle
158 %
159 %\begin{abstract}\noindent
160 %This package can be used to (conditionally) extract specific
161 %commands and environments from a source file and write them to a
162 %target file. This can be done without significant changes to the
163 %source document, but labels inside the source can be used for more
164 %flexibility. The package also provides environments to write code
165 %directly to the target file or use code in both the source and the
166 %target file. These tools allow one to generate ready-to-run files
167 %from a source document, containing only the extracted material, in
168 %an otherwise ordinary \LaTeX\ run.
169 %\end{abstract}
170 %
171 %\tableofcontents
172 %
173 %\section{Introduction}\label{sec:intro}
174 %I created this package when I was working on some lecture notes with
175 %exercises in the text and wanted to generate an exercises book on
176 %the fly. David Carlisle put forward the idea to use a technique as
177 %is now implemented in this package. The package heavily uses the
178 %\pf{verbatim} package \cite{verbatim} by Rainer Sch\"opf and uses
179 %the \pf{xkeyval} package \cite{xkeyval} to provide a simple and easy
180 %interface\footnote{And some tools like \cs{XKV@ifundefined} and
181 %\cs{XKV@sp@deflist}. See section~\ref{sec:imple} for more
182 %information.}.
183 %
184 %There are other packages around that provide tools for conditionally
185 %typesetting material or writing material to an external file. Let me list a few.
186 %\begin{description}
187 %\item[\pf{askinclude} \cite{askinclude}, \pf{excludeonly} \cite{excludeonly}]\indent\\
188 %These packages enhance \LaTeX's |\include| and |\includeonly|
189 %system to select the files that should be included in typesetting.
190 %\item[\pf{comment} \cite{comment}, \pf{verbatim} \cite{verbatim}, \pf{xcomment} \cite{xcomment}]\indent\\
191 %The first two packages define the |comment| environment and the
192 %third the |xcomment| environment. These environments ignore their
193 %body. But if the command |\xcomment| is used and supplied with a
194 %list of environments, these environments will be typeset when they
195 %appear in the body of the |xcomment| environment. The \pf{comment}
196 %package provides the commands |\includecomment| and
197 %|\excludecomment| to do a similar job.
198 %\item[\pf{optional} \cite{optional}, \pf{version} \cite{version}, \pf{versions} \cite{versions}]\indent\\
199 %These packages define some commands with which you can
200 %control which material should be typeset.
201 %\item[\pf{pagesel} \cite{pagesel}, \pf{pdfpages} \cite{pdfpages}, \pf{selectp} \cite{selectp}]\indent\\
202 %These packages only typeset certain pages.
203 %\item[\pf{fancyvrb} \cite{fancyvrb}, \pf{listings} \cite{listings}]\indent\\
204 %These packages (among others) provide tools to write text to an
205 %external file.
206 %\end{description}
207 %
208 %The \pf{extract} package differs from all these packages since it
209 %extracts content and leaves the typeset version of the original
210 %document untouched. Furthermore, for simple extraction jobs, it is
211 %not necessary to make any changes to the document other than adding
212 %the |\usepackage| command. This allows for conditional extraction of
213 %commands and environments based on the number of the command or
214 %environment counted from the beginning of the document. More
215 %flexible conditional extraction can be achieved by adding labels to
216 %the source document. How all of this works will be explained in the
217 %sections to come.
218 %
219 %\section{Environment extraction}\label{sec:envxtr}
220 %The following provides an example of the user interface of the package.
221 %\begin{example}
222 % \usepackage[
223 % active,
224 % generate=file,
225 % extract-env={figure,table}
226 % ]{extract}
227 %\end{example}
228 %\DescribeOptions{active,generate,extract-env}
229 %If the |active| option is not specified (or set to |false|), the
230 %package does nothing and no files are generated. If the option is
231 %specified, the package will redefine the environments |figure| and
232 %|table| so that they write their bodies (the content of the
233 %environment) to the file indicated with the |generate| option, here
234 %|file.tex|\footnote{If a file extension is lacking, \texttt{.tex}
235 %will be used.}, including the |\begin{figure}| and |\end{figure}|
236 %commands. Besides that, the environments will be executed as usual.
237 %Most environments are supported (known exception is the |document|
238 %environment). When the package encounters |\begin{document}| or
239 %|\end{document}| in the source file, by default\footnote{See
240 %section~\ref{sec:misc} for the \texttt{handles}
241 %option.}, it will also write these commands to the target file, such
242 %that, if a suitable preamble is added, the file is ready to be run
243 %by \LaTeX. See listing~\vref{list:env} for an example.\footnote{See
244 %section~\ref{sec:manual} for the \texttt{extract} environment,
245 %section~\ref{sec:misc} for the \texttt{copydocumentclass} option and
246 %section~\ref{sec:sande} how to obtain the example files.}
247 %\begin{Listing}\caption{Environment extraction.}\label{list:env}
248 %\begin{minipage}[t]{.49\linewidth}
249 %\hfill |xtrex1.tex|
250 %\begin{example}
251 % \documentclass[10pt]{article}
252 % \usepackage[
253 % active,
254 % generate=file,
255 % copydocumentclass=false,
256 % extract-env=equation
257 % ]{extract}
258 % \begin{extract}
259 % \documentclass[11pt]{article}
260 % \end{extract}
261 % \begin{document}
262 % Some text.
263 % \begin{equation}
264 % a^2+b^2=c^2
265 % \end{equation}
266 % Some text.
267 % \begin{equation}
268 % x^2+y^2=z^2
269 % \end{equation}
270 % Some text.
271 % \end{document}
272 %\end{example}
273 %\end{minipage}
274 %\hfill
275 %\begin{minipage}[t]{.49\linewidth}
276 %\hfill |file.tex|
277 %\begin{example}
278 % \documentclass[11pt]{article}
279 %
280 % \begin{document}
281 %
282 % \begin{equation}
283 % a^2+b^2=c^2
284 % \end{equation}
285 %
286 % \begin{equation}
287 % x^2+y^2=z^2
288 % \end{equation}
289 %
290 % \end{document}
291 %\end{example}
292 %\end{minipage}
293 %\end{Listing}
294 %The package will also write a header to the target file with some
295 %information about the source and time of generation of the target
296 %file. This header can be turned off with the |no-header| option.
297 %See also section~\ref{sec:misc}.
298 %
299 %\section{Command extraction}\label{sec:cmdxtr}
300 %\DescribeOptions{extract-cmd,extract-cmdline}
301 %This package can also extract commands. It supplies two methods to
302 %do this. See the example below.
303 %\begin{example}
304 % \usepackage[
305 % active,
306 % generate=file,
307 % extract-cmd=section,
308 % extract-cmdline=label
309 % ]{extract}
310 %\end{example}
311 %The first method (accessed with the |extract-cmd| option) is based
312 %on the particular syntax of the command and hence only supports
313 %particular commands. It will read it arguments and write them,
314 %together with the original command, to the target file. Besides
315 %that, the command will be executed as usual. Currently, the commands
316 %|\chapter|, |\section|, |\subsection|, and |\subsubsection| in the
317 %standard \LaTeX\ classes (and classes or packages derived from
318 %those) are supported. An optional argument to these commands, like
319 %|\chapter[short]{long}| is supported. However, the starred version
320 %|\chapter*{title}| will not be written to the file due to technical
321 %limitations. Sections~\ref{sec:how} and~\ref{sec:imple} will explain
322 %this in more detail.
323 %
324 %The second method (accessed with the |extract-cmdline| option) will
325 %redefine commands to write themselves and all the text following on
326 %the same line to the target file and will also execute the entire
327 %line as with an ordinary \LaTeX\ run. This allows to redefine any
328 %command that is not supported by the first method, but should be
329 %applied with care. If the command is used internally in a class or
330 %style file, your document might fail to run. In particular, one
331 %should not redefine one of the commands supported by the first
332 %method with this method. See listing~\vref{list:cmd} for a working
333 %example of both methods.\footnote{See section~\ref{sec:manual} for
334 %the \texttt{extract*} environment.}
335 %\begin{Listing}\caption{Command extraction.}\label{list:cmd}
336 %\begin{minipage}[t]{.49\linewidth}
337 %\hfill |xtrex2.tex|
338 %\begin{example}
339 % \documentclass{article}
340 % \usepackage[
341 % active,
342 % generate=file,
343 % extract-env=exercise,
344 % extract-cmd=section,
345 % extract-cmdline=label
346 % ]{extract}
347 % \begin{extract*}
348 % \newtheorem{exercise}{Exercise}
349 % \end{extract*}
350 % \begin{document}
351 % \section{Theory}
352 % \label{sec:1}
353 % Some text.
354 % \section{Exercises}
355 % \begin{exercise}
356 % Use the results from section
357 % \ref{sec:1} to show that\dots
358 % \end{exercise}
359 % Some text.
360 % \end{document}
361 %\end{example}
362 %\end{minipage}
363 %\hfill
364 %\begin{minipage}[t]{.49\linewidth}
365 %\hfill |file.tex|
366 %\begin{example}
367 % \documentclass{article}
368 % \newtheorem{exercise}{Exercise}
369 %
370 % \begin{document}
371 %
372 % \section{Theory}
373 %
374 % \label{sec:1}
375 %
376 % \section{Exercises}
377 %
378 % \begin{exercise}
379 % Use the results from section
380 % \ref{sec:1} to show that\dots
381 % \end{exercise}
382 %
383 % \end{document}
384 %\end{example}
385 %\end{minipage}
386 %\end{Listing}
387 %
388 %\section{Conditional extraction}\label{sec:conditional}
389 %\subsection{Extraction with numbers}
390 %\DescribeOptions{-nrs}
391 %It is also possible to conditionally extract environments and
392 %commands. After the options |extract-env|, |extract-cmd| and
393 %|exstract-cmdline| are used, for each environment or command
394 %specified there, there will be a new option with the name of that
395 %environment or command and the |-nrs| postfix. This option can take
396 %a comma separated list in which you can specify which environments
397 %or macros (counting from the |\usepackage{extract}|
398 %command\footnote{Notice that starred commands like \cs{chapter*},
399 %which won't be redefined by the \texttt{extract-cmd} option, will
400 %also not be counted.}) should be extracted. Table~\vref{tab:syntax} lists
401 %the syntax that can be used in the comma separated list. The term
402 %`item' is used for `command or environment'.
403 %\begin{table}[htb]\centering
404 %\begin{tabular}{cp{8.5cm}}
405 %Syntax&Meaning\\\hline
406 %$\meta{x}$&Item $\meta{x}$ will be extracted.\\
407 %-$\meta{x}$&All items up to and including item $\meta{x}$ will be extracted.\\
408 %$\meta{x}$-&All items from and including item $\meta{x}$ will be extracted.\\
409 %$\meta{x}$-$\meta{y}$&All items in between $\meta{x}$ and $\meta{y}$, including
410 %$\meta{x}$ and $\meta{y}$ will be extracted.
411 %\end{tabular}
412 %\caption{Syntax for conditional extraction with numbers.}\label{tab:syntax}
413 %\end{table}
414 %See an example in the listing below.
415 %\begin{example}
416 % \documentclass{book}
417 % \usepackage[
418 % active,
419 % generate=file,
420 % extract-env={figure,table},
421 % figure-nrs={-2,4-},
422 % extract-cmd=chapter,
423 % chapter-nrs={3-5,7}
424 % ]{extract}
425 % \begin{document}
426 % ...
427 % \end{document}
428 %\end{example}
429 %This example, when completed with content, will extract all |table|
430 %environments, |figure| environments 1, 2, and all figures from (and
431 %including) figure 4. It will also extract chapter commands 3 to 5 and 7.
432 %
433 %\subsection{Extraction with labels}
434 %\DescribeOptions{-labels}
435 %Conditional extraction is also possible with labels. The advantage of
436 %using labels is that output does not change (in comparison to using
437 %numbers) when commands or environments are added. The drawback is
438 %that one needs to modify the source document and add labels in the
439 %text.
440 %
441 %\DescribeMacro{\extractionlabel}
442 %Labels are declared with the following command.
443 %\begin{command}
444 % `\cs{extractionlabel}\marg{name}'
445 %\end{command}
446 %A label should be declared just before the command or environment
447 %that you want to extract. For instance
448 %\begin{example}
449 % \extractionlabel{exer-a}
450 % \begin{exercise}
451 % ...
452 % \end{exercise}
453 %\end{example}
454 %You can reuse the same label multiple times and you can specify
455 %which items should be extracted by the options with a |-labels|
456 %prefix. This works in the same way as with numbers.
457 %\begin{example}
458 % \documentclass{book}
459 % \usepackage[
460 % active,
461 % generate=file,
462 % extract-env=exercise,
463 % exercise-labels={exer-a,exer-c}
464 % ]{extract}
465 % \begin{document}
466 % ...
467 % \end{document}
468 %\end{example}
469 %This example will only extract exercises that have been preceded by
470 %the declaration |\extractionlabel{exer-a}| or
471 %|\extractionlabel{exer-c}|.
472 %
473 %When using both conditional extraction with numbers and with labels,
474 %the command or environment at hand will be extracted when at least
475 %on of the conditions is true. Find an example in listing~\vref{list:cond}.
476 %\begin{Listing}\caption{Conditional extraction.}\label{list:cond}
477 %\begin{minipage}[t]{.49\linewidth}
478 %\hfill |xtrex3.tex|
479 %\begin{example}
480 % \documentclass{article}
481 % \usepackage[
482 % active,
483 % generate=file,
484 % extract-env=figure,
485 % figure-nrs={1,3},
486 % figure-labels={fig-a,fig-b}
487 % ]{extract}
488 % \begin{document}
489 % Some text.
490 % \begin{figure}
491 % Figure 1.
492 % \end{figure}
493 % Some text.
494 % \extractionlabel{fig-a}
495 % \begin{figure}
496 % Figure 2.
497 % \end{figure}
498 % Some text.
499 % \extractionlabel{fig-b}
500 % \begin{figure}
501 % Figure 3.
502 % \end{figure}
503 % Some text.
504 % \extractionlabel{fig-c}
505 % \begin{figure}
506 % Figure 4.
507 % \end{figure}
508 % \end{document}
509 %\end{example}
510 %\end{minipage}
511 %\hfill
512 %\begin{minipage}[t]{.49\linewidth}
513 %\hfill |file.tex|
514 %\begin{example}
515 % \documentclass{article}
516 %
517 % \begin{document}
518 %
519 % \begin{figure}
520 % Figure 1.
521 % \end{figure}
522 %
523 % \begin{figure}
524 % Figure 2.
525 % \end{figure}
526 %
527 % \begin{figure}
528 % Figure 3.
529 % \end{figure}
530 %
531 % \end{document}
532 %\end{example}
533 %\end{minipage}
534 %\end{Listing}
535 %
536 %\section{Extraction tools}\label{sec:tools}
537 %\subsection{Manual extraction}\label{sec:manual}
538 %\DescribeEnv{extract}
539 %The package provides the environment |extract|.
540 %\begin{command}
541 % `\cs{begin\char`\{extract\char`\}}'
542 % `\meta{body}'
543 % `\cs{end\char`\{extract\char`\}}'
544 %\end{command}
545 %This environment writes its body only to the target file. This can
546 %be used to generate a preamble in the target file so that you can
547 %run the generated file through \LaTeX\ immediately after creation.
548 %See the example in listing~\vref{list:env} and the example below.
549 %
550 %\DescribeEnv{extract*}
551 %There also exists a starred version of the |extract| environment.
552 %\begin{command}
553 % `\cs{begin\char`\{extract*\char`\}}'
554 % `\meta{body}'
555 % `\cs{end\char`\{extract*\char`\}}'
556 %\end{command}
557 %This environment will not only write the body to the target file,
558 %but will also execute the code in the source document. This can be
559 %used to create a common preamble which holds packages and commands
560 %that will be used in both the source and the target file. See
561 %listing~\vref{list:cmd} and listing~\vref{list:xtrenv} for examples.
562 %Notice that the `answer' will not appear in |xtrex4.dvi|.
563 %\begin{Listing}\caption{Extract environments.}\label{list:xtrenv}
564 %\begin{minipage}[t]{.49\linewidth}
565 %\hfill |xtrex4.tex|
566 %\begin{example}
567 % \documentclass{article}
568 % \usepackage[
569 % active,
570 % generate=file,
571 % extract-env=equation*
572 % ]{extract}
573 % \begin{extract*}
574 % \usepackage{amsmath}
575 % \end{extract*}
576 % \begin{document}
577 % Some text.
578 % \begin{equation*}
579 % x^2+y^2=z^2
580 % \end{equation*}
581 % \begin{extract}
582 % $x=3$, $y=4$ and $z=5$
583 % satisfy this equation.
584 % \end{extract}
585 % \end{document}
586 %\end{example}
587 %\end{minipage}
588 %\hfill
589 %\begin{minipage}[t]{.49\linewidth}
590 %\hfill |file.tex|
591 %\begin{example}
592 % \documentclass{article}
593 % \usepackage{amsmath}
594 %
595 % \begin{document}
596 %
597 % \begin{equation*}
598 % x^2+y^2=z^2
599 % \end{equation*}
600 % $x=3$, $y=4$ and $z=5$
601 % satisfy this equation.
602 %
603 % \end{document}
604 %\end{example}
605 %\end{minipage}
606 %\end{Listing}
607 %
608 %\DescribeMacros{\extractline,\extractline*}
609 %The package also provides a command that extracts the current line.
610 %\begin{command}
611 % `\cs{extractline}'
612 % `\cs{extractline*}'
613 %\end{command}
614 %The starred version also executes the code at that line. See the
615 %example below.
616 %\begin{example}
617 % \extractline This line should be extracted.
618 % \extractline*This line should be extracted and executed.
619 %\end{example}
620 %Notice that a space is following the command |\extractline| and that no space is
621 %following the command |\extractline*|. In the first line, \LaTeX\ will eat this
622 %space, but it won't do that in the second line. If we add a space
623 %there in between the |*| and |This|, this space will be executed and
624 %extracted as well.
625 %
626 %\DescribeMacros{\extractline,\extractline*}
627 %\DescribeEnvs{extract,extract*}
628 %The |extract| and |extract*| environments and the macros
629 %|\extractionlabel| and |\extractionlabel*| have an optional argument
630 %for specifying the label directly.
631 %\begin{command}
632 % `\cs{begin\char`\{extract\char`\}}\oarg{name}'
633 % `\cs{begin\char`\{extract*\char`\}}\oarg{name}'
634 % `\cs{extractline}\oarg{name}'
635 % `\cs{extractline*}\oarg{name}'
636 %\end{command}
637 %\newpage
638 %\DescribeOptions{extract-nrs,line-nrs,extract-labels,line-labels}
639 %The options |extract-nrs| and |line-nrs| can be used to
640 %control conditional extraction of these environments and commands
641 %using numbers. Moreover, one can do conditional extractions with
642 %labels for these commands and environments as well. Use the options
643 %|extract-labels| and |line-labels| for that purpose. See also
644 %section~\ref{sec:conditional} for information about conditional extraction.
645 %
646 %See an example in listing~\vref{list:optlab}.
647 %This example will demonstrate that only certain lines and environments
648 %are extracted. Note that, when running |xtrex5.tex| with \LaTeX,
649 %the output, |xtrex5.dvi|, will contain the following.
650 %\begin{example}
651 % line 2
652 % line 4
653 % line 5
654 %\end{example}
655 %\begin{Listing}\caption{Optional labels.}\label{list:optlab}
656 %\begin{minipage}[t]{.49\linewidth}
657 %\hfill |xtrex5.tex|
658 %\begin{example}
659 % \documentclass{article}
660 % \usepackage[
661 % active,
662 % generate=file,
663 % copydocumentclass=false,
664 % extract-labels=type-a,
665 % line-labels={type-a,type-c},
666 % line-nrs=3
667 % ]{extract}
668 % \begin{extract}[type-a]
669 % \documentclass{article}
670 % \end{extract}
671 % \begin{extract}[type-b]
672 % \documentclass{book}
673 % \end{extract}
674 % \begin{document}
675 % \parindent0pt
676 % \extractline[type-a]line 1\\
677 % \extractline*line 2\\
678 % \extractline line 3\\
679 % \extractline*[type-a]line 4\\
680 % \extractline*[type-c]line 5\\
681 % \extractline line 6\\
682 % \end{document}
683 %\end{example}
684 %\end{minipage}
685 %\hfill
686 %\begin{minipage}[t]{.49\linewidth}
687 %\hfill |file.tex|
688 %\begin{example}
689 % \documentclass{article}
690 %
691 % \begin{document}
692 % line 1\\
693 % line 3\\
694 % line 4\\
695 % line 5\\
696 %
697 % \end{document}
698 %\end{example}
699 %\end{minipage}
700 %\end{Listing}
701 %
702 %\subsection{Skipping extraction}
703 %\DescribeEnv{extractskip}
704 %The package also provides the |extractskip| environment.
705 %\begin{command}
706 % `\cs{begin\char`\{extractskip\char`\}}\oarg{name}'
707 % `\meta{body}'
708 % `\cs{end\char`\{extractskip\char`\}}'
709 %\end{command}
710 %The body of this environment will not be written to the target file,
711 %but will be executed. This environment can be used to skip material
712 %in an environment which extracts its entire body. This could be the
713 %|extract| environment, but also an environment that has been
714 %redefined to be extracted using the |extract-env| option. The argument
715 %\meta{name} is optional and contains the label.
716 %
717 %\DescribeOptions{extractskip-nrs,extractskip-labels}
718 %This environment can also operate conditionally as has been
719 %described in section~\ref{sec:conditional} using the options
720 %|extractskip-nrs| and |extractskip-labels|. Listings~\vref{list:skip1}
721 %and~\vref{list:skip2} will demonstrate this environment.
722 %\begin{Listing}\caption{Skipping extraction.}\label{list:skip1}
723 %\begin{minipage}[t]{.49\linewidth}
724 %\hfill |xtrex6.tex|
725 %\begin{example}
726 % \documentclass{article}
727 % \usepackage[
728 % active,
729 % generate=file,
730 % extract-env=figure
731 % ]{extract}
732 % \begin{document}
733 % \begin{figure}[!h]
734 % \begin{extractskip}
735 % \fbox{figure 1}
736 % \end{extractskip}
737 % \fbox{figure 2}
738 % \end{figure}
739 % \begin{extract*}
740 % \begin{itemize}
741 % \item 1
742 % \item 2
743 % a\begin{extractskip}b
744 % \item 3
745 % c\end{extractskip}d
746 % \item 4
747 % \begin{extractskip}
748 % \item 5
749 % \end{extractskip}
750 % \end{itemize}
751 % \end{extract*}
752 % \end{document}
753 %\end{example}
754 %\end{minipage}
755 %\hfill
756 %\begin{minipage}[t]{.49\linewidth}
757 %\hfill |file.tex|
758 %\begin{example}
759 % \documentclass{article}
760 %
761 % \begin{document}
762 %
763 % \begin{figure}[!h]
764 % \fbox{figure 2}
765 % \end{figure}
766 % \begin{itemize}
767 % \item 1
768 % \item 2
769 % a
770 % d
771 % \item 4
772 % \end{itemize}
773 %
774 % \end{document}
775 %\end{example}
776 %\end{minipage}
777 %\end{Listing}
778 %\begin{Listing}\caption{Skipping extraction conditionally.}\label{list:skip2}
779 %\begin{minipage}[t]{.49\linewidth}
780 %\hfill |xtrex7.tex|
781 %\begin{example}
782 % \documentclass{article}
783 % \usepackage[
784 % active,
785 % generate=file,
786 % extractskip-labels=skipb
787 % ]{extract}
788 % \begin{document}
789 % \begin{extract*}
790 % \begin{itemize}
791 % \begin{extractskip}[skipa]
792 % \item 1
793 % \end{extractskip}
794 % \begin{extractskip}[skipb]
795 % \item 2
796 % \end{extractskip}
797 % \begin{extractskip}[skipc]
798 % \item 3
799 % \end{extractskip}
800 % \end{itemize}
801 % \end{extract*}
802 % \end{document}
803 %\end{example}
804 %\end{minipage}
805 %\hfill
806 %\begin{minipage}[t]{.49\linewidth}
807 %\hfill |file.tex|
808 %\begin{example}
809 % \documentclass{article}
810 %
811 % \begin{document}
812 % \begin{itemize}
813 % \item 1
814 % \item 3
815 % \end{itemize}
816 %
817 % \end{document}
818 %\end{example}
819 %\end{minipage}
820 %\end{Listing}
821 %
822 %\subsection{Miscellaneous options}\label{sec:misc}
823 %\DescribeOption{header} When setting the |header| option to
824 %|false|, no header will be written to the target file. If the option
825 %is not specified or set to |true|, the package will write a header
826 %to the target file including information on when the target file was
827 %generated and which source file was used.
828 %
829 %\DescribeOption{handles}
830 %This option controls whether the package will write
831 %|\begin{document}| and |\end{document}| to the target file when it
832 %encounters these commands in the source document. By default, this
833 %option is set to |true|. When the option is set to |false|, the
834 %generated file can be |\input|ed or |\include|d by another file
835 %immediately after production.
836 %
837 %\DescribeOption{copydocumentclass}
838 %This option control whether the target file should get the same
839 %|\documentclass| command as the source document (including class
840 %options). If set to |false|, you should specify another document class
841 %for the target file, for instance using the |extract| environment.
842 %See listing~\vref{list:env} for an example.
843 %
844 %\section{How it works, limitations}\label{sec:how}
845 %The package works as follows. When an environment is asked to be
846 %extracted, the package will first make a backup of the environment
847 %with the |XTR| prefix, for instance, |XTRequation*|. After that, the
848 %package will redefine the environment to read the lines of its body
849 %verbatim (without executing), parse the lines to locate
850 %|extractskip| environments and write all lines to a temporary file
851 %and the lines that are not in an |extractskip| environment to a
852 %temporary file. After the environment is finished, the temporary
853 %file, containing for instance
854 %\begin{example}
855 % \begin{XTRequation*}
856 % x^2+y^2=z^2
857 % \end{XTRequation*}
858 %\end{example}
859 %will be inserted in the source document using |\input|. This works,
860 %at least in theory, with most environments. Notice that this method
861 %does require a change to the |\begin| and |\end| macros provided by
862 %the \LaTeX\ kernel \cite{LaTeXbase}. I had to add a hook to these
863 %commands to be able to collect code to be executed after the current
864 %environment is ended. In particular, this package will use those
865 %hooks to |\input| the original code after finishing the current
866 %group. See section~\ref{sec:imple} for more details.
867 %
868 %Commands require a different approach. As a command can have a very
869 %specific argument structure, redefining commands safely, without
870 %distorting its original behavior, is not possible in general. I have
871 %chosen to support the most basic document structure commands as
872 %provided by standard \LaTeX\ classes, like \pf{book} and
873 %\pf{article}. Extraction of commands from other classes, like
874 %provided by the \pf{koma-script} bundle, might work, but there is no
875 %guarantee.
876 %
877 %To be more precise: when requested, the macros |\@chapter| and
878 %|\@sect| will be redefined. These commands are at the basis of all
879 %chapter and section commands. When \pf{extract} redefines one of
880 %these commands, it first makes a backup, like |\XTR@chapter|. After
881 %that, it will redefine the original command to read its argument(s),
882 %export them to the target file and execute the backup with the
883 %proper arguments.
884 %
885 %An alternative to this, rather restricted method is the method
886 %accessed by the |extract-cmdline| option which redefines the
887 %commands listed there to read the entire line of text, write that to
888 %the target file and afterwards execute it with a backup copy of the
889 %original command. This methods too has its drawbacks though as you
890 %can't redefine commands that are used internally in other macros.
891 %
892 %More details on the package code can be found in
893 %section~\ref{sec:imple}.
894 %
895 %\section{Source and examples}\label{sec:sande}
896 %To generate this documentation, find the source of this
897 %package, |extract.dtx| in your local \LaTeX\ installation or on CTAN
898 %and perform the following steps.
899 %\begin{example}
900 % latex extract.dtx
901 % latex extract.dtx
902 % bibtex extract
903 % makeindex -s gglo.ist -o extract.gls extract.glo
904 % makeindex -s gind.ist -o extract.ind extract.idx
905 % latex extract.dtx
906 % latex extract.dtx
907 %\end{example}
908 %
909 %If you only want to produce the package and example files from the
910 %source, then the first step is sufficient. This step will generate
911 %the package file |extract.sty| and the example files |xtrex1.tex|,
912 %|xtrex2.tex|, |xtrex3.tex|, |xtrex4.tex|, |xtrex5.tex|, |xtrex6.tex|
913 %and |xtrex7.tex|.
914 %
915 %\StopEventually{}
916 %
917 % \section{Implementation}\label{sec:imple}
918 % Initializations.
919 % \begin{macrocode}
920 %<*extract>
921 \NeedsTeXFormat{LaTeX2e}[1995/12/01]
922 \ProvidesPackage{extract}
923 [2019/09/18 v1.9a extract content from document (HA)]
924 \RequirePackage{verbatim}
925 \RequirePackage{xkeyval}
926 \newwrite\XTR@out
927 \newwrite\XTR@tmp
928 \newif\ifXTR@st
929 \newif\ifXTR@skip
930 \newif\ifXTR@extract
931 % \end{macrocode}
932 % \begin{macro}{\XTR@err}
933 % \marg{text}\\
934 % Error macro.
935 % \begin{macrocode}
936 \def\XTR@err#1{\PackageError{extract}{#1}\@ehc}
937 % \end{macrocode}
938 % \end{macro}
939 % \begin{macro}{\XTR@namelet}
940 % \marg{cmd1}\marg{cmd2}\\
941 % Version of |\let| for two command sequence names.
942 % \begin{macrocode}
943 \def\XTR@namelet#1#2{%
944 \expandafter\let\csname#1\expandafter\endcsname\csname#2\endcsname
945 }
946 % \end{macrocode}
947 % \end{macro}
948 % Options section, powered by \pf{xkeyval}.
949 % \DescribeOption{active}
950 % Control extraction with one switch.
951 % \begin{macrocode}
952 \define@boolkey[XTR]{extract.sty}[XTR@]{active}[true]{}
953 % \end{macrocode}
954 % \DescribeOption{header}
955 % Do not create a header in the target file.
956 % \begin{macrocode}
957 \define@boolkey[XTR]{extract.sty}[XTR@]{header}[true]{}
958 % \end{macrocode}
959 % \DescribeOption{handles}
960 % Extract |\begin{document}| and |\end{document}| or not.
961 % \begin{macrocode}
962 \define@boolkey[XTR]{extract.sty}[XTR@]{handles}[true]{}
963 % \end{macrocode}
964 % \DescribeOption{copydocumentclass}
965 % Copy the |\documentclass| command to the target file.
966 % \begin{macrocode}
967 \define@boolkey[XTR]{extract.sty}[XTR@]{copydocumentclass}[true]{}
968 % \end{macrocode}
969 % \DescribeOption{generate}
970 % Entry point for the target file name.
971 % \begin{macrocode}
972 \DeclareOptionX[XTR]{generate}{\lowercase{\def\XTR@file{#1}}}
973 % \end{macrocode}
974 % \DescribeOption{extract-env}
975 % Environments that should be extracted.
976 % \begin{macrocode}
977 \DeclareOptionX[XTR]{extract-env}{%
978 \def\XTR@envs{#1}%
979 \XKV@for@n{#1}\XTR@tempa\XTR@tempb
980 }
981 % \end{macrocode}
982 % \DescribeOption{extract-cmd}
983 % Commands that should be extracted with the `arguments method'.
984 % \begin{macrocode}
985 \DeclareOptionX[XTR]{extract-cmd}{%
986 \def\XTR@cmdsargs{#1}%
987 \XKV@for@n{#1}\XTR@tempa\XTR@tempb
988 }
989 % \end{macrocode}
990 % \DescribeOption{extract-cmdline}
991 % Commands that should be extracted with the `line method'.
992 % \begin{macrocode}
993 \DeclareOptionX[XTR]{extract-cmdline}{%
994 \def\XTR@cmdsline{#1}%
995 \XKV@for@n{#1}\XTR@tempa\XTR@tempb
996 }
997 \def\XTR@tempb{%
998 % \end{macrocode}
999 % \DescribeOptions{-nrs,-labels}
1000 % For each environment or command provide new package options that
1001 % save the argument to a list cleared from redundant spaces. The
1002 % |-nrs| options also create a `counter' for counting the commands or
1003 % environments. The lists and counters will be used for conditional
1004 % extraction. Note that |\XTR@tkey| contains the key name inside
1005 % the option macro (due to the use of |\ProcessOptionsXi|).
1006 % \begin{macrocode}
1007 \DeclareOptionX[XTR]{\XTR@tempa-nrs}{%
1008 \expandafter\XKV@sp@deflist\csname XTR@\XKV@tkey\endcsname{##1}%
1009 \XTR@namelet{XTR@\XKV@tkey @cnt}{z@}%
1010 }%
1011 \DeclareOptionX[XTR]{\XTR@tempa-labels}{%
1012 \expandafter\XKV@sp@deflist\csname XTR@\XKV@tkey\endcsname{##1}%
1013 }%
1014 }
1015 % \end{macrocode}
1016 % \DescribeOptions{line-nrs,line-labels}
1017 % Generate options for |\extractline| commands.
1018 % \begin{macrocode}
1019 \def\XTR@tempa{line}\XTR@tempb
1020 % \end{macrocode}
1021 % \DescribeOptions{extract-nrs,extract-labels}
1022 % Generate options for |extract| environments.
1023 % \begin{macrocode}
1024 \def\XTR@tempa{extract}\XTR@tempb
1025 % \end{macrocode}
1026 % \DescribeOptions{extractskip-nrs,extractskip-labels}
1027 % Generate options for |extractskip| environments.
1028 % \begin{macrocode}
1029 \def\XTR@tempa{extractskip}\XTR@tempb
1030 % \end{macrocode}
1031 % Generate an error for unknown options.
1032 % \begin{macrocode}
1033 \DeclareOptionX*{\XTR@err{Unknown option `\CurrentOption'}}
1034 % \end{macrocode}
1035 % Initialize options.
1036 % \begin{macrocode}
1037 \ExecuteOptionsX[XTR]{header=true,handles=true,copydocumentclass=true}
1038 % \end{macrocode}
1039 % Process options.
1040 % \begin{macrocode}
1041 \ProcessOptionsX[XTR]
1042 % \end{macrocode}
1043 % \begin{macro}{\XTR@opentmp}
1044 % \begin{macro}{\XTR@writetmp}
1045 % \begin{macro}{\XTR@closetmp}
1046 % \begin{macro}{\XTR@writeout}
1047 % Shortcut macros for much used command sequences.
1048 % \begin{macrocode}
1049 \def\XTR@opentmp{\immediate\openout\XTR@tmp\jobname.xtr\relax}
1050 \def\XTR@writetmp{\immediate\write\XTR@tmp}
1051 \def\XTR@closetmp{\immediate\closeout\XTR@tmp}
1052 \def\XTR@writeout{\immediate\write\XTR@out}
1053 % \end{macrocode}
1054 % \end{macro}
1055 % \end{macro}
1056 % \end{macro}
1057 % \end{macro}
1058 % Perform some checks on the input. Notice the use of |\XKV@ifundefined|
1059 % which is equal to |\@ifundefined| if no $\varepsilon$-\TeX\ engine
1060 % is available and which uses |\ifcsname| when it is. In the latter
1061 % case, testing whether commands are defined does not create an
1062 % entry in \TeX's hash table.
1063 % \begin{macrocode}
1064 \ifXTR@active
1065 \XKV@ifundefined{XTR@file}{
1066 \XTR@activefalse
1067 \XTR@err{no file to generate; extract deactivated}
1068 }{}
1069 \XTR@opentmp
1070 \XTR@writetmp{%
1071 \string\lowercase{\string\def\string\XTR@tempa{\jobname}}%
1072 }
1073 \XTR@closetmp
1074 \input{\jobname.xtr}
1075 \ifx\XTR@tempa\XTR@file
1076 \XTR@activefalse
1077 \XTR@err{attempt to overwrite source file; extract deactivated}
1078 \fi
1079 \fi
1080 % \end{macrocode}
1081 % \begin{macro}{\@envdepth}
1082 % Counter for depth of environments.
1083 % \begin{macrocode}
1084 \newcount\@envdepth\@envdepth\z@
1085 % \end{macrocode}
1086 % \end{macro}
1087 % \begin{macro}{\begin}
1088 % \marg{environment}\\
1089 % \changes{v1.9a}{2019/09/18}{Added definitions for robust versions of \cs{begin} and \cs{end}}
1090 % Modify the macro |\begin| to allow adding code to a level specific
1091 % hook which can be executed after |\endgroup| in |\end|. See for
1092 % more info on this macro the \LaTeX\ source~\cite{LaTeXbase}. We first do this
1093 % for the new \LaTeX\ format, which defines robust versions of |\begin| and |\end|.
1094 % \begin{macrocode}
1095 \@ifl@t@r\fmtversion{2019/10/01}%
1096 {% new format
1097 \@namedef{begin }#1{%
1098 \@ifundefined{#1}%
1099 {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
1100 {\def\reserved@a{\def\@currenvir{#1}%
1101 \edef\@currenvline{\on@line}%
1102 \csname #1\endcsname}}%
1103 \@ignorefalse
1104 \begingroup\@endpefalse
1105 % \end{macrocode}
1106 % Advance depth level.
1107 % \begin{macrocode}
1108 \global\advance\@envdepth\@ne
1109 % \end{macrocode}
1110 % Initialize the hook for this level.
1111 % \begin{macrocode}
1112 \global\@namedef{@afterendenvhook@\romannumeral\@envdepth}{}%
1113 \reserved@a
1114 }%
1115 % \end{macrocode}
1116 % \end{macro}
1117 % \begin{macro}{\end}
1118 % \marg{environment}\\
1119 % Modify |\end| to execute the code collected in the hook.
1120 % \begin{macrocode}
1121 \@namedef{end }#1{%
1122 \csname end#1\endcsname\@checkend{#1}%
1123 \expandafter\endgroup\if@endpe\@doendpe\fi
1124 % \end{macrocode}
1125 % Copy current hook code to a temporary macro.
1126 % \begin{macrocode}
1127 \expandafter\let\expandafter\reserved@a
1128 \csname @afterendenvhook@\romannumeral\@envdepth\endcsname
1129 % \end{macrocode}
1130 % Decrease the depth.
1131 % \begin{macrocode}
1132 \global\advance\@envdepth\m@ne
1133 % \end{macrocode}
1134 % Execute the hook of the current environment. This is done after
1135 % decreasing the depth as to avoid level mixing problems when the
1136 % hook contains another environment. This environment has to be
1137 % executed at the same level as the environment in which the hook was
1138 % defined since it is executed after the group and does not belong
1139 % anymore to the environment in which the hook was defined.
1140 % \begin{macrocode}
1141 \reserved@a\relax
1142 \if@ignore\@ignorefalse\ignorespaces\fi
1143 }%
1144 % \end{macrocode}
1145 % \end{macro}
1146 % \begin{macro}{\begin}
1147 % \marg{environment}\\
1148 % This is the code for the old format of \LaTeX.
1149 % \begin{macrocode}
1150 }{% old format
1151 \def\begin#1{%
1152 \@ifundefined{#1}%
1153 {\def\reserved@a{\@latex@error{Environment #1 undefined}\@eha}}%
1154 {\def\reserved@a{\def\@currenvir{#1}%
1155 \edef\@currenvline{\on@line}%
1156 \csname #1\endcsname}}%
1157 \@ignorefalse
1158 \begingroup\@endpefalse
1159 \global\advance\@envdepth\@ne
1160 \global\@namedef{@afterendenvhook@\romannumeral\@envdepth}{}%
1161 \reserved@a
1162 }%
1163 % \end{macrocode}
1164 % \end{macro}
1165 % \begin{macro}{\end}
1166 % \marg{environment}
1167 % This is the code for the old format of \LaTeX.
1168 % \begin{macrocode}
1169 \def\end#1{%
1170 \csname end#1\endcsname\@checkend{#1}%
1171 \expandafter\endgroup\if@endpe\@doendpe\fi
1172 \expandafter\let\expandafter\reserved@a
1173 \csname @afterendenvhook@\romannumeral\@envdepth\endcsname
1174 \global\advance\@envdepth\m@ne
1175 \reserved@a\relax
1176 \if@ignore\@ignorefalse\ignorespaces\fi
1177 }%
1178 }
1179 % \end{macrocode}
1180 % \end{macro}
1181 % \begin{macro}{\AfterEndEnv}
1182 % Adds code to the macros |\@afterendenvhook@i|, |ii|, etc. which will
1183 % be executed after the group of the current environment.
1184 % \begin{macrocode}
1185 \def\AfterEndEnv{%
1186 \expandafter\g@addto@macro
1187 \csname @afterendenvhook@\romannumeral\@envdepth\endcsname
1188 }
1189 % \end{macrocode}
1190 % \end{macro}
1191 % \begin{macro}{\XTR@checkxtr}
1192 % \marg{type}\marg{item}\\
1193 % Checks whether a certain environment or command should be extracted or skipped.
1194 % \meta{type} is the type of check: for extraction or for skipping
1195 % content. \meta{item} is the name of a command or an environment.
1196 % \begin{macrocode}
1197 \def\XTR@checkxtr#1#2{%
1198 \@nameuse{XTR@#1false}%
1199 \XTR@namelet{XTR@maketrue}{XTR@#1true}%
1200 % \end{macrocode}
1201 % First check whether, for this macro or environment, some method of
1202 % conditional extraction is used. If not, just extract.
1203 % \begin{macrocode}
1204 \XKV@ifundefined{XTR@#2-nrs}{%
1205 \XKV@ifundefined{XTR@#2-labels}\XTR@maketrue{}%
1206 }{%
1207 % \end{macrocode}
1208 % Advance the `counter'.
1209 % \begin{macrocode}
1210 \begingroup
1211 \expandafter\count@\csname XTR@#2-nrs@cnt\endcsname
1212 \advance\count@\@ne
1213 \edef\XTR@resa{\expandafter\noexpand\expandafter\gdef\expandafter
1214 \noexpand\csname XTR@#2-nrs@cnt\endcsname{\the\count@}}%
1215 \expandafter\endgroup\XTR@resa
1216 }%
1217 \@nameuse{ifXTR@#1}\else
1218 \XKV@ifundefined{XTR@#2-labels}{}{%
1219 % \end{macrocode}
1220 % If the current label is in the list for extraction, extract it.
1221 % \begin{macrocode}
1222 \ifx\XTR@currentlabel\relax\else
1223 \@expandtwoargs\in@{,\XTR@currentlabel,}%
1224 {,\csname XTR@#2-labels\endcsname,}%
1225 \ifin@\XTR@maketrue\fi
1226 \fi
1227 }%
1228 \fi
1229 \@nameuse{ifXTR@#1}\else
1230 \XKV@ifundefined{XTR@#2-nrs}{}{%
1231 % \end{macrocode}
1232 % If the current command or environment number is in the list, extract it.
1233 % \begin{macrocode}
1234 \expandafter\XTR@ch@ckxtr\csname XTR@#2-nrs\expandafter
1235 \endcsname\csname XTR@#2-nrs@cnt\endcsname
1236 }%
1237 \fi
1238 % \end{macrocode}
1239 % Redefine |\XTR@currentlabel| to avoid extracting all following
1240 % environments of this type.
1241 % \begin{macrocode}
1242 \global\let\XTR@currentlabel\relax
1243 }
1244 % \end{macrocode}
1245 % \end{macro}
1246 % \begin{macro}{\XTR@ch@ckxtr}
1247 % \meta{list}\meta{counter}\\
1248 % Parse the \meta{list} of numbers and compare each item with the
1249 %\meta{counter} holding the number of the current item.
1250 % \begin{macrocode}
1251 \def\XTR@ch@ckxtr#1#2{%
1252 \XKV@for@o#1\XTR@resa{\expandafter\XTR@ch@ck@tr\XTR@resa--\@nil#2}%
1253 }
1254 % \end{macrocode}
1255 % \end{macro}
1256 % \begin{macro}{\XTR@ch@ck@tr}
1257 % \meta{x}|-|\meta{y}|-|\meta{z}|\@nil|\meta{counter}\\
1258 % Parse an element of the list. Basically, decide whether we have |x|,
1259 % |x-y|, |x-| or |-y| and act accordingly.
1260 % \begin{macrocode}
1261 \def\XTR@ch@ck@tr#1-#2-#3\@nil#4{%
1262 \ifx\@empty#1\@empty
1263 \ifnum#4>#2 \else\XTR@maketrue\fi
1264 \else
1265 \ifx\@empty#2\@empty
1266 \ifx\@empty#3\@empty
1267 \ifnum#4=#1 \XTR@maketrue\fi
1268 \else
1269 \ifnum#4<#1 \else\XTR@maketrue\fi
1270 \fi
1271 \else
1272 \ifnum#4<#1 \else\ifnum#4>#2 \else\XTR@maketrue\fi\fi
1273 \fi
1274 \fi
1275 }
1276 % \end{macrocode}
1277 % \end{macro}
1278 % \begin{macro}{\extractionlabel}
1279 % \changes{v1.3}{2005/01/12}{Was \cs{extractlabel}}
1280 % \begin{macro}{\XTR@currentlabel}
1281 % |\extractionlabel| saves its argument (after removing redundant spaces).
1282 % This label will be used for conditional extraction. |\XTR@currentlabel|
1283 % is initialized.
1284 % \begin{macrocode}
1285 \def\extractionlabel{\KV@@sp@def\XTR@currentlabel}
1286 \let\XTR@currentlabel\relax
1287 % \end{macrocode}
1288 % \end{macro}
1289 % \end{macro}
1290 % \begin{macro}{\extract}
1291 % \begin{macro}{\extract*}
1292 % Define environments that write verbatim to the target file. The
1293 % starred version also executes the code by writing it to a temp file
1294 % and inputting it |\AfterEndEnv|, just as with redefining existing
1295 % environments. When the package is inactive, |extract| is equivalent
1296 % to the |comment| environment and |extract*| takes its body out of the
1297 % group and executes it hence acting as if |\begin{extract*}| and
1298 % |\end{extract*}| were never typed.
1299 % \begin{macrocode}
1300 \def\extract{\XTR@stfalse\XTR@extract}
1301 \@namedef{extract*}{\XTR@sttrue\XTR@extract}
1302 % \end{macrocode}
1303 % \end{macro}
1304 % \end{macro}
1305 % \begin{macro}{\XTR@extract}
1306 % Prepare verbatim reading and check for an optional argument.
1307 % \begin{macrocode}
1308 \def\XTR@extract{%
1309 \@bsphack
1310 \let\do\@makeother\dospecials\catcode`\^^M\active
1311 \@testopt\XTR@@xtract\@nil
1312 }
1313 % \end{macrocode}
1314 % \end{macro}
1315 % \begin{macro}{\XTR@@xtract}
1316 % \oarg{label}\\
1317 % Process the optional label, define line processing and start reading
1318 % verbatim. Do not extract when the package is not active. Use a
1319 % temporary file to extract the body to in case this needs to be
1320 % executed in the source document (|extract*| environment).
1321 % \begin{macrocode}
1322 \def\XTR@@xtract[#1]{%
1323 % \end{macrocode}
1324 % Check state.
1325 % \begin{macrocode}
1326 \ifXTR@active
1327 \def\XTR@tempa{#1}%
1328 \ifx\XTR@tempa\@nnil\else
1329 \KV@@sp@def\XTR@currentlabel{#1}%
1330 \fi
1331 \XTR@checkxtr{extract}{extract}%
1332 \else
1333 \XTR@extractfalse
1334 \fi
1335 \ifXTR@st\XTR@opentmp\fi
1336 \let\verbatim@processline\XTR@processline@begin
1337 \verbatim@start
1338 }
1339 % \end{macrocode}
1340 % \end{macro}
1341 % \begin{macrocode}
1342 \begingroup
1343 \lccode`\!=`\\ \lccode`\(=`\{ \lccode`\)=`\}
1344 \lowercase{\endgroup
1345 % \end{macrocode}
1346 % \begin{macro}{\XTR@processline@begin}
1347 % This macro starts the reparsing of a line read by \pf{verbatim}. It
1348 % is possible to have |\begin{extractskip}| and |\end{extractskip}|
1349 % on the same line.
1350 % \begin{macrocode}
1351 \def\XTR@processline@begin{%
1352 % \end{macrocode}
1353 % Initialize |\@temptokena| (used for temp file) and |\verbatim@line|
1354 % (used for output file). Save the original content of |\verbatim@line|
1355 % for later use.
1356 % \begin{macrocode}
1357 \@temptokena{}%
1358 \edef\XTR@orig@line{\the\verbatim@line}%
1359 \verbatim@line{}%
1360 \expandafter\XTR@testbegin\XTR@orig@line!begin(extractskip)\@nil
1361 }
1362 % \end{macrocode}
1363 % \end{macro}
1364 % \begin{macro}{\XTR@testbegin}
1365 % \meta{text1}|\begin{extractskip}|\meta{text2}|\@nil|\\
1366 % Checks whether |\begin{extractskip}| occurs.
1367 % \begin{macrocode}
1368 \def\XTR@testbegin#1!begin(extractskip)#2\@nil{%
1369 \@temptokena\expandafter{\the\@temptokena#1}%
1370 \verbatim@line\expandafter{\the\verbatim@line#1}%
1371 \def\XTR@tempa{#2}%
1372 % \end{macrocode}
1373 % If \meta{text2} empty, there is no |\begin{extractskip}|. Just write the
1374 % content to file.
1375 % \begin{macrocode}
1376 \ifx\XTR@tempa\@empty\XTR@processline@write\else\XKV@afterfi
1377 % \end{macrocode}
1378 % Check the label.
1379 % \begin{macrocode}
1380 \XTR@skiplabel#2[]\@nil
1381 % \end{macrocode}
1382 % Should we skip the |extractskip| environment or not?
1383 % \begin{macrocode}
1384 \XTR@checkxtr{skip}{extractskip}%
1385 % \end{macrocode}
1386 % Switch to scanning for |\end{extractskip}| in the next line.
1387 % \begin{macrocode}
1388 \let\verbatim@processline\XTR@processline@end
1389 % \end{macrocode}
1390 % Remove some stuff that we added and continue scanning for |\end{extractskip}|
1391 % on the current line.
1392 % \begin{macrocode}
1393 \ifx\XTR@tempa\@nnil\XKV@afterelsefi
1394 \XTR@t@stbegin#2\@nil
1395 \else\XKV@afterfi
1396 \expandafter\XTR@t@stbegin\XTR@tempa\@nil
1397 \fi
1398 \fi
1399 }
1400 % \end{macrocode}
1401 % \end{macro}
1402 % \begin{macro}{\XTR@skiplabel}
1403 % \meta{text1}\oarg{label}\meta{text2}|\@nil|\\
1404 % This macro checks whether a label is present and sets |\XTR@currentlabel|
1405 % if necessary.
1406 % \begin{macrocode}
1407 \def\XTR@skiplabel#1[#2]#3\@nil{%
1408 \def\XTR@tempa{#1}%
1409 \def\XTR@tempb{#2}%
1410 \ifx\XTR@tempa\@empty
1411 \ifx\XTR@tempb\@empty
1412 \let\XTR@tempa\@nnil
1413 \else
1414 \KV@@sp@def\XTR@currentlabel{#2}%
1415 \XTR@sk@plabel#3\@nil
1416 \fi
1417 \else
1418 \let\XTR@tempa\@nnil
1419 \fi
1420 }
1421 % \end{macrocode}
1422 % \end{macro}
1423 % \begin{macro}{\XTR@sk@plabel}
1424 % \meta{text}|[]\@nil|\\
1425 % Remove extra brackets from input.
1426 % \begin{macrocode}
1427 \def\XTR@sk@plabel#1[]\@nil{\def\XTR@tempa{#1}}
1428 % \end{macrocode}
1429 % \end{macro}
1430 % \begin{macro}{\XTR@t@stbegin}
1431 % \meta{text}|\begin{extractskip}\@nil|\\
1432 % Remove the extra |\begin{extractskip}| and start scanning for
1433 % |\end{extractskip}| in the current line.
1434 % \begin{macrocode}
1435 \def\XTR@t@stbegin#1!begin(extractskip)\@nil{%
1436 \XTR@testend#1!end(extractskip)\@nil
1437 }
1438 % \end{macrocode}
1439 % \end{macro}
1440 % \begin{macro}{\XTR@processline@end}
1441 % Starts scanning for |\end{extractskip}| in case this was not on one
1442 % line together with |\begin{extractskip}|. Comparable to |\XTR@processline@begin|.
1443 % \begin{macrocode}
1444 \def\XTR@processline@end{%
1445 \@temptokena{}%
1446 \edef\XTR@orig@line{\the\verbatim@line}%
1447 \verbatim@line{}%
1448 \expandafter\XTR@testend\XTR@orig@line!end(extractskip)\@nil
1449 }
1450 % \end{macrocode}
1451 % \end{macro}
1452 % \begin{macro}{\XTR@testend}
1453 % \meta{text1}|\end{extractskip}|\meta{text2}|\@nil|\\
1454 % Check whether |\end{extractskip}| occurs in the line.
1455 % \begin{macrocode}
1456 \def\XTR@testend#1!end(extractskip)#2\@nil{%
1457 \@temptokena\expandafter{\the\@temptokena#1}%
1458 % \end{macrocode}
1459 % Skip material conditionally on labels or numbers.
1460 % \begin{macrocode}
1461 \ifXTR@skip\else\verbatim@line\expandafter{\the\verbatim@line#1}\fi
1462 \def\XTR@tempa{#2}%
1463 \ifx\XTR@tempa\@empty\XTR@processline@write\else\XKV@afterfi
1464 % \end{macrocode}
1465 % Switch to scanning for |\begin{extractskip}| in the next line.
1466 % \begin{macrocode}
1467 \let\verbatim@processline\XTR@processline@begin
1468 % \end{macrocode}
1469 % Continue scanning for |\begin{extractskip}| in the current line.
1470 % \begin{macrocode}
1471 \XTR@t@stend#2\@nil
1472 \fi
1473 }
1474 % \end{macrocode}
1475 % \end{macro}
1476 % \begin{macro}{\XTR@t@stend}
1477 % \meta{text}|\end{extractskip}\@nil|\\
1478 % Remove the redundant |\end{extractskip}| and continue scanning for
1479 % for the string |\begin{extractskip}| in this line.
1480 % \begin{macrocode}
1481 \def\XTR@t@stend#1!end(extractskip)\@nil{%
1482 \XTR@testbegin#1!begin(extractskip)\@nil
1483 }}
1484 % \end{macrocode}
1485 % \end{macro}
1486 % \begin{macro}{\XTR@processline@write}
1487 % \changes{v1.8}{2005/05/07}{Solved bug of not copying empty lines to the target file}
1488 % Writes the material to the appropriate file. If one of the tokens
1489 % has become empty, it might be because the line was empty originally
1490 % or because the parsing and removal of |\begin{extractskip}| and
1491 % |\end{extractskip}| made it empty. In the latter case, do not write
1492 % the empty line. In the former case, do write it.
1493 % \begin{macrocode}
1494 \def\XTR@processline@write{%
1495 \ifXTR@st\ifcat$\the\@temptokena$\else
1496 \XTR@writetmp{\the\@temptokena}%
1497 \fi\fi
1498 \ifXTR@extract\ifcat$\the\verbatim@line$\else
1499 \XTR@writeout{\the\verbatim@line}%
1500 \fi\fi
1501 \ifx\XTR@orig@line\@empty\XTR@writetmp{}\XTR@writeout{}\fi
1502 }
1503 % \end{macrocode}
1504 % \end{macro}
1505 % \begin{macro}{\endextract}
1506 % \begin{macro}{\endextract*}
1507 % Stop reading verbatim and if necessary execute the body of the
1508 % environment after the |extract*| environment.
1509 % \begin{macrocode}
1510 \def\endextract{\XTR@stfalse\XTR@endextract}
1511 \@namedef{endextract*}{\XTR@sttrue\XTR@endextract}
1512 \def\XTR@endextract{%
1513 \@esphack
1514 \ifXTR@st
1515 \XTR@closetmp
1516 \AfterEndEnv{\input{\jobname.xtr}}%
1517 \fi
1518 }
1519 % \end{macrocode}
1520 % \end{macro}
1521 % \end{macro}
1522 % \begin{macro}{\extractskip}
1523 % \begin{macro}{\endextractskip}
1524 % The |extractskip| environment when it is not used inside an environment
1525 % that is redefined to be extracted. Hence this environment makes itself
1526 % disappear, just as |extract*|, but doesn't write to the output file.
1527 % The trick with |XTR@activefalse| will remain local.
1528 % \begin{macrocode}
1529 \@namedef{extractskip}{\XTR@activefalse\@nameuse{extract*}}
1530 \XTR@namelet{endextractskip}{endextract*}
1531 % \end{macrocode}
1532 % \end{macro}
1533 % \end{macro}
1534 % \begin{macro}{\extractline}
1535 % This macro extracts all text after the macro and at the same line.
1536 % First we check for an optional star.
1537 % \begin{macrocode}
1538 \def\extractline{%
1539 \XKV@ifstar{\XTR@sttrue\XTR@extractline}%
1540 {\XTR@stfalse\XTR@extractline}%
1541 }
1542 % \end{macrocode}
1543 % \end{macro}
1544 % \begin{macro}{\XTR@extractline}
1545 % Start the group and reset all catcodes for verbatim reading.
1546 % \begin{macrocode}
1547 \def\XTR@extractline{%
1548 \begingroup
1549 \let\do\@makeother\dospecials\catcode`\^^M\active
1550 % \end{macrocode}
1551 % Test for an optional argument. Note that, due to reset catcodes,
1552 % macros won't work in the optional argument, but that is not a real
1553 % restriction, while it saves some tokens and memory. If we want to
1554 % allow for macro arguments, we need an extra macro for the check.
1555 % \begin{macrocode}
1556 \@testopt\XTR@@xtractline\@nil
1557 }
1558 % \end{macrocode}
1559 % \end{macro}
1560 % \begin{macro}{\XTR@@xtractline}
1561 % \oarg{label}\meta{text}\meta{eol}\\
1562 % The workhorse that reads input until the end of the line. Use the
1563 % |\lowercase| trick for the definition.
1564 % \begin{macrocode}
1565 \begingroup
1566 \catcode`\~=\active\lccode`\~=`\^^M
1567 \lowercase{\endgroup
1568 \def\XTR@@xtractline[#1]#2~{%
1569 % \end{macrocode}
1570 % Check state.
1571 % \begin{macrocode}
1572 \ifXTR@active
1573 \def\XTR@tempa{#1}%
1574 \ifx\XTR@tempa\@nnil\else
1575 \KV@@sp@def\XTR@currentlabel{#1}%
1576 \fi
1577 \XTR@checkxtr{extract}{line}%
1578 \else
1579 \XTR@extractfalse
1580 \fi
1581 \ifXTR@extract\XTR@writeout{#2}\fi
1582 % \end{macrocode}
1583 % If we need to execute the line, the catcodes are wrong, so write it
1584 % to the temporary file and insert it again when the catcodes are
1585 % reset by |\endgroup|.
1586 % \begin{macrocode}
1587 \ifXTR@st\XTR@opentmp\XTR@writetmp{#2}\XTR@closetmp\fi
1588 \endgroup
1589 % \end{macrocode}
1590 % Insert original content.
1591 % \begin{macrocode}
1592 \ifXTR@st
1593 \input{\jobname.xtr}%
1594 \fi
1595 }%
1596 }
1597 % \end{macrocode}
1598 % \end{macro}
1599 % Only define the following macros when the package is active. This
1600 % branch also performs redefinitions of the macros and environments
1601 % that should be extracted.
1602 % \begin{macrocode}
1603 \ifXTR@active
1604 % \end{macrocode}
1605 % Start writing the target file.
1606 % \begin{macrocode}
1607 \immediate\openout\XTR@out\XTR@file\relax
1608 % \end{macrocode}
1609 % Write header to the target file.
1610 % \begin{macrocode}
1611 \ifXTR@header
1612 % \end{macrocode}
1613 % Compute the time.
1614 % \begin{macrocode}
1615 \@tempcnta\time
1616 \divide\@tempcnta 60
1617 \edef\XTR@tempb{%
1618 \the\year/\ifnum\the\month<10 0\fi\the\month/%
1619 \ifnum\the\day<10 0\fi\the\day,\the\@tempcnta:%
1620 }
1621 \multiply\@tempcnta 60
1622 \@tempcntb\time
1623 \advance\@tempcntb-\@tempcnta
1624 \ifnum\@tempcntb<10
1625 \xdef\XTR@tempb{\XTR@tempb0\the\@tempcntb}
1626 \else
1627 \xdef\XTR@tempb{\XTR@tempb\the\@tempcntb}
1628 \fi
1629 \begingroup
1630 % \end{macrocode}
1631 % Save the \% character.
1632 % \begin{macrocode}
1633 \catcode`\%=12
1634 \gdef\XTR@tempa{%%\space}
1635 \endgroup
1636 % \end{macrocode}
1637 % Write all information to the target file.
1638 % \begin{macrocode}
1639 \XTR@writeout{\XTR@tempa}
1640 \filename@parse\XTR@file
1641 \ifx\filename@ext\relax\def\filename@ext{tex}\fi
1642 \XTR@writeout{%
1643 \XTR@tempa This is file, `\filename@base.\filename@ext',%
1644 }
1645 \XTR@writeout{%
1646 \XTR@tempa generated with the extract package.^^J\XTR@tempa
1647 }
1648 \XTR@writeout{\XTR@tempa Generated on : \space\XTR@tempb}
1649 \filename@parse\jobname
1650 \ifx\filename@ext\relax\def\filename@ext{tex}\fi
1651 \XTR@writeout{%
1652 \XTR@tempa From source \space: \space\filename@base.\filename@ext
1653 }
1654 \XTR@writeout{%
1655 \XTR@tempa Using options: \space\csname [email protected]\endcsname
1656 }
1657 \XTR@writeout{\XTR@tempa}
1658 \fi
1659 % \end{macrocode}
1660 % If requested, reconstruct the |\documentclass| command using
1661 % information from \pf{xkeyval}.
1662 % \begin{macrocode}
1663 \ifXTR@copydocumentclass
1664 \def\XTR@tempa#1.cls\@nil{\def\XTR@tempa{#1}}
1665 \expandafter\XTR@tempa\XKV@documentclass\@nil
1666 \ifx\XKV@classoptionslist\@empty
1667 \XTR@writeout{\string\documentclass{\XTR@tempa}}
1668 \else
1669 \@temptokena\expandafter{\XKV@classoptionslist}%
1670 \XTR@writeout{\string\documentclass[\the\@temptokena]{\XTR@tempa}}
1671 \fi
1672 \fi
1673 % \end{macrocode}
1674 % Perform redefinitions at the beginning of the document.
1675 % \begin{macrocode}
1676 \AtBeginDocument{%
1677 \ifXTR@handles
1678 \XTR@writeout{}%
1679 \XTR@writeout{\string\begin{document}}%
1680 \fi
1681 % \end{macrocode}
1682 % Redefine environments.
1683 % \begin{macrocode}
1684 \XKV@ifundefined{XTR@envs}{}{%
1685 \XKV@for@o\XTR@envs\XTR@tempa{%
1686 % \end{macrocode}
1687 % Check whether the environment is defined.
1688 % \begin{macrocode}
1689 \XKV@ifundefined\XTR@tempa{%
1690 \XTR@err{%
1691 environment `\XTR@tempa' not defined; extraction canceled%
1692 }%
1693 }{%
1694 % \end{macrocode}
1695 % Backup the beginning of the environment.
1696 % \begin{macrocode}
1697 \XTR@namelet{XTR\XTR@tempa}{\XTR@tempa}%
1698 % \end{macrocode}
1699 % Redefine the beginning of the environment. This uses \pf{verbatim}
1700 % internally.
1701 % \begin{macrocode}
1702 \@namedef{\XTR@tempa\expandafter}\expandafter{\expandafter
1703 \def\expandafter\XTR@tempa\expandafter{\XTR@tempa}%
1704 % \end{macrocode}
1705 % Check whether the current environment should be extracted. Note
1706 % that |\XTR@tempa| contains the current environment name.
1707 % \begin{macrocode}
1708 \XTR@checkxtr{extract}\XTR@tempa
1709 \ifXTR@extract
1710 % \end{macrocode}
1711 % If extraction is required, write to the target file and to a temporary
1712 % file for inclusion afterwards.
1713 % \begin{macrocode}
1714 \XTR@writeout{}\XTR@opentmp
1715 \@bsphack
1716 \let\do\@makeother\dospecials\catcode`\^^M\active
1717 % \end{macrocode}
1718 % \begin{macro}{\verbatim@processline}
1719 % \changes{v1.1}{2005/01/01}{Made to write content on same line as
1720 % environment heading if so in source file}
1721 % Process macro for \pf{verbatim}.
1722 % \begin{macrocode}
1723 \def\verbatim@processline{%
1724 % \end{macrocode}
1725 % |\verbatim@processline| is redefined here since the first line is
1726 % treated specially, see below.
1727 % \begin{macrocode}
1728 \let\verbatim@processline\XTR@processline@begin
1729 % \end{macrocode}
1730 % Write the content to the files.
1731 % \begin{macrocode}
1732 \XTR@writeout{%
1733 \string\begin{\XTR@tempa}\the\verbatim@line
1734 }%
1735 \XTR@writetmp{%
1736 \string\begin{XTR\XTR@tempa}\the\verbatim@line
1737 }%
1738 }%
1739 % \end{macrocode}
1740 % \end{macro}
1741 % \begin{macrocode}
1742 \XTR@sttrue\let\XTR@tempb\verbatim@
1743 \else
1744 % \end{macrocode}
1745 % Else, execute the backup of the current environment.
1746 % \begin{macrocode}
1747 \edef\XTR@tempb{\noexpand\begin{XTR\XTR@tempa}}%
1748 \fi
1749 \XTR@tempb
1750 }%
1751 % \end{macrocode}
1752 % Backup the end of the environment.
1753 % \begin{macrocode}
1754 \XTR@namelet{endXTR\XTR@tempa}{end\XTR@tempa}%
1755 % \end{macrocode}
1756 % Redefine the end of the environment.
1757 % \begin{macrocode}
1758 \@namedef{end\XTR@tempa\expandafter}\expandafter{\expandafter
1759 \def\expandafter\XTR@tempa\expandafter{\XTR@tempa}%
1760 \ifXTR@extract
1761 \@esphack
1762 % \end{macrocode}
1763 % Finalize writing and add the |\input| to the hook at the end of the
1764 % current environment.
1765 % \begin{macrocode}
1766 \XTR@writeout{\string\end{\XTR@tempa}}%
1767 \XTR@writetmp{\string\end{XTR\XTR@tempa}}%
1768 \XTR@closetmp
1769 \AfterEndEnv{\input{\jobname.xtr}}%
1770 \else
1771 % \end{macrocode}
1772 % If not extracting, execute the backup of the end of the environment.
1773 % \begin{macrocode}
1774 \edef\XTR@tempa{\noexpand\end{XTR\XTR@tempa}}%
1775 \expandafter\XTR@tempa
1776 \fi
1777 }%
1778 }%
1779 }%
1780 }%
1781 % \end{macrocode}
1782 % Redefine commands using the arguments.
1783 % \begin{macrocode}
1784 \XKV@ifundefined{XTR@cmdsargs}{}{%
1785 % \end{macrocode}
1786 % Once backup the current definitions.
1787 % \begin{macrocode}
1788 \let\XTR@sect\@sect
1789 \let\XTR@chapter\@chapter
1790 \def\XTR@tempb{chapter}%
1791 % \end{macrocode}
1792 % Redefine a list of macros to write themselves to the target file.
1793 % Chapters and section are treated differently since they are
1794 % constructed differently. |\chapter*| will not extract itself since
1795 % this gives technical difficulties due to the fact that this macro
1796 % is reused at several places inside other macros, taking none-character
1797 % input in its argument.
1798 % \begin{macrocode}
1799 \XKV@for@o\XTR@cmdsargs\XTR@tempa{%
1800 \XKV@ifundefined\XTR@tempa{%
1801 \XTR@err{command `\@backslashchar\XTR@tempa' not defined;
1802 extraction canceled%
1803 }%
1804 }{%
1805 % \end{macrocode}
1806 % Check whether allowed or not.
1807 % \begin{macrocode}
1808 \@expandtwoargs\in@{,\XTR@tempa,}%
1809 {,chapter,section,subsection,subsubsection,}%
1810 \ifin@
1811 \ifx\XTR@tempa\XTR@tempb
1812 \def\@chapter[#1]#2{%
1813 % \end{macrocode}
1814 % Check whether to extract this chapter or not.
1815 % \begin{macrocode}
1816 \XTR@checkxtr{extract}{chapter}%
1817 \ifXTR@extract
1818 \XTR@writeout{}%
1819 \def\XTR@tempa{#1}%
1820 \def\XTR@tempb{#2}%
1821 \ifx\XTR@tempa\XTR@tempb
1822 \@temptokena{{#2}}%
1823 \else
1824 \@temptokena{[#1]{#2}}%
1825 \fi
1826 % \end{macrocode}
1827 % Write to file.
1828 % \begin{macrocode}
1829 \XTR@writeout{\string\chapter\the\@temptokena}%
1830 \fi
1831 % \end{macrocode}
1832 % Typeset the chapter.
1833 % \begin{macrocode}
1834 \XTR@chapter[#1]{#2}%
1835 }%
1836 \else
1837 % \end{macrocode}
1838 % We do a similar thing for sections created with |\@sect|.
1839 % \begin{macrocode}
1840 \def\@sect#1#2#3#4#5#6[#7]#8{%
1841 \@expandtwoargs\in@{,#1,}{,\XTR@cmdsargs,}%
1842 \ifin@
1843 \XTR@checkxtr{extract}{#1}%
1844 \ifXTR@extract
1845 \XTR@writeout{}%
1846 \def\XTR@tempa{#7}%
1847 \def\XTR@tempb{#8}%
1848 \ifx\XTR@tempa\XTR@tempb
1849 \@temptokena{{#8}}%
1850 \else
1851 \@temptokena{[#7]{#8}}%
1852 \fi
1853 \XTR@writeout{\expandafter
1854 \string\csname#1\endcsname\the\@temptokena}%
1855 \fi
1856 \fi
1857 \XTR@sect{#1}{#2}{#3}{#4}{#5}{#6}[#7]{#8}%
1858 }%
1859 \fi
1860 \else
1861 \XTR@err{unsupported command `\XTR@tempa';
1862 try the `extract-cmdline option}%
1863 \fi
1864 }%
1865 }%
1866 }%
1867 \XKV@ifundefined{XTR@cmdsline}{}{%
1868 % \end{macrocode}
1869 % Redefine a list of commands to write themselves and the text on the
1870 % same line to the target file. This works similar to |\extractline|.
1871 % \begin{macrocode}
1872 \XKV@for@o\XTR@cmdsline\XTR@tempa{%
1873 \XKV@ifundefined\XTR@tempa{%
1874 % \end{macrocode}
1875 % Check whether the command is defined.
1876 % \begin{macrocode}
1877 \XTR@err{command `\@backslashchar\XTR@tempa' not defined;
1878 extraction canceled}%
1879 }{%
1880 % \end{macrocode}
1881 % Check whether allowed or not.
1882 % \begin{macrocode}
1883 \@expandtwoargs\in@{,\XTR@tempa,}%
1884 {,chapter,section,subsection,subsubsection,}%
1885 \ifin@
1886 \XTR@err{%
1887 use the `extract-cmd' option for command `\XTR@tempa'%
1888 }%
1889 \else
1890 % \end{macrocode}
1891 % Backup the command.
1892 % \begin{macrocode}
1893 \XTR@namelet{XTR\XTR@tempa}{\XTR@tempa}%
1894 % \end{macrocode}
1895 % Redefine the command. Note that, inside the definition of the command,
1896 % |\XTR@tempa| contains the command name.
1897 % \begin{macrocode}
1898 \@namedef{\XTR@tempa\expandafter}\expandafter{\expandafter
1899 \def\expandafter\XTR@tempa\expandafter{\XTR@tempa}%
1900 % \end{macrocode}
1901 % Check whether this command should be extracted.
1902 % \begin{macrocode}
1903 \XTR@checkxtr{extract}\XTR@tempa
1904 \begingroup
1905 \let\do\@makeother\dospecials\catcode`\^^M\active
1906 \XTR@extractcmdline
1907 }%
1908 \fi
1909 }%
1910 }%
1911 \begingroup
1912 \catcode`\~=\active\lccode`\~=`\^^M
1913 % \end{macrocode}
1914 % \begin{macro}{\XTR@extractcmdline}
1915 % \changes{v1.4}{2005/02/06}{Changed temp macro to token register}
1916 % \meta{text}\meta{eol}\\
1917 % Workhorse for the command line extraction method. This macros reads
1918 % until the next end of line and saves the content in |\XTR@tempb|.
1919 % \begin{macrocode}
1920 \lowercase{\endgroup
1921 \def\XTR@extractcmdline#1~{\verbatim@line{#1}\XTR@@xtractcmdline}%
1922 }%
1923 % \end{macrocode}
1924 % \end{macro}
1925 % \begin{macro}{\XTR@@xtractcmdline}
1926 % Finalize the operation with the content of the current line. We write
1927 % it to a target file and to a temporary file for execution in the
1928 % current document. Note that |\XTR@tempa| still contains the current
1929 % command name.
1930 % \begin{macrocode}
1931 \def\XTR@@xtractcmdline{%
1932 \XTR@writeout{}%
1933 \XTR@writeout{\expandafter\string\csname\XTR@tempa
1934 \endcsname\the\verbatim@line
1935 }%
1936 \XTR@opentmp
1937 \XTR@writetmp{\expandafter\string\csname XTR\XTR@tempa
1938 \endcsname\the\verbatim@line
1939 }%
1940 \XTR@closetmp
1941 \endgroup
1942 \input{\jobname.xtr}%
1943 }%
1944 }%
1945 }
1946 % \end{macrocode}
1947 % \end{macro}
1948 % Finalize writing the target file.
1949 % \begin{macrocode}
1950 \AtEndDocument{%
1951 \ifXTR@handles
1952 \XTR@writeout{}%
1953 \XTR@writeout{\string\end{document}}%
1954 \fi
1955 \immediate\closeout\XTR@out
1956 }
1957 \fi
1958 %</extract>
1959 % \end{macrocode}
1960 % \Finale
1961 % \endinput
1962 % \iffalse
1963 %<*xtrex1>
1964 \documentclass[10pt]{article}
1965 \usepackage[
1966 active,
1967 generate=file,
1968 copydocumentclass=false,
1969 extract-env=equation
1970 ]{extract}
1971 \begin{extract}
1972 \documentclass[11pt]{article}
1973 \end{extract}
1974 \begin{document}
1975 Some text.
1976 \begin{equation}
1977 a^2+b^2=c^2
1978 \end{equation}
1979 Some text.
1980 \begin{equation}
1981 x^2+y^2=z^2
1982 \end{equation}
1983 Some text.
1984 \end{document}
1985 %</xtrex1>
1986 %
1987 %<*xtrex2>
1988 \documentclass{article}
1989 \usepackage[
1990 active,
1991 generate=file,
1992 extract-env=exercise,
1993 extract-cmd=section,
1994 extract-cmdline=label
1995 ]{extract}
1996 \begin{extract*}
1997 \newtheorem{exercise}{Exercise}
1998 \end{extract*}
1999 \begin{document}
2000 \section{Theory}
2001 \label{sec:1}
2002 Some text.
2003 \section{Exercises}
2004 \begin{exercise}
2005 Use the results from section
2006 \ref{sec:1} to show that\dots
2007 \end{exercise}
2008 Some text.
2009 \end{document}
2010 %</xtrex2>
2011 %
2012 %<*xtrex3>
2013 \documentclass{article}
2014 \usepackage[
2015 active,
2016 generate=file,
2017 extract-env=figure,
2018 figure-nrs={1,3},
2019 figure-labels={fig-a,fig-b}
2020 ]{extract}
2021 \begin{document}
2022 Some text.
2023 \begin{figure}
2024 Figure 1.
2025 \end{figure}
2026 Some text.
2027 \extractionlabel{fig-a}
2028 \begin{figure}
2029 Figure 2.
2030 \end{figure}
2031 Some text.
2032 \extractionlabel{fig-b}
2033 \begin{figure}
2034 Figure 3.
2035 \end{figure}
2036 Some text.
2037 \extractionlabel{fig-c}
2038 \begin{figure}
2039 Figure 4.
2040 \end{figure}
2041 \end{document}
2042 %</xtrex3>
2043 %
2044 %<*xtrex4>
2045 \documentclass{article}
2046 \usepackage[
2047 active,
2048 generate=file,
2049 extract-env=equation*
2050 ]{extract}
2051 \begin{extract*}
2052 \usepackage{amsmath}
2053 \end{extract*}
2054 \begin{document}
2055 Some text.
2056 \begin{equation*}
2057 x^2+y^2=z^2
2058 \end{equation*}
2059 \begin{extract}
2060 $x=3$, $y=4$ and $z=5$
2061 satisfy this equation.
2062 \end{extract}
2063 \end{document}
2064 %</xtrex4>
2065 %
2066 %<*xtrex5>
2067 \documentclass{article}
2068 \usepackage[
2069 active,
2070 generate=file,
2071 copydocumentclass=false,
2072 extract-labels=type-a,
2073 line-labels={type-a,type-c},
2074 line-nrs=3
2075 ]{extract}
2076 \begin{extract}[type-a]
2077 \documentclass{article}
2078 \end{extract}
2079 \begin{extract}[type-b]
2080 \documentclass{book}
2081 \end{extract}
2082 \begin{document}
2083 \parindent0pt
2084 \extractline[type-a]line 1\\
2085 \extractline*line 2\\
2086 \extractline line 3\\
2087 \extractline*[type-a]line 4\\
2088 \extractline*[type-c]line 5\\
2089 \extractline line 6\\
2090 \end{document}
2091 %</xtrex5>
2092 %
2093 %<*xtrex6>
2094 \documentclass{article}
2095 \usepackage[
2096 active,
2097 generate=file,
2098 extract-env=figure
2099 ]{extract}
2100 \begin{document}
2101 \begin{figure}[!h]
2102 \begin{extractskip}
2103 \fbox{figure 1}
2104 \end{extractskip}
2105 \fbox{figure 2}
2106 \end{figure}
2107 \begin{extract*}
2108 \begin{itemize}
2109 \item 1
2110 \item 2
2111 a\begin{extractskip}b
2112 \item 3
2113 c\end{extractskip}d
2114 \item 4
2115 \begin{extractskip}
2116 \item 5
2117 \end{extractskip}
2118 \end{itemize}
2119 \end{extract*}
2120 \end{document}
2121 %</xtrex6>
2122 %
2123 %<*xtrex7>
2124 \documentclass{article}
2125 \usepackage[
2126 active,
2127 generate=file,
2128 extractskip-labels=skipb
2129 ]{extract}
2130 \begin{document}
2131 \begin{extract*}
2132 \begin{itemize}
2133 \begin{extractskip}[skipa]
2134 \item 1
2135 \end{extractskip}
2136 \begin{extractskip}[skipb]
2137 \item 2
2138 \end{extractskip}
2139 \begin{extractskip}[skipc]
2140 \item 3
2141 \end{extractskip}
2142 \end{itemize}
2143 \end{extract*}
2144 \end{document}
2145 %</xtrex7>
2146 %
2147 %<*preamble>
2148 \usepackage{url}
2149 \usepackage{extract}
2150 \usepackage{xcolor}
2151 \usepackage{fourier}
2152 \usepackage{varioref}
2153 \usepackage{pst-text}
2154 \def\reftextafter{on page~\thevpagerefnum}
2155 \def\reftextbefore{on page~\thevpagerefnum}
2156 \def\reftextfaceafter{on page~\thevpagerefnum}
2157 \def\reftextfacebefore{on page~\thevpagerefnum}
2158 \usepackage{listings}
2159 \lstnewenvironment{command}{%
2160 \lstset{columns=flexible,frame=single,backgroundcolor=\color{blue!20},%
2161 xleftmargin=\fboxsep,xrightmargin=\fboxsep,escapeinside=`',gobble=1}}{}
2162 \lstnewenvironment{example}{%
2163 \lstset{basicstyle=\footnotesize\ttfamily,columns=flexible,frame=single,%
2164 backgroundcolor=\color{yellow!20},xleftmargin=\fboxsep,%
2165 xrightmargin=\fboxsep,gobble=1}}{}
2166 \def\mktitledecor{%
2167 \rput[tl]{90}(-6.5,-22.56){%
2168 \psline[linewidth=1pt](0,1.5)(\paperheight,1.5)%
2169 \rput[lB](.075\paperheight,.5){\pscharpath[linecolor=blue!50,%
2170 fillcolor=yellow!20,fillstyle=solid,linewidth=.5pt]%
2171 {\Huge\bfseries\sffamily extract}%
2172 }%
2173 \rput[rB](.925\paperheight,.5){\pscharpath[linecolor=blue!50,%
2174 fillcolor=yellow!20,fillstyle=solid,linewidth=.5pt]%
2175 {\Huge\bfseries Documentation}%
2176 }%
2177 \psline[linewidth=1pt](0,0)(\paperheight,0)%
2178 }%
2179 }
2180 \usepackage{float}
2181 \newfloat{Listing}{htb}{loe}
2182 \makeatletter
2183 \def\tableofcontents{%
2184 \begin{multicols}{2}%
2185 [\section*{Contents}%
2186 \setlength{\columnseprule}{.4pt}%
2187 \setlength{\columnsep}{18pt}]%
2188 \@starttoc{toc}%
2189 \end{multicols}%
2190 }
2191 \def\changes@#1#2#3{%
2192 \protected@edef\@tempa{%
2193 \noexpand\glossary{\textbf{#1}\hfill\emph{(#2)}%
2194 \levelchar
2195 \ifx\saved@macroname\@empty
2196 \space\actualchar\generalname
2197 \else
2198 \expandafter\@gobble\saved@macroname
2199 \actualchar\string\verb\quotechar*%
2200 \verbatimchar\saved@macroname\verbatimchar
2201 \fi
2202 :\levelchar #3}%
2203 }%
2204 \@tempa\endgroup\@esphack
2205 }
2206 \def\DescribeMacros{\leavevmode\@bsphack
2207 \begingroup\MakePrivateLetters\Describe@Macros}
2208 \def\Describe@Macros#1{\endgroup\strut
2209 \marginpar{\raggedleft
2210 \def\@tempa{#1}\count@\z@
2211 \@for\@tempa:=\@tempa\do{%
2212 \ifnum\count@>\z@\\\fi\advance\count@\@ne
2213 \MacroFont\expandafter\string\@tempa
2214 \expandafter\SpecialUsageIndex\expandafter{\@tempa}%
2215 }}%
2216 \@esphack\ignorespaces
2217 }
2218 \def\DescribeOption#1{\leavevmode\@bsphack
2219 \marginpar{\raggedleft\PrintDescribeOption{#1}}%
2220 \SpecialOptionIndex{#1}\@esphack\ignorespaces}
2221 \def\PrintDescribeOption#1{\strut\emph{option}\\\MacroFont #1\ }
2222 \def\SpecialOptionIndex#1{\@bsphack
2223 \index{#1\actualchar{\protect\ttfamily#1}
2224 (option)\encapchar usage}%
2225 \index{options:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar
2226 usage}\@esphack}
2227 \def\DescribeOptions#1{\leavevmode\@bsphack
2228 \marginpar{\raggedleft\strut\emph{options}%
2229 \@for\@tempa:=#1\do{%
2230 \\\strut\MacroFont\@tempa\SpecialOptionIndex\@tempa
2231 }}\@esphack\ignorespaces}
2232 \def\DescribeEnv#1{\leavevmode\@bsphack
2233 \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
2234 \SpecialEnvIndex{#1}\@esphack\ignorespaces}
2235 \def\PrintDescribeEnv#1{\strut\emph{environment}\\\MacroFont #1\ }
2236 \def\SpecialEnvIndex#1{\@bsphack
2237 \index{#1\actualchar{\protect\ttfamily#1}
2238 (environment)\encapchar usage}%
2239 \index{environments:\levelchar#1\actualchar{\protect\ttfamily#1}\encapchar
2240 usage}\@esphack}
2241 \def\SpecialMainEnvIndex#1{\@bsphack\special@index{%
2242 #1\actualchar
2243 {\string\ttfamily\space#1}
2244 \encapchar main}%
2245 \special@index{environments:\levelchar#1\actualchar{%
2246 \string\ttfamily\space#1}\encapchar
2247 main}\@esphack}
2248 \def\DescribeEnvs#1{\leavevmode\@bsphack
2249 \marginpar{\raggedleft\strut\emph{environments}%
2250 \@for\@tempa:=#1\do{%
2251 \\\strut\MacroFont\@tempa\SpecialEnvIndex\@tempa
2252 }}\@esphack\ignorespaces}
2253 \renewenvironment{theglossary}{%
2254 \glossary@prologue
2255 \GlossaryParms \let\item\@idxitem \ignorespaces
2256 }{}%
2257 \makeatother
2258 \def\PrintChangesX{%
2259 \begingroup
2260 \let\efill\relax
2261 \PrintChanges
2262 \endgroup
2263 }
2264 \def\PrintIndexX{%
2265 \begingroup
2266 \setcounter{IndexColumns}{2}
2267 \setlength{\columnsep}{18pt}%
2268 \setlength{\columnseprule}{.4pt}%
2269 \PrintIndex
2270 \endgroup
2271 }
2272 \def\pf#1{\textsf{#1}}
2273 \def\descriptionlabel{\hspace\labelsep\normalfont}
2274 \EnableCrossrefs
2275 \RecordChanges
2276 \GlossaryPrologue{\section*{Version history}}
2277 \CodelineIndex
2278 %</preamble>
2279 %
2280 %<*bib>
2281 @MISC{LaTeXbase,
2282 author = {Johannes Braams and David Carlisle and Alan Jeffrey and Leslie Lamport
2283 and Frank Mittelbach and Chris Rowley and Rainer Sch\"opf},
2284 title = {The {\LaTeXe} Sources},
2285 howpublished = {\url{CTAN:/macros/latex/base}},
2286 year = 2003
2287 }
2288
2289 @MISC{xkeyval,
2290 author = {Hendri Adriaens},
2291 title = {\pf{xkeyval} package},
2292 howpublished = {\url{CTAN:/macros/latex/contrib/xkeyval}}
2293 }
2294
2295 @MISC{verbatim,
2296 author = {Rainer Sch\"opf},
2297 title = {\pf{verbatim} package, v1.5q},
2298 howpublished = {\url{CTAN:/macros/latex/required/tools}},
2299 year = {2003/08/22}
2300 }
2301
2302 @MISC{xcomment,
2303 author = {Timothy Van Zandt},
2304 title = {\pf{xcomment} package, v1.2},
2305 howpublished = {\url{CTAN:/macros/latex/contrib/seminar}},
2306 year = {1993/02/12}
2307 }
2308
2309 @MISC{askinclude,
2310 author = {{Pablo A. Straub}},
2311 title = {\pf{askinclude} package, v1.2e},
2312 howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
2313 year = {1994/11/11}
2314 }
2315
2316 @MISC{excludeonly,
2317 author = {Dan Luecking},
2318 title = {\pf{excludeonly} package, v1.0},
2319 howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
2320 year = {2003/03/14}
2321 }
2322
2323 @MISC{comment,
2324 author = {Victor Eijkhout},
2325 title = {\pf{comment} package, v3.6},
2326 howpublished = {\url{CTAN:/macros/latex/contrib/comment}},
2327 year = {1999/10}
2328 }
2329
2330 @MISC{optional,
2331 author = {Donald Arseneau},
2332 title = {\pf{optional} package, v2.2},
2333 howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
2334 year = {2001/09}
2335 }
2336
2337 @MISC{version,
2338 author = {Stephen Bellantoni},
2339 title = {\pf{version} package},
2340 howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
2341 year = {1990}
2342 }
2343
2344 @MISC{versions,
2345 author = {Uwe L\"uck},
2346 title = {\pf{versions} package, v0.51},
2347 howpublished = {\url{CTAN:/macros/latex/contrib/versions}},
2348 year = {2003/10/15}
2349 }
2350
2351 @MISC{pagesel,
2352 author = {Heiko Oberdiek},
2353 title = {\pf{pagesel} package, v1.1},
2354 howpublished = {\url{CTAN:/macros/latex/contrib/oberdiek}},
2355 year = {1999/04/13}
2356 }
2357
2358 @MISC{pdfpages,
2359 author = {Andreas Matthias},
2360 title = {\pf{pdfpages} package, v0.3e},
2361 howpublished = {\url{CTAN:/macros/latex/contrib/pdfpages}},
2362 year = {2004/01/31}
2363 }
2364
2365 @MISC{selectp,
2366 author = {Donald Arseneau},
2367 title = {\pf{selectp} package, v0.9},
2368 howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
2369 year = {1992/09/25}
2370 }
2371
2372 @MISC{fancyvrb,
2373 author = {Timothy Van Zandt},
2374 title = {\pf{fancyvrb} package, v2.6},
2375 howpublished = {\url{CTAN:/macros/latex/contrib/fancyvrb}},
2376 year = {1998/07/17}
2377 }
2378
2379 @MISC{listings,
2380 author = {Carsten Heinz},
2381 title = {\pf{listings} package, v1.3},
2382 howpublished = {\url{CTAN:/macros/latex/contrib/listings}},
2383 year = {2004/09/07}
2384 }
2385 %</bib>
2386 %
2387 % \fi