summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/hyper/hyper.dtx
blob: bf83272d0fb9e36dfc71d81d9256799010183a60 (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
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
% \iffalse
%% File: hyper.dtx Copyright (C) 1995--1999 Michael Mehlich
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN
%% archives in directory macros/latex/base/lppl.txt; either
%% version 1 of the License, or any later version.
%<*driver>
\documentclass[letterpaper]{ltxdoc}
\usepackage{tabularx}
\makeatletter
\let\TX@vwarn\relax
\makeatother
\IfFileExists{hyper.sty}{%
  \message{*** Generating hypertext documentation ***}
  \usepackage[color,fixhyperbox,pagetop]{hyper}%
}{%
  \def\hyperURL##1##2##3##4{##4}
}
\def\AmS{{\protect\usefont{OMS}{cmsy}{m}{n}%
  A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
\def\amslatex{{\protect\AmS-\protect\LaTeXe}}
\def\CWEB{{\scshape Cweb}}
%</driver>
\def\fileversion{V4.2d}
\def\filedate{1999/03/09}
\def\docdate{1999/03/09}
%<*driver>
\begin{document}
  \hbadness=10000
  \hfuzz100pt
  \title{HyperText Documents with \LaTeXe\\\fileversion}
  \author{Michael Mehlich}
  \date{\docdate}
  \maketitle
  \tableofcontents
  \DocInput{hyper.dtx}
\end{document}
%</driver>
% \fi
% \CheckSum{5034}
%%
%% \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         \~}
%%
% \MakeShortVerb{|}
%
% \title{Hyper\LaTeXe}
% \maketitle
%
% \section{Introduction}
% Traditional texts only have a linear structure given by its series of
% characters. But this is not sufficient for any kind of documents one
% may think of. Thus, recently the number of documents using a more
% complex graphical structure (called ``hyper text'' documents) have
% increased.
%
% This package provides the generation of such documents based on the
% already given structure of \LaTeXe{}-documents without the document
% writer having to consider new commands.
%
% \section{Usage}
%
% Just insert |\usepackage{hyper}| in the preamble of your
% \LaTeX2e--document as the last package to be loaded.\par
% If you use the theorem package define the theorems via
% |\newtheorem| after inserting the hyper package.\medskip
%
% You may also give some options for the package, i.e.\ instead of
% the command above you may use |\usepackage[<option list>]{hyper}|
% in your preamble.\medskip
%
% \noindent Currently the following options are known:
% \begin{itemize}
%   \item |yes|, |no|
%                       determine whether the hypertext marks are inserted
%                       or not (default is |yes|)
%   \item |fixhyperbox|
%                       modifies the position of the html-marks in the |dvi|-file
%                       so that |dvips| creates the right bounding boxes for
%                       the hyper references; it is highly recommended to use
%                       this option (though for compatibility reasons with earlier
%                       versions this is not the default setting); note, that the
%                       text of the reference is packed into a horizontal box (|\hbox|)
%                       due to the need of measuring its size
%   \item |black|, |gray|, |color|
%                       determine the colors anchors and references
%                       are printed in (default is |black|);\newline
%                       the colors can be changed by
%                       |\definecolor{refcolor}{rgb}{|\emph{r}|,|\emph{g}|,|\emph{b}|}|
%                       for references,
%                       |\definecolor{undefrefcolor}{rgb}{|\emph{r}|,|\emph{g}|,|\emph{b}|}|
%                       for unresolved references, and
%                       |\definecolor{anchorcolor}{rgb}{|\emph{r}|,|\emph{g}|,|\emph{b}|}|
%                       for anchors where \emph{r}, \emph{g}, \emph{b} stand for the
%                       red, green, and blue, respectively, values (between 0.0 and 1.0)
%                       of the color (cf.\ |graphics| package)
%   \item |pagenumber|, |pagetop|
%                       determine whether a page number refers to the page
%                       number of the respectively page or to the top of
%                       the page
%   \item |indexcmds| has to be given explicitely whenever an
%                       index or glossary file has been created using
%                       this package if the file is not regenerated using
%                       the commands |\makeindex| and |\makeglossary|,
%                       respectively.
%   \item |backcitepages|, |backcitesections| introduce back references
%                       from the bibliography to the pages and sections,
%                       respectively, they have been cited in
%   \item |amsart|, |amsbook|, |amsdtx|, |amsldoc|, |amsproc|, |article|,
%         |book|, |cweb|, |letter|, |ltxdoc|, |ltxguide|, |ltnews|, |proc|,
%         |report|, |slides|
%                       determine the document class for which the
%                       modifications are loaded
%                       (default is the document class given via
%                       |\documentclass| if it can be derived)
%   \item |leqno|
%                       adds modifications for the document class option
%                       |leqno| (will be used automagically for known
%                       document classes)
%   \item |amsmath|, |amstex|, |amsthm|, |doc|, |fancyheadings|, |ftnright|, |longtable|,
%         |natbib|, |subeqnarray|, |theorem|, |upref|
%                       add modifications for the corresponding package
%                       (will be used automagically)
%   \item |xr|
%                       add modifications for the package |xr| and
%                       redefine it's internal macro |\externaldocument|
%                       addint a new parameter determining the URL--address
%                       of the document for the cross references used
%                       (will be used automagically)
%   \item |harvard|     add modifications for the respectively packages that
%                       are part of the distribution but provided by other
%                       authors
%   \item |<other>|
%                       add a modification file |<other>.hyp| that has to
%                       be provided by yourself
% \end{itemize}
%
% \section{Macros Provided}
% The following macros are defined by the package and may be used:
% \begin{itemize}
%    \item |\hyperanchor#1#2|
%               lets |#1| being the hypertext anchor for |#2|
%               (|#1| may neither be a natural number nor beginning
%                with |page.| or |fn.|)
%    \item |\blindhyperanchor#1|
%               lets |#1| being a hypertext anchor
%               (|#1| may neither be a natural number nor beginning
%                with |page.| or |fn.|)
%    \item |\hyperreference#1#2|
%               lets |#2| being a hypertext reference to the anchor |#1|,
%               (|#1| may not start with a |[|)
%    \item |\hyperURL#1#2#3#4|
%               lets |#4| being a hypertext reference to an external URL
%               with type |#1|, domain |#2|, and document |#3|, i.e.\
%               to the URL |#1://#2/#3|
%    \item |\labeltext#1#2|
%               lets |#1| being the hypertext capable (\LaTeXe) reference to the text |#2|
%               and prints |#2|
%    \item |\noref[#1]#2|
%               lets |#1| being a hypertext reference to the
%               anchor defined by the \LaTeXe reference |#2| without printing the reference
%               (|#1| is not optional!)
%    \item |\ref[#1]#2|
%               is the same as \LaTeXe's original |#1~\ref{#2}| except that
%               the hypertext reference is provided from the complete
%               |#1~\ref{#2}| instead of |\ref{#2}| only
%    \item |\pageref[#1]#2|
%               is the same as |\ref| except that we get a reference to the
%               page number
%    \item |\refcurrent#1|
%               lets |#1| being a hypertext reference to the last numerical anchor
%               that has been generated
%    \item |\refnext#1|
%               lets |#1| being a hypertext reference to the next numerical anchor
%               that will be generated
% \end{itemize}
%
% \noindent The following macros are redefined when using the
% corresponding packages:
% \begin{itemize}
%   \item for |xr|:
%     \begin{itemize}
%       \item |\externaldocument(#1)[#2]#3|, |\externaldocument[#1](#2)#3|
%               are equivalent to the original |\externaldocument| of the
%               |xr|--package except for the additional parameter surrounded
%               by |(||)| determining the URL--address of the external
%               document (the URL--type |file:| is added automagically)
%               (default is |#3.dvi|)
%     \end{itemize}
% \end{itemize}
%
% \noindent The following macros are provided when using the option |backcitepages|
% or |backcitesections| (definitions show default value):
% \begin{itemize}
%    \item |\def\hyperbackcitepage{Cited on page~}| is the text preceeding a
%          back reference to a single page number.
%    \item |\def\hyperbackcitepages{Cited on pages~}| is the text preceeding a
%          back reference to multiple page numbers.
%    \item |\def\hyperbackcitesection{Cited in~}| is the text preceeding a
%          back reference to a single section reference.
%    \item |\def\hyperbackcitesections{Cited in~}| is the text preceeding a
%          back reference to multiple section references.
%    \item |\def\hyperbackcitenormalseparator{, }| is the text between two
%          page numbers or section references (except for the last pair).
%    \item |\def\hyperbackcitefinalseparatorpair{ and~}| is the text
%          between the page numbers or section references if there are
%          exactly two entries.
%    \item |\def\hyperbackcitefinalseparatorlist{, and~}| is the text
%          between the last pair page numbers or section references if
%          there are more than two entries.
% \end{itemize}
% \section{Viewing Hyper\LaTeXe--documents}
%
% There are several methods that can be used to view the dvi--documents
% with html--marks resulting from using this package.
%
% \begin{itemize}
%    \item For UNIX$^{\mathrm{TM}}$--systems with the graphical user interface
%          |X| there is a modification of |xdvi| called |xhdvi| available at any CTAN-site.
%    \item For systems running under NeXTSTEP$^{\mathrm{TM}}$ there exists a
%          Hyper\TeX-capable modification of |TeXview|, called |HyperTeXview|.
%    \item There exists a variant of |dvips| (called |dvihps|) translating hyperdvi--files to
%          hyperps--files containing the html--marks when using the parameter |-z|.
%          (|emtex| provides this feature with |dvips|).\par
%          \noindent The resulting files can be viewed using a HyperPS-capable Postscript-viewer,
%          (e.g. a hacked version of |ghostview| (for UNIX$^{\mathrm{TM}}$) or the actual |gsview|
%          (for Windows$^{\mathrm{TM}}$))
%    \item Another way is to use |dvihps| to get a HyperPS--file ready to be handled by
%          the Acrobat$^{\mathrm{TM}}$--distiller available from Adobe
%          or by ghostscript's |pdfwriter|--output--device
%          which both can translate hyperps--files to  |pdf|--files that can be viewed
%          using an Acrobat$^{\mathrm{TM}}$--reader or any other |pdf|--reader.
% \end{itemize}
%
% \section{Bugs}
% Currently there are only a few known problems. Unfortunately they
% cannot be avoided. You have to care about this:
% \begin{itemize}
%   \item If you write your bibliographies with the |thebibliograpy|-environment
%         by hand (not using bibtex) you may get an error message due to a
%         command not matching its definition. This can be avoided by providing
%         an empty line or a |\par| command at the end of each bibliographic entry
%         (with |\bibitem|) including the last entry before |\end{thebibliography}|.
%   \item If you include an index or glossary file into the current
%         document you may get a message from \LaTeX{} like
%         |Undefined control sequence.| $\ldots$ |\hyperpage|.
%         This is due to you not using |\makeindex| or |\makeglossary|
%         in the preamble. In this case just add the package option
%         |indexcmds| when loading the hyper--package.
%   \item In indexing commands you can't use |]| without surrounding braces.
%         If you do, \TeX{} will parse the command in a wrong way.
%         To get the sorting of the index right you therefore should use
%         |\index{A[zzzzB@A{]}B}| instead of |\index{A]B}|.
%   \item Similarly, a protected $\mid$, i.e.\ |"|$\mid$ is not handled
%         correctly. Use a similar method as above to circumnavigate
%         this problem.
% \end{itemize}
% \vskip0.5em
% \noindent There is another problem in connection with (a html-capable) |dvips| and paper formats different
% from |letter|. Apparently the positions for the |html|-specials are not computed correctly. The package
% provides a perl-script that allows to modify the positions of these specials.
% When using e.g.\ a4paper you have to call |perl dvi2pdf.pl -z "-s0,50" -nopdf <normal parameters to dvips>|
% to create an appropriate ps-file.
% Note, that the script |dvi2pdf.pl| has to be configured
% and has only been tested on a Windows$^{\mathrm{TM}}$ system.
% \vskip0.5em
% \noindent Other problems are not known so far. But surely there are some
% (otherwise the history would not be already that long).
% Thus, if you detect one please report it with the package version and
% a small example to\medskip
%
% |      Michael Mehlich|\par
% |      mmehlich@semdesigns.com|
%
% \section{Related Work, Acknowledgement}
% Sebastian Rahtz has written another package for adding
% HyperText--capabilities to \LaTeX{}. His package
% |hyperref| has been developed in parallel with this one
% and uses a slightly different realization for getting
% similar results. Some of the ideas found there have been
% added to this package, too.
% Thus, I have to give a special thank to him.
%
% Thanks also to Ulrich Fuchs for further suggestions.
%
% \StopEventually{}
%
% \section{History}
% \leavevmode
% \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
% \hline
% When & By & What & \multicolumn{2}{|c|}{V}
% \\ \hline\hline
% 1998/10/29 & Michael Mehlich &
% fixed macro name for |amsthm|
% & 4&2d
% \\ \hline
% 1998/10/28 & Michael Mehlich &
% corrected problem with wrong references produced
% & 4&2c
% \\ \hline
% 1997/09/22 & Michael Mehlich &
% corrected problem with |\uppercase| and |\lowercase| in internally used names
% & 4&2b
% \\ \hline
% 1997/09/15 & Michael Mehlich &
% corrected problem with |\noalign| in |eqnarray| environment
% & 4&2a
% \\ \hline
% 1997/08/28 & Michael Mehlich &
% corrected definition of new hyper anchor name to appear
% only locally within |\labeltext|\newline
% redefined |\label| for |amstex.sty|\newline
% added support for package |subeqnarray|
% & 4&2
% \\ \hline
% 1997/08/24 & Michael Mehlich &
% reduced problems when adding or removing the |hyper|-package\newline
% patched around problem in interaction of option |fixhyperbox| with
% |dvips|\newline
% problem with undefined hyper references when using cross references
% provided by the package |xr| resolved
% & 4&1
% \\ \hline
% 1997/07/14 & Michael Mehlich &
% corrected bug when creating cross-references between documents
% (bug was introduced when introducing resolution of nested html-marks)
% & 4&0h
% \\ \hline
% 1997/05/28 & Michael Mehlich &
% ensured hyper references for footnotes being created
% even if footnote is moved to the next page
% (but not further)\newline
% corrected marks introduced by the index environment |\theindex|
% in the classes |report| and |book|\newline
% changed mechanism for change flags
% & 4&0g
% \\ \hline
% 1997/05/07 & Michael Mehlich &
% redirected output for special hyper informations to main auxiliary file
% & 4&0f
% \\ \hline
% 1997/04/25 & Michael Mehlich &
% changed catcodes for reading the parameters of |\hyperURL|
% & 4&0e
% \\ \hline
% 1997/04/17 & Michael Mehlich &
% resolved some problem with the |cweb|-package modifications
% & 4&0d
% \\ \hline
% 1997/03/25 & Michael Mehlich &
% resolved problem with wrong footnote references when using package |footnpag|
% (this also corrects the former wrong naming of anchors for footnotes)
% & 4&0c
% \\ \hline
% 1997/03/21 & Michael Mehlich &
% removed bug in interaction of package with |cweb|'s chunk naming mechanism
% & 4&0b
% \\ \hline
% \end{tabularx}
% \newpage
% \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
% \hline
% When & By & What & \multicolumn{2}{|c|}{V}
% \\ \hline\hline
% 1997/03/08 & Michael Mehlich &
% added color for external URL added by |\hyperURL|
% & 4&0a
% \\ \hline
% 1997/03/01 & Michael Mehlich &
% added check for anchor existing before introducing reference to it\newline
% added check whether the anchors have changed beween two \LaTeXe\ runs\newline
% added handling of nested html-marks by unnesting (shit, this conflicts with
% the option |fixhyperbox|)\newline
% added option |fixhyperbox|\newline
% changed creation of anchor names for footnotes due to illegal names and
% duplicated names in the old version\newline
% improved extension package |backcites|\newline
% added handling of sorted citations for package |natbib|\newline
% changed macros for package |natbib|\newline
% added support for common package |fancyheadings| (this was needed for handling
% page references to page numbers when creating pages with empty headers
% and footers)\newline
% modified header and footer modification for inserting appropriate
% anchors and references
% & 4&0
% \\ \hline
% 1997/02/03 & Michael Mehlich &
% allow |\makeindex| and |\makeglossary| to appear after including the package\newline
% corrected mishandling of |pagetop|\newline
% changed colors for references and anchors\newline
% added documentation about how to change colors for colored references and anchors
% & 3&0c
% \\ \hline
% 1997/01/12 & Michael Mehlich &
% corrected problem with loop occurring on even pages
% & 3&0b
% \\ \hline
% 1996/11/01 & Michael Mehlich &
% corrected problem with empty headings causing an overful hbox\newline
% bug of having two page anchors on empty pages in case of |pagetop| removed\newline
% adapted to current version of |natbib|
% & 3&0a
% \\ \hline
% \end{tabularx}
% \newpage
% \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
% \hline
% When & By & What & \multicolumn{2}{|c|}{V}
% \\ \hline\hline
% 1996/10/26 & Michael Mehlich &
% added code for bibliographic references with |natbib|\newline
% added possibility of let pagelinks go to the top of the page
% & 3&0
% \\ \hline
% 1996/10/21 & Michael Mehlich &
% corrected problem with empty page style
% & 2&8a
% \\ \hline
% 1996/01/07 & Michael Mehlich &
% adapted to current version of latex
% & 2&8
% \\ \hline
% 1995/12/19 & Michael Mehlich &
% adapted to current version of the cweb--package
% & 2&7b
% \\ \hline
% 1995/10/22 & Michael Mehlich &
% made reference commands robust
% & 2&7a
% \\ \hline
% 1995/09/24 & Michael Mehlich &
% added support for the \CWEB\ document class
% & 2&7
% \\ \hline
% 1995/07/13 & Michael Mehlich &
% |\hyper@next| changed to |\fragilerefnext| to avoid problems when writing
% the command into the |.toc|--file
% & 2&6a
% \\ \hline
% 1995/07/06 & Michael Mehlich &
% |\hyperbackcite| occurred mistakenly in each file\newline
% bug fix in redefinition of |theindex|-environment in |doc.hyp|\newline
% handling of footnotes corrected\newline
% modified |\@xeqncr| instead of |\@eqncr|\newline
% adapted redefinition of captions for |longtable| to current
% version of |longtable|
% & 2&6
% \\ \hline
% 1995/07/04 & Michael Mehlich &
% correction of optional parameter of |\\| in eqnarray--environment
% mistakenly ignored
% & 2&5d
% \\ \hline
% 1995/06/14 & Michael Mehlich &
% corrected |\hyper@oddfoot|
% & 2&5c
% \\ \hline
% 1995/05/29 & Michael Mehlich &
% added support for contribution |harvard.hyp|,
% changed automatical uploading of packages to
% conditional uploading (tests if the package
% really exists)
% & 2&5b
% \\ \hline
% 1995/05/23 & Michael Mehlich &
% changed wrong page numbers for certain
% document classes
% & 2&5a
% \\ \hline
% 1995/05/10 & Michael Mehlich &
% added support for backcites
% &2&5
% \\ \hline
% 1995/05/08 & Michael Mehlich &
% internal handling of references to pages simplified\newline
% bug in |xr.hyp| fixed\newline
% anchor on empty pages added
% & 2&4c
% \\ \hline
% 1995/05/07 & Michael Mehlich &
% let |\item| accept |]| in optional argument
% & 2&4b
% \\ \hline
% \end{tabularx}
% \newpage
% \begin{tabularx}{\textwidth}{|c|l|X|r@{.}l|}
% \hline
% When & By & What & \multicolumn{2}{|c|}{V}
% \\ \hline\hline
% 1995/04/20 & Michael Mehlich &
% added new option |indexcmds|
% & 2&4a
% \\ \hline
% 1995/04/20 & Michael Mehlich &
% added support for |amstex|
% & 2&4
% \\ \hline
% 1995/04/18 & Michael Mehlich &
% corrected bug in index (reported by Ulrich Fuchs)
% & 2&3a
% \\ \hline
% 1995/02/12 & Michael Mehlich &
% support for package |xr| added\newline
% handling of options improved
% & 2&3
% \\ \hline
% 1995/02/11 & Michael Mehlich &
% definition of |\label| corrected (bug introduced at 1995/01/31)
% & 2&2b
% \\ \hline
% 1995/02/02 & Michael Mehlich &
% macros for |amsthm| changed according to new definition in amslatex
% & 2&2a
% \\ \hline
% 1995/02/01 & Michael Mehlich &
% support for package |amslatex| added\newline
% support for package |longtable| added
% & 2&2
% \\ \hline
% 1995/01/31 & Michael Mehlich &
% support for package |theorem| added\newline
% catcodes of \verb+|+, |@|, and |!| for parsing the parameters of
% |\index| and |\glossary| changed\newline
% |\@makecaption| modified\newline
% hypertext references in |eqnarray| corrected\newline
% redefinition of |\label| changed
% & 2&1
% \\ \hline
% 1995/01/30 & Michael Mehlich &
% handling of series of page numbers for index/glossary added\newline
% |\protected@write| stopped from inserting an extra space
% & 2&0b
% \\ \hline
% 1995/01/29 & Michael Mehlich &
% references from headers to sections for bibliography, index, glossary, and
% table of contents added
% & 2&0a
% \\ \hline
% 1995/01/26 & Michael Mehlich &
% options to be handled are determined automagically now\newline
% protected the anchor and reference adding macros instead of {\tt"}\newline
% some internal algorithms changed\newline
% some macro--names changed
% & 2&0
% \\ \hline
% 1995/01/25 & Michael Mehlich & handling of index and glossary added & 1&3
% \\ \hline
% 1995/01/24 & Michael Mehlich &
% handling of options changed\newline
% color support for anchors and references added
% & 1&2
% \\ \hline
% 1995/01/24 & Michael Mehlich &
% |\noref| added\newline
% bug in writing wrong page numbers to auxiliary files removed
% & 1&1
% \\ \hline
% 1995/01/20 & Michael Mehlich &
% protected {\tt"} for compatibility with the package |german.sty|
% & 1&0g
% \\ \hline
% 1995/01/12 & Michael Mehlich &
% first official version
% & 1&0
% \\ \hline
% \end{tabularx}
%
% \clearpage
%
% \section{The Realization}
%
% \subsection{The Package Header}
% We need a version of \LaTeX2e{} dated with June 1, 1995 or newer.
% Thus, we just demand it.
%    \begin{macrocode}
%<*hyper>
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
%    \end{macrocode}
% Now we have to introduce ourself.
%    \begin{macrocode}
\ProvidesPackage{hyper}[\filedate\space HyperLaTeX2e extension]
%    \end{macrocode}
%
% \subsection{Special Characters}
% First of all let us reserve some characters which are important and are
% not preserved by every other package.
%    \begin{macrocode}
\bgroup
  \catcode`\!00\relax
  \catcode`\"12\relax
  !catcode`!\12!relax
  !gdef!hyper@quote{"}
  !gdef!hyper@backslash{\}
  !global!edef!hyper@hash{!string#}
  !global!edef!hyper@tilde{!string~}
!egroup
%    \end{macrocode}
% For compatibility with other packages this may need to be extended.
% But for now we suppose this being sufficient.
%
% \subsection{The Basic Anchor/Reference-Entries}
% Let us set the output channel for special hyper informations first.
%    \begin{macrocode}
\AtBeginDocument{\let\hyper@auxout\@auxout}
%    \end{macrocode}
% We have to define some macros that allow us to insert the hypertext marks
% for anchors and references into the resulting dvi-file. This can be
% done by using the |\special|--macro.\par
% \noindent But before introducing them, we need some auxiliaries that allow
% us to write the hyper anchors to the auxiliary file and reread them at
% program start. This way we can check, whether we use a reference to an
% existing anchor; thus we can avoid introducing invalid references.
% This mechanism can additionally be used to check whether the hyper anchors
% may have changed between two \LaTeXe\ runs.\par
% \noindent This is also a good place to recheck whether there have been some
% undefined or multiply defined hyper anchors or forwarded references
% used in hyper references.
%     \begin{macrocode}
\newcount\hyper@changed
\global\hyper@changed=0
\newcount\hyper@cnt%careful, this is used as a temporary counter in various places
\def\hyper@change#1{%set change value (powers of 2 only), in use: 1,2,4,8
  \hyper@cnt\hyper@changed\relax%
  \divide\hyper@cnt#1\relax%
  \ifodd\hyper@cnt\else%
     \global\advance\hyper@changed#1\relax%
  \fi%
}
\def\newhyper#1#2{%
  \bgroup%
     \def\uppercase{<UPPERCASE>}%
     \def\lowercase{<LOWERCASE>}%
     \expandafter\ifx\csname hyper@#1\endcsname\relax\else%
        \hyper@change2\relax%
        \PackageWarningNoLine{hyper}%
                     {Hyper anchor #1 multiply defined}%
     \fi%
     \expandafter\global\expandafter\def\csname hyper@#1\endcsname{#2}%
  \egroup%
}
\def\newhyper@check#1#2{%
   \def\reserved@a{#2}%
  \bgroup%
     \def\uppercase{<UPPERCASE>}%
     \def\lowercase{<LOWERCASE>}%
     \expandafter\ifx\csname hyper@#1\endcsname\reserved@a\else%
       \expandafter\ifx\csname hyper@new@#1\endcsname\reserved@a\else%
          \global\hyper@change4\relax%
        \fi%
     \fi%
  \egroup%
}
\let\hyper@enddocument\enddocument
\def\hyper@check@end{%
  \ifodd\hyper@changed%1
     \PackageWarningNoLine{hyper}{There were undefined hyper references}%
  \fi%
  \divide\hyper@changed2\relax%
  \ifodd\hyper@changed%2
     \PackageWarningNoLine{hyper}%
          {There were multiply defined hyper anchors}%
  \fi%
  \divide\hyper@changed2\relax%
  \ifodd\hyper@changed%4
     \PackageWarningNoLine{hyper}%
          {Hyper anchor(s) may have changed.\MessageBreak
           Rerun to get hyper references right}%
  \fi%
  \divide\hyper@changed2\relax%
  \ifodd\hyper@changed%8
     \PackageWarningNoLine{hyper}%
          {Footnote hyper reference(s) may have been forwarded\MessageBreak
             to next page.\MessageBreak
           Check result to ensure this being correct.\MessageBreak
           If not rerun to get footnote hyper references right}%
  \fi%
}
\def\enddocument{%
  \let\hyper@@end\@@end%
  \def\@@end{\hyper@check@end\hyper@@end}%
  \let\newhyper\newhyper@check%
  \hyper@enddocument%
}
\def\hyper@to@aux#1{%
  \bgroup%
     \def\uppercase{<UPPERCASE>}%
     \def\lowercase{<LOWERCASE>}%
     \expandafter\ifx\csname hyper@#1\endcsname\relax%
        \expandafter\ifx\csname hyper@new@#1\endcsname\relax%
           \expandafter\global%
             \expandafter\expandafter\expandafter\def\csname hyper@new@#1\endcsname%
                 {{\@currentlabel}{\thepage}}%
        \fi%
     \fi%
     \@bsphack%
        \protected@write%
           \hyper@auxout%
             {}%
             {\string\newhyper%
               {#1}%
               {{\@currentlabel}{\thepage}}%
             }%
     \@esphack%
   \egroup%
}
%    \end{macrocode}
% \noindent The macros |\hyperreference| |\hyperpagereference| and insert a html-reference
% to an internal label except when the first parameter begins with |[|. Then the
% parameter must have the form |[#1][#2]| where |#1| is an external URL and
% |#2| an anchor within this URL. This is used when generating cross references
% between documents.\par
% \noindent The whole stuff is complicated by two problems: We have to avoid
% nesting of the html-markups in the dvi-file and we have to tell |dvips| about the
% right dimension of the box by modifying the positions of the specials from which
% |dvips| gets the bounding box for a hyper reference (The latter one is optionally
% done when passing the corresponding parameter to the package).
%    \begin{macrocode}
\newbox\hyper@box@text
\newbox\hyper@box@ref
\newdimen\hyper@fixdim
\newif\if@hyper@is@active
\@hyper@is@activefalse
\def\hyper@html{html:}
\bgroup
  \catcode`\<12\catcode`\>12\relax%
  \catcode`\:12\catcode`\=12\catcode`\/12\relax%
  \gdef\hyper{%
    \def\hyper@unnested@special##1##2##3{%
       \special{\hyper@html##1}##3\special{\hyper@html##2}%
    }%
    \def\hyper@unnested@special@anchor@nofix##1##2##3{%
       \special{\hyper@html##1}\hyper@anchor@color{##3}\special{\hyper@html##2}%
    }%
    \def\hyper@unnested@special@reference@nofix##1##2##3{%
       \special{\hyper@html##1}\hyper@ref@color{##3}\special{\hyper@html##2}%
    }%
    \def\hyper@unnested@special##1##2{%
       \hyper@fixdim\ht\hyper@box@text%
       \advance\hyper@fixdim\dp\hyper@box@text%
       \advance\hyper@fixdim-8pt%
       \setbox\hyper@box@ref=\hbox{%
          \parindent0pt\leftskip0pt\rightskip0pt%
          \leftmargin0pt\rightmargin\wd\hyper@box@text\advance\rightmargin0.5pt%
          \linewidth\rightmargin\textwidth\rightmargin%
          \noindent\vbox{%
             \hrule height \hyper@fixdim width 0pt%
             \special{\hyper@html##1}\hbox to\linewidth{\hfill}%
             \hrule height -\hyper@fixdim width 0pt%
             \hbox to\linewidth{\hfill\special{\hyper@html##2}}%
             \hrule height 0pt width 0pt%
          }%
       }%
       \ht\hyper@box@ref0pt%
       \dp\hyper@box@ref0pt%
       \wd\hyper@box@ref0pt%
       \hyper@fixdim\ht\hyper@box@text%
       \advance\hyper@fixdim-8pt%
       \hbox{\raise\hyper@fixdim\copy\hyper@box@ref\copy\hyper@box@text}%
       \setbox\hyper@box@ref=\hbox{}%
    }%
    \def\hyper@unnested@special@anchor@fix##1##2##3{%
       \setbox\hyper@box@text=\hbox{\hyper@anchor@color{##3}}%
       \hyper@unnested@special{##1}{##2}%
       \setbox\hyper@box@text=\hbox{}%
    }%
    \def\hyper@unnested@special@reference@fix##1##2##3{%
       \setbox\hyper@box@text=\hbox{\hyper@ref@color{##3}}%
       \hyper@unnested@special{##1}{##2}%
       \setbox\hyper@box@text=\hbox{}%
    }
    \let\hyper@unnested@special@reference\hyper@unnested@special@reference@nofix%
    \let\hyper@unnested@special@anchor\hyper@unnested@special@anchor@nofix%
    \def\hyper@nested@special##1##2##3##4{%
       \ifx\hyper@unnested@special@reference\hyper@unnested@special@reference@nofix%
          \if@hyper@is@active%
             \expandafter\expandafter\expandafter%
                  \special\expandafter\@firstoftwo\hyper@special@last%
               {\def\hyper@special@last{{{\hyper@html##4}}{{\hyper@html##2}}}%
                ##1{##2}{##4}{##3}%
               }%
             \expandafter\expandafter\expandafter%
                 \special\expandafter\@secondoftwo\hyper@special@last%
          \else%
            \def\hyper@special@last{{{\hyper@html##4}}{{\hyper@html##2}}}%
            \@hyper@is@activetrue\relax%
            ##1{##2}{##4}{##3}%
            \@hyper@is@activefalse\relax%
          \fi%
       \else%
          \if@hyper@is@active%
             ##1{##2}{##4}{##3}%
          \else%
            \@hyper@is@activetrue\relax%
            ##1{##2}{##4}{##3}%
            \@hyper@is@activefalse\relax%
          \fi%
       \fi%
    }%
    \def\hyper@special@anchor{\hyper@nested@special\hyper@unnested@special@anchor}
    \def\hyper@special@reference{\hyper@nested@special\hyper@unnested@special@reference}
    \def\f@hyper@ref@ext[##1][##2][##3]\end@hyper@ref##4{%
      \ifvmode\leavevmode\fi%
      \hyper@special@reference%
         {<a href=\hyper@quote##1##2\hyper@hash##3\hyper@quote>}%
            {##4}%
         {</a>}%
    }%
    \def\hyper@check@fn##1.##2.##3.##4\hyper@check@fn{%
       \def\hyper@tmpa{fn}%mark for link to footnote
       \def\hyper@tmpb{##1}%
       \ifx\hyper@tmpa\hyper@tmpb{%
           \ifx?##3\relax%
              \global\let\hyper@forwarded@fn\@empty%
           \else%
              \hyper@cnt##3\relax%                                   fetch page
              \advance\hyper@cnt1\relax%                             advance page by one
              \global\edef\hyper@forwarded@fn{fn.##2.\the\hyper@cnt}%create new link
           \fi%
         }%
       \else%
         \global\let\hyper@forwarded@fn\@empty%
       \fi%
    }%
    \let\hyper@thepage\thepage%
    \def\f@hyper@ref@int##1\end@hyper@ref##2{%
      \ifvmode\leavevmode\fi%
      \expandafter\ifx\csname hyper@##1\endcsname\relax%
         \expandafter\ifx\csname hyper@new@##1\endcsname\relax%
            \hyper@check@fn##1...\hyper@check@fn%
            \ifx\hyper@forwarded@fn\@empty%
               \PackageWarning{hyper}%
                  {Hyper reference `##1' for `##2' on page \hyper@thepage\space undefined}%
               \hyper@change1\relax%
               \hyper@undef@color{##2}%
            \else%
               \expandafter\ifx\csname hyper@\hyper@forwarded@fn\endcsname\relax%
                  \expandafter\ifx\csname hyper@new@\hyper@forwarded@fn\endcsname\relax%
                     \PackageWarning{hyper}%
                        {Hyper reference `##1' for `##2'  %
                         on page \hyper@thepage\space undefined}%
                     \hyper@change1\relax%
                     \hyper@undef@color{##2}%
                  \else%
                     \hyper@change8\relax%
                     \PackageWarning{hyper}%
                        {Hyper reference `##1' for `##2' on page \hyper@thepage\space%
                         forwarded to `\hyper@forwarded@fn'}%
                     \hyper@special@reference%
                        {<a href=\hyper@quote\hyper@hash\hyper@forwarded@fn\hyper@quote>}%
                           {##2}%
                        {</a>}%
                  \fi%
               \else%
                  \hyper@change8\relax%
                  \PackageWarning{hyper}%
                     {Hyper reference `##1' for `##2' on page \hyper@thepage\space%
                      forwarded to `\hyper@forwarded@fn'}%
                  \hyper@special@reference%
                     {<a href=\hyper@quote\hyper@hash\hyper@forwarded@fn\hyper@quote>}%
                        {##2}%
                     {</a>}%
               \fi%
            \fi%
         \else%
            \hyper@special@reference%
               {<a href=\hyper@quote\hyper@hash##1\hyper@quote>}%
                  {##2}%
               {</a>}%
         \fi%
      \else%
        \hyper@special@reference%
           {<a href=\hyper@quote\hyper@hash##1\hyper@quote>}%
              {##2}%
           {</a>}%
      \fi%
    }%
    \def\f@hyper@ref{%
      \@ifnextchar[{\f@hyper@ref@ext[]}{\f@hyper@ref@int}%
    }%
    \def\fragilehyperreference##1{%
      \expandafter\expandafter\expandafter\f@hyper@ref##1\end@hyper@ref%
    }%
    \def\f@hyper@page@ref{%
      \@ifnextchar[{\f@hyper@ref@page@ext[page.]}{\f@hyper@ref@int page.}%
    }%
    \def\fragilehyperpagereference##1{%
      \expandafter\expandafter\expandafter%
      \f@hyper@page@ref##1\end@hyper@ref%
    }%
    \def\fragilehyperanchor##1##2{%
      \ifvmode\leavevmode\fi%
      \hyper@special@anchor%
         {<a name=\hyper@quote##1\hyper@quote>}%
            {\hyper@to@aux{##1}%
             ##2%
            }%
         {</a>}%
    }%
    \def\fragileblindhyperanchor##1{%
      \hyper@special@anchor%
         {<a name=\hyper@quote##1\hyper@quote>}%
            {\hyper@to@aux{##1}}%
         {</a>}%
    }%
    \def\fragilehyperURL##1##2##3##4{%
      \ifvmode\leavevmode\fi%
      \def\hyper@tmp{##4}%
      \def\hyper@tmpa{##1}%
      \def\hyper@tmpb{##2}%
      \def\hyper@tmpc{##3}%
      \ifx\hyper@tmp\@empty%
         %
      \else\ifx\hyper@tmpa\@empty%
         \ifx\hyper@tmpb\@empty%
            \ifx\hyper@tmpc\@empty%
               {##4}%
            \else%
               \hyper@special@reference%
                  {<a href=\hyper@quote##3\hyper@quote>}%
                     {##4}%
                  {</a>}%
            \fi%
         \else\ifx\hyper@tmpc\@empty%
            \hyper@special@reference%
               {<a href=\hyper@quote//##2/\hyper@quote>}%
                  {##4}%
               {</a>}%
         \else%
            \hyper@special@reference%
               {<a href=\hyper@quote//##2/##3\hyper@quote>}%
                  {##4}%
               {</a>}%
         \fi\fi%
      \else\ifx\hyper@tmpb\@empty%
         \ifx\hyper@tmpc\@empty%
            {##4}%
         \else%
            \hyper@special@reference%
               {<a href=\hyper@quote##1:##3\hyper@quote>}%
                  {##4}%
               {</a>}%
         \fi%
      \else\ifx\hyper@tmpc\@empty%
        \hyper@special@reference%
           {<a href=\hyper@quote##1://##2/\hyper@quote>}%
              {##4}%
           {</a>}%
      \else%
        \hyper@special@reference%
           {<a href=\hyper@quote##1://##2/##3\hyper@quote>}%
              {##4}%
           {</a>}%
       \fi\fi\fi\fi%
    }%
  }
\egroup
\hyper
%    \end{macrocode}
% Sometimes we need this package without being allowed to insert
% the hypertext marks into the dvi--file. Note, thate |\hyper@fix| is
% defined for the sole purpose of having the same \TeX-output behaviour
% regardless whether we create or do not create hypertext markups.
%    \begin{macrocode}
\def\nohyper{%
  \def\hyper@fix##1{%
     \ifx\hyper@unnested@special@reference\hyper@unnested@special@reference@nofix%
        ##1%
     \else%
        \hbox{##1}%
     \fi%
  }
  \def\fragilehyperreference##1##2{%
     \ifvmode\leavevmode\fi\hyper@fix{\hyper@ref@color{##2}}%
  }%
  \def\fragilehyperpagereference##1##2{%
     \ifvmode\leavevmode\fi\hyper@fix{\hyper@ref@color{##2}}%
  }%
  \def\fragilehyperanchor##1##2{%
     \ifvmode\leavevmode\fi\hyper@anchor@color{##2}%
  }%
  \def\fragileblindhyperanchor##1{}%
  \def\fragilehyperURL##1##2##3##4{%
     \ifvmode\leavevmode\fi\hyper@fix{\hyper@ref@color{##4}}%
  }%
}
%    \end{macrocode}
% Now let's protect the fragile commands.
%    \begin{macrocode}
\def\hyperreference{\protect\fragilehyperreference}
\def\hyperpagereference{\protect\fragilehyperpagereference}
\def\hyperanchor{\protect\fragilehyperanchor}
\def\blindhyperanchor{\protect\fragileblindhyperanchor}
\def\fragileChyperURL{%
  \bgroup%
     \catcode`\<12\catcode`\>12\catcode`\"12\relax%
     \catcode`\:12\catcode`\=12\catcode`\/12\relax%
     \catcode`\#12\catcode`\~12\relax%\catcode`\%12\relax%
     \finish@hyperURL%
}
\def\finish@hyperURL#1#2#3#4{%
    \fragilehyperURL{#1}{#2}{#3}{#4}%
  \egroup%
}
\def\hyperURL{\protect\fragileChyperURL}
%    \end{macrocode}
%
% \subsection{Colored Anchors/References}
% Above we have used three macros |\hyper@ref@color|, |\hyper@undef@color|, and |\hyper@anchor@color|
% with which we can modify the text that is printed to the document.
% As their name indicates we want to use them to color the anchors resp.\
% references. Hence we should define some variants of these macros.\par
% \noindent The first variant prints the text in different colors.
%    \begin{macrocode}
\def\hyper@color{%
  \definecolor{refcolor}{rgb}{0,0,1}%
  \definecolor{undefrefcolor}{rgb}{1,0,0}%
  \definecolor{anchorcolor}{rgb}{0,0.75,0.75}%
  \def\hyper@ref@color##1{\textcolor{refcolor}{##1}}%
  \def\hyper@undef@color##1{\textcolor{undefrefcolor}{##1}}%
  \def\hyper@anchor@color##1{\textcolor{anchorcolor}{##1}}%
}
%    \end{macrocode}
% If we do not have colors we may use gray text instead.
%    \begin{macrocode}
\def\hyper@gray{%
  \definecolor{refcolor}{gray}{0.75}%
  \definecolor{undefrefcolor}{gray}{0.25}%
  \definecolor{anchorcolor}{gray}{0.5}%
  \def\hyper@ref@color##1{\textcolor{refcolor}{##1}}%
  \def\hyper@undef@color##1{\textcolor{undefrefcolor}{##1}}%
  \def\hyper@anchor@color##1{\textcolor{anchorcolor}{##1}}%
}
%    \end{macrocode}
% In ready to print documents we should not use these options but print
% the text in ordinary black. This is also the default definition.
%    \begin{macrocode}
\def\hyper@black{%
  \def\hyper@ref@color##1{##1}%
  \def\hyper@undef@color##1{##1}%
  \def\hyper@anchor@color##1{##1}%
}
\hyper@black
%    \end{macrocode}
%
% \subsection{Automatic Generation of Anchor Names}
% As we want to insert hypertext marks automagically we need a service that
% provides new names for anchors. The simplest solution is to let the
% name be a natural number.\par
% \noindent Thus we need an initialization for providing them.
%    \begin{macrocode}
\newcount\hypercount
\hypercount=0\relax
\def\@currenthyper{}
%    \end{macrocode}
% Now we can compute the next anchor from the last one generated.
%    \begin{macrocode}
\def\hyper@setcurrent{%
  \global\advance\hypercount1\relax%
  \edef\@currenthyper{\the\hypercount}%
}%
\def\hyper@settype#1{%
\edef\@currenthypertype{#1}%
}%
%    \end{macrocode}
% The automatic generation of anchor names leads to a little problem.
% We have to ensure that |\@currenthyper| is expanded at an appropriate
% time. Thus we define a macro that allow us to get an expanded
% hypertext reference that follows a not yet expanded
% token list.
%    \begin{macrocode}
\def\hyper@ref@toggle#1#2#3{#3[\hyperreference{#1}{#2}]}
\def\ref@by@expanded@hyper#1\end@hyper{{#1}}
\def\callwithexpandedhyperref#1#2{%
  \expandafter\expandafter\expandafter\hyper@ref@toggle%
    \expandafter\ref@by@expanded@hyper\@currenthyper\end@hyper%
  {#2}{#1}%
}
%    \end{macrocode}
%
% \subsection{HyperText Cross--Referencing for \LaTeXe}
% For a replacement of \LaTeXe's cross--referencing features we need to
% redefine the commands |\label| and |\ref|.\par
% \noindent Let us first define a label command for writing the current
% hypertext reference to the |.aux|--file. It must print four components
% of a label: the hypertext--type, the hypertext--anchor, the \LaTeXe--anchor,
% and the \LaTeXe--page. This is due to the fact that we need to know not only
% the stuff we reference to but also the internal name of the anchor.
%    \begin{macrocode}
\def\hyperlabel#1{\@bsphack
  \protected@write\hyper@auxout{}%
         {\string\newlabel{#1}%
           {{\@currenthypertype}{\@currenthyper}{\@currentlabel}{\thepage}}}%
  \@esphack}
%    \end{macrocode}
% Now we need some auxiliary macros to be able to select each of the three
% parts of the second argument of |\newlabel| that has been written to the
% |.aux|--file. Note, that the third component may contain informations
% about the URL of an external document (for cross referencing between
% documents) that has to be stripped of a page
% number before printing it.
%    \begin{macrocode}
\def\hyper@secondoffour#1#2#3#4{#2}
\def\hyper@thirdoffour#1#2#3#4{#3}
\def\hyper@forthoffour#1#2#3#4{#4}
\def\hyper@snd@forthoffour[#1][#2]\end@hyper{#2}
\def\hyper@this@forthoffour#1\end@hyper{#1}
\def\hyper@test@forthoffour{%
  \@ifnextchar[{\hyper@snd@forthoffour}{\hyper@this@forthoffour}%
}
\def\hyper@page@forthoffour#1#2#3#4{%
  \expandafter\hyper@test@forthoffour#4\end@hyper%
}
%    \end{macrocode}
% When setting a reference to an anchor we also have to add the corresponding
% hypertext link into the dvi-file.
%    \begin{macrocode}
\let\hyper@thepage\thepage
\def\hyper@setref#1#2#3#4{%
  \ifx#1\relax%
     \protect\G@refundefinedtrue%
     #4\nfss@text{\reset@font\bfseries ??}%
     \@latex@warning{Reference `#3' on page \hyper@thepage \space undefined}%
  \else%
    \edef\hyper@tmp{\expandafter\hyper@secondoffour#1}%
    \ifx\hyper@tmp\@empty%
       \ifx#2\hyper@secondoffour%
          #4\null%
       \else\ifx#2\hyper@thirdoffour%
         #4\expandafter#2#1\null%
       \else%
         #4\expandafter#2#1\null%
       \fi\fi%
    \else%
       \ifx#2\hyper@secondoffour%
          \hyperreference{\expandafter\hyper@secondoffour#1}{#4}\null%
       \else\ifx#2\hyper@thirdoffour%
         \hyperreference%
           {\expandafter\hyper@secondoffour#1}%
           {#4\expandafter#2#1\null}\null%
       \else%
         \hyperpagereference%
           {\expandafter\hyper@forthoffour#1}%
           {#4\expandafter#2#1\null}\null%
       \fi\fi%
    \fi%
  \fi%
}
%    \end{macrocode}
% Proceeding from this we can define three macros |\hypernoref|, |\hyperref|,
% and |\hyperpageref| that correspond to the same \LaTeXe--macros where the
% hyper does not occur. But we want to do a little bit more. Thus an
% additional optional argument may be given to these macros to allow
% the user to reference from a whole text and not only from the number
% to the anchor.
%    \begin{macrocode}
\def\@@hypernoref[#1]#2{%
  \expandafter\hyper@setref\csname r@#2\endcsname%
    \hyper@secondoffour{#2}{#1}%
}
\def\@hypernoref[#1]{\@@hypernoref[#1]}
\def\hypernoref{\@ifnextchar[{\@hypernoref}{\@@hypernoref[]}}
\def\@@hyperref[#1]#2{%
  \expandafter\hyper@setref\csname r@#2\endcsname%
    \hyper@thirdoffour{#2}{#1}%
}
\def\@hyperref[#1]{\@@hyperref[#1~]}
\def\hyperref{\@ifnextchar[{\@hyperref}{\@@hyperref[]}}
\def\@@hyperpageref[#1]#2{%
   \expandafter\hyper@setref\csname r@#2\endcsname%
     \hyper@page@forthoffour{#2}{#1}%
}
\def\@hyperpageref[#1]{\@@hyperpageref[#1~]}
\def\hyperpageref{\@ifnextchar[{\@hyperpageref}{\@@hyperpageref[]}}
%    \end{macrocode}
% Now let's patch \LaTeXe's ref/label-system:
%    \begin{macrocode}
\let\label\hyperlabel
\def\noref{\protect\hypernoref}
\def\ref{\protect\hyperref}
\def\pageref{\protect\hyperpageref}
%    \end{macrocode}
% Up to now we only can reference to anchors but haven't yet defined some.
% This will be done in many of the following subsections.
% \subsection{Other Cross--Referencing Features}
% Though \LaTeXe{} has a very good reference mechanism this is not enough
% for hypertext documents. The user should be able to add an anchor to
% a text of his own choice.
%    \begin{macrocode}
\def\labeltext#1#2{%
  \bgroup%
    \hyper@setcurrent%
    \hyper@settype{text}%
    \def\@currentlabel{#2}%
    \label{#1}%
    \hyperanchor{\@currenthyper}{#2}%
  \egroup%
}
%    \end{macrocode}
% But that is not enough. Some of the macros of this package define anchors
% which cannot be caught by a |\label| command. But then it is the current or
% the next anchor generated. The following macros will allow us to reference
% to them:
%    \begin{macrocode}
\def\refcurrent#1{\hyperreference{\@currenthyper}{#1}}
\def\fragilerefnext#1#2{\bgroup%
  \hypercount=#1\relax\advance\hypercount1\relax%
  \hyperreference{\the\hypercount}{#2}%
\egroup}
\def\refnext#1{\protect\fragilerefnext{\the\hypercount}{#1}}
%    \end{macrocode}
% This is especially usefull for inserting links from the table of contents
% to an unnumbered section like e.g.\ the references of a document.\par
% \noindent But wait, there is more. \LaTeXe{} not only uses |\ref| and
% |\label| for it's referencing mechanism but also |\refstepcounter| to
% determine to what the next |\label| should reference.
% This has to be reflected for the hypertext stuff.
%    \begin{macrocode}
\let\hyper@refstepcounter\refstepcounter
\def\refstepcounter{\hyper@setcurrent\hyper@settype{counter}\hyper@refstepcounter}
%    \end{macrocode}
% As we will patch some latex internals below we also need
% a macro that allow us to forget the next |\refstepcounter|.
%    \begin{macrocode}
\def\ignore@next@refstepcounter{%
  \def\refstepcounter##1{%
    \def\refstepcounter{\hyper@setcurrent\hyper@settype{counter}\hyper@refstepcounter}%
  }%
}
%    \end{macrocode}
%
% \subsection{Handling Page Numbers}
% We want to refer from the pages in the table of contents
% to the corresponding page. Thus we have to recall the necessary
% information when printing the table.
%    \begin{macrocode}
\let\hyper@contentsline\contentsline
\def\contentsline#1#2#3{%
  \hyper@contentsline{#1}{#2}{\hyperpagereference{#3}{#3}}%
}
%    \end{macrocode}
% The same is valid for indices and glossaries. But they are more
% problematic. Hence we will handle them in a subsection of its own.\par
% \noindent So far the result is a couple of references from page numbers
% to pages. But we haven't defined the anchors they refer to.\par
% \noindent To resolve this we have to modify headers and footers of
% a page. This can be done for an arbitrary page style when we change
% (misuse!) |\@begindvi|.\par
% \noindent Let's provide to different styles for this purpose, one allowing
% jumps to the page number, and one allowing jumps to the top of the page.
% In the latter case we let the page numbers in the headers and footers refer
% to the top of the page.
%    \begin{macrocode}
\let\hyper@thepage\thepage
\def\hyper@anchorpage{%
  \fragilehyperanchor{page.\hyper@thepage}{\hyper@thepage}%
}
\def\hyper@referencepage{%
  \fragilehyperreference{page.\hyper@thepage}{\hyper@thepage}%
}
\def\hyper@empty{\@empty}
\def\hyper@evenhead{\@evenhead}
\def\hyper@oddhead{\@oddhead}
\def\hyper@evenfoot{\@evenfoot}
\def\hyper@oddfoot{\@oddfoot}
\def\hyper@modifyheadfoot@pagenumber{%
  \let\hyper@thehead\@thehead%
  \ifx\hyper@thehead\hyper@oddhead\let\hyper@thehead\@oddhead\fi%
  \ifx\hyper@thehead\hyper@evenhead\let\hyper@thehead\@evenhead\fi%
  \let\hyper@thefoot\@thefoot%
  \ifx\hyper@thefoot\hyper@oddfoot\let\hyper@thefoot\@oddfoot\fi%
  \ifx\hyper@thefoot\hyper@evenfoot\let\hyper@thefoot\@evenfoot\fi%
  \def\@thehead{%
      \ifnum\ifnum\ifx\hyper@thehead\@empty1\else0\fi%
                  \ifx\hyper@thehead\hyper@empty1\else0\fi%
                  >0 0\else1\fi%
            \ifnum\ifx\hyper@thefoot\@empty1\else0\fi%
                  \ifx\hyper@thefoot\hyper@empty1\else0\fi%
                  >0 0\else1\fi%
            >0\relax%
      \else%
         \blindhyperanchor{page.\thepage}%
      \fi%
      \let\hyper@thepage\thepage%
      \let\thepage\hyper@anchorpage%
      \ifx\hyper@thehead\@empty%
         \hfil%
      \else\ifx\hyper@thehead\hyper@empty%
         \hfil%
      \else%
        \hyper@thehead%
      \fi\fi%
  }%
  \def\@thefoot{%
      \let\hyper@thepage\thepage%
      \let\thepage\hyper@anchorpage%
      \ifx\hyper@thefoot\@empty%
         \hfil%
      \else\ifx\hyper@thefoot\hyper@empty%
         \hfil%
      \else%
         \hyper@thefoot%
      \fi\fi%
  }%
}
\def\hyper@modifyheadfoot@pagetop{%
  \let\hyper@thehead\@thehead%
  \ifx\hyper@thehead\hyper@oddhead\let\hyper@thehead\@oddhead\fi%
  \ifx\hyper@thehead\hyper@evenhead\let\hyper@thehead\@evenhead\fi%
  \let\hyper@thefoot\@thefoot%
  \ifx\hyper@thefoot\hyper@oddfoot\let\hyper@thefoot\@oddfoot\fi%
  \ifx\hyper@thefoot\hyper@evenfoot\let\hyper@thefoot\@evenfoot\fi%
  \def\@thehead{%
      \blindhyperanchor{page.\thepage}%
      \let\hyper@thepage\thepage%
      \let\thepage\hyper@referencepage%
      \ifx\hyper@thehead\@empty%
         \hfil%
      \else\ifx\hyper@thehead\hyper@empty%
         \hfil%
      \else%
         \hyper@thehead%
      \fi\fi%
  }%
  \def\@thefoot{%
      \let\hyper@thepage\thepage%
      \let\thepage\hyper@referencepage%
      \ifx\hyper@thefoot\@empty%
         \hfil%
      \else\ifx\hyper@thefoot\hyper@empty%
         \hfil%
      \else%
         \hyper@thefoot%
      \fi\fi%
    }%
}
\let\hyper@begindvi\@begindvi
\def\@begindvi{%
  \hyper@begindvi%
  \hyper@modifyheadfoot%
  \global\let\@begindvi\hyper@modifyheadfoot%
}
%    \end{macrocode}
% Hopefully we do not use a page number twice in headers or footers if we want to jump to the pagenumber.\par
% \noindent We use pagenumbers as the default position for page anchors.
%    \begin{macrocode}
\let\hyper@modifyheadfoot\hyper@modifyheadfoot@pagenumber
%    \end{macrocode}
% \subsection{Table of Contents}
% In the subsection ``Handling of Pages'' we already have inserted
% references from the page number to the corresponding page.
% Now we want to add further references from the title of an entry
% in the table of contents to the corresponding text within the
% document.\par
% \noindent To do that we have to modify the corresponding sectioning commands.
%     \begin{macrocode}
\let\hyper@sect\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum #2>\c@secnumdepth%
    \hyper@setcurrent%
  \else%
    \refstepcounter{#1}%
    \ignore@next@refstepcounter%
  \fi%
  \hyper@settype{#1}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \callwithexpandedhyperref%
    {\hyper@sect{#1}{#2}{#3}{#4}{#5}{#6}}%
    {#7}%
    {\hyperanchor{\@currenthyper}{#8}}%
}
\let\hyper@ssect\@ssect
\def\@ssect#1#2#3#4#5{%
  \hyper@setcurrent%
  \hyper@settype{#1}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \hyper@ssect{#1}{#2}{#3}{#4}{\hyperanchor{\@currenthyper}{#5}}%
}
%</hyper>
%    \end{macrocode}
% The classes |book| and |report| additionally define a |\chapter| command.
% Unfortunately they do it in a different way. But the differences are fairly
% small. Thus we will use nearly the same definition.
%    \begin{macrocode}
%<*book,report>
\let\hyper@chapter\@chapter
\let\hyper@schapter\@schapter
\def\@chapter[#1]#2{%
  \ifnum\c@secnumdepth>\m@ne%
%</book,report>
%<*book>
    \if@mainmatter%
%</book>
%<*book,report>
      \refstepcounter{chapter}%
      \ignore@next@refstepcounter%
%</book,report>
%<*book>
    \else%
      \hyper@setcurrent%
    \fi%
%</book>
%<*book,report>
  \else%
    \hyper@setcurrent%
  \fi%
  \hyper@settype{chapter}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \callwithexpandedhyperref%
    {\hyper@chapter}%
    {#1}%
    {\hyperanchor{\@currenthyper}{#2}}%
}
\def\@schapter#1{%
  \hyper@setcurrent%
  \hyper@settype{chapter}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \hyper@schapter{\hyperanchor{\@currenthyper}{#1}}%
}
%    \end{macrocode}
% However, this is not sufficient. The classes |book| and |report| use a different mechanism
% for the index heading not using the macro |\chapter*|. So we have to fix this.
%    \begin{macrocode}
\let\hyper@theindex\theindex
\def\theindex{%
  \bgroup%
    \let\hyper@makeschapterhead\@makeschapterhead%
    \def\@makeschapterhead##1{%
      \hyper@setcurrent%
      \hyper@settype{chapter}%
      \global\let\@currenthyper\@currenthyper%
      \global\let\@currenthypertype\@currenthypertype%
      \hyper@makeschapterhead{\hyperanchor{\@currenthyper}{##1}}%
    }
    \hyper@theindex%
  \egroup%
  \let\item\@idxitem%
}
%</book,report>
%    \end{macrocode}
% There is also a |\part|--macro defined in the classes |article|, |book|,
% |ltnews|, |ltxdoc|, |ltxguide|, |proc|, and |report|.
% Unfortunately there are two different definitions we have to modify.
% But they differ only in a constant in a conditional expression.
% Thus we can use a nearly common definition.
%    \begin{macrocode}
%<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
\let\hyper@part\@part
\def\@part[#1]#2{%
  \ifnum\c@secnumdepth>%
%</article,book,ltnews,ltxdoc,ltxguide,proc,report>
%<*article,ltnews,ltxdoc,ltxguide,proc>
-1\relax%
%</article,ltnews,ltxdoc,ltxguide,proc>
%<*book,report>
-2\relax%
%</book,report>
%<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
      \refstepcounter{part}%
      \ignore@next@refstepcounter%
  \else%
    \hyper@setcurrent%
  \fi%
  \hyper@settype{part}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \callwithexpandedhyperref%
    {\hyper@part}%
    {#1}%
    {\hyperanchor{\@currenthyper}{#2}}%
}
\let\hyper@spart\@spart
\def\@spart#1{%
  \hyper@setcurrent%
  \hyper@settype{part}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \hyper@spart{\hyperanchor{\@currenthyper}{#1}}%
}
%</article,book,ltnews,ltxdoc,ltxguide,proc,report>
%    \end{macrocode}
% Now we do not only get references from the table of contents to the
% corresponding sections but also from the headers and footers to them.
% There is only one exception these references are not inserted:
% If we used the |*|--ed variants of the sectioning commands the marks
% are not inserted in the headers.\par
% \noindent For bibliography, glossary, index, and table of contents
% this can be changed by modifying |\@mkboth|.
%    \begin{macrocode}
%<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
\def\hyper@mkboth@do[#1][#2]{%
  \markboth{#1}{#2}%
}
\def\hyper@mkboth#1#2{%
  \callwithexpandedhyperref%
    {\callwithexpandedhyperref{\hyper@mkboth@do}{#1}}%
    {#2}%
}
%    \end{macrocode}
% As marks are only inserted when using the pagestyle ``headings'',
% the corresponding macro has to be modified to get the desired result.
%    \begin{macrocode}
\let\hyper@ps@headings\ps@headings
\def\ps@headings{%
  \hyper@ps@headings%
  \let\@mkboth\hyper@mkboth%
}
%</article,book,ltnews,ltxdoc,ltxguide,proc,report>
%    \end{macrocode}
% Last but not least set the new page style.
%    \begin{macrocode}
%<*book,report>
\pagestyle{headings}
%</book,report>
%    \end{macrocode}
% Unfortunately, the package |doc.sty| modifies the |theindex| environment
% in a way that the above changes do not work correctly with it.
% Hence, we have to modify this environment to resolve this.
%    \begin{macrocode}
%<*doc>
\g@addto@macro\index@prologue{%
  \def\markboth#1#2{%
    \@mkboth{\refcurrent{#1}}{\refcurrent{#2}}%
  }%
}
%</doc>
%    \end{macrocode}
%
% \subsection{Bibliography}
% We want to reference from citation points within the text,
% given by |\cite|, to the corresponding entry in the bibliography.
% To realize this we only have to modify the |\bibitem|--macro.
%    \begin{macrocode}
%<*hyper>
\def\@lbibitem[#1]#2{%
  \hyper@setcurrent%
  \hyper@settype{citation}%
  \item[\@biblabel{\hyperanchor{\@currenthyper}{#1}}\hfill]%
  \if@filesw%
      {\let\protect\@unexpandable@protect%
       \immediate%
       \write\@auxout{%
         \string\bibcite{#2}{\hyperreference{\@currenthyper}{#1}}%
       }%
      }%
  \fi%
  \ignorespaces%
}
\def\@bibitem{%
  \stepcounter{\@listctr}%
  \hyper@settype{citation}%
  \@lbibitem[\the\value{\@listctr}]%
}
%    \end{macrocode}
% \subsection{Equations}
% The goal is to reference to the equation number in equations and
% arrays of equations. This is really simple to do.
%    \begin{macrocode}
\def\@eqnnum{%
  \hyperanchor{\@currenthyper}{\normalfont\normalcolor(\theequation)}%
}
\let\hyper@eqnarray\eqnarray
\def\eqnarray{%
  \hyper@setcurrent%
  \def\@currenthyper{\the\hypercount}%
  \hyper@settype{equation}%
  \hyper@eqnarray%
}
\let\hyper@xeqncr\@xeqncr
\def\@xeqncr[#1]{%
  \hyper@xeqncr[#1]%
  \noalign{\hyper@setcurrent\hyper@settype{equation}}%
}
%</hyper>
%    \end{macrocode}
% There is a document class option |leqno| that has to be redefined for us.
%    \begin{macrocode}
%<*leqno>
\def\@eqnnum{%
  \hbox to .01\p@{}%
  \rlap{\reset@font\rmfamily%
        \hskip -\displaywidth%
        \hyperanchor{\@currenthyper}{\reset@font\rmfamily (\theequation)}%
       }%
}
%</leqno>
%    \end{macrocode}
%
% \subsection{Float Captions}
% What do you think we want to do here? Simply using |\caption| to define
% an anchor that may be used to refer to the current float.
%     \begin{macrocode}
%<*hyper>
\long\def\@caption#1[#2]#3{\par%
  \addcontentsline%
    {\csname ext@#1\endcsname}%
    {#1}%
    {\protect\numberline{\csname the#1\endcsname}%
     {\ignorespaces \hyperreference{\@currenthyper}{#2}}%
    }%
  \begingroup%
    \@parboxrestore%
    \normalsize%
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par%
  \endgroup%
}
%</hyper>
%    \end{macrocode}
% Obviously we need to modify |\@makecaption| to define the anchor.
% As this macro is defined only for the classes |article|, |book|,
% |ltnews|, |ltxdoc|, |ltxguide|, |proc|,  and |report| we redefine
% it only for them.
%    \begin{macrocode}
%<*article,book,ltnews,ltxdoc,ltxguide,proc,report>
\let\hyper@makecaption\@makecaption
\long\def\@makecaption#1#2{%
  \hyper@makecaption{\hyperanchor{\@currenthyper}{#1}}{#2}%
}
%</article,book,ltnews,ltxdoc,ltxguide,proc,report>
%    \end{macrocode}
%
% \subsection{Footnotes}
% Here we want to handle references from footnotemarks to footnotes
% at the bottom of the page.\par
% \noindent At first modify the standard definition of |\@makefnmark| to
% refer to a footnote which is complicated by the fact that |\thepage| does not
% necessarily refer to the actual page when used. So we have to write the page
% to an auxiliary file and reread it afterwards. Let's not forget to check for
% changes of these entries to warn the user about possible changes.
%    \begin{macrocode}
%<*hyper>
\newcount\hyper@fnmark@count
\hyper@fnmark@count0
\def\hyper@currentfnmark{%
   \global\advance\hyper@fnmark@count1\relax%
   \@bsphack%
      \protected@write\hyper@auxout%
         {}%
         {\string\hyperfnpage{\the\hyper@fnmark@count}{\thepage}}%
   \@esphack%
   \hb@xt@\z@{%
    \ifx\hyper@minipage@label\@empty%
      \global\edef\hyper@current@fnmark%
        {fn.\@arabic\c@footnote.%
           \expandafter%
              \ifx\csname hyper@fn@\the\hyper@fnmark@count\endcsname%
                  \relax%
              ?%
           \else%
              \csname hyper@fn@\the\hyper@fnmark@count\endcsname%
           \fi%
        }%
    \else\ifnum\hyper@minipage@label=0\relax%
      \global\edef\hyper@current@fnmark%
        {fn.\hyper@minipage@label.\@arabic\c@footnote.%
           \expandafter%
              \ifx\csname hyper@fn@\the\hyper@fnmark@count\endcsname%
                  \relax%
              ?%
           \else%
              \csname hyper@fn@\the\hyper@fnmark@count\endcsname%
           \fi%
        }%
    \else%
      \global\edef\hyper@current@fnmark%
        {fn.\hyper@minipage@label.\@arabic\c@mpfootnote.%
           \expandafter%
              \ifx\csname hyper@fn@\the\hyper@fnmark@count\endcsname%
                  \relax%
              ?%
           \else%
              \csname hyper@fn@\the\hyper@fnmark@count\endcsname%
           \fi%
        }%
   \fi\fi%
  }%
}
\def\hyperfnpage#1#2{%
  \expandafter\global\expandafter\def\csname hyper@fn@#1\endcsname{#2}%
}
\def\hyperfnpage@check#1#2{%
   \def\reserved@a{#2}%
   \expandafter\ifx\csname hyper@fn@#1\endcsname\reserved@a\else%
      \hyper@change4\relax%
   \fi%
}
\let\hyper@fn@enddocument\enddocument
\def\enddocument{%
  \let\hyperfnpage\hyperfnpage@check%
  \global\hyper@fnmark@count0\relax%
  \hyper@fn@enddocument%
}
\def\@makefnmark{%
  \hyper@currentfnmark%
  \hbox{\@textsuperscript{%
          \normalfont\hyperreference%
           {\hyper@current@fnmark}%
           {\@thefnmark}%
     }}%
}
\def\hyper@makefnmark@text{%
  \hyper@currentfnmark%
  \hbox{\@textsuperscript{%
          \normalfont\hyperanchor%
            {\hyper@current@fnmark}%
            {\@thefnmark}%
       }}%
}
%</hyper>
%    \end{macrocode}
% Unfortunately, the definition of |\@makefntext| is dependend of the
% document class we use.\par
% \noindent For |article|, |book|, |letter|, |ltnews|, |ltxdoc|, |ltxguide|,
% |proc|, |report|, and |slides| we have to use the following
% hypertext--variant.
%    \begin{macrocode}
%<*article,book,letter,ltnews,ltxdoc,ltxguide,proc,report,slides>
\let\hyper@makefntext\@makefntext%
\long\def\@makefntext#1{%
  \bgroup%
    \hyper@currentfnmark%
    \edef\@currenthyper{\hyper@current@fnmark}%
    \let\@makefnmark\hyper@makefnmark@text%
    \hyper@makefntext{#1}%
  \egroup%
}
%</article,book,letter,ltnews,ltxdoc,ltxguide,proc,report,slides>
%    \end{macrocode}
% There are also footnotes within minipages. Therefore we should handle them.
%    \begin{macrocode}
%<*hyper>
\newcount\hyper@minipage@cnt
\hyper@minipage@cnt=0
\edef\hyper@minipage@label{}
\let\hyper@minipage\minipage
\let\hyper@endminipage\endminipage
\def\minipage{%
  \bgroup%
    \global\advance\hyper@minipage@cnt1\relax%
    \edef\hyper@minipage@label{\the\hyper@minipage@cnt}%
    \hyper@minipage%
}
\def\endminipage{%
    \hyper@endminipage%
  \egroup%
}
%</hyper>
%    \end{macrocode}
% Note, that there exists only one level of minipages the footnotes
% are handled correctly by \LaTeXe. Thus we haven't to do more.\par
% \noindent Unfortunately there is another problem. The footnote--macros
% are redefined by the |\maketitle|--macro in some classes.\par
% \noindent Thus we need the following changes for the classes
% |article|, |book|, |ltxdoc|, |ltxguide|, and |report|.
%    \begin{macrocode}
%<*article,book,ltxdoc,ltxguide,report>
\if@titlepage\else
\renewcommand\maketitle{\par
  \begingroup
    \renewcommand\thefootnote{\fnsymbol{footnote}}%
    \def\@makefnmark{%
      \hyper@currentfnmark%
      \rlap{\@textsuperscript{%
        \normalfont%
        \hyperreference{\hyper@current@fnmark}%
        {\@thefnmark}%
      }}%
    }%
    \long\def\@makefntext##1{%
      \hyper@currentfnmark%
      \bgroup%
        \edef\@currenthyper{\hyper@current@fnmark}%
        \parindent 1em\noindent
        \hb@xt@1.8em{%
          \hss\@textsuperscript{%
            \normalfont%
            \hyperanchor{\hyper@current@fnmark}{\@thefnmark}
          }%
        }%
        ##1%
      \egroup%
    }%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
  \endgroup
  \setcounter{footnote}{0}%
  \let\thanks\relax
  \let\maketitle\relax\let\@maketitle\relax
  \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
\fi
%</article,book,ltxdoc,ltxguide,report>
%    \end{macrocode}
% For the class |proc| another redefinition is needed.
%    \begin{macrocode}
%<*proc>
\def\maketitle{\par
 \begingroup
   \renewcommand\thefootnote{\fnsymbol{footnote}}%
   \def\@makefnmark{%
      \hyper@currentfnmark%
      \hbox to\z@{%
      \@textsuperscript{%
        \normalfont%
        \hyperreference{\hyper@current@fnmark}%
        {\@thefnmark}%
      }%
   }}%
   \twocolumn[\@maketitle]%
   \@thanks
 \endgroup
 \setcounter{footnote}{0}%
 \let\maketitle\relax
 \let\@maketitle\relax
 \gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax}
%</proc>
%    \end{macrocode}
% The package |doc.sty| also modifies |\maketitle| that has a redefinition
% of |\@makefnmark| and |\@makefntext|.
%    \begin{macrocode}
%<*doc>
\def\maketitle{\par
      \begingroup \def \thefootnote {\fnsymbol {footnote}}%
      \setcounter {footnote}\z@
      \def\@makefnmark{%
        \hyper@currentfnmark%
        \hbox to\z@{%
        $\m@th^{%
          \hyperreference%
            {\hyper@current@fnmark}%
            {\@thefnmark}%
        }$\hss%
      }}%
      \long\def\@makefntext##1{%
        \hyper@currentfnmark%
        \bgroup
          \edef\@currenthyper{\hyper@current@fnmark}
          \parindent 1em\noindent
          \hbox to1.8em{%
            \hss$\m@th^{%
              \hyperanchor{\hyper@current@fnmark}{\@thefnmark}%
            }$%
          }%
          ##1%
        \egroup%
      }%
      \if@twocolumn \twocolumn [\@maketitle ]%
      \else \newpage \global \@topnum \z@ \@maketitle \fi
       \thispagestyle{titlepage}\@thanks \endgroup
      \setcounter {footnote}\z@
      \gdef\@date{\today}\gdef\@thanks{}%
      \gdef\@author{}\gdef\@title{}}
%</doc>
%    \end{macrocode}
% Shit, now we can get the same name for hyper anchors, one via maketitle and one for the following text.
% Let's pretend the titlepage being minipage 0. Note, that the definition of |\hyper@currentfnmark| given
% above tests for this. (This is necessary!) Additionally we have to modify the macro |\thanks| to get
% the correct anchors in the footnote texts.
%    \begin{macrocode}
%<*hyper>
\AtBeginDocument{%
   \let\hyper@maketitle\maketitle%
   \def\maketitle{%
     \edef\hyper@minipage@label{0}%
     \hyper@maketitle%
     \let\hyper@minipage@label\@empty%
   }%
}
\def\hyper@thanks@footnotetext#1[#2]#3{%
  \bgroup%
     \edef\hyper@current@fnmark{#1}%
     \let\hyper@currentfnmark\relax%
     \footnotetext[#2]{#3}%
  \egroup%
}
\def\thanks#1{\footnotemark%
    \expandafter\protected@xdef\expandafter\@thanks\expandafter{\expandafter\@thanks%
        \expandafter\protect%
           \expandafter\hyper@thanks@footnotetext%
              \expandafter{\hyper@current@fnmark}[\the\c@footnote]{#1}}%
}
%</hyper>
%    \end{macrocode}
% \subsection{Lists}
% Some lists have enumerated items which may be referenced to by the
% label command. Hence we have to set the corresponding anchors.
%    \begin{macrocode}
%<*hyper>
\let\hyper@item\@item
\def\@item[#1]{%
  \if@noitemarg%
    \if@nmbrlist%
      \hyper@item[\hyperanchor{\@currenthyper}{#1}]%
    \else%
      \hyper@item[{#1}]%
    \fi%
  \else%
    \hyper@item[{#1}]%
  \fi%
}
%    \end{macrocode}
%
% \subsection{Index and Glossary}
% As already has been said, we don't write the page number together with a
% reference to |.idx|-- resp.\ |.glo|--files. |makeindex| wouldn't accept
% such informations. But that means that we have to think of a way to get
% back the references after |makeindex| has generated the index resp.\
% glossary.\par
% \noindent As this stuff needs an additional package we should include it only
% if it is necessary. Thus, let us at first save it in a macro.
%    \begin{macrocode}
\def\hyper@idxglo@cmds{
%    \end{macrocode}
% \noindent For the following definition we need the |defpattern|-package.
%    \begin{macrocode}
\RequirePackage{defpattern}
%    \end{macrocode}
% Now we can define hypertext variants of the macros |\index| and
% |\glossary|.\par
% \noindent First of all we handle series of page numbers and ranges.
%    \begin{macrocode}
\def\hyper@ref@page##1{\hyperpagereference{##1}{##1}}
\defpattern\hyper@page@range[##2]{\hyper@ref@page{##2}}
\defpattern\hyper@page@range[##2--##3]{%
  \hyper@ref@page{##2}--\hyper@ref@page{##3}%
}
\defpattern\hyper@page@range[##2, ##3]{%
  \hyper@page@range[##2], \hyper@page@range[##3]%
}
%    \end{macrocode}
% Based on this we can define a macro |\hyperpage| with an optional executable
% macro as provided by the indexing system to surround a page number.
%    \begin{macrocode}
\def\hyper@page@cmd[##1]##2{##1{\hyper@page@range[##2]}}
\def\hyper@page@nocmd##1{\hyper@page@range[##1]}
\def\hyperpage{\@ifnextchar[{\hyper@page@cmd}{\hyper@page@nocmd}}
%    \end{macrocode}
% After saving the original meaning of |\index| and |\glossary|
%    \begin{macrocode}
\let\hyper@index\index
\let\hyper@glossary\glossary
%    \end{macrocode}
% we can insert the page number surrounding command for |makeindex| by
%    \begin{macrocode}
\defpattern\hyper@ig@pat[##2|##3]{##2{##3|hyperpage}}
\defpattern\hyper@ig@pat[##2|##3|##4]{%
  ##2{##3|hyperpage[\hyper@backslash##4]}%
}
\defpattern\hyper@ig@pat[##2|##3|(##4]{%
  ##2{##3|(hyperpage[\hyper@backslash##4]}%
}
\defpattern\hyper@ig@pat[##2|##3|)##4]{%
  ##2{##3|)hyperpage[\hyper@backslash##4]}%
}
\defpattern\hyper@ig@pat[##2|##3|(]{##2{##3|(hyperpage}}
\defpattern\hyper@ig@pat[##2|##3|)]{##2{##3|)hyperpage}}
%    \end{macrocode}
% and define the new |\index|-- and |\glossary|--macros as follows.
%    \begin{macrocode}
\def\hyper@ig{%
  \@bsphack\begingroup%
    \catcode`\@=12\catcode`\!=12\catcode`\|=12\catcode`\"=12\relax%
    \@sanitize\hyper@ig@%
}
\def\hyper@ig@##1##2{%
    \hyper@ig@pat[##1|##2]%
  \endgroup\@esphack%
}
\def\index{\hyper@ig\hyper@index}
\def\glossary{\hyper@ig\hyper@glossary}
%    \end{macrocode}
% We have reached the end of the macro. But as we do not call its contents
% twice we just let the macro being a no-op before.
%    \begin{macrocode}
\let\hyper@idxglo@cmds\relax
}
%    \end{macrocode}
% Now let's call the stuff whenever an index or glossary has to be generated.
%    \begin{macrocode}
\ifnum%
  \ifx\@indexfile\@undefined0\else1\fi%
  \ifx\@glossaryfile\@undefined0\else1\fi%
  >0\relax
    \hyper@idxglo@cmds
\fi
\ifx\makeindex\@empty\else
  \let\hyper@makeindex\makeindex
  \def\makeindex{\hyper@makeindex\hyper@idxglo@cmds}
\fi
\ifx\makeglossary\@empty\else
  \let\hyper@makeglossary\makeglossary
  \def\makeglossary{\hyper@makeglossary\hyper@idxglo@cmds}
\fi
%    \end{macrocode}
%
% \subsection{Theorems}
% Theorems, Lemmatas, Corollaries, Examples, etc.\ are often refered to. Hence
% they have to introduce an anchor for these references.
%    \begin{macrocode}
\let\hyper@begintheorem\@begintheorem%
\def\@begintheorem#1#2{\trivlist%
   \item[\hskip%
         \labelsep{\hyperanchor{\@currenthyper}{\bfseries #1\ #2}}%
        ]\itshape%
}
\def\@opargbegintheorem#1#2#3{\trivlist%
      \item[\hskip%
            \labelsep%
               {\hyperanchor{\@currenthyper}{\bfseries #1\ #2}\ (#3)}%
           ]\itshape%
}
%</hyper>
%    \end{macrocode}
% These definitions are changed by the theorem--package. Hence, we have to
% give hypertext definitions for them below.
%
% \subsection{Additional Patches}
% The Hyper\TeX--previewer for NeXTSTEP can't handle multiple pages with the
% same name correctly. It supposes that each link on a page number 1 is on
% the first page with the number one. This is a problem for the title page
% often having the same number as one of the following pages. Hence we patch
% the page number of the title page from 1 to -1 (if the next page also has
% number 1).
%    \begin{macrocode}
%<*article,report>
\let\hyper@titlepage\titlepage
\def\titlepage{%
  \hyper@titlepage%
  \if@compatibility%
     \global\setcounter{page}{0}%
  \else%
     \global\setcounter{page}{-1}%
  \fi%
}
%</article,report>
%    \end{macrocode}
% We have to ignore the stuff that is written to the |.aux|--file
% by the extensional packages
%    \begin{macrocode}
%<*hyper>
\def\hyperbackcite#1#2#3#4{}
%</hyper>
%    \end{macrocode}
%
% \subsection{Handling Options}
% At first let us define some macros to collect and detect mutually
% excluding options.
%    \begin{macrocode}
%<*hyper>
\def\hyper@set@option#1#2#3{%
  \ifx#1\@undefined%
    \def#1{#2}%
  \else%
    \PackageError{hyper}{#3}{}%
  \fi}
\def\set@hyper@class#1{%
  \hyper@set@option\hyper@class{#1}%
    {Only one class is allowed in option list}%
}
\def\set@hyper@do#1{%
  \hyper@set@option\hyper@do{#1}%
    {Excluding options 'yes' and 'no' in option list found}%
}
\def\set@hyper@pageanchor#1{%
  \hyper@set@option\hyper@pageanchor{#1}%
    {Excluding options 'pagenumber' and 'pagetop' in option list found}%
}
\def\set@hyper@color#1{%
  \hyper@set@option\hyper@this@color{#1}%
    {Multiple color options in option list found}%
}
\def\set@hyper@idxglo{%
  \let\hyper@idxglo\hyper@idxglo@cmds%
}
%    \end{macrocode}
% We suppose each other option given being an additional package.
% They are collected without regarding multiple occurrences.
%    \begin{macrocode}
\def\hyper@packages{}
\def\add@hyper@package#1{%
  \edef\hyper@packages{\hyper@packages(#1)}%
}
\def\hyper@extensions{}
\def\add@hyper@extension#1{%
  \edef\hyper@extensions{\hyper@extensions(#1)}%
}
%    \end{macrocode}
% Now we define the options known to distribute them between the macros
% given above.\par
% \noindent The document classes known by the package are the following.
%    \begin{macrocode}
\DeclareOption{article}{\set@hyper@class{article}}
\DeclareOption{book}{\set@hyper@class{book}}
\DeclareOption{letter}{\set@hyper@class{letter}}
\DeclareOption{ltxdoc}{\set@hyper@class{ltxdoc}}
\DeclareOption{ltxguide}{\set@hyper@class{ltxguide}}
\DeclareOption{ltnews}{\set@hyper@class{ltnews}}
\DeclareOption{proc}{\set@hyper@class{proc}}
\DeclareOption{report}{\set@hyper@class{report}}
\DeclareOption{slides}{\set@hyper@class{slides}}
\DeclareOption{amsart}{\set@hyper@class{amsart}}
\DeclareOption{amsproc}{\set@hyper@class{amsproc}}
\DeclareOption{amsbook}{\set@hyper@class{amsbook}}
\DeclareOption{amsdtx}{\set@hyper@class{amsdtx}}
\DeclareOption{amsldoc}{\set@hyper@class{amsldoc}}
\DeclareOption{cweb}{\set@hyper@class{cweb}}
%    \end{macrocode}
% There are two options determining whether we want to insert the
% hypertext--marks into the dvi--file.
%    \begin{macrocode}
\DeclareOption{yes}{\set@hyper@do{\hyper}}
\DeclareOption{no}{\set@hyper@do{\nohyper}}
%    \end{macrocode}
% We should not forget that we have an optional behaviour for fixing the bounding box
% of a hyper reference. So we have to introduce and handle an option for it.
%    \begin{macrocode}
\DeclareOption{fixhyperbox}{%
  \AtBeginDocument{%
     \let\hyper@unnested@special@reference\hyper@unnested@special@reference@fix%
     \let\hyper@unnested@special@anchor\hyper@unnested@special@anchor@fix%
  }%
}
% In the subsection ``Colored Anchors/References'' we have introduced
% three variants of colors the anchors resp.\ references may be printed in.
%    \begin{macrocode}
\DeclareOption{color}{\set@hyper@color{\hyper@color}}
\DeclareOption{gray}{\set@hyper@color{\hyper@gray}}
\DeclareOption{black}{\set@hyper@color{\hyper@black}}
%    \end{macrocode}
% We additionally have to choose whether a hyperlink to a page always
% jumps to the page number or to the top of the page.
%    \begin{macrocode}
\DeclareOption{pagenumber}{\set@hyper@pageanchor{\hyper@modifyheadfoot@pagebottom}}
\DeclareOption{pagetop}{\set@hyper@pageanchor{\hyper@modifyheadfoot@pagetop}}
%    \end{macrocode}
% If the user want to have the index and glossary commands,
% e.g.\ when including an index or glossary
% without using |\makeindex| respectively |\makeglossary| he may
% give the option |indexcmds|.
%    \begin{macrocode}
\DeclareOption{indexcmds}{\set@hyper@idxglo}
%    \end{macrocode}
% Additionally we have to pass the options for the extensional packages
%    \begin{macrocode}
\DeclareOption{backcitepages}{%
  \PassOptionsToPackage{pages}{hxt-bc}%
  \add@hyper@extension{hxt-bc}%
}
\DeclareOption{backcitesections}{%
  \PassOptionsToPackage{sections}{hxt-bc}%
  \add@hyper@extension{hxt-bc}%
}
%    \end{macrocode}
% All other options to be given are considered as packages.
%    \begin{macrocode}
\DeclareOption*{\add@hyper@package{\CurrentOption}}
%    \end{macrocode}
% Now let's collect the options given.
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
% So far now we know the options the user has send to us.\par
% \noindent If no option determining a document class has been given we should
% try to determine which class the document is of.
%    \begin{macrocode}
\ifx\hyper@class\@undefined
  \@ifclassloaded{slides}{\def\hyper@class{slides}}{}
  \@ifclassloaded{report}{\def\hyper@class{report}}{}
  \@ifclassloaded{letter}{\def\hyper@class{letter}}{}
  \@ifclassloaded{book}{\def\hyper@class{book}}{}
  \@ifclassloaded{article}{\def\hyper@class{article}}{}
  \@ifclassloaded{proc}{\def\hyper@class{proc}}{}
  \@ifclassloaded{ltnews}{\def\hyper@class{ltnews}}{}
  \@ifclassloaded{ltxguide}{\def\hyper@class{ltxguide}}{}
  \@ifclassloaded{ltxdoc}{\def\hyper@class{ltxdoc}}{}
  \@ifclassloaded{amsart}{\def\hyper@class{amsart}}{}
  \@ifclassloaded{amsproc}{\def\hyper@class{amsproc}}{}
  \@ifclassloaded{amsbook}{\def\hyper@class{amsbook}}{}
  \@ifclassloaded{amsdtx}{\def\hyper@class{amsdtx}}{}
  \@ifclassloaded{amsldoc}{\def\hyper@class{amsldoc}}{}
  \@ifclassloaded{cweb}{\def\hyper@class{cweb}}{}
\fi
%    \end{macrocode}
% If there is a document class load the corresponding |.hyp|--file
% otherwise give an error message.
%    \begin{macrocode}
\ifx\hyper@class\@undefined
  \PackageError{hyper}{Document class can't be determined.\MessageBreak
              Please add one to the option list%
             }{}
\else
  \InputIfFileExists{\hyper@class.hyp}{}%
    {\PackageError{hyper}{\hyper@class.hyp not found.\MessageBreak
                 Please reinstall the complete package%
                }{}%
    }%
\fi
%    \end{macrocode}
% If we explicitely want to have the commands for index and glossary
% we have to introduce them by calling the macro holding the stuff.
% Note, that the macro is a nop when the stuff already has been added.
%    \begin{macrocode}
\ifx\hyper@idxglo\@undefined\else
  \hyper@idxglo@cmds
\fi
%    \end{macrocode}
% If we want to print the anchors resp.\ references in colors we have to
% load the |color|-package and defined the appropriate macros.
%    \begin{macrocode}
\ifx\hyper@this@color\@undefined
\else
  \expandafter\ifx\hyper@this@color\hyper@gray
    \RequirePackage{color}
  \else\expandafter\ifx\hyper@this@color\hyper@color
    \RequirePackage{color}
  \else\expandafter\ifx\hyper@this@color\hyper@black
  \else
    \PackageError{hyper}{Implementation error:\MessageBreak
                Case for reference/anchor color definition not defined}{}
  \fi\fi\fi
  \hyper@this@color
\fi
%    \end{macrocode}
% Afterwards we have to load modifications.\par
% \noindent At first we just handle the document class option |leqno|
% if it can be found in the option list.
%    \begin{macrocode}
\@ifclasswith\hyper@class{leqno}%
  {\InputIfFileExists{leqno.hyp}{}%
     {\PackageError{hyper}{leqno.hyp not found.\MessageBreak
                  Please reinstall the complete package}{}%
     }%
  }%
  {}
%    \end{macrocode}
% We may have to handle some known packages, i.e.\ we need to load
% some modifications for them.\par
% \noindent As there is a common way to do this let us first define
% a generic macro.
%    \begin{macrocode}
\def\hyper@loadpackage#1{%
  \@ifpackageloaded{#1}%
    {\InputIfFileExists{#1.hyp}%
       {\expandafter\edef\csname hyper@loaded@#1\endcsname{#1.hyp}}%
       {\PackageError{hyper}{#1.hyp not found.\MessageBreak
                    Please reinstall the complete package}{}%
       }%
    }%
    {}
}
%    \end{macrocode}
% Now we can call this macro for each package known.
%    \begin{macrocode}
\hyper@loadpackage{amsmath}
\hyper@loadpackage{amstex}
\hyper@loadpackage{amsthm}
\hyper@loadpackage{doc}
\hyper@loadpackage{fancyheadings}
\hyper@loadpackage{ftnright}
\hyper@loadpackage{harvard}
\hyper@loadpackage{longtable}
\hyper@loadpackage{natbib}
\hyper@loadpackage{subeqnarray}
\hyper@loadpackage{theorem}
\hyper@loadpackage{upref}
\hyper@loadpackage{xr}
%    \end{macrocode}
% Afterwards we add each package the user has told us to do.
%    \begin{macrocode}
\def\@hyper@load@pkg(#1){%
  \expandafter\ifx\csname hyper@loaded@#1\endcsname\relax%
    \IfFileExists{#1.hyp}%
      {\IfFileExists{#1.sty}{\RequirePackage{#1}}{}%
       \input{#1.hyp}%
       \expandafter\edef\csname hyper@loaded@#1\endcsname{#1.hyp}%
      }%
      {\PackageError{hyper}{Modification file #1.hyp not found}{}}%
  \fi%
  \hyper@loadpackage%
}
\def\hyper@loadpackage{\@ifnextchar({\@hyper@load@pkg}{}}
\expandafter\hyper@loadpackage\hyper@packages\relax
%    \end{macrocode}
% Additionally, we have to load some extensions of the hyper package.
%    \begin{macrocode}
\def\@hyper@load@ext(#1){%
  \expandafter\ifx\csname hyper@loaded@ext@#1\endcsname\relax%
    \IfFileExists{#1.sty}%
      {\RequirePackage{#1}%
       \expandafter\edef\csname hyper@loaded@ext@#1\endcsname{#1.sty}%
      }%
      {\PackageError{hyper}{Extension file #1.sty not found}{}}%
  \fi%
  \hyper@loadpackage%
}
\def\hyper@load@extension{\@ifnextchar({\@hyper@load@ext}{}}
\expandafter\hyper@load@extension\hyper@extensions\relax
%    \end{macrocode}
% Now we have to activate the (nondefault) decision for placing the anchors on pages (top of page or pagenumber)
%    \begin{macrocode}
\ifx\hyper@pageanchor\@undefined
\else
  \expandafter\let\expandafter\hyper@modifyheadfoot\hyper@pageanchor
\fi
%    \end{macrocode}
% Last but not least we have to decide whether we really want the
% hypertext--marks being inserted into the dvi--file.
%    \begin{macrocode}
\ifx\hyper@do\@undefined\else\hyper@do\fi
%</hyper>
%    \end{macrocode}
%
% \subsection{Compatibility with Ordinary \LaTeX}
% The package redefines the notion of a label. Thus, to be able to add the
% package to an exising \LaTeX-file without having trouble with an existing
% |.aux|-file we have to be able to handle the old as well as the new definition:
%    \begin{macrocode}
%<*hyper>
\def\hyper@end@newlabel{\relax}
\let\hyper@orig@newlabel\newlabel
\def\hyper@newlabel#1#2#3#4#5{%
   \ifx|#4|%
      \hyper@orig@newlabel{#1}{{}{}{#2}{#3}}%
   \else%
      \hyper@orig@newlabel{#1}{{#2}{#3}{#4}{#5}}%
   \fi%
}
\def\newlabel#1#2{\hyper@newlabel{#1}#2\hyper@end@newlabel\hyper@end@newlabel}
%    \end{macrocode}
%
% The package leaves traces for intermediate informations in several auxiliary files.
% To be able to remove the package without deleting these auxiliary files, certain
% definitions have to remain to exist. The following code ensures, that these definitions
% are availlable, by adding them to the subsequently generated |.aux|-files.
%    \begin{macrocode}
\begingroup
  \catcode`\<=\catcode`\{
  \catcode`\>=\catcode`\}
  \catcode`\{=12\catcode`\}=12
  \catcode`\%=12
  \gdef\hyper@open<{>
  \gdef\hyper@close<}>
  \gdef\hyper@comment<%>
\endgroup
\def\hyper@nl{^^J}%
\long\def\hyper@protected@write#1{%
   \begingroup%
      \let\thepage\relax%
      \let\protect\@unexpandable@protect%
      \edef\reserved@a{\immediate\write\@auxout{#1}}%
      \reserved@a%
   \endgroup%
   \if@nobreak\ifvmode\nobreak\fi\fi%
}
\gdef\hyper@aux@write{
   \hyper@protected@write{\hyper@comment@potential%
      \string\ifx\string\newhyper\string\@undefined%
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\gdef\string\newhyper\hyper@hash1\hyper@hash2{}\hyper@nl
      \string\gdef\string\hyperfnpage\hyper@hash1\hyper@hash2{}\hyper@nl
      \string\global\string\let\string\@hyper@newlabel\string\newlabel\hyper@nl
      \string\gdef\string\hyper@end@newlabel{\string\relax}\hyper@nl
      \string\gdef\string\hyper@newlabel\hyper@hash1\hyper@hash2\hyper@hash3\hyper@hash4\hyper@hash5%
                      {\hyper@comment@potential%
        \string\ifx\string|\hyper@hash4\string|\string\hyper@end@newlabel\hyper@comment@potential%
          \string\@hyper@newlabel{\hyper@hash1}{{\hyper@hash2}{\hyper@hash3}}%
                      \hyper@comment@potential%
        \string\else\hyper@comment@potential%
          \string\@hyper@newlabel{\hyper@hash1}{{\hyper@hash4}{\hyper@hash5}}%
                      \hyper@comment@potential%
        \string\fi\hyper@comment@potential%
      }\hyper@nl
      \string\gdef\string\newlabel\hyper@hash1\hyper@hash2%
                      {\string\hyper@newlabel{\hyper@hash1}\hyper@hash2%
                      \string\hyper@end@newlabel\string\hyper@end@newlabel}\hyper@nl
      \string\gdef\string\@@hyperpage[\hyper@hash1]{\hyper@hash1}\hyper@nl
      \string\gdef\string\@hyperpage\hyper@hash1{\hyper@hash1}\hyper@nl
      \string\gdef\string\hyperpage%
                      {\string\@ifnextchar[\string\@@hyperpage\string\@hyperpage}\hyper@nl
      \string\global\string\let\string\fragilehyperreference\string\@gobble\hyper@nl
      \string\global\string\let\string\fragilehyperpagereference\string\@gobble\hyper@nl
      \string\global\string\let\string\fragilehyperanchor\string\@gobble\hyper@nl
      \string\global\string\let\string\fragileblindhyperanchor\string\@gobble\hyper@nl
      \string\global\string\let\string\fragilehyperURL\string\@gobble\hyper@nl
      \string\gdef\string\hyperbackcite\hyper@hash1\hyper@hash2\hyper@hash3\hyper@hash4%
                      {}\hyper@nl
      \string\global\string\let\string\hyper@setref\string\@setref\hyper@nl
      \string\gdef\string\hyper@thirdoffour\hyper@hash1\hyper@hash2\hyper@hash3%
                      {\hyper@hash2}\hyper@nl
      \string\gdef\string\hyper@forthoffour\hyper@hash1\hyper@hash2\hyper@hash3%
                      {\hyper@hash3}\hyper@nl
      \string\gdef\string\hyper@end@forthoffour{\string\relax}\hyper@nl
      \string\gdef\string\@setref\hyper@hash1{\hyper@comment@real\hyper@nl
        \string\ifx\hyper@hash1\string\relax\hyper@comment@real\hyper@nl
           \string\def\string\hyper@next{\string\hyper@setref{\hyper@hash1}}%
                      \hyper@comment@real\hyper@nl
        \string\else\hyper@comment@real\hyper@nl
          \string\edef\string\hyper@tmp%
                      {\string\expandafter\string\hyper@forthoffour\hyper@hash1%
                      \string\hyper@end@forthoffour}\hyper@comment@real\hyper@nl
          \string\ifx\string\hyper@tmp\string\hyper@end@forthoffour%
                      \hyper@comment@real\hyper@nl
             \string\def\string\hyper@next{\string\hyper@setref{\hyper@hash1}}%
                      \hyper@comment@real\hyper@nl
          \string\else\hyper@comment@real\hyper@nl
             \string\edef\string\hyper@tmp%
                      {{\string\expandafter\string\hyper@thirdoffour\hyper@hash1}%
                      {\string\expandafter\string\hyper@forthoffour\hyper@hash1}}%
                      \hyper@comment@real\hyper@nl
             \string\def\string\hyper@next{\string\hyper@setref{\string\hyper@tmp}}%
                      \hyper@comment@real\hyper@nl
          \string\fi\hyper@comment@real\hyper@nl
        \string\fi\hyper@comment@real\hyper@nl
        \string\hyper@next\hyper@comment@real\hyper@nl
      }
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\begingroup\hyper@nl
         \string\catcode\string`\string\<\string=\string\catcode\string`\string\{\hyper@nl
         \string\catcode\string`\string\>\string=\string\catcode\string`\string\}\hyper@nl
         \string\catcode\string`\string\{\string=12%
         \string\catcode\string`\string\}\string=12\hyper@nl
         \string\catcode\string`\string\%\string=12\hyper@nl
         \string\gdef\string\hyper@open<{>\hyper@nl
         \string\gdef\string\hyper@close<}>\hyper@nl
         \string\gdef\string\hyper@comment<\hyper@comment@real>\hyper@nl
      \string\endgroup
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\bgroup\hyper@nl
         \string\global\string\edef\string\hyper@hash{\string\string\hyper@hash}\hyper@nl
      \string\egroup
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\gdef\string\hyper@nl{\string^\string^J}
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\def\string\hyper@hash@four{\string\hyper@hash\string\hyper@hash%
                      \string\hyper@hash\string\hyper@hash}
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\global\string\long\string\def\string\hyper@protected@write\hyper@hash1%
                      {\hyper@nl
         \string\begingroup\hyper@nl
            \string\let\string\thepage\string\relax\hyper@nl
            \string\let\string\protect\string\@unexpandable@protect\hyper@nl
            \string\edef\string\reserved@a{\string\immediate\string\write\string\@auxout%
                      {\hyper@hash1}}\hyper@nl
            \string\reserved@a\hyper@nl
         \string\endgroup\hyper@nl
      \string\if@nobreak\string\ifvmode\string\nobreak\string\fi\string\fi\hyper@nl
      }
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\gdef\string\hyper@aux@write\hyper@open
   }%
   \hyper@second@write{\hyper@comment@potential%
      \string\hyper@write\hyper@open\hyper@nl
         \string\begingroup\hyper@nl
            \string\let\string\@hyper@protected@write\string\hyper@protected@write\hyper@nl
            \string\def\string\hyper@protected@write@do\hyper@hash\hyper@hash1%
                      \hyper@hash\hyper@hash2{\hyper@nl
               \string\begingroup\hyper@nl
                  \string\let\string\hyper@string\string\string\hyper@nl
                  \string\def\string\string%
                      {\string\hyper@string\string\string\string\hyper@string}\hyper@nl
                  \string\def\string\hyper@open%
                      {\string\hyper@string\string\hyper@open}\hyper@nl
                  \string\def\string\hyper@close%
                      {\string\hyper@string\string\hyper@close}\hyper@nl
                  \string\def\string\hyper@nl%
                      {\string\hyper@string\string\hyper@nl\string^\string^J}\hyper@nl
                  \string\def\string\hyper@comment@real%
                      {\string\hyper@string\string\hyper@comment@real}\hyper@nl
                  \string\def\string\hyper@comment@potential%
                      {\string\hyper@string\string\hyper@comment@potential%
                      \string\hyper@comment\string^\string^J}\hyper@nl
                  \string\def\string\hyper@hash%
                      {\string\hyper@string\string\hyper@hash}\hyper@nl
                  \string\@hyper@protected@write%
                      {\string\hyper@string\hyper@hash\hyper@hash1%
                      {\hyper@hash\hyper@hash2\string^\string^J}}\hyper@nl
               \string\endgroup\hyper@nl
            }\hyper@nl
            \string\def\string\hyper@protected@write%
                      {\string\hyper@protected@write@do\string\hyper@protected@write}%
                      \hyper@nl
            \string\def\string\hyper@second@write\hyper@hash\hyper@hash1{\hyper@nl
               \string\hyper@protected@write@do\string\hyper@second@write%
                      {\hyper@hash\hyper@hash1}\hyper@nl
               \string\@hyper@protected@write{\hyper@hash\hyper@hash1}\hyper@nl
            }\hyper@nl
            \string\def\string\hyper@write{\string\@gobble}\hyper@nl
            \string\hyper@aux@write\hyper@nl
         \string\endgroup\hyper@nl
      \hyper@close
   }
   \hyper@write{
      \begingroup
         \let\@hyper@protected@write\hyper@protected@write
         \def\hyper@protected@write@do##1##2{
            \begingroup
               \let\hyper@string\string
               \def\string{\hyper@string\string\hyper@string}
               \def\hyper@open{\hyper@string\hyper@open}
               \def\hyper@close{\hyper@string\hyper@close}
               \def\hyper@nl{\hyper@string\hyper@nl^^J}
               \def\hyper@comment@real{\hyper@string\hyper@comment@real}
               \def\hyper@comment@potential%
                      {\hyper@string\hyper@comment@potential\hyper@comment^^J}
               \def\hyper@hash{\hyper@string\hyper@hash}
               \@hyper@protected@write{\hyper@string##1{##2^^J}}
            \endgroup
         }
         \def\hyper@protected@write{\hyper@protected@write@do\hyper@protected@write}
         \def\hyper@second@write##1{
            \hyper@protected@write@do\hyper@second@write{##1}
            \@hyper@protected@write{##1}
         }
         \def\hyper@write{\@gobble}
         \hyper@aux@write
      \endgroup
   }
   \hyper@protected@write{\hyper@comment@potential%
      \hyper@close
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\AtBeginDocument{\hyper@comment@real\hyper@nl%
         \string\let\string\hyper@write\string\relax%
                      \hyper@comment@real\hyper@nl%
         \string\let\string\hyper@second@write\string\@gobble%
                      \hyper@comment@real\hyper@nl%
         \string\let\string\hyper@comment@potential\string\@empty%
                      \hyper@comment@real\hyper@nl%
         \string\let\string\hyper@comment@real\string\hyper@comment%
                      \hyper@comment@real\hyper@nl%
         \string\hyper@aux@write\hyper@comment@real\hyper@nl%
      }
   }
   \hyper@protected@write{\hyper@comment@potential%
      \string\fi
   }
 \relax
}
\AtBeginDocument{%
   \let\hyper@write\relax%
   \let\hyper@second@write\@gobble%
   \let\hyper@comment@potential\@empty%
   \let\hyper@comment@real\hyper@comment%
   \hyper@aux@write%
}
%</hyper>
%    \end{macrocode}
%
% \clearpage
%
% \section{Supported Packages}
%
% \subsection{\amslatex}
% \subsubsection{The Classes}
% First of all let us modify the \amslatex--classes.\par
% \noindent We change |amsart.cls|, |amsproc.cls|, and |amsbook.cls|
% in the following way.
%    \begin{macrocode}
%<*amsart,amsproc,amsbook>
\let\hyper@makecaption\@makecaption
\def\@makecaption#1#2{%
  \hyper@makecaption{\hyperanchor{\@currenthyper}{#1}}{#2}%
}
\def\@makefnmark{%
  \hyper@currentfnmark%
  \hbox{%
      \@textsuperscript{%
        \normalfont%
        \hyperreference{\hyper@current@fnmark}%
        {\@thefnmark}%
      }%
    }%
}
\long\def\@makefntext#1{\indent%
  \hyper@currentfnmark%
  \bgroup%
    \edef\@currenthyper{\hyper@current@fnmark}%
    \parindent 1em\noindent
    \hbox{%
      \hss\@textsuperscript{%
        \normalfont%
        \hyperanchor{\hyper@current@fnmark}{\@thefnmark}%
      }%
    }%
    #1
  \egroup%
}
\let\hyper@tocwriteb\@tocwriteb
\def\hyper@tocwriteb@def[#1]{%
    \def\@tocwriteb##1##2##3{%
       \hyper@tocwriteb{##1}{##2}{#1}%
       \let\@tocwriteb\hyper@tocwriteb%
    }%
}
\def\@sect#1#2#3#4#5#6[#7]#8{%
  \ifnum#2>\c@secnumdepth%
    \hyper@setcurrent%
  \else%
    \refstepcounter{#1}%
    \ignore@next@refstepcounter%
  \fi%
  \hyper@settype{#1}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \ifnum#2>\@m\else%
    \callwithexpandedhyperref{\hyper@tocwriteb@def}{#8}%
  \fi%
  \callwithexpandedhyperref%
    {\hyper@sect{#1}{#2}{#3}{#4}{#5}{#6}}%
    {#7}%
    {\hyperanchor{\@currenthyper}{#8}}%
}
%</amsart,amsproc,amsbook>
%    \end{macrocode}
% For |amsbook.cls| we need some additional modifications for parts and chapters.
%    \begin{macrocode}
%<*amsbook>
\let\hyper@chapter\@chapter
\def\@chapter[#1]#2{%
  \refstepcounter{chapter}%
  \ignore@next@refstepcounter%
  \hyper@settype{chapter}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \callwithexpandedhyperref{\hyper@tocwriteb@def}{#2}%
  \hyper@chapter[#1]{\hyperanchor{\@currenthyper}{#2}}%
}
\let\hyper@chaptermark\chaptermark
\def\hyper@chaptermark@def[#1]{%
    \def\chaptermark##1{%
       \hyper@chaptermark{#1}%
       \let\chaptermark\hyper@chaptermark%
    }%
}
\let\hyper@schapter\@schapter
\def\@schapter#1{%
  \hyper@setcurrent%
  \hyper@settype{chapter}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \callwithexpandedhyperref{\hyper@tocwriteb@def}{#1}%
  \callwithexpandedhyperref{\hyper@chaptermark@def}{#1}%
  \hyper@schapter{\hyperanchor{\@currenthyper}{#1}}%
}
\let\hyper@part\@part
\def\@part[#1]#2{%
  \ifnum\c@secnumdepth>-2\relax%
    \refstepcounter{part}%
    \ignore@next@refstepcounter%
  \else%
    \hyper@setcurrent%
  \fi%
  \hyper@settype{part}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \callwithexpandedhyperref%
    {\hyper@part}%
    {#1}%
    {\hyperanchor{\@currenthyper}{#2}}%
}
\def\hyper@add@part[#1]{%
  \addcontentsline{toc}{part}{\protect\noindent#1}%
}
\def\@spart#1{%
  \hyper@setcurrent%
  \hyper@settype{part}%
  \global\let\@currenthyper\@currenthyper%
  \global\let\@currenthypertype\@currenthypertype%
  \callwithexpandedhyperref{\hyper@add@part}{#1}%
  \begingroup\centering
  \fontsize{\@xxpt}{25}\bfseries
     \hyperanchor{\@currenthyper}{#1}%
     \vfil\vfil\endgroup \newpage\thispagestyle{empty}}
%</amsbook>
%    \end{macrocode}
% |amsdtx.cls| has to be modified as follows.
%    \begin{macrocode}
%<*amsdtx>
\input{book.hyp}
\renewcommand\maketitle{\par
  \begingroup
    \renewcommand\thefootnote{\fnsymbol{footnote}}%
    \def\@makefnmark{%
      \hyper@currentfnmark%
      \hbox to\z@{%
      \@textsuperscript{%
        \normalfont%
        \hyperreference%
          {\hyper@current@fnmark}%
          {\@thefnmark}%
      }%
    }}%
    \long\def\@makefntext##1{%
      \hyper@currentfnmark%
      \bgroup%
        \edef\@currenthyper{\hyper@current@fnmark}%
        \parindent 1em%
        \noindent%
        \hbox to1.8em%
          {\hss$\m@th^{%
            \hyperanchor{\hyper@current@fnmark}{\@thefnmark}%
          }$}##1%
       \egroup%
    }%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
  \endgroup
  \setcounter{footnote}{0}%
  \let\thanks\relax
  \let\maketitle\relax\let\@maketitle\relax
  \gdef\@thanks{}\gdef\@author{}\gdef\@title{}}
%</amsdtx>
%    \end{macrocode}
% For |amsldoc.cls| we need the following changes.
%    \begin{macrocode}
%<*amsldoc>
\input{book.hyp}
\let\hyper@theindex@ams\theindex%fetch modified index from book.hyp
\def\theindex{%
  \hyper@theindex@ams%
  \let\autoindex\@gobble%
}
%</amsldoc>
%    \end{macrocode}
% \subsubsection{The Packages}
% To add the hypertext--capability to |amsmath| respectively |amstex|
% some macros of them have to be modified.\par
% \noindent As we have redefined |\@eqnnum| and we need another
% definition for |amsmath| and |amstex| let us set the macro to its
% default.
%    \begin{macrocode}
%<*amsmath,amstex>
\iftagsleft@
  \def\@eqnnum{\hbox to1sp{}\rlap{\normalfont\normalcolor
    \hskip -\displaywidth\tagform@\theequation}}
\else
  \def\@eqnnum{{\normalfont\normalcolor \tagform@\theequation}}
\fi
%</amsmath,amstex>
%    \end{macrocode}
% |amsmath| temporary redefines |\label| but needs the original definition
% that is hold in |\ltx@label|.
%    \begin{macrocode}
%<*amsmath>
\let\ltx@label\label
%</amsmath>
%    \end{macrocode}
% Now let us define a blind anchor for referencing a couple of equations
% bound together.
%    \begin{macrocode}
%<*amsmath,amstex>
\let\hyper@subequations\subequations
\def\subequations{%
  \hyper@setcurrent%
  \hyper@settype{equation}%
  \blindhyperanchor{\@currenthyper}%
  \hyper@subequations%
}
%    \end{macrocode}
% To allow the references pointing to an equation number we have to define an
% appropriate anchor.
%    \begin{macrocode}
\let\hyper@tagform@\tagform@
\def\tagform@#1{%
  \maketag@@@{\hyperanchor{\@currenthyper}{(\ignorespaces#1\unskip)}}%
}
%</amsmath,amstex>
%    \end{macrocode}
% For user defined tags it is necessary to generate a new hypertext number
% in |amsmath|.
%    \begin{macrocode}
%<*amsmath>
\let\hyper@make@display@tag\make@display@tag
\def\make@display@tag{%
  \if@eqnsw\else\iftag@%
    \hyper@setcurrent%
    \hyper@settype{equation}%
  \fi\fi%
  \hyper@make@display@tag%
}
%</amsmath>
%    \end{macrocode}
% For |amstex| a similar result cannot be provided with an as simple changing.
% This is due to |\@seteqlabel| being called when introducing a new tag.
% Supposing |\@seteqlabel| defining the correct |\@currenthyper| we therefore
% have to modify |\make@df@tag| as follows.
%    \begin{macrocode}
%<*amstex>
\def\make@df@tag@@@#1{%
  \@seteqlabel{#1}%
  \global\let\ams@currenthyper\@currenthyper%
  \gdef\df@tag{\let\@currenthyper\ams@currenthyper\tagform@{#1}}%
}
%    \end{macrocode}
% Now we just have to ensure |\@seteqlabel| defining the correct
% |\@currenthyper|.
%    \begin{macrocode}
\def\@seteqlabel#1{%
  \toks@\@xp{\p@equation{#1}}%
  \hyper@setcurrent%
  \hyper@settype{equation}%
  \edef\@currenthyper{\@currenthyper.\the\toks@}%
  \edef\@currentlabel{\the\toks@}%
}
%</amstex>
%    \end{macrocode}
% We should not use an anchor when using |\eqref|
%    \begin{macrocode}
%<*amsmath,amstex>
\def\eqref#1{\textup{\hyper@tagform@{\ref{#1}}}}
%</amsmath,amstex>
%    \end{macrocode}
% Damned |amstex| redefines the macro |\label|. We have to ensure that the 
% correct stuff is written into the |.aux|-file when this macro is called.
%    \begin{macrocode}
%<*amstex>
\def\hyperlabel#1{%
   \@bsphack%
       \iffirstchoice@\if@filesw%
          {\let\thepage\relax%
           \def\protect{\noexpand\noexpand\noexpand}%
           \xdef\@gtempa{%
              \write\@auxout{%
                 \string\newlabel{#1}{{\@currenthypertype}{\@currenthyper}{\@currentlabel}{\thepage}}%
              }%
           }%
          }%
          \@gtempa%
          \if@nobreak\ifvmode\nobreak\fi\fi%
       \fi\fi%
   \@esphack%
}
\let\label\hyperlabel
%</amstex>
%    \end{macrocode}
% To get hypertext references to theorems, lemmas, etc.\ |amsthm| has to
% be modified.
%    \begin{macrocode}
%<*amsthm>
\let\@begintheorem\hyper@begintheorem
\def\thmhead@plain#1#2#3{%
  \hyperanchor{\@currenthyper}{\thmname{#1}\thmnumber{ #2}}%
  \thmnote{ {\the\thm@notefont(#3)}}%
}
\let\thmhead\thmhead@plain
\def\swappedhead#1#2#3{%
  \hyperanchor{\@currenthyper}{\thmnumber{#2}\thmname{. #1}}%
  \thmnote{ {\the\thm@notefont(#3)}}%
}
%</amsthm>
%    \end{macrocode}
% For |upref| working correct it is sufficient to modify |\hyper@setref|.
%    \begin{macrocode}
%<*upref>
\def\hyper@setref#1#2#3#4{%
  \ifx#1\relax%
     \protect\G@refundefinedtrue%
     #4\nfss@text{\reset@font\bfseries ??}%
     \@latex@warning{Reference `#3' on page \thepage \space undefined}%
  \else%
    \edef\hyper@tmp{\expandafter\hyper@secondoffour#1}%
    \ifx\hyper@tmp\@empty%
       \ifx#2\hyper@secondoffour%
          #4\null%
        \else\ifx#2\hyper@thirdoffour%
          #4\protect\textup{\expandafter#2#1\hbox{}}\null%
        \else%
          #4\protect\textup{\expandafter#2#1\hbox{}}\null%
        \fi\fi%
    \else%
       \ifx#2\hyper@secondoffour%
          \hyperreference{\expandafter\hyper@secondoffour#1}{#4}\null%
        \else\ifx#2\hyper@thirdoffour%
          \hyperreference%
            {\expandafter\hyper@secondoffour#1}%
            {#4\protect\textup{\expandafter#2#1\hbox{}}}\null%
        \else%
          \hyperpagereference%
            {\expandafter\hyper@forthoffour#1}%
            {#4\protect\textup{\expandafter#2#1\hbox{}}}\null%
        \fi\fi%
    \fi%
  \fi%
}
%</upref>
%    \end{macrocode}
%
% \subsection{Cross References between Documents}
% The package |xr| adds the capability of generating cross--references
% between different \LaTeXe--documents. It is a nice feature to support
% this by hypertext links. Thus we have to modify |xr| appropriately.\par
% \noindent At first let us provide an additional parameter to |\externaldocument|
% giving the URL--address of the document we use references to. It has to
% be given with surrounding |(||)|. The default value is given by
% |documentname.dvi|.
%    \begin{macrocode}
%<*xr>
\def\externaldocument{%
  \@ifnextchar(%
    {\hyper@externaldocument}%
    {\hyper@externaldocument()}%
}
\def\hyper@externaldocument(#1){%
  \@ifnextchar[%
    {\hyper@@externaldocument(#1)}%
    {\hyper@@externaldocument(#1)[]}%
}
\def\hyper@@externaldocument(#1)[#2]#3{%
  \def\hyper@XR@docprefix{#1}%
  \ifx\hyper@XR@docprefix\@empty%
    \def\hyper@XR@docprefix{#3.dvi}%
  \fi%
  \XR@[#2]{#3}%
}
%    \end{macrocode}
% Now we have to modify the anchors we refer to from their local definition
% in the documents |.aux|--file to its external URL--definitions.
%    \begin{macrocode}
\def\hyper@xr@end@newlabel{\relax}
\def\hyper@xr@newlabel#1#2#3#4#5{%
   \ifx#4\hyper@xr@end@newlabel%
      \newlabel%
         {\XR@prefix#1}%
         {{}%
          {}%
          {#2}%
          {[file:\hyper@XR@docprefix][#3]}%
         }%
   \else%
      \newlabel%
         {\XR@prefix#1}%
         {{#2}%
          {[file:\hyper@XR@docprefix][#3]}%
          {#4}%
          {[file:\hyper@XR@docprefix][#5]}%
         }%
   \fi
}
\long\def\XR@test#1#2#3#4\XR@{%
  \ifx#1\newlabel%
    \expandafter\hyper@xr@newlabel{#2}#3\hyper@xr@end@newlabel\hyper@xr@end@newlabel%
  \else\ifx#1\newhyper%
     \newhyper{\XR@prefix#2}{#3}%
  \else\ifx#1\@input%
     \edef\XR@list{\XR@list#2\relax}%
  \fi\fi\fi%
  \ifeof%
    \@inputcheck\expandafter\XR@aux%
  \else%
    \expandafter\XR@read%
  \fi%
}
%</xr>
%    \end{macrocode}
%
% \subsection{Fancy Headings}
% The package |fancyheadings| uses a different way to express headings. This gives us trouble on
% pages with an ``empty'' page style via the (default) settings for headers and footers using
% the macro |\fancyplain|. To get the page number if all the parts for the heads and foots are empty
% demands a fairly complicated mechanism to implement if we want to refer to the page number as we
% do have to detect whether we really have a page number on the page. For sake of simplicity of
% processing we assume that any time there is a non-empty text for the head or the foot there also
% is a page number printed in either the head or the foot.
%    \begin{macrocode}
%<*fancyheadings>
\def\hyper@fancy@oddhead{\@fancyhead\@lodd\@olhead\@ochead\@orhead\@rodd}
\def\hyper@fancy@oddfoot{\@fancyfoot\@lodd\@olfoot\@ocfoot\@orfoot\@rodd}
\def\hyper@fancy@evenhead{\@fancyhead\@rodd\@elhead\@echead\@erhead\@lodd}
\def\hyper@fancy@evenfoot{\@fancyfoot\@rodd\@elfoot\@ecfoot\@erfoot\@lodd}
\def\hyper@fancy@empty{{\hyper@empty\hyper@empty}}
\def\hyper@iffancyplain@empty#1#2#3#4#5\hyper@iffancyplain@empty{%
  \ifx#4\hyper@fancy@empty%
     \ifx#1\fancyplain%
        \if@fancyplain%
           \ifx\\#2\\1\else0\fi%
        \else%
           \ifx\\#3\\1\else0\fi%
        \fi%
     \else%
        0%
     \fi%
  \else%
     0%
  \fi%
}
\def\hyper@iffancy@empty#1{%
   \ifnum\ifx#1\@empty1\else0\fi%
         \ifx#1\hyper@empty1\else0\fi%
         \expandafter%
            \hyper@iffancyplain@empty%
               #1\hyper@fancy@empty%
                 \hyper@fancy@empty\hyper@fancy@empty%
                 \hyper@fancy@empty\hyper@fancy@empty%
            \hyper@iffancyplain@empty%
         >0 0\else1\fi%
}
\def\hyper@modifyheadfoot@pagenumber{%
  \let\hyper@thehead\@thehead%
  \ifx\hyper@thehead\hyper@oddhead\let\hyper@thehead\@oddhead\fi%
  \ifx\hyper@thehead\hyper@evenhead\let\hyper@thehead\@evenhead\fi%
  \let\hyper@thefoot\@thefoot%
  \ifx\hyper@thefoot\hyper@oddfoot\let\hyper@thefoot\@oddfoot\fi%
  \ifx\hyper@thefoot\hyper@evenfoot\let\hyper@thefoot\@evenfoot\fi%
  \def\@thehead{%
      \ifnum\ifnum\ifx\hyper@thehead\@empty1\else0\fi%
                  \ifx\hyper@thehead\hyper@empty1\else0\fi%
                  \ifx\hyper@thehead\relax1\else0\fi%
                  >0 0\else1\fi%
            \ifnum\ifx\hyper@thefoot\@empty1\else0\fi%
                  \ifx\hyper@thefoot\hyper@empty1\else0\fi%
                  \ifx\hyper@thefoot\relax1\else0\fi%
                  >0 0\else1\fi%
            >0\relax%
         \ifnum\ifnum\ifx\hyper@thehead\hyper@fancy@oddhead1\else0\fi%
                     \ifx\hyper@thehead\hyper@fancy@evenhead1\else0\fi%
                     >0 0\else1\fi%
               \ifnum\ifx\hyper@thefoot\hyper@fancy@oddfoot1\else0\fi%
                     \ifx\hyper@thefoot\hyper@fancy@evenfoot1\else0\fi%
                     >0 0\else1\fi%
               >0\relax%
         \else%
            \ifnum\ifnum\hyper@iffancy@empty\@olhead%
                        \hyper@iffancy@empty\@ochead%
                        \hyper@iffancy@empty\@orhead%
                        >0 1\else0\fi%
                  \ifnum\hyper@iffancy@empty\@olfoot%
                        \hyper@iffancy@empty\@ocfoot%
                        \hyper@iffancy@empty\@orfoot%
                        >0 1\else0\fi%
                  >0\relax%
            \else%
               \blindhyperanchor{page.\thepage}%
            \fi%
         \fi%
      \else%
         \blindhyperanchor{page.\thepage}%
      \fi%
      \let\hyper@thepage\thepage%
      \let\thepage\hyper@anchorpage%
      \ifx\hyper@thehead\@empty%
         \hfil%
      \else\ifx\hyper@thehead\hyper@empty%
         \hfil%
      \else%
         \hyper@thehead%
      \fi\fi%
  }%
  \def\@thefoot{%
      \let\hyper@thepage\thepage%
      \let\thepage\hyper@anchorpage%
      \ifx\hyper@thefoot\@empty%
         \hfil%
      \else\ifx\hyper@thefoot\hyper@empty%
         \hfil%
      \else%
         \hyper@thefoot%
      \fi\fi%
  }%
}
\let\hyper@modifyheadfoot\hyper@modifyheadfoot@pagenumber
%</fancyheadings>
%    \end{macrocode}
% \subsection{Long Tables}
% The package |longtable| uses a definition of |\caption| for it's own.
% Thus we have to modify this to reflect the hypertext needs.
%    \begin{macrocode}
%<*longtable>
\let\hyper@LT@array\LT@array
\def\LT@array{%
  \refstepcounter{table}\ignore@next@refstepcounter%
  \def\@currenthyper{\the\hypercount}%
  \hyper@LT@array%
}
\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}\ifx\@tempa\@empty\else
     {\let\\\space%
      \edef\@currenthyper{\the\hypercount}%
      \addcontentsline%
        {lot}%
        {table}%
        {\protect\numberline{\thetable}{\hyperreference{\@currenthyper}{#2}}}%
     }%
  \fi}
\def\LT@makecaption#1#2#3{%
  \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
    \hyper@setcurrent%
    \hyper@settype{caption}%
    \sbox\@tempboxa{\hyperanchor{\@currenthyper}{#1{#2}}: #3}%
    \ifdim\wd\@tempboxa>\hsize
      \hyperanchor{\@currenthyper}{#1{#2}}: #3%
    \else
      \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
    \fi
    \endgraf\vskip\baselineskip}%
  \hss}}%
}
%</longtable>
%    \end{macrocode}
%
% \subsection{Right Column Footnotes in Double Column Documents}
% |ftnright.sty| redefines the macro |\@makefntext|. Thus we have to
% modify it's definition when needed.
%    \begin{macrocode}
%<*ftnright>
\long\def\@makefntext#1{%
  \hyper@currentfnmark%
  \bgroup%
    \edef\@currenthyper{\hyper@current@fnmark}%
    \parindent 1em%
    \noindent\hbox to 2em{}%
    \llap{${\hyperanchor{\hyper@current@fnmark}{\@thefnmark}}.\;\;$}#1%
  \egroup%
}
%</ftnright>
%    \end{macrocode}
%
% \subsection{The {\tt natbib}-Package}
% Unfortunately, the bibliography stuff is changed by the |natbib|-package. So we have to provide
% a special macrocode fragment for it which is complicated by the fact, that the package scans
% parts of the |\bibitem| parameters from the |*.aux|-file.\par
% \noindent Let's start with adding an anchor to the bibliographic entries.
%    \begin{macrocode}
%<*natbib>
\def\@lbibitem[#1]#2{%
   \hyper@setcurrent%
   \hyper@settype{citation}%
   \@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
   \item[\hfil\hyperanchor{\@currenthyper}{\@biblabel{\NAT@num}}]%
    \NAT@ifcmd#1()()\@nil{#2}%
}
%    \end{macrocode}
% To be able to associate the correct hyperlinks from citations to the respectively
% bibliographic entries, we have to save the hyper-addresses into the |.aux|-file
% and provide a macro to read them. Note, that we cannot use the same technique as
% in standard \LaTeXe\ as the |natbib|-package scans parts of the arguments of
% |\bibitem| and we have to ensure, that we do not introduce conflicts by surrounding
% the entries with a hyperlink. To avoid that we store the hyperlink in another macro.
%    \begin{macrocode}
\renewcommand\NAT@wrout[5]{%
  \if@filesw%
    {\let\protect\noexpand\let~\relax%
     \immediate%
     \write\@auxout%
       {\string\bibcite{#5}{{#1}{#2}{{#3}}{{#4}}}{\@currenthyper}}%
    }%
  \fi%
  \ignorespaces%
}
\renewcommand\bibcite[3]{%
   \@ifundefined{b@#1\@extra@binfo}\relax
     {\NAT@citemultiple%
      \PackageWarningNoLine{natbib}{Citation `#1' multiply defined}%
     }%
   \global\@namedef{b@#1\@extra@binfo}{#2}%
   \global\@namedef{hyper@b@#1\@extra@binfo}{#3}%
}
\AtEndDocument{\NAT@swatrue\renewcommand\bibcite[3]{\NAT@testdef{#1}{#2}}}%
%    \end{macrocode}
% Now comes the crucial part. We have to invoke the hyperlinks at appropriate points in the
% citation macros. Fortunately |natbib| supports |hyperref| by adding macros at appropriate places
% that can be redefined for introducing the links.
%    \begin{macrocode}
\def\hyper@natlinkstart#1#2\hyper@natlinkend{%
  \hyperreference{\csname hyper@b@#1\@extra@b@citeb\endcsname}{#2}%
}
\def\hyper@natlinkend{\relax}
%    \end{macrocode}
% But we do not like their solution for citations with author name and year. We can do better
% by not including the separators into the links.
%    \begin{macrocode}
\def\NAT@citex%
  [#1][#2]#3{\let\@citea\@empty%
  \@cite{\let\NAT@nm\@empty\let\NAT@year\@empty%
    \@for\@citeb:=#3\do%
    {\edef\@citeb{\expandafter\@firstofone\@citeb}%
     \if@filesw\immediate\write\@auxout{\string\citation{\@citeb}}\fi%
     \@ifundefined{b@\@citeb\@extra@b@citeb}{\@citea%
       {\reset@font\bfseries ?}\NAT@citeundefined%
                 \PackageWarning{natbib}%
       {Citation `\@citeb' on page \thepage \space undefined}}%
     {\let\NAT@last@nm=\NAT@nm\let\NAT@last@yr=\NAT@year%
     \NAT@parse{\@citeb}\ifNAT@full\let\NAT@nm\NAT@all@names\else%
       \let\NAT@nm\NAT@name\fi%
     \ifNAT@swa%
       \ifx\NAT@last@nm\NAT@nm\NAT@yrsep%
         \ifx\NAT@last@yr\NAT@year%
           \hyper@natlinkstart{\@citeb}{\NAT@exlab}\hyper@natlinkend%
         \else%
           \unskip\ %
           \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
         \fi%
       \else\@citea%
          \hyper@natlinkstart{\@citeb}{{\NAT@nm}}\hyper@natlinkend%
          \NAT@aysep\ %
          \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
       \fi%
       \def\@citea{\NAT@sep\ }%
     \else%
       \ifx\NAT@last@nm\NAT@nm\NAT@yrsep%
         \ifx\NAT@last@yr\NAT@year%
           \hyper@natlinkstart{\@citeb}{\NAT@exlab}\hyper@natlinkend%
         \else%
            \unskip\ %
            \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
         \fi%
       \else\@citea%
         \hyper@natlinkstart{\@citeb}{{\NAT@nm}}\hyper@natlinkend%
         \ \NAT@open%
         \hyper@natlinkstart{\@citeb}{\NAT@date}\hyper@natlinkend%
       \fi%
       \def\@citea{\NAT@close\NAT@sep\ }%
     \fi}}\ifNAT@swa\else\NAT@close\fi}{#1}{#2}}
%    \end{macrocode}
% Damned, |natbib| accesses this macros through |\@citex| using a |\let|-assignment.
% We have to recall this assignment to define it. Fortunately, the package provides
% a macro to achieve this.
%    \begin{macrocode}
\NAT@set@cites
%    \end{macrocode}
% Bad news, |natbib| does not provide dummies for inserting hypertext-markups into ranges.
% Thus we have to patch the sorting macros of the package.
%    \begin{macrocode}
\ifnum\NAT@sort=1
\begingroup \catcode`\_=8
\gdef\@make@cite@list{%
    \edef\@citeb{\expandafter\@firstofone\@citeb}%
     \@ifundefined{b@\@citeb\@extra@b@citeb}{%
      \@citea{\reset@font\bfseries?}%
      \def\@citea{\NAT@sep\penalty\@m\NAT@space}%
      \NAT@citeundefined\PackageWarning{natcite}%
      {Citation `\@citeb' on page \thepage\space undefined}}%
    {\NAT@parse{\@citeb}%
      \ifcat_\ifnum\z@<0\NAT@num_\else A\fi%
       \@tempcnta\NAT@num\relax%
       \ifnum\@tempcnta>\@tempcntb%
          \edef\@cite@list{\@cite@list \@celt{{\NAT@num}{\@citeb}}}%
          \@tempcntb\@tempcnta%
       \else%
          \edef\@cite@list{\expandafter\@sort@celt\@cite@list\@gobble @}%
       \fi%
    \else%
       \@citea\hyper@natlinkstart{\@citeb}{\NAT@num}\hyper@natlinkend%
       \def\@citea{\NAT@sep\penalty\@m\NAT@space}%
 \fi}}
\endgroup
\def\@sort@celt#1#2{%
   \ifx \@celt #1%
      \hyper@sort@celt#2%
   \fi%
}%
\def\hyper@sort@celt#1#2{%
   \ifnum #1<\@tempcnta%
      \@celt{{#1}{#2}}%
      \expandafter\expandafter\expandafter\@sort@celt%
   \else%
      \@celt{{\NAT@num}{\@citeb}}\@celt{{#1}{#2}}%
  \fi%
}
\def\@compress@cite#1{\hyper@compress@cite#1}
\def\hyper@compress@cite#1#2{%
  \advance\@tempcnta\@ne%
  \ifnum #1=\@tempcnta%
     \ifx\@h@ld\relax%
        \edef\@h@ld{%
           \@citea%
           \noexpand\hyper@natlinkstart{#2}{#1}\noexpand\hyper@natlinkend%
        }%
     \else%
        \def\@h@ld{%
           \hbox{--}%
           \hyper@natlinkstart{#2}{#1}\hyper@natlinkend%
        }%
     \fi%
  \else%
     \@h@ld\@citea%
     \hyper@natlinkstart{#2}{#1}\hyper@natlinkend%
     \let\@h@ld\relax%
  \fi%
  \@tempcnta#1\def\@citea{\NAT@sep\penalty\@m\NAT@space}%
}
\fi
%</natbib>
%    \end{macrocode}
%
% \subsection{The Subequationarray Package}
% First of all we have to set some anchors in the |subeqnarray|-environment
% we can refer to.
%    \begin{macrocode}
%<*subeqnarray>
\def\hyper@subeqnnum@leqno{%
   \hbox to .01\p@{}%
   \rlap{%
      \reset@font\rmfamily%
      \hskip-\displaywidth\hyperanchor{\@currenthyper}{(\thesubequation)}%
   }%
}
\def\hyper@subeqnnum@reqno{%
   {\reset@font\rmfamily \hyperanchor{\@currenthyper}{(\thesubequation)}}%
}
\let\@subeqnnum\hyper@subeqnnum@reqno
\@ifpackagewith{subeqnarray}{leqno}
  {\let\@subeqnnum\hyper@subeqnnum@leqno}
  {\let\@subeqnnum\hyper@subeqnnum@reqno}
\let\hyper@subeqnarray\subeqnarray
\def\subeqnarray{%
   \hyper@setcurrent%
   \hyper@settype{equation}%
   \let\label@currenthyper\@currenthyper%
   \let\label@currenthypertype\@currenthypertype%
   \def\label##1{%
      \let\@currenthyper\label@currenthyper%
      \let\@currenthypertype\label@currenthypertype%
      \hyperlabel{##1}%
      \blindhyperanchor{\label@currenthyper}%
      \def\@currenthyper{\the\hypercount}%
   }%
   \hyper@setcurrent%
   \hyper@settype{equation}%
   \def\@currenthyper{\the\hypercount}%
   \hyper@subeqnarray%
}
%    \end{macrocode}
% The subeqnarray package defines a new label command called |\slabel|.
% Thus, we have to redefine it in order to ensure that the hyper reference is
% added to the label when written into the |.aux|-file.
%    \begin{macrocode}
\def\slabel#1{%
  \@bsphack
  \if@filesw
    {\let\thepage\relax
     \def\protect{\noexpand\noexpand\noexpand}%
     \edef\@tempa{\write\@auxout{\string
        \newlabel{#1}{{\@currenthypertype}{\@currenthyper}{\thesubequation}{\thepage}}}}%
     \expandafter}\@tempa
     \if@nobreak \ifvmode\nobreak\fi\fi
  \fi\@esphack}
%</subeqnarray>
%    \end{macrocode}
% \subsection{The Theorem Package}
% Analoguous to the theorem environment of \LaTeXe{} we have to modify
% the different theorem styles of the theorem package.
%    \begin{macrocode}
%<*theorem>
%plain
\gdef\th@plain{\normalfont\itshape%
  \def\@begintheorem##1##2{%
     \item[\hskip\labelsep%
           \hyperanchor{\@currenthyper}{\theorem@headerfont ##1\ ##2}%
          ]%
  }%
  \def\@opargbegintheorem##1##2##3{%
     \item[\hskip\labelsep%
           \hyperanchor%
             {\@currenthyper}%
             {\theorem@headerfont ##1\ ##2}\ (##3)%
          ]%
  }%
}
%break
\gdef\th@break{\normalfont\slshape%
  \def\@begintheorem##1##2{%
     \item[\rlap{\vbox{\hbox{\hskip \labelsep%
             \hyperanchor{\@currenthyper}{\theorem@headerfont ##1\ ##2}%
           }\hbox{\strut}}}%
          ]%
  }%
  \def\@opargbegintheorem##1##2##3{%
    \item[\rlap{\vbox{\hbox{\hskip \labelsep%
            \hyperanchor%
              {\@currenthyper}%
              {\theorem@headerfont ##1\ ##2}\ (##3)%
          }\hbox{\strut}}}%
         ]%
  }%
}
%marginbreak
\gdef\th@marginbreak{\normalfont\slshape%
  \def\@begintheorem##1##2{%
    \item[\rlap{\vbox{\theorem@headerfont%
            \hbox{\llap{##2}\hskip\labelsep%
                  \hyperanchor{\@currenthyper}{##1}%
                 }%
          \hbox{\strut}}}%
         ]%
  }%
  \def\@opargbegintheorem##1##2##3{%
    \item[\rlap{\vbox{\theorem@headerfont%
            \hbox{\llap{##2}\hskip\labelsep%
                  \hyperanchor{\@currenthyper}{##1}\ (##3)
                 }%
          \hbox{\strut}}}%
         ]%
  }%
}
%changebreak
\gdef\th@changebreak{\normalfont\slshape%
  \def\@begintheorem##1##2{%
    \item[\rlap{\vbox{\hbox{\hskip\labelsep%
            \hyperanchor{\@currenthyper}{\theorem@headerfont ##2\ ##1}%
          }\hbox{\strut}}}%
         ]%
  }%
  \def\@opargbegintheorem##1##2##3{%
    \item[\rlap{\vbox{\hbox{\hskip\labelsep%
            \hyperanchor%
              {\@currenthyper}%
              {\theorem@headerfont ##2\ ##1}\ (##3)%
          }\hbox{\strut}}}%
         ]%
  }%
}
%change
\gdef\th@change{\normalfont\slshape%
  \def\@begintheorem##1##2{%
    \item[\hskip\labelsep%
          \hyperanchor{\@currenthyper}{\theorem@headerfont ##2\ ##1}%
         ]%
  }%
  \def\@opargbegintheorem##1##2##3{%
    \item[\hskip\labelsep%
          \hyperanchor%
            {\@currenthyper}%
            {\theorem@headerfont ##2\ ##1}\ (##3)%
         ]%
  }%
}
%margin
\gdef\th@margin{\normalfont\slshape%
  \def\@begintheorem##1##2{%
    \item[\theorem@headerfont \llap{##2}\hskip\labelsep%
          \hyperanchor{\@currenthyper}{##1}%
         ]%
  }%
  \def\@opargbegintheorem##1##2##3{%
    \item[\theorem@headerfont \llap{##2}\hskip\labelsep%
          \hyperanchor{\@currenthyper}{##1}\ (##3)%
         ]%
  }%
}
%</theorem>
%    \end{macrocode}
%
% \subsection{The CWEB Document Class}
% For \CWEB\ there exists a \LaTeXe\ document class that defined a reference
% mechanism for literate programming using latex and \CWEB.\par
% \noindent
% First of all it is based on another document class. Thus we have to
% load the modifications for this class, too.
%    \begin{macrocode}
%<*cweb>
\InputIfFileExists{\CwebBaseClass.hyp}{}%
  {\PackageError{hyper}{\CwebBaseClass.hyp not found.\MessageBreak
               Please choose another base document class for cweb\MessageBreak
               or redefine \string\CwebBaseClass to point to a\MessageBreak
               modification document class for the base document class
              }{}%
  }%
%    \end{macrocode}
% As we use pattern--like definitions for some stuff following below
% an additiional package has to be loaded.
%    \begin{macrocode}
\RequirePackage{defpattern}
%    \end{macrocode}
% |cweb.cls| uses the underscore character as a letter for some macro names
% we have to redefine. Thus we set the category code of |_| correspondingley.
%    \begin{macrocode}
\chardef\hyper@CatUsCode=\catcode`\_
\catcode`\_=\CatLetter
%    \end{macrocode}
% Why the hell must the class use a redefinition of |\refstepcounter| for
% its own? This means that we have to redefine it another time.
%    \begin{macrocode}
\let\hyper@cweb@refstepcounter=\hyper@refstepcounter
\def\refstepcounter#1{%
    \def\@tempa{#1}%
    \ifx \@tempa\cweb@string@chunk%
       \protected@edef\@currenthyper{cweb.\cweb@refchunk}%
       \hyper@settype{chunk}%
       \protected@edef\@currentlabel{\cweb@refchunk}%
    \else%
       \hyper@setcurrent%
       \hyper@settype{chunk}%
       \hyper@cweb@refstepcounter{#1}%
    \fi%
}
%    \end{macrocode}
% Naturally, we want to use the chunk numbers as links to the corresponding
% chunks. This means that we have to redefine |\CwebRefName|.
% Don't ask why it's that complicated.
%    \begin{macrocode}
\let\hyper@CwebRefName\CwebRefName
\def\CwebRefName#1:#2\X{%
    \ifmmode  \gdef\cwbb@toggle_text{\null$\null}%
    \else  \let\cwbb@toggle_text\relax%
    \fi%
    \cwbb@toggle_text%
    \expandafter\ifx\csname hyper@cweb.#1\endcsname\relax%
       \expandafter\ifx\csname hyper@new@cweb.#1\endcsname\relax%
          \PackageWarning{hyper}%
                   {Hyper reference for `cweb.#1' on page \hyper@thepage\space undefined}%
          \hyper@change1\relax%
          \hyper@undef@color{%
             $\langle\,${\cwbb@tex \cwbb@check_dot{#2}\CwebRefNumber{#1}}$\,\rangle$%
          }%
       \else%
          \hyperreference{cweb.#1}{%
             $\langle\,${\cwbb@tex \cwbb@check_dot{#2}\CwebRefNumber{#1}}$\,\rangle$%
          }%
       \fi%
    \else%
       \hyperreference{cweb.#1}{%
          $\langle\,${\cwbb@tex \cwbb@check_dot{#2}\CwebRefNumber{#1}}$\,\rangle$%
       }%
    \fi%
    \cwbb@toggle_text%
}
%    \end{macrocode}
% However, there has to exist anchors for these links to the chunks.\par
% \noindent Well, for a hierarchical structure the chunk numbers are
% written into the
% margin whereas for a flat structure they are written at the beginning of
% the chunk using the chunk begin macro |\M|. Therefore we need the following
% modifications of the original code.
%    \begin{macrocode}
\ifcase \cweb@structure
    %% hierarchic
    \let\hyper@cwbb@marginal_chunkno\cwbb@marginal_chunkno%
    \def\cwbb@marginal_chunkno{%
      \let\hyper@thechunk\thechunk%
      \def\thechunk{\hyperanchor{cweb.\arabic{chunk}}{\hyper@thechunk}}%
      \hyper@cwbb@marginal_chunkno%
      \let\thechunk\hyper@thechunk%
    }
  \or
    %% flat
    \let\hyper@M\M%
    \def\M#1{%
      \let\hyper@thechunk\thechunk%
      \def\thechunk{\hyperanchor{cweb.\arabic{chunk}}{\hyper@thechunk}}%
      \hyper@M{#1}%
      \let\thechunk\hyper@thechunk%
    }
\fi
%    \end{macrocode}
% Unfortunately, this is not sufficient. The class uses an additional
% cross referencing mechanism.\par
% \noindent Damned, it uses seperators for a list of cross references that
% cannot be used for the pattern-like definition we need to seperate the
% different references. Thus we have to redefinie the seperators and reinvoke
% them after splitting.
%    \begin{macrocode}
\let\hyper@CwebCREt\CwebCREt
\let\hyper@CwebCRsEt\CwebCRsEt
\def\CwebCREt{!}
\def\CwebCRsEt{?}
%
\defpattern\hyper@split@CwebCrossRef[#2]{\hyperreference{cweb.#2}{#2}}
\defpattern\hyper@split@CwebCrossRef[ #2]{\hyper@split@CwebCrossRef[#2]}
\defpattern\hyper@split@CwebCrossRef[#2,#3]{%
  \hyper@split@CwebCrossRef[#2], %
  \hyper@split@CwebCrossRef[#3]%
}
\defpattern\hyper@split@CwebCrossRef[#2!#3]{%
  \hyper@split@CwebCrossRef[#2]\hyper@CwebCREt%
  \hyper@split@CwebCrossRef[#3]%
}
\defpattern\hyper@split@CwebCrossRef[#2?#3]{%
  \hyper@split@CwebCrossRef[#2]\hyper@CwebCRsEt%
  \hyper@split@CwebCrossRef[#3]%
}
\def\hypersplit@CwebCrossRef[#1]{%
  \edef\hyper@tmp{#1}%
  \expandafter\hyper@split@CwebCrossRef\expandafter[\hyper@tmp]%
}
%
\let\hyper@CwebCrossRef\CwebCrossRef
\def\CwebCrossRef#1#2.{%
  \hyper@CwebCrossRef{#1}{\hypersplit@CwebCrossRef[#2]}.%
}
%    \end{macrocode}
% As you might have expected, this even does not resolve all problems.
% The list of references may contain multiple entries pointing to
% different chunks containing code for the same literate.
% Therefore we have to redefine the literates to allow links to different
% occurrences.
%    \begin{macrocode}
\let\hyper@CwebRefList\CwebRefList
\def\hyper@CwebRefName@RefList#1:#2\X{%
  \hyper@CwebRefName\hypersplit@CwebCrossRef[#1]:#2\X%
}
\def\CwebRefList{%
  \let\hyper@CwebReadPPList\CwebReadPPList%
  \let\CwebReadPPList\relax%
  \hyper@CwebRefList%
  \let\X\hyper@CwebRefName@RefList
  \def\CwebCrossRef##1##2.{%
    \quad {\reset@font\footnotesize ##1~\hypersplit@CwebCrossRef[##2].}%
  }%
  \let\CwebReadPPList\hyper@CwebReadPPList%
  \CwebReadPPList%
}
%    \end{macrocode}
% Last but not least we have to handle the index referencing from variables
% to the chunks they occur in. The modifications below are just a little bit
% complicated as we have to split the list of occurrences to several parts
% each of which has to be handled sepeartely without being allowed to use
% the original list that may contain the character |]| that cannot be used
% in pattern--like definitions we need here.
%    \begin{macrocode}
\let\hyper@CwebIndexEntry\CwebIndexEntry
\let\hyper@CwebIndexDeclared\CwebIndexDeclared
\def\CwebIndexDeclared#1]{|#1|}
\defpattern\hyper@cwebindex[#2]{\hyperreference{cweb.#2}{#2}}
\defpattern\hyper@cwebindex[|#2|]{%
  \hyperreference{cweb.#2}{\hyper@CwebIndexDeclared#2]}%
}
\defpattern\hyper@cwebindex[#2, #3]{%
  \hyper@cwebindex[#2], \hyper@cwebindex[#3]%
}
\def\hyper@cweb@index#1{%
  \edef\hyper@tmp{#1}%
  \expandafter\hyper@cwebindex\expandafter[\hyper@tmp]%
}
\def\CwebIndexEntry#1, #2.{%
  \hyper@CwebIndexEntry#1, \hyper@cweb@index{#2}.%
}
%    \end{macrocode}
% Now it just remains to reset the category code for |_| to the one we had
% before the modifications started.
%    \begin{macrocode}
\catcode`\_=\hyper@CatUsCode
%</cweb>
%    \end{macrocode}
%
% \clearpage
%
% \section{Needed Packages (Part of this Distribution)}
%
% \subsection{Pattern--Like Definition of Macros}
% For the index and glossary definitions we have used the package |defpattern|
% that is already part of the fp--package on |CTAN:macros/latex/contrib/other/fp|.
% This is a very usefull macro allowing the definition of other macros by
% pattern matching rules.\par
% \noindent The package has been adapted from Alan Jeffrey's |\howto| that can be
% found in ``\TeX and TUG NEWS 2(2)''.
%    \begin{macrocode}
%<*defpattern>
\ProvidesPackage{defpattern}
\message{%
  `\string\defpattern-macro %
   (adapted from \string\howto\space%
    (Alan Jeffrey in TeX and TUG NEWS 2(2))%
   )%
  '%
}
\def\xcs#1#2{\expandafter#1\csname#2\endcsname}
\newcount\actioncount
\def\defpattern#1[#2]#3{%
  \xcs\ifx{\expandafter\gobble\string#1}\relax
  \def#1{\erroraction#1}\fi
  \advance\actioncount by 1\relax
  \expandafter\defaction\expandafter{#1}{#3}{#2}%
  \def\temp##1##2##3##4##5##6##7##8##9{\def\temp{[#2]}}%
  \temp\empty\empty\empty\empty\empty\empty\empty\empty\empty
  \edef#1{\noexpand\doaction\xcs\noexpand
    {action-\the\actioncount}\temp}}
\def\defaction#1#2#3{%
  \xcs\def{action-\the\actioncount}##1[#3]{\applyto{#1}{#2}}}
\def\gobble#1{}
\def\applyto#1#2#3{#3{#1}{#2}}
\def\doaction#1[#2][#3]{#1[#3]\success[#2]\failure[#3]}
\def\success#1#2[#3]\failure[#4]{#2}
\def\failure#1#2{#1}
\def\erroraction#1[#2]{%
   \PackageError{defpattern}{I don't know how to \string#1[#2]}{}}
%</defpattern>
%    \end{macrocode}
%
% \clearpage
%
% \section{Extensions}
% Currently the following extensions exist for this package.
% \begin{itemize}
%    \item Back references from the bibliography to the citations\newline
%          (described in |backcite.dtx|)
% \end{itemize}
%
% \Finale