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

@MISC{xkeyval,
  author       = {Hendri Adriaens},
  title        = {\pf{xkeyval} package},
  howpublished = {\url{CTAN:/macros/latex/contrib/xkeyval}}
}

@MISC{verbatim,
  author       = {Rainer Sch\"opf},
  title        = {\pf{verbatim} package, v1.5q},
  howpublished = {\url{CTAN:/macros/latex/required/tools}},
  year         = {2003/08/22}
}

@MISC{xcomment,
  author       = {Timothy Van Zandt},
  title        = {\pf{xcomment} package, v1.2},
  howpublished = {\url{CTAN:/macros/latex/contrib/seminar}},
  year         = {1993/02/12}
}

@MISC{askinclude,
  author       = {{Pablo A. Straub}},
  title        = {\pf{askinclude} package, v1.2e},
  howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
  year         = {1994/11/11}
}

@MISC{excludeonly,
  author       = {Dan Luecking},
  title        = {\pf{excludeonly} package, v1.0},
  howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
  year         = {2003/03/14}
}

@MISC{comment,
  author       = {Victor Eijkhout},
  title        = {\pf{comment} package, v3.6},
  howpublished = {\url{CTAN:/macros/latex/contrib/comment}},
  year         = {1999/10}
}

@MISC{optional,
  author       = {Donald Arseneau},
  title        = {\pf{optional} package, v2.2},
  howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
  year         = {2001/09}
}

@MISC{version,
  author       = {Stephen Bellantoni},
  title        = {\pf{version} package},
  howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
  year         = {1990}
}

@MISC{versions,
  author       = {Uwe L\"uck},
  title        = {\pf{versions} package, v0.51},
  howpublished = {\url{CTAN:/macros/latex/contrib/versions}},
  year         = {2003/10/15}
}

@MISC{pagesel,
  author       = {Heiko Oberdiek},
  title        = {\pf{pagesel} package, v1.1},
  howpublished = {\url{CTAN:/macros/latex/contrib/oberdiek}},
  year         = {1999/04/13}
}

@MISC{pdfpages,
  author       = {Andreas Matthias},
  title        = {\pf{pdfpages} package, v0.3e},
  howpublished = {\url{CTAN:/macros/latex/contrib/pdfpages}},
  year         = {2004/01/31}
}

@MISC{selectp,
  author       = {Donald Arseneau},
  title        = {\pf{selectp} package, v0.9},
  howpublished = {\url{CTAN:/macros/latex/contrib/misc}},
  year         = {1992/09/25}
}

@MISC{fancyvrb,
  author       = {Timothy Van Zandt},
  title        = {\pf{fancyvrb} package, v2.6},
  howpublished = {\url{CTAN:/macros/latex/contrib/fancyvrb}},
  year         = {1998/07/17}
}

@MISC{listings,
  author       = {Carsten Heinz},
  title        = {\pf{listings} package, v1.3},
  howpublished = {\url{CTAN:/macros/latex/contrib/listings}},
  year         = {2004/09/07}
}
%</bib>
%
% \fi