summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/glossaries/glossaries.dtx
blob: a86c855cb8513104a080ffff7c687e4bcb9f46a9 (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
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
5198
5199
5200
5201
5202
5203
5204
5205
5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240
5241
5242
5243
5244
5245
5246
5247
5248
5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5297
5298
5299
5300
5301
5302
5303
5304
5305
5306
5307
5308
5309
5310
5311
5312
5313
5314
5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
5340
5341
5342
5343
5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
5355
5356
5357
5358
5359
5360
5361
5362
5363
5364
5365
5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
5444
5445
5446
5447
5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482
5483
5484
5485
5486
5487
5488
5489
5490
5491
5492
5493
5494
5495
5496
5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
5512
5513
5514
5515
5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
5526
5527
5528
5529
5530
5531
5532
5533
5534
5535
5536
5537
5538
5539
5540
5541
5542
5543
5544
5545
5546
5547
5548
5549
5550
5551
5552
5553
5554
5555
5556
5557
5558
5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
5573
5574
5575
5576
5577
5578
5579
5580
5581
5582
5583
5584
5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
5604
5605
5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
5634
5635
5636
5637
5638
5639
5640
5641
5642
5643
5644
5645
5646
5647
5648
5649
5650
5651
5652
5653
5654
5655
5656
5657
5658
5659
5660
5661
5662
5663
5664
5665
5666
5667
5668
5669
5670
5671
5672
5673
5674
5675
5676
5677
5678
5679
5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
5693
5694
5695
5696
5697
5698
5699
5700
5701
5702
5703
5704
5705
5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
5735
5736
5737
5738
5739
5740
5741
5742
5743
5744
5745
5746
5747
5748
5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
5772
5773
5774
5775
5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
5869
5870
5871
5872
5873
5874
5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
5907
5908
5909
5910
5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
%\iffalse
% glossaries.dtx generated using makedtx version 0.94b (c) Nicola Talbot
% Command line args:
%   -macrocode "glossaries\.perl"
%   -src "glossaries.sty=>glossaries.sty"
%   -src "(glossary-.+)\.(sty)\Z=>\1.\2"
%   -src "glossaries\.perl=>glossaries.perl"
%   -author "Nicola Talbot"
%   -dir "source"
%   -setambles "glossaries\.perl=>\nopreamble\nopostamble"
%   -comment "glossaries\.perl"
%   -doc "manual.tex"
%   -codetitle "Documented Code"
%   glossaries
% Created on 2007/9/13 20:21
%\fi
%\iffalse
%<*package>
%% \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         \~}
%</package>
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
% Copyright (C) 2007 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{ifthen}
\usepackage{alltt}
\usepackage[colorlinks,
            bookmarks,
            hyperindex=false,
            pdfauthor={N.L.C. Talbot},
            pdftitle={glossaries.sty: LaTeX2e Package to Assist Generating Glossaries},
            pdfkeywords={LaTeX,package,glossary,acronyms}]{hyperref}

 %hyperindex conflicts with doc
 %(end up with |usage|hyperpage in indexentry)
 %This unfortunately means that the changes section doesn't
 %have active links, but at least it will keep makeindex happy.


\renewcommand{\usage}[1]{\textit{\hyperpage{#1}}}
\renewcommand{\main}[1]{\hyperpage{#1}}
\newcommand{\see}[2]{\emph{see} #1}
\makeatletter
\def\index@prologue{\section*{Index}}
\makeatother
\RecordChanges
\PageIndex
\CheckSum{2826}
\CodelineNumbered
\newcommand*{\termdef}[1]{\emph{#1}\iterm{#1}}
\newcommand*{\term}[1]{#1\iterm{#1}}
\newcommand*{\iterm}[1]{\index{#1|main}}



\newcommand*{\istkey}[1]{\texttt{#1}\index{makeindex=\texttt{makeindex}>#1=\texttt{#1}|hyperpage}}
\newcommand*{\icmdname}[1]{\texttt{\char`\\#1}\SpecialMainIndex{#1}}
\newcommand*{\appname}[1]{\texttt{#1}\index{#1=\texttt{#1}|hyperpage}}
\newcommand*{\mkidxspch}{\index{makeindex=\texttt{makeindex}>special characters|hyperpage}}
\newcommand*{\igloskey}[2][newglossaryentry]{\index{#1 options=\cs{#1} options>#2=\textsf{#2}|hyperpage}}
\newcommand*{\gloskey}[2][newglossaryentry]{\textsf{#2}\igloskey[#1]{#2}}
\newcommand*{\pkgopt}[2][]{%
\ifthenelse{\equal{#1}{}}{%
\textsf{#2}\index{package options>#2=\textsf{#2}|hyperpage}}{%
\textsf{#2=#1}\index{package options>#2=\textsf{#2}>#1=\textsf{#1}|hyperpage}}}
\newcommand*{\pkgoptval}[2]{\textsf{#1}\index{package options>#2>#1|hyperpage}}
\newcommand*{\glostyle}[1]{\textsf{#1}\index{glossary styles>#1|hyperpage}}
\newcommand*{\filetype}[1]{\texttt{#1}\index{file types>#1|hyperpage}}
\newcommand*{\styname}[1]{\textsf{#1}\index{#1 package=\textsf{#1} package|hyperpage}}
\newcommand*{\envname}[1]{\textsf{#1}}


\begin{document}
\DocInput{glossaries.dtx}
\end{document}
%</driver>
%\fi
%\MakeShortVerb{"}
%\DeleteShortVerb{\|}
%
% \title{glossaries.sty v 1.07: \LaTeXe\ Package to Assist Generating Glossaries}
% \author{Nicola L.C. Talbot\\[10pt]
%School of Computing Sciences\\
%University of East Anglia\\
%Norwich. Norfolk\\
%NR4 7TJ. United Kingdom.\\
%\url{http://theoval.cmp.uea.ac.uk/~nlct/}}
%
% \date{13th September 2007}
% \maketitle
%\tableofcontents
%
% \section{Introduction}
%
% \changes{1.0}{2007 May 16}{Initial version}
%The \styname{glossaries} package is provided to assist 
%generating glossaries.  It has a certain amount of flexibility, 
%allowing the user to customize the format of the glossary,
%define new glossary styles, and multiple glossaries. It
%also supports acronyms, and glossary styles which 
%include symbols in addition to a name and description for a
%given glossary entry. There is provision for loading a database
%of glossary terms, where only those terms used in the
%text are added to the glossary.  This
%package replaces the \styname{glossary} package which is now
%obsolete.
%
%The \styname{glossaries} package comes with the Perl script
%\appname{makeglossaries} which will run \appname{makeindex} on
%all the glossary files using a customized \appname{makeindex}
%style file (which is created by \icmdname{makeglossaries}). 
%The relevant extensions are obtained from the
%auxiliary file, so you only need to pass the basename as the
%argument. For example, if your document is called 
%\texttt{myfile.tex}, do:
%\begin{verbatim}
%latex myfile
%makeglossaries myfile
%latex myfile
%\end{verbatim}
%You may need to explicitly load \appname{makeglossaries} into
%Perl:
%\begin{verbatim}
%perl makeglossaries myfile
%\end{verbatim}
%There is a batch file called \texttt{makeglossaries.bat} which
%does this for Windows users.
%
%If you don't have Perl installed, you will have to run 
%\appname{makeindex} for each glossary type you have defined.
%For example, if you have used the \pkgopt{acronym} package option,
%so you have both a main glossary as well as a list of acronyms, you
%will need to do (assuming your document is called \texttt{myfile.tex}):
%\begin{verbatim}
%makeindex -s myfile.ist -t myfile.glg -o myfile.gls myfile.glo
%makeindex -s myfile.ist -t myfile.alg -o myfile.acr myfile.acn
%\end{verbatim}
%This requires remembering all extensions for each of the glossaries
%defined in your document, so where possible you should use
%\appname{makeglossaries} instead to reduce the possibility of error.
%
%This documentation is structured as follows: \autoref{sec:quick}
%is for people who want a few quick pointers of how to get started,
%without having to read through lengthy descriptions, 
%\autoref{sec:overview} gives an overview of available commands
%and their syntax, \autoref{sec:code} contains the documented
%source code for those who want to know more about how the
%package works, and how to do more complicated things, such as
%changing the way glossary entries appear.
%
%\section{A Quick Guide For The Impatient}
%\label{sec:quick}
%
%This section is for people who want a few quick pointers
%of how to get started, without having to read through
%lengthy descriptions.
%
%\begin{enumerate}
%\item Load \styname{glossaries} \emph{after} \styname{hyperref}:
%\begin{verbatim}
%\usepackage{hyperref}
%\usepackage{glossaries}
%\end{verbatim}
%Similarly for the \styname{html} package:
%\begin{verbatim}
%\usepackage{html}
%\usepackage{glossaries}
%\end{verbatim}
%
%\item Always use \icmdname{makeglossaries} if you want the glossary
%entries to be written to the glossary file:
%\begin{verbatim}
%\documentclass{article}
%\usepackage{glossaries}
%\makeglossaries
%\end{verbatim}
%If you don't use \icmdname{makeglossaries}, your glossaries will
%not appear in the document!
%
%\item Use \icmdname{printglossaries} to make your glossaries appear 
%in the document at that point. For example:
%\begin{verbatim}
%\maketitle
%\printglossaries
%\section{Introduction}
%\end{verbatim}
%Note that only the glossary entries that have been used in the
%document text will appear in the glossary.
%
%\item When you have created your document, run \LaTeX\ on it,
%then the Perl script \appname{makeglossaries}, then run \LaTeX\
%on it again:
%\begin{verbatim}
%latex myfile
%makeglossaries myfile
%latex myfile
%\end{verbatim}
%If you use Windows, there is a batch file called 
%\texttt{makeglossaries.bat} which you can use, but you will
%still need Perl installed.
%
%\item New glossaries can be defined using:\par
%\icmdname{newglossary}%
%\marg{label}\marg{in-ext}\marg{out-ext}%
%\marg{title}\par where \meta{label} is an identifying label,
%\meta{in-ext} is the extension of the file to be created
%by \appname{makeindex} (called by \appname{makeglossaries}),
%\meta{out-ext} is the extension of the file to be read by
%\appname{makeindex} and \meta{title} is the title for this
%new glossary. Example:
%\begin{verbatim}
%\newglossary{notation}{not}{ntn}{Notation}
%\end{verbatim}
%This glossary's label is \texttt{notation} and its title
%will be Notation.
%
%\item Any new glossaries must be defined before 
%\cs{makeglossaries}
%\begin{verbatim}
%\documentclass{article}
%\usepackage{glossaries}
%\newglossary{notation}{not}{ntn}{Notation}
%\makeglossaries
%\end{verbatim}
%
%\item If you use the \pkgopt{acronym} package option, the 
%\styname{glossaries} package
%will automatically create a new glossary type labelled
%\texttt{acronym}:
%\begin{verbatim}
%\usepackage[acronym]{glossaries}
%\end{verbatim}
%
%\item If your pages have a hyphen compositor (i.e.\ your page
%numbers appear in the form 2-1), redefine \icmdname{glscompositor}
%\emph{before} \icmdname{makeglossaries}:
%\begin{verbatim}
%\documentclass{article}
%\usepackage{glossaries}
%\renewcommand{\glscompositor}{-}
%\makeglossaries
%\end{verbatim}
%
%\item To add the glossaries to the table of contents use the
%\pkgopt{toc} package option:
%\begin{verbatim}
%\usepackage[toc]{glossaries}
%\end{verbatim}
%
%\item Define a new entry with:\par
%\icmdname{newglossaryentry}\marg{label}\marg{key-val list}\par
%The \meta{key-val list} must at least contain a \gloskey{name}
%key and a \gloskey{description} key.
%For example:
%\begin{verbatim}
%\newglossaryentry{perl}{name=Perl,
%description=A scripting language}
%\end{verbatim}
%In this example, I have given the entry the label \texttt{perl}.
%Whenever I want to use this entry, that is the label I need
%to use to identify it.
%
%\item If the entry name starts with an accented letter, you will
%need to group the first letter (otherwise it will cause a
%problem for \icmdname{Gls} and \icmdname{Glspl}):
%\begin{verbatim}
%\newglossaryentry{elite}{name={{\'e}lite},
%description={select group or class}}
%\end{verbatim}
%
%\item If you have multiple glossaries, use the \gloskey{type}
%key to specify in which glossary the entry belongs. For example:
%\begin{verbatim}
%\newglossary{languages}{lan}{lng}{Index of Languages}
%
%\makeglossaries
%
%\newglossaryentry{perl}{name=Perl,
%description=A scripting language,
%type=languages}
%\end{verbatim}
%If \gloskey{type} is omitted, the default glossary is used.
%
%\item Remember to group values that have a comma or equal sign.
%For example:
%\begin{verbatim}
%\newglossaryentry{pagelist}{name=page list,
%description={A list of individual pages or page ranges
%(e.g.\ 1,2,4,7--9)}}
%\end{verbatim}
%
%\item Plural forms are assumed to be the singular form with an
%``s'' appended, unless otherwise specified. To specify an
%irregular plural, use the \gloskey{plural} key. For example:
%\begin{verbatim}
%\newglossaryentry{matrix}{name=matrix,
%description=rectangular array of quantities,
%plural=matrices}
%\end{verbatim}
%
%\item The way the term appears in the main text can be different
%from the way the term appears in the glossary:
%\begin{verbatim}
%\newglossaryentry{matrix}{name=Matrix,
%description=rectangular array of quantities,
%text=matrix,
%plural=matrices}
%\end{verbatim}
%In this example, the entry name appears as Matrix in the 
%glossary, and either matrix or matrices in the text.
%
%\item The way the term appears on first use can be different
%to the way it appears subsequently:
%\begin{verbatim}
%\newglossaryentry{singmtx}{name=Singular Matrix,
%description=A matrix with a zero determinant,
%first=singular matrix (SM),
%text=SM,
%firstplural=singular matrices (SMs)}
%\end{verbatim}
%In this example, the entry name appears as Singular Matrix in
%the glossary, and in the text it appears as singular matrix (SM)
%or singular matrices (SMs) the first time the entry is used,
%and subsequently appears as SM or SMs.
%
%\item The quick and easy way to define an acronym is to use:\par
%\icmdname{newacronym}\oarg{key-val list}\marg{label}\marg{abbrev}%
%\marg{long}\par
%For example:
%\begin{verbatim}
%\newacronym{svm}{SVM}{support vector machine}
%\end{verbatim}
%This is equivalent to:
%\begin{verbatim}
%\newglossaryentry{svm}{type=\acronymtype,
%name={SVM},
%description={support vector machine},
%text={SVM},
%first={support vector machine (SVM)},
%plural={SVMs},
%firstplural={support vector machines (SVMs)}}
%\end{verbatim}
%(The value of \icmdname{acronymtype} varies depending on whether
%the glossary package option \pkgopt{acronym} is used or not.
%The optional argument \meta{key-val list} can be used to
%override any of the \icmdname{newglossaryentry} keys, for
%example, if the acronym has an irregular plural.)
%
%\item The font used to display the entry name in the glossary
%is governed by \icmdname{glsnamefont}. This can be redefined
%as required. For example, to make the entry names appear
%in a medium sans-serif font do:
%\begin{verbatim}
%\renewcommand{\glsnamefont}[1]{\textsf{\mdseries #1}}
%\end{verbatim}
%Note that the list-like glossary styles defined in the
%\styname{glossary-list} package place the entry name in
%the optional argument to \icmdname{item}, so they will
%appear in bold, unless you redefine \icmdname{glsnamefont}.
%
%\item In the document use \icmdname{gls}\marg{label}
%to use a predefined term (this will also enter the term into 
%the associated glossary output file.) For example:
%\begin{verbatim}
%A \gls{singmtx} is a matrix with a zero determinant.
%\end{verbatim}
%
%\item Other variations:
%\begin{itemize}
%\item \icmdname{Gls}\marg{label} : like \cs{gls},
%but with first letter in upper case
%\item \icmdname{GLS}\marg{label} : like \cs{gls},
%but all upper case.
%\item \icmdname{glspl}\marg{label} : use plural
%\item \icmdname{Glspl}\marg{label} : use plural with
%first letter in upper case
%\item \icmdname{GLSpl}\marg{label} : use plural but
%all upper case
%\item \icmdname{glslink}\marg{label}\marg{link text} :
%use \meta{link text} to link to the given entry in the glossary.
%\end{itemize}
%For example, the following will produce the plural form with
%the first letter in uppercase:
%\begin{verbatim}
%\Glspl{singmtx} are matrices with a zero determinant.
%\end{verbatim}
%
%\item Additional text can be appended to the link using the
%end optional argument. For example, to form the possessive:
%\begin{verbatim}
%The \gls{singmtx}['s] dimensions are not necessarily equal.
%\end{verbatim}
%
%\item The format of the associated entry number can be
%changed using the \gloskey[glslink]{format} key in the optional argument.
%Note that the value of the \gloskey[glslink]{format} key should be the
%name of a command \emph{without} the initial backslash. For
%example:
%\begin{verbatim}
%The primary definition of \glspl[format=textbf]{singmtx}.
%\end{verbatim}
%In this example the relevant glossary entry will have the
%page number in bold (since it uses \cs{textbf}) but
%it will no longer have a hyperlink (if hyperlinks are enabled.)
%
%\item The \styname{glossaries} package provides commands to
%change the font whilst ensuring that the number remains a
%hyperlink. These are of the form \cs{hyper}\meta{xx} and
%are equivalent to the standard font changing commands of the
%form \cs{text}\meta{xx}, as well as \icmdname{hyperemph}
%(which uses \icmdname{emph}.) For example:
%\begin{verbatim}
%The primary definition of \glspl[format=hyperbf]{singmtx}.
%\end{verbatim}
%
%\item Entries can be added to the glossary without producing
%any text using \icmdname{glsadd}\marg{label} or
%\icmdname{glsaddall}. These commands also taken an optional
%argument where you can specify the format. For example
%\begin{verbatim}
%\glsadd[format=hyperbf]{singmtx}
%\end{verbatim}
%will add a line to the
%glossary file for the specified term, but will not produce
%any text where the command occurs.
%
%\item A number range can be entered using "format=(" and "format=)"
%to mark the beginning and ending of the range\footnote{This is new
%to version 1.01}. For example:
%\begin{verbatim}
% \glsadd[format=(]{singmtx}
% This is a very long section all about \glspl{singmtx}.
%
% % lots of text omitted
%
% \glsadd[format=)]{singmtx}
%\end{verbatim}
%This is equivalent to \appname{makeindex}'s "|(" and "|)" formats.
%
%\item You can combine the range markers with a formatting command
%(again without the preceding backslash.) For example:
%\begin{verbatim}
% This is the start of a very long section all 
% about \glspl[format=(hyperbf]{singmtx}.
%
% % lots of text omitted
%
% This is the end a very long section all about 
% \glspl[format=)hyperbf]{singmtx}.
%\end{verbatim}
%
%\item Only those terms that have actually been used in the
%document will be placed in the glossary. If you have defined
%a term that doesn't appear in the document, then it means
%you haven't used it in the text (either via \icmdname{glslink}
%or \icmdname{gls} and related commands, or via \icmdname{glsadd}
%or \icmdname{glsaddall}.)
%
%\item To change the sorting order, use the \gloskey{sort} key.
%For example:
%\begin{verbatim}
%\newglossaryentry{universal}{name={\ensuremath{\mathcal{U}}},
%description=The universal set,
%sort=U}
%\end{verbatim}
%
%\item You don't need to escape \appname{makeindex}'s special characters:
%\begin{verbatim}
%\newglossaryentry{quote}{name={"},
%description={Double quote character}}
%
%\newglossaryentry{exclam}{name={!},
%description={Exclamation mark}}
%
%\newacronym{rna}{RNA}{ribonukleins\"aure}
%\end{verbatim}
%
%\item Associated symbols can also be specified, but whether the
%symbol appears in the glossary depends on the glossary style.
%For example:
%\begin{verbatim}
%\newglossaryentry{metre}{name={metre},
%description={A metric measurement of length},
%symbol={m}}
%\end{verbatim}
%The predefined glossary styles that display the entry symbol
%are: \glostyle{long4col}, \glostyle{long4colheader},
%\glostyle{long4colborder}, \glostyle{long4colheaderborder},
%\glostyle{super4col}, \glostyle{super4colheader}, 
%\glostyle{super4colborder} and \glostyle{super4colheaderborder}.
%All the other styles supplied by this package ignore the associated 
%symbol.
%
%\item Glossary styles can be set using the \pkgopt{style} 
%package option. For example:
%\begin{verbatim}
%\usepackage[style=long3col]{glossary}
%\end{verbatim}
%or using \icmdname{glossarystyle}\marg{style}. For example:
%\begin{verbatim}
%\glossarystyle{altlist}
%\end{verbatim}
%The predefined glossary styles provided by the \styname{glossaries}
%bundle are detailed in \autoref{sec:styles}.
%
%\item The list of numbers associated with each glossary entry
%can be suppressed using the package option \pkgopt{nonumberlist}:
%\begin{verbatim}
%\usepackage[nonumberlist]{glossaries}
%\end{verbatim}
%
%\item By default, the glossaries will appear in an unnumbered 
%chapter if chapters are defined, otherwise in an unnumbered
%section. This can be changed using the \pkgopt{section} package
%option. For example, to make the glossaries appear in an unnumbered
%section, even if chapters are defined, do:
%\begin{verbatim}
%\usepackage[section]{glossaries}
%\end{verbatim}
%Other sectional units can also be specified as 
%\pkgopt{section}=\meta{value}. For example, to make the glossaries
%appear in unnumbered subsections:
%\begin{verbatim}
%\usepackage[section=subsection]{glossaries}
%\end{verbatim}
%
%\end{enumerate}
%
%\section{Overview}\label{sec:overview}
% \changes{1.02}{2007 May 25}{added overview section}
%
%\subsection{Package Options}
%
%The \styname{glossaries} package options are as follows:
%\begin{description}
%\item[\pkgopt{toc}] Add the glossaries to the table of contents
%\item[\pkgopt{section}] This is a key=value option. Its value should
%be the name of a sectional unit (e.g.\ "chapter"). This will make
%the glossaries appear in the named sectional unit, otherwise the
%each glossary will appear in an unnumber chapter, if chapters 
%exists, otherwise in an unnumbered section. Example:
%\begin{verbatim}
%\usepackage[section=subsection]{glossaries}
%\end{verbatim}
%You can omit the value if you want to use sections, i.e.\
%\begin{verbatim}
%\usepackage[section]{glossaries}
%\end{verbatim}
%is equivalent to
%\begin{verbatim}
%\usepackage[section=section]{glossaries}
%\end{verbatim}
%Note that the starred form of the sectioning command is always used
%since glossaries tend to be placed in unnumbered sections or chapters.
%If you want the glossaries to appeared in a numbered section, you
%will need to set \DescribeMacro{\glossarysection}\cs{glossarysection} 
%to the relevant sectioning command. For example, to make the 
%glossaries appear in numbered chapters, do:
%\begin{verbatim}
%\let\glossarysection\chapter
%\end{verbatim}
%
%\item[\pkgopt{style}] This is a key=value option. Its value should
%be the name of the glossary style to use.
%
%\item[\pkgopt{nonumberlist}] This option will suppress the 
%associated number lists\iterm{number list} in the glossaries (see also 
%\autoref{sec:numberlists}.)
%
%\item[\pkgopt{acronym}] Make a separate glossary for acronyms.
%
%\item[\pkgopt{counter}] This is a key=value option. The value should
%be the name of the default counter to use in the 
%number lists\iterm{number list}.
%
%\hypertarget{sanitize}{}\relax
%\item[\pkgopt{sanitize}] This is a key=value option whose value is a
%key=value list. By default, the \styname{glossaries} package
%sanitizes the values of the \gloskey{name}, \gloskey{description} and
%\gloskey{symbol} keys used when defining a new glossary entry. This
%may lead to unexpected results if you try to
%display these values within the document text. This sanitization can
%be switched off using the \pkgopt{sanitize} package option. (See
%\autoref{sec:pkgopt} and \autoref{sec:newentry} for further details.)
%For example, to switch off the sanitization for the 
%\gloskey{description} and \gloskey{name} keys, but not for
%the \gloskey{symbol} key, do:
%\begin{verbatim}
%\usepackage[sanitize={name=false,description=false,%
%symbol=true}]{glossaries}
%\end{verbatim}
%
%\textbf{Note}: this sanitization only applies to the \gloskey{name}, 
%\gloskey{description} and \gloskey{symbol} keys. It doesn't apply
%to any of the other keys (except the \gloskey{sort} key which is
%always sanitized) so fragile commands contained in the value of
%the other keys must always be protected using \cs{protect}.
%Since the value of the \gloskey{text} key is obtained from the
%\gloskey{name} key, you will still need to protect fragile commands
%in the \gloskey{name} key if you don't use the \gloskey{text} key. 
%
%\end{description}
%
%\subsection{Defining Glossary Entries}
%\label{sec:newglosentry}
%
%All glossary entries that are used in a document must be defined in
%the preamble. Only those entries that occur in the document
%(using any of the commands described in \autoref{sec:glslink} and
%\autoref{sec:glsadd}) will appear in the glossary. Each time an entry
%is used in this way, a line is added to an associated glossary (.glo)
%file, which then needs to be converted into a corresponding .gls file
%which contains the typeset glossary. The Perl script
%\appname{makeglossaries} can be used to call \appname{makeindex}
%using a customised style file for each of the glossaries that are
%defined in the document.
%
%\DescribeMacro{\makeglossaries}
%The command \cs{makeglossaries} must be placed in the preamble,
%in order to create the customised \appname{makeindex} style file,
%and to ensure that glossary entries are written to the appropriate
%output file.
%
%\DescribeMacro{\newglossaryentry}
%New glossary entries are defined using the command:\\[10pt]
%\cs{newglossaryentry}\marg{label}\marg{key-val list}\\[10pt]
%The first argument, \meta{label}, must be a unique label with which to
%identify this entry. The second argument, \meta{key-val list},
%is a key=value list that supplies the relevant information about this
%entry. There are two required fields: \gloskey{name} and
%\gloskey{description}. Available fields are listed below:
%
%\begin{description}
%\item[{\gloskey{name}}] The name of the entry (as it will appear in the
%glossary.)
%\item[{\gloskey{description}}] A brief description of this term (to
%appear in the glossary.)
%\item[{\gloskey{text}}] How this entry will appear in the document text
%when using \icmdname{gls} (or one of its
%uppercase variants.) If this field is omitted, the value of the
%\gloskey{name} key is used.
%\item[{\gloskey{first}}] How the entry will appear in the document text
%the first time it is used with \icmdname{gls}
%(or one of its uppercase variants.) If this field is omitted,
%the value of the \gloskey{text} key is used.
%\item[{\gloskey{plural}}] How the entry will appear in the document text
%when using \icmdname{glspl} (or one of its uppercase variants.)
%If this field is omitted, the value is obtained by appending an
%``s'' to the value of the \gloskey{text} field.
%\item[{\gloskey{firstplural}}] How the entry will appear in the document
%text the first time it is used with \icmdname{glspl} (or one of
%its uppercase variants.) If this field is omitted, the value is
%obtained by appending an ``s'' to the value of the \gloskey{first}
%field.
%\item[{\gloskey{symbol}}] This field is provided to allow the user to
%specify an associated symbol, but most glossary styles ignore
%this value. If omitted, the value is set to \cs{relax}.
%\item[{\gloskey{sort}}] This value indicates how \appname{makeindex} 
%should sort this entry. If omitted, the value is given by  
%the \gloskey{name} field.
%This value is equivalent to \appname{makeindex}'s ``actual''
%character (which is usually the at-sign @.)
%\item[{\gloskey{type}}] This is the glossary type to which this entry
%belongs. If omitted, the default glossary is assumed.
%\end{description}
%
%\DescribeMacro{\loadglsentries}
%You can store all your glossary entry definitions in another
%file, and use:\\[10pt]
%\cs{loadglsentries}\oarg{type}\marg{filename}\\[10pt]
%where \meta{filename} is the name of the file containing all the
%\cs{newglossaryentry} commands. The optional argument
%\meta{type} is the name of the glossary to which those entries
%should belong, for those entries where the \gloskey{type} key has 
%been omitted. Note that only those entries that have been used
%in the text will appear in the relevant glossaries.
%
%\subsection{Number lists}
%\label{sec:numberlists}
%
%Each entry in the glossary has an associated \termdef{number list}. 
%By default,
%these numbers refer to the pages on which that entry has been used
%(using any of the commands described in \autoref{sec:glslink}
%and \autoref{sec:glsadd}.) The number list can be suppressed using
%the \pkgopt{nonumberlist} package option, or an alternative counter
%can be set as the default using the \pkgopt{counter} package option.
%
%\subsection{Links to Glossary Entries}
%\label{sec:glslink}
%
%Once you have defined a glossary entry using 
%\icmdname{newglossaryentry}, you can refer to that entry in the
%document using one of the commands listed in this section. The
%text which appears at that point in the document when using 
%one of these commands is referred to as the 
%\termdef{link text} (even if there are no hyperlinks.)
%
%The way the \term{link text} is displayed 
%depends on \DescribeMacro{\glstextformat}\cs{glstextformat}\marg{text}.
%For example, to make all \term{link text} appear in a sans-serif
%font, do:
%\begin{verbatim}
%\renewcommand*{\glstextformat}[1]{\textsf{#1}}
%\end{verbatim}
%
%\DescribeMacro{\glslink}
%The command:\\[10pt]
%\cs{glslink}\oarg{options}\marg{label}\marg{text}\\[10pt]
%will place \meta{text} in the document at that point, and add
%a line into the associated glossary file for the glossary entry
%given by \meta{label}. If hyperlinks are supported, \meta{text}
%will be a hyperlink to the relevant line in the glossary. The
%optional argument \meta{options} must be a key=value list which
%can take any of the following keys:
%
%\begin{description}
%\item[{\gloskey[glslink]{format}}] This specifies how to format
%the associated number for this entry in the glossary. This value
%is equivalent to the \appname{makeindex} encap value, and (as with
%\cs{index}) the value needs to be the name of a 
%command \emph{without} the initial backslash. As with
%\cs{index}, the characters "(" and ")" can also be used to 
%specify the beginning and ending of a number range.
%Again, as with \cs{index} the command should be the name of a 
%command which takes an argument (which will be the associated number.)
%Be careful not to use a declaration (such as \cs{bfseries}) instead of 
%a text block command (such as \cs{textbf}) as the effect will not be
%localised. If you want to apply more than one
%style to a given entry (e.g.\ \textbf{bold} and \emph{italic}) you
%will need to create a command that applies both formats, e.g.\ 
%\begin{verbatim}
%\newcommand*{\textbfem}[1]{\textbf{\emph{#1}}}
%\end{verbatim}
%and use that command. (Just as you would have to do with \cs{index}.)
%
%If you are using hyperlinks, and you want to change the font of the
%hyperlink, don't use \cs{hyperpage} (provided by the \styname{hyperref}
%package) as the numbers may not refer to a page number.
%Instead, the \styname{glossaries} package provides the following 
%number formats:
%\begin{center}
%\begin{tabular}{@{\sffamily}lp{0.8\linewidth}}
%hyperrm & The number is a serif hyperlink to the relevant part of the 
%document\\
%hypersf & The number is a sans-serif hyperlink to the relevant part 
%of the document\\
%hypertt & The number is a monospaced hyperlink to the relevant part 
%of the document\\
%hyperbf & The number is a bold hyperlink to the relevant part of the 
%document\\
%hypermd & The number is a medium weight hyperlink to the relevant 
%part of the document\\
%hyperit & The number is an italic hyperlink to the relevant 
%part of the document\\
%hypersl & The number is a slanted hyperlink to the relevant 
%part of the document\\
%hyperup & The number is an upright hyperlink to the relevant 
%part of the document\\
%hypersc & The number is a small caps hyperlink to the relevant 
%part of the document\\
%hyperemph & The number is an emphasized hyperlink to the relevant 
%part of the document\\
%\end{tabular}
%\end{center}
%Note that if the \cs{hyperlink} command hasn't been defined,
%the "hyper"\meta{xx} formats are equivalent to the
%analogous \cs{text}\meta{xx} font commands. If you want to
%make a new format, you will need to define a command which takes
%one argument, for example, if you want the associated number in
%the glossary to be in a bold sans-serif font, you can define a
%command called, say, \cs{hyperbsf}:
%\begin{verbatim}
%\newcommand{\hyperbsf}[1]{\textbf{\hypersf{#1}}}
%\end{verbatim}
%and then use "hyperbsf" as the value for the \gloskey{format} key.
%(See also \autoref{sec:printglos}.)
%
%\item[{\gloskey[glslink]{counter}}] This specifies which counter
%to use for the associated number for this glossary entry. (See also
%\autoref{sec:numberlists}.)
%
%\item[{\gloskey[glslink]{hyper}}] This is a boolean key which can
%be used to enable/disable the hyperlink to the relevant entry
%in the glossary. (Note that setting "hyper=true" will have no
%effect if \cs{hyperlink} has not been defined.) The default
%value is "hyper=true".
%
%\end{description}
%\DescribeMacro{\glslink*}
%There is also a starred version:\\[10pt]
%\cs{glslink*}\oarg{options}\marg{label}\marg{text}\\[10pt]
%which is equivalent to \cs{glslink}, except it sets
%"hyper=false".
%
%\DescribeMacro{\gls}
%The command:\\[10pt]
%\cs{gls}\oarg{options}\marg{label}\oarg{insert}\\[10pt]
%is the same as \cs{glslink}, except that the \term{link text}
%is determined from the values of the \gloskey{text} and 
%\gloskey{first} keys supplied when the entry was defined using
%\icmdname{newglossaryentry}. There are two uppercase variants:\\[10pt]
%\DescribeMacro{\Gls}
%\cs{Gls}\oarg{options}\marg{label}\oarg{insert}\\[10pt]
%and
%\DescribeMacro{\GLS}
%\cs{GLS}\oarg{options}\marg{label}\oarg{insert}\\[10pt]
%which make the first letter of the link, or all the link text,
%uppercase, respectively.
%
%The final optional argument \meta{insert}, allows you to insert
%some additional text into the link text. By default, this will
%append \meta{insert} at the end of the link text. The first optional
%argument, \meta{options}, is the same as the optional argument to
%\icmdname{glslink}.
%
%There are also analogous plural forms:\\[10pt]
%\DescribeMacro{\glspl}
%\cs{glspl}\oarg{options}\marg{label}\oarg{insert}\\[10pt]
%\DescribeMacro{\Glspl}
%\cs{Glspl}\oarg{options}\marg{label}\oarg{insert}\\[10pt]
%\DescribeMacro{\GLSpl}
%\cs{GLSpl}\oarg{options}\marg{label}\oarg{insert}\\[10pt]
%These determine the link text from the \gloskey{plural} and
%\gloskey{firstplural} keys supplied when the entry was first
%defined.
%
%To make the description or symbol also appear in the \term{link text},
%you will need to redefine \cs{glsdisplayfirst} and \cs{glsdisplay}
%or use the commands \cs{defglsdisplayfirst} and \cs{defglsdisplay}.
%See \autoref{sec:code:glslink} for further details. (Note that if you
%want either the description or symbol to appear in the 
%\term{link text}, you will have to disable the 
%\hyperlink{sanitize}{sanitization} of these 
%keys, and protect fragile commands.)
%
%\subsection{Adding an entry to the glossary without generating text}
%\label{sec:glsadd}
%
%\DescribeMacro{\glsadd}
%It is also possible to add a line in the glossary file without
%generating any text at that point in the document.\\[10pt]
%\cs{glsadd}\oarg{options}\marg{label}\\[10pt]
%This is similar to \icmdname{glslink}, only it doesn't produce
%any text (so therefore, there is no \gloskey[glslink]{hyper} key
%available in \meta{options}.)
%
%\DescribeMacro{\glsaddall}
%To add a line for all entries that have been defined, use:\\[10pt]
%\cs{glsaddall}\oarg{glossary list}\\[10pt]
%If there are multiple glossaries, you can specify to add only
%those entries which belong to the glossaries listed in
%\meta{glossary list} (which must be a comma separated list of
%glossary names.)
%
%\subsection{Displaying a glossary}
%
%\DescribeMacro{\printglossaries}
%The command \cs{printglossaries} will display all the
%defined glossaries. Note that no glossaries will appear until
%you have either used the Perl script \appname{makeglossaries}
%or have directly used \appname{makeindex}. If the glossary still
%does not appear, after you re-\LaTeX\ your document, then check
%the \appname{makeindex} log files to see if there is a problem.
%
%\DescribeMacro{\printglossary}
%An individual glossary is displayed using:\\[10pt]
%\cs{printglossary}\oarg{options}\\[10pt]
%where \meta{options} is a key-val list of options. The following
%keys are available:
%\begin{description}
%\item[{\gloskey[printglossary]{type}}] The value of this key
%specifies which glossary to print. If omitted, the default
%glossary is assumed.
%
%\item[{\gloskey[printglossary]{title}}] This is the glossary's
%title (overriding the title specified when the glossary was 
%defined.)
%
%\item[{\gloskey[printglossary]{toctitle}}] This is the title
%to use for the table of contents (if the \pkgopt{toc} package
%option has been used.)
%
%\item[{\gloskey[printglossary]{style}}] This specifies which
%glossary style to use for this glossary.
%\end{description}
%
%\subsection{Defining New Glossaries}
%
%\DescribeMacro{\newglossary}
%A new glossary can be defined using:\\[10pt]
%\cs{newglossary}\oarg{log-ext}\marg{name}\marg{in-ext}\marg{out-ext}\marg{title}\oarg{counter}\\[10pt]
%where \meta{name} is label to assign to this glossary. (Note that
%the default glossary is labelled "main" and if you use the
%\pkgopt{acronym} package option, there will also be a glossary
%called "acronym".) The arguments \meta{in-ext} and \meta{out-ext}
%specify the extensions to give to the input and output files
%for that glossary, \meta{title} is the default title for this
%new glossary and the final optional argument \meta{counter} specifies
%which counter to use for the associated 
%number lists\iterm{number list} (see also
%\autoref{sec:numberlists}.) The first optional argument specifies
%the extension for the \appname{makeindex} transcript file (this 
%information is only used by \appname{makeglossaries} which picks
%up the information from the auxiliary file.)
%
%\subsection{Acronyms}
%
%\DescribeMacro{\newacronym}
%As you may have noticed in \autoref{sec:newglosentry}, when you
%specify a new entry, you can specify alternate text to use when
%the term is first used in the document, this provides a useful
%means to define acronyms. The \styname{glossaries} package defines
%the command:\\[10pt]
%\cs{newacronym}\oarg{key-val list}\marg{label}\marg{abbrv}\marg{long}\\[10pt]
%This is equivalent to:\vskip5pt
%\begin{ttfamily}\obeylines
%\cs{newglossaryentry}\textrm{\marg{label}}\{type=\cs{acronymtype},
%name=\textrm{\marg{abbrv}},
%description=\textrm{\marg{long}},
%text=\textrm{\marg{abbrv}},
%first=\{\textrm{\meta{long}} (\textrm{\meta{abbrv}})\},
%plural=\{\textrm{\meta{abbrv}}s\},
%firstplural=\{\textrm{\meta{long}}s (\textrm{\meta{abbrv}}s)\},
%\textrm{\meta{key-val list}}\}
%\end{ttfamily}
%\vskip5pt
%The command \cs{acronymtype} is the name of the glossary
%in which the acronyms should appear. If the \pkgopt{acronym}
%package option has been used, this will be "acronym", otherwise
%it will be "main". The acronyms can then be used in exactly
%the same way as any other glossary entry.
%
%As you can see from the above, \cs{newacronym} sets the 
%description to the long form of the acronym. You may prefer to
%have a description, and set the name to both the long and abbreviated
%forms. For example, the following defines the acronym IDN:
%\begin{verbatim}
%\newacronym[name={identification number (IDN)},
%description={A number uniquely identifying a particular
%object}]{idn}{IDN}{identification number}
%\end{verbatim}
%Alternatively:
%\begin{verbatim}
%\newacronym[description={identification number --- a number uniquely 
%identifying a particular object}]{idn}{IDN}{identification number}
%\end{verbatim}
%
%\subsection{Glossary Styles}
%The \styname{glossaries} package comes with some pre-defined
%glossary styles. These are as follows:
%\begin{description}
%\item[list] The \glostyle{list} style uses the \envname{description}
%environment. The entry name is placed in the optional argument
%of the \cs{item} command (so it will appear in bold by
%default). The description follows, and then the associated number
%list for that entry.
%
%\item[listgroup] The \glostyle{listgroup} style is like 
%\glostyle{list}, but the glossary groups have headings.
%
%\item[listhypergroup] The \glostyle{listhypergroup} style is like 
%\glostyle{listgroup}, but has a set of links to the glossary 
%groups.
%
%\item[altlist] The \glostyle{altlist} style is like \glostyle{list}
%but the description is placed on the following line.
%
%\item[altlistgroup] The \glostyle{altlistgroup} style is like 
%\glostyle{altlist}, but the glossary groups have headings.
%
%\item[altlisthypergroup] The \glostyle{altlisthypergroup} style is like 
%\glostyle{altlistgroup}, but has a set of links to the glossary 
%groups.
%
%\item[long] The \glostyle{long} style uses the \envname{longtable}
%environment. It has two columns, the first column contains the
%entry's name, the second column contains the description followed
%by the \term{number list}.
%
%\item[longborder] The \glostyle{longborder} style is like
%\glostyle{long}, but has horizontal and vertical lines around it.
%
%\item[longheader] The \glostyle{longheader} style is like
%\glostyle{long}, but has a header row.
%
%\item[longheaderborder] The \glostyle{longheaderborder} style is
%like \glostyle{longheader}, but has horizontal and vertical lines
%around it.
%
%\item[long3col] The \glostyle{long3col} style is like
%\glostyle{long} but has three columns. The first column contains
%the entry's name, the second column contains the description
%and the third column contains the \term{number list}.
%
%\item[long3colborder] The \glostyle{long3colborder} style is like
%the \glostyle{long3col} style but has horizontal and vertical
%lines around it.
%
%\item[long3colheader] The \glostyle{long3colheader} style is like
%\glostyle{long3col}, but has a header row.
%
%\item[long3colheaderborder] The \glostyle{long3colheaderborder} style is
%like \glostyle{long3colheader}, but has horizontal and vertical lines
%around it.
%
%\item[long4col] The \glostyle{long4col} style is like 
%\glostyle{long3col} but has an additional column in which the
%entry's associated symbol appears.
%
%\item[long4colborder] The \glostyle{long4colborder} style is like
%the \glostyle{long4col} style but has horizontal and vertical
%lines around it.
%
%\item[long4colheader] The \glostyle{long4colheader} style is like
%\glostyle{long4col}, but has a header row.
%
%\item[long4colheaderborder] The \glostyle{long4colheaderborder} style is
%like \glostyle{long4colheader}, but has horizontal and vertical lines
%around it.
%
%\item[super] The \glostyle{super} style uses the \envname{supertabular}
%environment. It has two columns, the first column contains the
%entry's name, the second column contains the description followed
%by the \term{number list}.
%
%\item[superborder] The \glostyle{superborder} style is like
%\glostyle{super}, but has horizontal and vertical lines around it.
%
%\item[superheader] The \glostyle{superheader} style is like
%\glostyle{super}, but has a header row.
%
%\item[superheaderborder] The \glostyle{superheaderborder} style is
%like \glostyle{superheader}, but has horizontal and vertical lines
%around it.
%
%\item[super3col] The \glostyle{super3col} style is like
%\glostyle{super} but has three columns. The first column contains
%the entry's name, the second column contains the description
%and the third column contains the \iterm{number list}.
%
%\item[super3colborder] The \glostyle{super3colborder} style is like
%the \glostyle{super3col} style but has horizontal and vertical
%lines around it.
%
%\item[super3colheader] The \glostyle{super3colheader} style is like
%\glostyle{super3col}, but has a header row.
%
%\item[super3colheaderborder] The \glostyle{super3colheaderborder} style is
%like \glostyle{super3colheader}, but has horizontal and vertical lines
%around it.
%
%\item[super4col] The \glostyle{super4col} style is like 
%\glostyle{super3col} but has an additional column in which the
%entry's associated symbol appears.
%
%\item[super4colborder] The \glostyle{super4colborder} style is like
%the \glostyle{super4col} style but has horizontal and vertical
%lines around it.
%
%\item[super4colheader] The \glostyle{super4colheader} style is like
%\glostyle{super4col}, but has a header row.
%
%\item[super4colheaderborder] The \glostyle{super4colheaderborder} style is
%like \glostyle{super4colheader}, but has horizontal and vertical lines
%around it.
%
%\end{description}
%
%The glossary style can be set using the \pkgopt{style} package option,
%or using the \gloskey[printglossary]{style} key in the optional
%argument to \icmdname{printglossary}, or using the command:\\[10pt]
%\cs{glossarystyle}\marg{style-name}\\[10pt]
%For further details on creating or modifying glossary styles see 
%\autoref{sec:printglos} and \autoref{sec:styles}.
%
% \changes{1.03}{2007 July 4}{'glspostdescription added}
%All the styles except for the three and four column styles use the
%command \DescribeMacro{\glspostdescription}\cs{glspostdescription}
%after the description. This simply displays a full stop by default.
%To eliminate this full stop (or replace it with something else,
%say a comma), you will need to redefine \cs{glspostdescription}
%before the glossary is displayed.
%
% \StopEventually{\phantomsection\addcontentsline{toc}{section}{Index}\PrintIndex}
%
%
%
%
%\section{Documented Code}
%\iffalse
%    \begin{macrocode}
%<*glossaries.sty>
%    \end{macrocode}
%\fi
%\label{sec:code}
% \subsection{Package Definition}
% This package requires \LaTeXe.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries}[2007/09/13 v1.07 (NLCT)]
%    \end{macrocode}
% Required packages:
%    \begin{macrocode}
\RequirePackage{ifthen}
\RequirePackage{xkeyval}[2006/11/18]
\RequirePackage{xspace}
%    \end{macrocode}
%
% \subsection{Package Options}\label{sec:pkgopt}
% The \pkgopt{toc} package option will add the glossaries 
% to the table of contents. This is a boolean key, if the
% value is omitted it is taken to be true.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{toc}[true]{}
%    \end{macrocode}
%
% The sectional unit used to start the glossary is stored in
% \cs{@@glossarysec}. If chapters are defined, this
% is initialised to \texttt{chapter}, otherwise it is
% initialised to \texttt{section}.
%\begin{macro}{\@@glossarysec}
%    \begin{macrocode}
\@ifundefined{chapter}{\newcommand*{\@@glossarysec}{section}}{%
\newcommand*{\@@glossarysec}{chapter}}
%    \end{macrocode}
%\end{macro}
% The \pkgopt{section} key can be used to set the sectional unit.
% If no unit is specified, use \texttt{section} as the default.
% The starred form of the named sectional unit will be used.
% If you want some other way to start the glossary section (e.g.\ 
% a numbered section) you will have to redefined 
% \icmdname{glossarysection}.
%    \begin{macrocode}
\define@choicekey{glossaries.sty}{section}{part,chapter,section,%
subsection,subsubsection,paragraph,subparagraph}[section]{%
\renewcommand*{\@@glossarysec}{#1}}
%    \end{macrocode}
%
% The default glossary style is stored in 
% \cs{@glossary@default@style}. This is initialised to
% \texttt{list}. (The \glostyle{list} style is
% defined in the accompanying \styname{glossary-list} package
% described in \autoref{sec:styles}.)
%\begin{macro}{\@glossary@default@style}
%    \begin{macrocode}
\newcommand*{\@glossary@default@style}{list}
%    \end{macrocode}
%\end{macro}
% The default glossary style can be changed using the \pkgopt{style}
% package option. The value can be the name of any
% defined glossary style. The glossary style is set at the beginning
% of the document, so you can still use the \pkgopt{style} key to
% set a style that is defined in another package. This package comes
% with some predefined styles that are defined in 
% \autoref{sec:styles}.
%    \begin{macrocode}
\define@key{glossaries.sty}{style}{%
\renewcommand*{\@glossary@default@style}{#1}}
%    \end{macrocode}
%
% Each entry within a given glossary will have an associated
% number list. By default, this refers to the page numbers on
% which that entry has been used, but it can also refer to any counter
% used in the document (such as the section or equation counters).
% The default number list format displays the number list ``as is'':
%\begin{macro}{\glossaryentrynumbers}
%    \begin{macrocode}
\newcommand*{\glossaryentrynumbers}[1]{#1}
%    \end{macrocode}
%\end{macro}
% Note that the entire number list for a given entry will be
% passed to \cs{glossaryentrynumbers} so any font changes
% will also be applied to the delimiters.
% The \pkgopt{nonumberlist} package option suppresses the 
% number lists (this simply redefines 
% \cs{glossaryentrynumbers} to ignores its argument.)
%    \begin{macrocode}
\DeclareOptionX{nonumberlist}{%
\renewcommand*{\glossaryentrynumbers}[1]{}}
%    \end{macrocode}
%
% Keep track of the default glossary. This is initialised to
% the main glossary, but can be changed if for some reason
% you want to make a secondary glossary the main glossary. This
% affects any commands that can optionally take a glossary name
% as an argument (or as the value of the 
% \gloskey{type}\igloskey[printglossary]{type} key in 
%a key-value list.) This was mainly done so that 
% \icmdname{loadglsentries} can temporarily change 
% \cs{glsdefaulttype} while it loads a file containing
% new glossary entries (see \autoref{sec:load}).
%\begin{macro}{\glsdefaulttype}
%    \begin{macrocode}
\newcommand{\glsdefaulttype}{main}
%    \end{macrocode}
%\end{macro}
% Keep track of which glossary the acronyms are in. This is 
% initialised to \cs{glsdefaulttype}, but is changed by
% the \pkgopt{acronym} package option.
%\begin{macro}{\acronymtype}
%    \begin{macrocode}
\newcommand{\acronymtype}{\glsdefaulttype}
%    \end{macrocode}
%\end{macro}
% The \pkgopt{acronym} option sets an associated conditional 
% which is used in \autoref{sec:acronym} to determine whether
% or not to define a separate glossary for acronyms.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{acronym}[true]{}
%    \end{macrocode}
%
% The default counter associated with the numbers in the glossary
% is stored in \cs{glscounter}. This is initialised to the 
% page counter. This is used as the default counter when a
% new glossary is defined, unless a different counter is specified
% in the optional argument to \icmdname{newglossary} (see
% \autoref{sec:newglos}).
%\begin{macro}{\glscounter}
%    \begin{macrocode}
\newcommand{\glscounter}{page}
%    \end{macrocode}
%\end{macro}
% The \pkgopt{counter} option changes the default counter. (This
% just redefines \cs{glscounter}.)
%    \begin{macrocode}
\define@key{glossaries.sty}{counter}{%
\renewcommand*{\glscounter}{#1}}
%    \end{macrocode}
%
% The glossary keys whose values are written to another file (i.e.\
% \gloskey{sort}, \gloskey{name}, \gloskey{description} and
% \gloskey{symbol}) need to be sanitized, otherwise fragile
% commands would not be able to be used in 
% \icmdname{newglossaryentry}. However, strange results will occur
% if you then use those fields in the document. As these fields
% are not normally used in the document, but are by default only
% used in the glossary, the default is to sanitize them. If however
% you want to use these values in the document (either by redefining
% commands like \icmdname{glsdisplay} or by using commands like
% \icmdname{glsentrydesc}) you will have to switch off the 
% sanitization using the \pkgopt{sanitize} package option, but
% you will then have to use \icmdname{protect} to protect fragile 
% commands when defining new glossary entries. 
% The \pkgopt{sanitize} option
% takes a key-value list as its value, which can be used to 
% switch individual values on and off. For example:
%\begin{verbatim}
%\usepackage[sanitize={description,name,symbol=false}]{glossaries}
%\end{verbatim}
%will switch off the sanitization for the \gloskey{symbol} key, but
% switch it on for the \gloskey{description} and \gloskey{name} keys.
% This would mean that you can use fragile commands in the
%description and name when defining a new glossary entry, but not
% for the symbol.
%
% The default values are defined as:
%\begin{macro}{\@gls@sanitizedesc}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizedesc}{\@onelevel@sanitize\@glo@desc}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@sanitizename}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizename}{\@onelevel@sanitize\@glo@name}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@sanitizesymbol}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizesymbol}{\@onelevel@sanitize\@glo@symbol}
%    \end{macrocode}
%\end{macro}
% (There is no equivalent for the \gloskey{sort} key, since that
% is only provided for the benefit of \appname{makeindex}, and
% so will always be sanitized.)
%
% Before defining the \pkgopt{sanitize} package option, The 
% key-value list for the \pkgopt{sanitize} value needs to be defined.
% These are all boolean keys. If they are not given a value, assume
% \texttt{true}.
%
% Firstly the \gloskey{description}. If set, it will redefine
% \cs{@gls@sanitizedesc} to use \cs{@onelevel@sanitize},
% otherwise \cs{@gls@sanitizedesc} will do nothing.
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{description}[true]{%
\ifgls@sanitize@description
  \renewcommand*{\@gls@sanitizedesc}{\@onelevel@sanitize\@glo@desc}%
\else
  \renewcommand*{\@gls@sanitizedesc}{}%
\fi
}
%    \end{macrocode}
% Similarly for the \gloskey{name} key:
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{name}[true]{%
\ifgls@sanitize@name
  \renewcommand*{\@gls@sanitizename}{\@onelevel@sanitize\@glo@name}%
\else
  \renewcommand*{\@gls@sanitizename}{}%
\fi}
%    \end{macrocode}
% and for the \gloskey{symbol} key:
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{symbol}[true]{%
\ifgls@sanitize@symbol
  \renewcommand*{\@gls@sanitizesymbol}{%
\@onelevel@sanitize\@glo@symbol}%
\else
  \renewcommand*{\@gls@sanitizesymbol}{}%
\fi}
%    \end{macrocode}
% Now define the \pkgopt{sanitize} option. It can either take
% a key-val list as its value, or it can take the keyword
% \texttt{none}, which is equivalent to \texttt{description=false,
% symbol=false, name=false}:
%    \begin{macrocode}
\define@key{glossaries.sty}{sanitize}[description=true,symbol=true,
name=true]{%
\ifthenelse{\equal{#1}{none}}{%
\renewcommand*{\@gls@sanitizedesc}{}%
\renewcommand*{\@gls@sanitizename}{}%
\renewcommand*{\@gls@sanitizesymbol}{}%
}{\setkeys[gls]{sanitize}{#1}}%
}
%    \end{macrocode}
% Process package options:
%    \begin{macrocode}
\ProcessOptionsX
%    \end{macrocode}
%
% If chapters are defined and the user has requested the
% section counter as a package option, \cs{@chapter} will
% be modified so 
% that it adds a \texttt{section.}\meta{n}\texttt{.0} target, 
% otherwise entries placed before the first section of a chapter
% will have undefined links.
%
% The same problem will also occur if a lower sectional unit is
% used, but this is less likely to happen. If it does, or if
% you change \cs{glscounter} to "section" later, you
% will have to specify a different counter for the entries
% that give rise to a \texttt{name}"{"\meta{section-level}"."\meta{n}".0}"
% non-existent warning (e.g. "\gls[counter=chapter]{label}").
%    \begin{macrocode}
\ifthenelse{\equal{\glscounter}{section}}{%
\@ifundefined{chapter}{}{%
\let\@gls@old@chapter\@chapter
\def\@chapter[#1]#2{\@gls@old@chapter[{#1}]{#2}%
\@ifundefined{hyperdef}{}{\hyperdef{section}{\thesection}{}}}}}{}
%    \end{macrocode}
%
%\subsection{Default values}
% This section sets up default values that are used by this
% package. Some of the names may already be defined (e.g.\ by
% \styname{babel}) so \cs{providecommand} is used.
%
% Main glossary title:
%\begin{macro}{\glossaryname}
%    \begin{macrocode}
\providecommand*{\glossaryname}{Glossary}
%    \end{macrocode}
%\end{macro}
% The title for the "acronym" glossary type (which is defined if 
% \pkgopt{acronym} package option is used) is given by
% \cs{acronymname}. If the \pkgopt{acronym}
% package option is not used, \cs{acronymname} won't be used.
%\begin{macro}{\acronymname}
%    \begin{macrocode}
\providecommand*{\acronymname}{Acronyms}
%    \end{macrocode}
%\end{macro}
%
% The following commands provide text for the headers used by 
% some of the tabular-like glossary 
% styles. Whether or not they get used in the glossary depends on
% the glossary style.
%\begin{macro}{\entryname}
%    \begin{macrocode}
\providecommand*{\entryname}{Notation}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\descriptionname}
%    \begin{macrocode}
\providecommand*{\descriptionname}{Description}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\symbolname}
%    \begin{macrocode}
\providecommand*{\symbolname}{Symbol}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\pagelistname}
%    \begin{macrocode}
\providecommand*{\pagelistname}{Page List}
%    \end{macrocode}
%\end{macro}
% Labels for \appname{makeindex}'s symbol and number groups:
%\begin{macro}{\glssymbolsgroupname}
%    \begin{macrocode}
\providecommand*{\glssymbolsgroupname}{Symbols}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsnumbersgroupname}
%    \begin{macrocode}
\providecommand*{\glsnumbersgroupname}{Numbers}
%    \end{macrocode}
%\end{macro}
% The description terminator is given by \cs{glspostdescription}
% (except for the 3 and 4 column styles). This is a full stop
% by default:
%\begin{macro}{\glspostdescription}
%    \begin{macrocode}
\newcommand*{\glspostdescription}{.}
%    \end{macrocode}
%\end{macro}
%
% The name of the \appname{makeindex} style file is given by
% \cs{istfilename}. This file is 
% created by \icmdname{writeist} (which is used by 
% \icmdname{makeglossaries}) so
% redefining this command will only have an effect if it is 
% done \emph{before} the \filetype{ist} file is created.
%\begin{macro}{\istfilename}
%    \begin{macrocode}
\providecommand*{\istfilename}{\jobname.ist}
%    \end{macrocode}
%\end{macro}
% The \appname{makeglossaries} Perl script picks up this name
% from the auxiliary file and passes it to \appname{makeindex}
% using the \texttt{-s} option. Since its not required by
% \LaTeX, \cs{@istfilename} ignores its argument.
%\begin{macro}{\@istfilename}
%    \begin{macrocode}
\newcommand*{\@istfilename}[1]{}
%    \end{macrocode}
%\end{macro}
%
% This command is the value of the \istkey{page\_compositor}
% \appname{makeindex} key. Again, any redefinition of this command 
% must take place \emph{before} \cs{writeist} otherwise it 
% will have no effect.
%\begin{macro}{\glscompositor}
%    \begin{macrocode}
\newcommand{\glscompositor}{.}
%    \end{macrocode}
%\end{macro}
% (The page compositor is usually defined as a dash when using
% \appname{makeindex}, but most of the standard counters used
% by \LaTeX\ use a full stop as the compositor, which is why I
% have used it as the default.)
%
% The command \cs{glsnumberformat} indicates the default
% format for the page numbers in the glossary. (Note that this
% is not the same as \icmdname{glossaryentrynumbers}, but applies
% to individual numbers or groups of numbers within an entry's
% associated number list.) If hyperlinks are defined, it will use
% \icmdname{glshypernumber}, otherwise it will simply display its 
% argument ``as is''.
%\begin{macro}{\glsnumberformat}
%    \begin{macrocode}
\@ifundefined{hyperlink}{%
\newcommand*{\glsnumberformat}[1]{#1}}{%
\newcommand*{\glsnumberformat}[1]{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
% Individual numbers in an entry's associated number list are
% delimited using \cs{delimN} (which corresponds to the 
% \istkey{delim\_n} \appname{makeindex} keyword.) The default value
% is a comma followed by a space.
%\begin{macro}{\delimN}
%    \begin{macrocode}
\newcommand{\delimN}{, }
%    \end{macrocode}
%\end{macro}
% A range of numbers within an entry's associated number list is
% delimited using \cs{delimR} (which corresponds to the
% \istkey{delim\_r} \appname{makeindex} keyword.) The default is
% an en-dash.
%\begin{macro}{\delimR}
%    \begin{macrocode}
\newcommand{\delimR}{--}
%    \end{macrocode}
%\end{macro}
%
% The glossary preamble is given by \cs{glossarypreamble}. This
% will appear after the glossary sectioning command, and before the
% \envname{theglossary} environment. It is designed to allow the
% user to add information pertaining to the glossary (e.g.\ ``page
% numbers in italic indicate the primary definition'') therefore 
% \cs{glossarypremable} shouldn't be affected by the glossary
% style. (So if you define your own glossary style, don't have it 
% change \cs{glossarypreamble}.) The preamble is empty by
% default. If you have multiple glossaries, and you want a 
% different preamble for each glossary, you will need to use
% \icmdname{printglossary} for each glossary type, instead of 
% \icmdname{printglossaries}, and redefine \cs{glossarypreamble}
% before each \icmdname{printglossary}.
%\begin{macro}{\glossarypreamble}
%    \begin{macrocode}
\newcommand*{\glossarypreamble}{}
%    \end{macrocode}
%\end{macro}
%
% The glossary postamble is given by \cs{glossarypostamble}.
% This is provided to allow the user to
% add something after the end of the \envname{theglossary}
% environment (again, this shouldn't be affected by the
% glossary style.) It is, of course, possible to simply add the
% text after \icmdname{printglossary}, but if you only want the
% postamble to appear after the first glossary, but not after 
% subsequent glossaries, you can do something like:
%\begin{verbatim}
%\renewcommand{\glossarypostamble}{For a complete list of terms
%see \cite{blah}\gdef\glossarypreamble{}}
%\end{verbatim}
%\begin{macro}{\glossarypostamble}
%    \begin{macrocode}
\newcommand*{\glossarypostamble}{}
%    \end{macrocode}
%\end{macro}
%
% The sectioning command that starts a glossary is given by
% \cs{glossarysection}. (This does not form part of the
% glossary style, and so should not be changed by a glossary
% style.) If \icmdname{phantomsection}
% is defined, it uses \cs{\@p@glossarysection}, otherwise it
% uses \cs{@glossarysection}.
%\changes{1.05}{2007 Aug 10}{added '@mkboth to 'glossarysection}
%\begin{macro}{\glossarysection}
%    \begin{macrocode}
\newcommand*{\glossarysection}[2][\@gls@title]{%
\def\@gls@title{#2}%
\@ifundefined{phantomsection}{%
\@glossarysection{#1}{#2}}{\@p@glossarysection{#1}{#2}}%
\@mkboth{\glossarytoctitle}{\glossarytoctitle}%
}
%    \end{macrocode}
%\end{macro}
%
% The required sectional unit is given by \cs{@@glossarysec}
% which was defined by the \pkgopt{section} package option. The
% starred form of the command is chosen. If you want a numbered 
% section for the glossary or if you don't want any sectional
% command, you will need to redefine \cs{glossarysection}.
%
%The command \cs{@glossarysection} indicates how to start
% the glossary section if \icmdname{phantomsection} is not defined.
%\begin{macro}{\@glossarysection}
%    \begin{macrocode}
\newcommand*{\@glossarysection}[2]{%
\csname\@@glossarysec\endcsname*{#2}%
\@gls@toc{#1}{\@@glossarysec}}
%    \end{macrocode}
%\end{macro}
%
% As \cs{@glossarysection}, but put in 
% \icmdname{phantomsection}, and swap where \cs{@gls@toc} goes. 
% If using chapters do a \cs{clearpage}. This ensures that
% the hyper link from the table of contents leads to the line above
% the heading, rather than the line below it.
%\begin{macro}{\@p@glossarysection}
%    \begin{macrocode}
\newcommand*{\@p@glossarysection}[2]{%
\gls@doclearpage
\phantomsection\@gls@toc{#1}{\@@glossarysec}%
\csname\@@glossarysec\endcsname*{#2}}
%    \end{macrocode}
%\end{macro}
%
%The \cs{gls@doclearpage} command is used to issue a
% \cs{clearpage} (or \cs{cleardoublepage}) depending
% on whether the glossary sectional unit is a chapter. If the
% sectional unit is something else, do nothing.
%\begin{macro}{\gls@doclearpage}
%    \begin{macrocode}
\newcommand{\gls@doclearpage}{%
\ifthenelse{\equal{\@@glossarysec}{chapter}}{%
\@ifundefined{cleardoublepage}{\clearpage}{\cleardoublepage}}{}%
}
%    \end{macrocode}
%\end{macro}
%
% The glossary is added to the table of contents if glstoc flag set.
% If it is set, \cs{@gls@toc} will add a line to the 
% \filetype{toc} file, otherwise it will do nothing.
% (The first argument to \cs{@gls@toc} is the title for the
% table of contents, the second argument is the sectioning type.) 
%\begin{macro}{\@gls@toc}
%    \begin{macrocode}
\newcommand*{\@gls@toc}[2]{%
\ifglstoc \addcontentsline{toc}{#2}{#1}\fi}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Loops and conditionals}
% To iterate through all glossaries (or comma-separated list of
% glossary names given in optional argument) use:\\[10pt]
% \cs{forallglossaries}\oarg{glossary list}\marg{cmd}\marg{code}\\[10pt]
% where \meta{cmd} is
% a control sequence which will be set to the name of the
% glossary in the current iteration.
%\begin{macro}{\forallglossaries}
%    \begin{macrocode}
\newcommand*{\forallglossaries}[3][\@glo@types]{%
\@for#2:=#1\do{\ifthenelse{\equal{#2}{}}{}{#3}}}
%    \end{macrocode}
%\end{macro}
%
% To iterate through all entries in a given glossary use:\\[10pt]
%\cs{forglsentries}\oarg{type}\marg{cmd}\marg{code}\\[10pt]
%where \meta{type} is the glossary label and \meta{cmd} is a
% control sequence which will be set to the entry label in the
% current iteration.
%\begin{macro}{\forglsentries}
%    \begin{macrocode}
\newcommand*{\forglsentries}[3][\glsdefaulttype]{%
\edef\@@glo@list{\csname glolist@#1\endcsname}%
\@for#2:=\@@glo@list\do{%
\ifthenelse{\equal{#2}{}}{}{#3}}}
%    \end{macrocode}
%\end{macro}
%
% To iterate through all glossary entries over all glossaries listed
% in the optional argument (the default is all glossaries) use:\\[10pt] 
% \cs{forallglsentries}\oarg{glossary list}\marg{cmd}\marg{code}\\[10pt]
% Within \cs{forallglsentries}, the current glossary type
% is given by \cs{@@this@glo@}.
%\begin{macro}{\forallglsentries}
%    \begin{macrocode}
\newcommand*{\forallglsentries}[3][\@glo@types]{%
\expandafter\forallglossaries\expandafter[#1]{\@@this@glo@}{%
\forglsentries[\@@this@glo@]{#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%
% To check to see if a glossary exists use:\\[10pt]
%\cs{ifglossaryexists}\marg{type}\marg{true-text}\marg{false-text}\\[10pt]
%where \meta{type} is the glossary's label.
%\begin{macro}{\ifglossaryexists}
%    \begin{macrocode}
\newcommand{\ifglossaryexists}[3]{%
\@ifundefined{@glotype@#1@out}{#3}{#2}}
%    \end{macrocode}
%\end{macro}
%
% To check to see if a glossary entry has been defined use:\\[10pt]
% \cs{ifglsentryexists}\marg{label}\marg{true text}\marg{false text}\\[10pt]
%where \meta{label} is the entry's label.
%\begin{macro}{\ifglsentryexists}
%    \begin{macrocode}
\newcommand{\ifglsentryexists}[3]{%
\@ifundefined{glo@#1@name}{#3}{#2}}
%    \end{macrocode}
%\end{macro}
%
% To determine if given glossary entry has been 
% used in the document text yet use:\\[10pt]
% \cs{ifglsused}\marg{label}\marg{true text}\marg{false text}\\[10pt]
% where \meta{label} is the entry's label.
% If true it will do \meta{true text}
% otherwise it will do \meta{false text}.
%\begin{macro}{\ifglsused}
%    \begin{macrocode}
\newcommand*{\ifglsused}[3]{\ifthenelse{\boolean{glo@#1@flag}}{#2}{#3}}
%    \end{macrocode}
%\end{macro}
%The following two commands will cause an error if the given
% condition fails:
%
%\cs{glsdoifexists}\marg{label}\marg{code}\par
% Generate an error if entry specified by \meta{label} doesn't 
% exists, otherwise do \meta{code}.
%\begin{macro}{\glsdoifexists}
%    \begin{macrocode}
\newcommand{\glsdoifexists}[2]{\ifglsentryexists{#1}{#2}{%
\PackageError{glossaries}{Glossary entry `#1' has not been
defined.}{You need to define a glossary entry before you
can use it.}}}
%    \end{macrocode}
%\end{macro}
%
%\cs{glsdoifnoexists}\marg{label}\marg{code}\par
% The opposite: only do second argument if the entry doesn't
% exists. Generate an error message if it exists.
%\begin{macro}{\glsdoifnoexists}
%    \begin{macrocode}
\newcommand{\glsdoifnoexists}[2]{\ifglsentryexists{#1}{%
\PackageError{glossaries}{Glossary entry `#1' has already
been defined.}{}}{#2}}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Defining new glossaries}\label{sec:newglos}
% A comma-separated list of glossary names is stored
% in \cs{@glo@types}. When a new glossary type
% is created, its identifying name is added to this list.
% This is used by commands that iterate through all glossaries
% (such as \icmdname{makeglossaries} and \icmdname{printglossaries}.)
%\begin{macro}{\@glo@types}
%    \begin{macrocode}
\newcommand*{\@glo@types}{,}
%    \end{macrocode}
%\end{macro}
%
% A new glossary type is defined using \cs{newglossary}.
% Syntax:\\[10pt]\cs{newglossary}\oarg{log-ext}\marg{name}\marg{in-ext}\marg{out-ext}%
%\marg{title}\oarg{counter}\\[10pt]%
% where \meta{log-ext} is the extension of the \appname{makeindex}
% transcript file, \meta{in-ext} is the extension of the glossary 
% input file (read in by \icmdname{printglossary} and created by
% \appname{makeindex}), \meta{out-ext} is the extension of the
% glossary output file which is read in by \appname{makeindex} 
% (lines are written to this file by the \icmdname{glossary} command),
% \meta{title} is the title of the glossary that is used in
% \icmdname{glossarysection} and
% \meta{counter} is the default counter to be used by entries
% belonging to this glossary. The \appname{makeglossaries} Perl
% script reads in the relevant extensions from the auxiliary file,
% and passes the appropriate file names and switches to 
% \appname{makeindex}.)
%\begin{macro}{\newglossary}
%    \begin{macrocode}
\newcommand*{\newglossary}[5][glg]{%
\ifglossaryexists{#2}{%
\PackageError{glossaries}{Glossary type `#2' already exists}{%
You can't define a new glossary called `#2' because it already
exists}%
}{%
%    \end{macrocode}
% Add this to the list of glossary types:
%    \begin{macrocode}
\toks@{#2}\edef\@glo@types{\@glo@types\the\toks@,}%
%    \end{macrocode}
% Define a comma-separated list of labels for this glossary type, 
% so that all the entries for this glossary can be reset with a 
% single command. When a new entry is created, its label is added
% to this list.
%    \begin{macrocode}
\expandafter\gdef\csname glolist@#2\endcsname{,}%
%    \end{macrocode}
% Store details of this new glossary type:
%    \begin{macrocode}
\expandafter\def\csname @glotype@#2@in\endcsname{#3}%
\expandafter\def\csname @glotype@#2@out\endcsname{#4}%
\expandafter\def\csname @glotype@#2@title\endcsname{#5}%
\protected@write\@auxout{}{\string\@newglossary{#2}{#1}{#3}{#4}}%
%    \end{macrocode}
% How to display this entry in the document text (uses
% \cs{glsdisplay} and \cs{glsdisplayfirst} by
% default). These can be redefined by the user later if required
% (see \icmdname{defglsdisplay} and \icmdname{defglsdisplayfirst})
%    \begin{macrocode}
\expandafter\gdef\csname gls@#2@display\endcsname{%
\glsdisplay}%
\expandafter\gdef\csname gls@#2@displayfirst\endcsname{%
\glsdisplayfirst}%
%    \end{macrocode}
% Find out if the final optional argument has been specified, and
% use it to set the counter associated with this glossary. (Uses
% \icmdname{glscounter} if no optional argument is present.)
%    \begin{macrocode}
\@ifnextchar[{\@gls@setcounter{#2}}{\@gls@setcounter{#2}[\glscounter]}}}
%    \end{macrocode}
%\end{macro}
% Only defined new glossaries in the preamble:
%    \begin{macrocode}
\@onlypreamble{\newglossary}
%    \end{macrocode}
%\cs{@newglossary} is used to specify the file extensions
% for the \appname{makeindex} input, output and transcript files.
% It is written to the auxiliary file by \icmdname{newglossary}.
% Since it is not used by \LaTeX, \cs{@newglossary} simply
% ignores its arguments.
%\begin{macro}{\@newglossary}
%    \begin{macrocode}
\newcommand*{\@newglossary}[4]{}
%    \end{macrocode}
%\end{macro}
% Store counter to be used for given glossary type (the first
% argument is the glossary label, the second argument is the name 
% of the counter):
%\begin{macro}{\@gls@setcounter}
%    \begin{macrocode}
\def\@gls@setcounter#1[#2]{%
\expandafter\def\csname @glotype@#1@counter\endcsname{#2}%
}
%    \end{macrocode}
%\end{macro}
% Get counter associated with given glossary (the argument is
% the glossary label):
%\begin{macro}{\@gls@getcounter}
%    \begin{macrocode}
\newcommand*{\@gls@getcounter}[1]{%
\csname @glotype@#1@counter\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Define the main glossary. This will be the first glossary to
% be displayed when using \icmdname{printglossaries}.
%    \begin{macrocode}
\newglossary{main}{gls}{glo}{\glossaryname}
%    \end{macrocode}
%
%\subsection{Defining new entries}\label{sec:newentry}
% New glossary entries are defined using \cs{newglossaryentry}.
% This command requires a label and a key-value list that defines
% the relevant information for that entry. The definition for these
% keys follows. Note that the \gloskey{name},
% \gloskey{description} and \gloskey{symbol} keys will be
% sanitized later, depending on the value of the package option
% \pkgopt{sanitize} (this means that if some of the keys haven't
% been defined, they can be constructed from the \gloskey{name}
% and \gloskey{description} key before they are sanitized).
%
%The \gloskey{name} key indicates the name
% of the term being defined. This is how the term will appear in
% the glossary. The \gloskey{name} key is required when defining
% a new glossary entry.
%    \begin{macrocode}
\define@key{glossentry}{name}{%
\def\@glo@name{#1}%
}
%    \end{macrocode}
%
% The \gloskey{description} key is usually only used in
% the glossary, but can be made to appear in the text by redefining
% \icmdname{glsdisplay} and \icmdname{glsdisplayfirst} (or
% using \icmdname{defglsdisplay} and \icmdname{defglsdisplayfirst}), however,
% you will have to disable the sanitize option (using the 
% \pkgopt{sanitize} package option, 
% "sanitize={description=false}", and protect fragile
% commands.) The \gloskey{description} key is required when
% defining a new glossary entry. (Be careful not to make the
% description too long, because \appname{makeindex} has a limited
% buffer. \cs{@glo@desc} is defined to be a short command 
% to discourage lengthy descriptions
% for this reason. If you do have a very long description, or if
% you require paragraph breaks, define a separate command that 
% contains the description, and use it as the value to the 
% \gloskey{description} key.)
%    \begin{macrocode}
\define@key{glossentry}{description}{%
\def\@glo@desc{#1}%
}
%    \end{macrocode}
%
% The \gloskey{sort} key needs to be sanitized here 
% (the sort key is provided for \appname{makeindex}'s benefit, 
% not for use in the document.) The \gloskey{sort} key is optional
% when defining a new glossary entry. If omitted, the value 
% is given by \meta{name} \meta{description}.
%    \begin{macrocode}
\define@key{glossentry}{sort}{%
\def\@glo@sort{#1}%
\@onelevel@sanitize\@glo@sort}
%    \end{macrocode}
%
% The \gloskey{text} key determines how the term should appear when
% used in the document (i.e.\ outside of the glossary). If omitted, 
% the value of the \gloskey{name} key is used instead.
%    \begin{macrocode}
\define@key{glossentry}{text}{%
\def\@glo@text{#1}%
}
%    \end{macrocode}
%
% The \gloskey{plural} key determines how the plural form of the term
% should be displayed in the document. If omitted, the plural is
% constructed by appending an ``s'' to the value of the \gloskey{text}
% key.
%    \begin{macrocode}
\define@key{glossentry}{plural}{%
\def\@glo@plural{#1}%
}
%    \end{macrocode}
%
% The \gloskey{first} key determines how the entry should be displayed
% in the document when it is first used. If omitted, it is taken
% to be the same as the value of the \gloskey{text} key.
%    \begin{macrocode}
\define@key{glossentry}{first}{%
\def\@glo@first{#1}%
}
%    \end{macrocode}
%
% The \gloskey{firstplural} key is used to set the plural form for
% first use, in the event that the plural is required the first 
% time the term is used. If omitted, it is constructed by 
% appending an ``s'' to the value of the \gloskey{first} key.
%    \begin{macrocode}
\define@key{glossentry}{firstplural}{%
\def\@glo@firstplural{#1}%
}
%    \end{macrocode}
%
% The \gloskey{symbol} key is ignored by most of the predefined
% glossary styles, and defaults to \cs{relax} if omitted. 
% It is provided for glossary styles that require an associated 
% symbol, as well as a name and description. To make this value 
% appear in the glossary, you need to redefine 
% \icmdname{glossaryentryfield} so that it uses its fourth parameter.
% If you want this value to appear in the text when the term is used 
% by commands like \icmdname{gls}, you will need to change
% \icmdname{glsdisplay} and \icmdname{glsdisplayfirst} (either 
% explicitly for all glossaries or via \icmdname{defglsdisplay}
% and \icmdname{defglsdisplayfirst} for individual glossaries.)
%    \begin{macrocode}
\define@key{glossentry}{symbol}{%
\def\@glo@symbol{#1}%
}
%    \end{macrocode}
%
% The \gloskey{type} key specifies to which glossary this
% entry belongs. If omitted, the default glossary is used.
%    \begin{macrocode}
\define@key{glossentry}{type}{%
\def\@glo@type{#1}}
%    \end{macrocode}
%
% The \gloskey{counter} key specifies the name of the counter 
% associated with this glossary entry:
%    \begin{macrocode}
\define@key{glossentry}{counter}{%
\@ifundefined{c@#1}{\PackageError{glossaries}{There is no counter
called `#1'}{The counter key should have the name of a valid 
counter as its value}}{%
\def\@glo@counter{#1}}}
%    \end{macrocode}
%
% Define \cs{newglossaryentry}%
% \marg{label} \marg{key-val list}. 
% There are two required fields in \meta{key-val list}: 
% \gloskey{name} and 
% \gloskey{description}. (See above.)
%\begin{macro}{\newglossaryentry}
%    \begin{macrocode}
\DeclareRobustCommand{\newglossaryentry}[2]{%
%    \end{macrocode}
% Check to see if this glossary entry has already been defined:
%    \begin{macrocode}
\glsdoifnoexists{#1}{%
%    \end{macrocode}
% Set up defaults. If the \gloskey{name} or \gloskey{description}
% keys are omitted, an error will be generated.
%\changes{1.05}{2007 Aug 10}{Changed the default value of the sort
% key to just the value of the name key}%
%    \begin{macrocode}
\def\@glo@name{\PackageError{glossaries}{name key required in 
\string\newglossaryentry}{You haven't specified the entry name}}%
\def\@glo@desc{\PackageError{glossaries}{desc key required in 
\string\newglossaryentry}{You haven't specified the entry description}}%
\def\@glo@type{\glsdefaulttype}%
\def\@glo@symbol{\relax}%
\def\@glo@text{\@glo@name}%
\def\@glo@plural{\@glo@text s}%
\def\@glo@first{\@glo@text}%
\def\@glo@firstplural{\@glo@plural}%
\def\@glo@sort{\@glo@name}%
\def\@glo@counter{\@gls@getcounter{\@glo@type}}%
%    \end{macrocode}
% Extract key-val information from third parameter:
%    \begin{macrocode}
\setkeys{glossentry}{#2}%
%    \end{macrocode}
% Check to see if this glossary type has been defined, if it has,
% add this label to the relevant list, otherwise generate an error.
%    \begin{macrocode}
\@ifundefined{glolist@\@glo@type}{\PackageError{glossaries}{%
Glossary type '\@glo@type' has not been defined}{%
You need to define a new glossary type, before making entries
in it}}{%
\protected@edef\@glolist@{\csname glolist@\@glo@type\endcsname}%
\expandafter\xdef\csname glolist@\@glo@type\endcsname{\@glolist@{#1},}%
}%
%    \end{macrocode}
% Define commands associated with this entry:
%    \begin{macrocode}
\expandafter\protected@xdef\csname glo@#1@text\endcsname{\@glo@text}%
\expandafter\protected@xdef\csname glo@#1@plural\endcsname{\@glo@plural}%
\expandafter\protected@xdef\csname glo@#1@first\endcsname{\@glo@first}%
\expandafter\protected@xdef\csname glo@#1@firstpl\endcsname{\@glo@firstplural}%
\expandafter\protected@xdef\csname glo@#1@type\endcsname{\@glo@type}%
\expandafter\protected@xdef\csname glo@#1@counter\endcsname{\@glo@counter}%
\@gls@sanitizename
\expandafter\protected@xdef\csname glo@#1@name\endcsname{\@glo@name}%
\@gls@sanitizedesc
\expandafter\protected@xdef\csname glo@#1@desc\endcsname{\@glo@desc}%
\expandafter\protected@xdef\csname glo@#1@sort\endcsname{\@glo@sort}%
\@gls@sanitizesymbol
\expandafter\protected@xdef\csname glo@#1@symbol\endcsname{\@glo@symbol}%
%    \end{macrocode}
% Define an associated boolean variable to determine whether this
% entry has been used yet (needs to be defined globally):
%    \begin{macrocode}
\expandafter\gdef\csname glo@#1@flagfalse\endcsname{%
\expandafter\global\expandafter
\let\csname ifglo@#1@flag\endcsname\iffalse}%
\expandafter\gdef\csname glo@#1@flagtrue\endcsname{%
\expandafter\global\expandafter
\let\csname ifglo@#1@flag\endcsname\iftrue}%
\csname glo@#1@flagfalse\endcsname
}}
%    \end{macrocode}
%\end{macro}
% Only defined new glossary entries in the preamble:
%    \begin{macrocode}
\@onlypreamble{\newglossaryentry}
%    \end{macrocode}
%
%\subsection{Resetting and unsetting entry flags}
% Each glossary entry is assigned a conditional of the form
%\cs{ifglo@}\meta{label}\texttt{@flag} which determines
% whether or not the entry has been used (see also 
% \icmdname{ifglsused} defined below.) These flags can
% be set and unset using the following macros:
%
% The command \cs{glsreset}\marg{label} can be used
% to set the entry flag to indicate that it hasn't been used yet. The
% required argument is the entry label.
%\begin{macro}{\glsreset}
%    \begin{macrocode}
\newcommand*{\glsreset}[1]{%
\glsdoifexists{#1}{%
\expandafter\global\csname glo@#1@flagfalse\endcsname}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalreset}
%    \begin{macrocode}
\newcommand*{\glslocalreset}[1]{%
\glsdoifexists{#1}{%
\expandafter\let\csname ifglo@#1@flag\endcsname\iffalse}}
%    \end{macrocode}
%\end{macro}
% The command \cs{glsunset}\marg{label} can be used to
% set the entry flag to indicate that it has been used. The required
% argument is the entry label.
%\begin{macro}{\glsunset}
%    \begin{macrocode}
\newcommand*{\glsunset}[1]{%
\glsdoifexists{#1}{%
\expandafter\global\csname glo@#1@flagtrue\endcsname}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalunset}
%    \begin{macrocode}
\newcommand*{\glslocalunset}[1]{%
\glsdoifexists{#1}{%
\expandafter\let\csname ifglo@#1@flag\endcsname\iftrue}}
%    \end{macrocode}
%\end{macro}
% Reset all entries for the named glossaries (supplied in a 
% comma-separated list). 
% Syntax: \cs{glsresetall}\oarg{glossary-list}
%\begin{macro}{\glsresetall}
%    \begin{macrocode}
\newcommand*{\glsresetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glsreset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalresetall}
%    \begin{macrocode}
\newcommand*{\glslocalresetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glslocalreset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
% Unset all entries for the named glossaries (supplied in a 
% comma-separated list). 
% Syntax: \cs{glsunsetall}\oarg{glossary-list}
%\begin{macro}{\glsunsetall}
%    \begin{macrocode}
\newcommand*{\glsunsetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glsunset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalunsetall}
%    \begin{macrocode}
\newcommand*{\glslocalunsetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glslocalunset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
%
% \subsection{Loading files containing glossary entries}
%\label{sec:load}
% Glossary entries can be defined in an external file.
% These external files can contain \icmdname{newglossaryentry}
% and \icmdname{newacronym} commands.\footnote{and any other valid 
%\LaTeX\ code that can be used in the preamble.}\\[10pt]
% \cs{loadglsentries}\oarg{type}\marg{filename}\\[10pt]
% This command will input the file using \cs{input}.
% The optional argument specifies to which glossary the
% entries should be assigned if they haven't used the \gloskey{type}
% key. If the optional argument is not specified, the default
% glossary is used. Only those entries used in the document (via
% \icmdname{glslink}, \icmdname{gls}, \icmdname{glspl} and uppercase
% variants or \icmdname{glsadd} and \icmdname{glsaddall} 
% will appear in the glossary.) The mandatory argument is 
% the filename (with or without .tex extension.)
%\begin{macro}{\loadglsentries}
%    \begin{macrocode}
\newcommand*{\loadglsentries}[2][\@gls@default]{%
\let\@gls@default\glsdefaulttype
\def\glsdefaulttype{#1}\input{#2}%
\let\glsdefaulttype\@gls@default}
%    \end{macrocode}
%\end{macro}
% \cs{loadglsentries} can only be used in the preamble:
%    \begin{macrocode}
\@onlypreamble{\loadglsentries}
%    \end{macrocode}
%
%\subsection{Using glossary entries in the text}
%\label{sec:code:glslink}
%
% Any term that has been defined using \icmdname{newglossaryentry}
% (or \icmdname{newacronym}) can be displayed in the text 
% (i.e.\ outside of the glossary) using
% one of the commands defined in this section. Unless you use
% \icmdname{glslink}, the way the term appears in the text is
% determined by \icmdname{glsdisplayfirst} (if it is the first
% time the term has been used) or \icmdname{glsdisplay} (for
% subsequent use.) Any formatting commands (such as \cs{textbf}
% is governed by \icmdname{glstextformat}. By default this just 
% displays the \term{link text} ``as is''.
%\changes{1.04}{2007 Aug 3}{Added 'glstextformat}%
%\begin{macro}{\glstextformat}
%    \begin{macrocode}
\newcommand*{\glstextformat}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
% The first time an entry is used, the way in which it is
% displayed is governed by \cs{glsdisplayfirst}. This
% takes four parameters: \verb|#1| will be the value
% of the entry's \gloskey{first} or \gloskey{firstplural} key, 
% \verb|#2| will be the value of the entry's \gloskey{description}
% key, \verb|#3| will be the value of the entry's \gloskey{symbol}
% key and \verb|#4| is additional text supplied by the final optional
% argument to commands like \icmdname{gls} and \icmdname{glspl}.
% The default is to display the first parameter followed by the
% additional text.
%\begin{macro}{\glsdisplayfirst}
%    \begin{macrocode}
\newcommand*{\glsdisplayfirst}[4]{#1#4}
%    \end{macrocode}
%\end{macro}
%
% After the first use, the entry is displayed according to
% the format of \cs{glsdisplay}. Again, it takes four
% parameters: \verb|#1| will be the value of the
% entry's \gloskey{text} or \gloskey{plural} key, 
% \verb|#2| will be the value of the entry's \gloskey{description} 
% key, \verb|#3| will be the value of the entry's \gloskey{symbol}
% key and \verb|#4| is additional text supplied by the final optional
% argument to commands like \icmdname{gls} and \icmdname{glspl}.
%\begin{macro}{\glsdisplay}
%    \begin{macrocode}
\newcommand*{\glsdisplay}[4]{#1#4}
%    \end{macrocode}
%\end{macro}
%
% When a new glossary is created it uses \cs{glsdisplayfirst}
% and \cs{glsdisplay} as the default way of displaying its
% entry in the text. This can be changed for the entries belonging 
% to an individual glossary using 
% \icmdname{defglsdisplay} and \icmdname{defglsdisplayfirst}.
%\\[10pt]
% \cs{defglsdisplay}\oarg{type}\marg{definition}\\[10pt]%
% The glossary type is given by \meta{type} (the default glossary
% if omitted) and
% \meta{definition} should have at most \verb|#1|, \verb|#2|,
% \verb|#3| and \verb|#4|. These represent the same arguments
% as those described for \icmdname{glsdisplay}.
%\begin{macro}{\defglsdisplay}
%    \begin{macrocode}
\newcommand*{\defglsdisplay}[2][\glsdefaulttype]{%
\expandafter\def\csname gls@#1@display\endcsname##1##2##3##4{#2}}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
% \cs{defglsdisplayfirst}\oarg{type}\marg{definition}\\[10pt]%
% The glossary type is given by \meta{type} (the default glossary
% if omitted) and
% \meta{definition} should have at most \verb|#1|, \verb|#2|,
% \verb|#3| and \verb|#4|. These represent the same arguments
% as those described for \icmdname{glsdisplayfirst}.
%\begin{macro}{\defglsdisplayfirst}
%    \begin{macrocode}
\newcommand*{\defglsdisplayfirst}[2][\glsdefaulttype]{%
\expandafter\def\csname gls@#1@displayfirst\endcsname##1##2##3##4{#2}}
%    \end{macrocode}
%\end{macro}
%
%\subsubsection{Links to glossary entries}
% The links to glossary entries all have a first optional 
% argument that can be used to change the format and counter
% of the associated entry number. Except for \cs{glslink},
% the commands like \cs{gls} have a final optional
% argument that can be used to insert additional text in the
% link (this will usually be appended, but can be redefined using
% \icmdname{defglsdisplay} and \icmdname{defglsdisplayfirst}). 
% It goes against the \LaTeX\ norm to have an optional
% argument after the mandatory arguments, but it makes more
% sense to write, say, \verb|\gls{label}['s]| rather than, say,
% \verb|\gls[append='s]{label}|. Since these control sequences
% are defined to include the final square bracket, spaces
% will be ignored after them. This is likely to lead to
% confusion as most users would not expect, say, "\gls{"\meta{label}"}"
% to ignore following spaces, so \icmdname{xspace} is used.
%
% The following keys can be used in the first optional 
% argument. The \gloskey[glslink]{counter} key checks that the 
% value is the name of a valid counter.
%    \begin{macrocode}
\define@key{glslink}{counter}{%
\@ifundefined{c@#1}{\PackageError{glossaries}{There is no counter
called `#1'}{The counter key should have the name of a valid 
counter as its value}}{%
\def\@gls@counter{#1}}}
%    \end{macrocode}
% The value of the \gloskey[glslink]{format} key should be the name of a 
% command (without the initial backslash) that has a single mandatory 
% argument which can be used to format the associated entry
% number.
%    \begin{macrocode}
\define@key{glslink}{format}{%
\def\@glsnumberformat{#1}}
%    \end{macrocode}
% The \gloskey[glslink]{hyper} key is a boolean key, it can either have the 
% value true or false, and indicates whether or not to make a 
% hyperlink to the relevant glossary entry. If hyper is false, an 
% entry will still be made in the glossary, but the given text 
% won't be a hyperlink.
%    \begin{macrocode}
\define@boolkey{glslink}{hyper}[true]{}
%    \end{macrocode}
%
%Syntax:\\[10pt]
% \cs{glslink}\oarg{options}\marg{label}\marg{text}
%\\[10pt]
% Display \meta{text} in the document, and add the entry information
% for \meta{label} into the relevant glossary. The optional
% argument should be a key value list using the \texttt{glslink}
% keys defined above.
%
% There is also a starred version:\\[10pt]
% \cs{glslink*}\oarg{options}\marg{label}\marg{text}\\[10pt]
% which is equivalent to 
% \cs{glslink}"[hyper=false,"\meta{options}"]"\marg{label}\marg{text}
%
% First determine whether or not we are using the starred version:
%\begin{macro}{\glslink}
%    \begin{macrocode}
\newcommand{\glslink}{%
\@ifstar\@sgls@link\@gls@link}
%    \end{macrocode}
%\end{macro}
% Define the starred version:
%\begin{macro}{\@sgls@link}
%    \begin{macrocode}
\newcommand*{\@sgls@link}[1][]{\@gls@link[hyper=false,#1]}
%    \end{macrocode}
%\end{macro}
% Define the un-starred version:
%\begin{macro}{\@gls@link}
%\changes{1.07}{2007 Sep 13}{fixed bug caused by \cs{theglsentrycounter} setting the page number too soon}
%    \begin{macrocode}
\newcommand*{\@gls@link}[3][]{%
\glsdoifexists{#2}{%
\def\@glsnumberformat{glsnumberformat}%
\edef\@gls@counter{\csname glo@#2@counter\endcsname}%
\KV@glslink@hypertrue
\setkeys{glslink}{#1}%
\edef\theglsentrycounter{\expandafter\noexpand\csname the\@gls@counter\endcsname}%
\ifKV@glslink@hyper
\@glslink{glo:#2}{\glstextformat{#3}}%
\else
\glstextformat{#3}\relax
\fi
\protected@edef\@glo@sort{\csname glo@#2@sort\endcsname}%
\@gls@checkmkidxchars\@glo@sort
\protected@edef\@@glo@name{\csname glo@#2@name\endcsname}%
\@gls@checkmkidxchars\@@glo@name
\protected@edef\@glo@name{\string\glsnamefont{\@@glo@name}}%
\protected@edef\@glo@desc{\csname glo@#2@desc\endcsname}%
\@gls@checkmkidxchars\@glo@desc
\protected@edef\@glo@symbol{\csname glo@#2@symbol\endcsname}%
\@gls@checkmkidxchars\@glo@symbol
\@set@glo@numformat\@glo@numfmt\@gls@counter\@glsnumberformat
\glossary[\csname glo@#2@type\endcsname]{%
\@glo@sort\@gls@actualchar
\string\glossaryentryfield{#2}{\@glo@name}{\@glo@desc
}{\@glo@symbol}\@gls@encapchar\@glo@numfmt}%
}}
%    \end{macrocode}
%\end{macro}
%\changes{1.01}{2007 May 17}{Added range facility in format key}%
% Set the formatting information in the format required by 
% \appname{makeindex}:
%\begin{macro}{\@set@glo@numformat}
%    \begin{macrocode}
\def\@set@glo@numformat#1#2#3{%
\expandafter\@glo@check@mkidxrangechar#3\@nil
\protected@edef#1{\@glo@prefix setentrycounter{#2}%
\expandafter\string\csname\@glo@suffix\endcsname}%
\@gls@checkmkidxchars#1}
%    \end{macrocode}
%\end{macro}
% Check to see if the given string starts with a ( or ). If it
% does set \cs{@glo@prefix} to the starting character,
% and \cs{@glo@suffix} to the rest (or "glsnumberformat"
% if there is nothing else),
% otherwise set \cs{@glo@prefix} to nothing and
% \cs{@glo@suffix} to all of it.
%\begin{macro}{\@glo@check@mkidxrangechar}
%    \begin{macrocode}
\def\@glo@check@mkidxrangechar#1#2\@nil{%
\if#1(\relax
  \def\@glo@prefix{(}%
  \if\relax#2\relax
    \def\@glo@suffix{glsnumberformat}%
  \else
    \def\@glo@suffix{#2}%
  \fi
\else
  \if#1)\relax
    \def\@glo@prefix{)}%
    \if\relax#2\relax
      \def\@glo@suffix{glsnumberformat}%
    \else
      \def\@glo@suffix{#2}%
  \fi
  \else
    \def\@glo@prefix{}\def\@glo@suffix{#1#2}%
  \fi
\fi}
%    \end{macrocode}
%\end{macro}
% Catch \appname{makeindex} special characters\mkidxspch:
%\begin{macro}{\@gls@checkmkidxchars}
%    \begin{macrocode}
\newcommand{\@gls@checkmkidxchars}[1]{%
\def\@gls@checkedmkidx{}%
\expandafter\@gls@checkquote#1\@nil""\null%
\expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
\def\@gls@checkedmkidx{}%
\expandafter\@gls@checkescquote#1\@nil\"\"\null%
\expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
\def\@gls@checkedmkidx{}%
\expandafter\@gls@checkescactual#1\@nil\?\?\null%
\expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
\def\@gls@checkedmkidx{}%
\expandafter\@gls@checkactual#1\@nil??\null%
\expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
\def\@gls@checkedmkidx{}%
\expandafter\@gls@checkbar#1\@nil||\null%
\expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
\def\@gls@checkedmkidx{}%
\expandafter\@gls@checkescbar#1\@nil\|\|\null%
\expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
\def\@gls@checkedmkidx{}%
\expandafter\@gls@checklevel#1\@nil!!\null%
\expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
}
%    \end{macrocode}
%\end{macro}
% Update the control sequence and strip trailing \cs{@nil}:
%\begin{macro}{\@gls@updatechecked}
%    \begin{macrocode}
\def\@gls@updatechecked#1\@nil#2{\def#2{#1}}
%    \end{macrocode}
%\end{macro}
% Replace \verb|"| with \verb|""| since \verb|"| is a makeindex
% special character\mkidxspch.
%    \begin{macrocode}
\toksdef\@gls@tmpb=2
\def\@gls@checkquote#1"#2"#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkquote{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@quotechar\@gls@quotechar\@gls@quotechar}%
  \def\@@gls@checkquote{\@gls@checkquote#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@quotechar}%
 \ifx\null#3\null
   \def\@@gls@checkquote{\@gls@checkquote#2""\null}%
 \else
   \def\@@gls@checkquote{\@gls@checkquote#2"#3\null}%
 \fi
\fi
\@@gls@checkquote}
%    \end{macrocode}
% Do the same for \verb|\"|:
%    \begin{macrocode}
\def\@gls@checkescquote#1\"#2\"#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkescquote{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@quotechar
    \@gls@quotechar\string\"\@gls@quotechar}%
  \def\@@gls@checkescquote{\@gls@checkescquote#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@quotechar}%
 \ifx\null#3\null
   \def\@@gls@checkescquote{\@gls@checkescquote#2\"\"\null}%
 \else
   \def\@@gls@checkescquote{\@gls@checkescquote#2\"#3\null}%
 \fi
\fi
\@@gls@checkescquote}
%    \end{macrocode}
% Similarly for \verb|\?| (which is replaces @ as 
% \appname{makeindex}'s special character):
%    \begin{macrocode}
\def\@gls@checkescactual#1\?#2\?#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkescactual{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@actualchar
    \@gls@quotechar\string\"\@gls@actualchar}%
  \def\@@gls@checkescactual{\@gls@checkescactual#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@actualchar}%
 \ifx\null#3\null
  \def\@@gls@checkescactual{\@gls@checkescactual#2\?\?\null}%
 \else
  \def\@@gls@checkescactual{\@gls@checkescactual#2\?#3\null}%
 \fi
\fi
\@@gls@checkescactual}
%    \end{macrocode}
% Similarly for \verb"\|":
%    \begin{macrocode}
\def\@gls@checkescbar#1\|#2\|#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkescbar{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@encapchar
    \@gls@quotechar\string\"\@gls@encapchar}%
  \def\@@gls@checkescbar{\@gls@checkescbar#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@encapchar}%
 \ifx\null#3\null
  \def\@@gls@checkescbar{\@gls@checkescbar#2\|\|\null}%
 \else
  \def\@@gls@checkescbar{\@gls@checkescbar#2\|#3\null}%
 \fi
\fi
\@@gls@checkescbar}
%    \end{macrocode}
% Similarly for \verb"\!":
%    \begin{macrocode}
\def\@gls@checkesclevel#1\!#2\!#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkesclevel{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@levelchar
    \@gls@quotechar\string\"\@gls@levelchar}%
  \def\@@gls@checkesclevel{\@gls@checkesclevel#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@levelchar}%
 \ifx\null#3\null
  \def\@@gls@checkesclevel{\@gls@checkesclevel#2\!\!\null}%
 \else
  \def\@@gls@checkesclevel{\@gls@checkesclevel#2\!#3\null}%
 \fi
\fi
\@@gls@checkesclevel}
%    \end{macrocode}
% and for \verb"|":
%    \begin{macrocode}
\def\@gls@checkbar#1|#2|#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkbar{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@encapchar\@gls@quotechar\@gls@encapchar}%
  \def\@@gls@checkbar{\@gls@checkbar#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@encapchar}%
 \ifx\null#3\null
   \def\@@gls@checkbar{\@gls@checkbar#2||\null}%
 \else
   \def\@@gls@checkbar{\@gls@checkbar#2|#3\null}%
 \fi
\fi
\@@gls@checkbar}
%    \end{macrocode}
% and for \verb"!":
%    \begin{macrocode}
\def\@gls@checklevel#1!#2!#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checklevel{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@levelchar\@gls@quotechar\@gls@levelchar}%
  \def\@@gls@checklevel{\@gls@checklevel#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@levelchar}%
 \ifx\null#3\null
   \def\@@gls@checklevel{\@gls@checklevel#2!!\null}%
 \else
   \def\@@gls@checklevel{\@gls@checklevel#2!#3\null}%
 \fi
\fi
\@@gls@checklevel}
%    \end{macrocode}
% and for \verb"?":
%    \begin{macrocode}
\def\@gls@checkactual#1?#2?#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null%
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkactual{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@actualchar\@gls@quotechar\@gls@actualchar}%
  \def\@@gls@checkactual{\@gls@checkactual#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@actualchar}%
 \ifx\null#3\null
   \def\@@gls@checkactual{\@gls@checkactual#2??\null}%
 \else
   \def\@@gls@checkactual{\@gls@checkactual#2?#3\null}%
 \fi
\fi
\@@gls@checkactual}
%    \end{macrocode}
%
% If \icmdname{hyperlink}
% is not defined, \cs{@glslink} and \cs{@glstarget}
% ignore their first argument, and just do the second argument,
% otherwise they are equivalent to \icmdname{hyperlink} and
%\icmdname{hypertarget}.
%    \begin{macrocode}
\@ifundefined{hyperlink}{%
\gdef\@glslink#1#2{#2}\gdef\@glstarget#1#2{#2}%
}{\gdef\@glslink#1#2{\hyperlink{#1}{#2}}%
\gdef\@glstarget#1#2{\hypertarget{#1}{#2}}}
%    \end{macrocode}
%
% Glossary hyperlinks can be disabled using \cs{glsdisablehyper}
% (effect can be localised):
%\begin{macro}{\glsdisablehyper}
%    \begin{macrocode}
\newcommand{\glsdisablehyper}{%
\renewcommand*\@glslink[2]{##2}%
\renewcommand*\@glstarget[2]{##2}}
%    \end{macrocode}
%\end{macro}
% Glossary hyperlinks can be enabled using \cs{glsenablehyper}
% (effect can be localised):
%\begin{macro}{\glsenablehyper}
%    \begin{macrocode}
\newcommand{\glsenablehyper}{%
\renewcommand*\@glslink[2]{\hyperlink{##1}{##2}}%
\renewcommand*\@glstarget[2]{\hypertarget{##1}{##2}}}
%    \end{macrocode}
%\end{macro}
%
%Syntax:\\[10pt]
% \cs{gls}\oarg{options}\marg{label}\oarg{insert text}\\[10pt]
% Link to glossary entry using singular form. The link text
% is taken from the value of the \gloskey{text} or \gloskey{first}
% keys used when the entry was defined.
%
%  The first optional argument is a key-value list, the same as
% \icmdname{glslink}\igloskey[glslink]{hyper}\igloskey[glslink]{format}\igloskey[glslink]{counter}, 
% the mandatory argument is the entry label. 
% After the mandatory argument, there is another optional argument 
% to insert extra text in the link text (the location of the inserted
% text is governed by \icmdname{glsdisplay} and 
% \icmdname{glsdisplayfirst}). As with \cs{glslink}
% there is a starred version which is the same as the unstarred 
% version but with the \gloskey[glslink]{hyper} key set to \texttt{false}.
% (Additional options can also be specified 
% in the first optional argument.)
%
% First determine if we are using the starred form:
%\begin{macro}{\gls}
%    \begin{macrocode}
\newcommand*{\gls}{\@ifstar\@sgls\@gls}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%\begin{macro}{\@sgls}
%    \begin{macrocode}
\newcommand*{\@sgls}[1][]{\@gls[hyper=false,#1]}
%    \end{macrocode}
%\end{macro}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%\begin{macro}{\@gls}
%    \begin{macrocode}
\newcommand*{\@gls}[2][]{%
\@ifnextchar[{\@gls@{#1}{#2}}{\@gls@{#1}{#2}[]}}
%    \end{macrocode}
%\end{macro}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@gls@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\ifglsused{#2}{\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\glsentrytext{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text}%
%    \end{macrocode}
% Indicate that this entry has now been used, and add a space if
% appropriate
%    \begin{macrocode}
\glsunset{#2}}%
\xspace}
%    \end{macrocode}
%
% \cs{Gls} behaves like \cs{gls}, but the first letter
% of the link text is converted to uppercase (note that if the
% first letter has an accent, the accented letter will need to
% be grouped when you define the entry.) It is mainly intended
% for terms that start a sentence:
%\begin{macro}{\Gls}
%    \begin{macrocode}
\newcommand*{\Gls}{\@ifstar\@sGls\@Gls}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGls}[1][]{\@Gls[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Gls}[2][]{%
\@ifnextchar[{\@Gls@{#1}{#2}}{\@Gls@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Gls@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\ifglsused{#2}{\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\glsentrytext{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\expandafter\MakeUppercase\@glo@text}%
%    \end{macrocode}
% Indicate that this entry has now been used, and add a space if
% appropriate
%    \begin{macrocode}
\glsunset{#2}}%
\xspace}
%    \end{macrocode}
%
% \cs{GLS} behaves like \icmdname{gls}, but the link
% text is converted to uppercase:
%\begin{macro}{\GLS}
%    \begin{macrocode}
\newcommand*{\GLS}{\@ifstar\@sGLS\@GLS}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLS}[1][]{\@GLS[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLS}[2][]{%
\@ifnextchar[{\@GLS@{#1}{#2}}{\@GLS@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLS@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\ifglsused{#2}{\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\glsentrytext{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
%    \end{macrocode}
% Indicate that this entry has now been used, and add a space if
% appropriate
%    \begin{macrocode}
\glsunset{#2}}%
\xspace}
%    \end{macrocode}
%
% \cs{glspl} behaves in the same way as \icmdname{gls} except
% it uses the plural form.
%\begin{macro}{\glspl}
%    \begin{macrocode}
\newcommand*{\glspl}{\@ifstar\@sglspl\@glspl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglspl}[1][]{\@glspl[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glspl}[2][]{%
\@ifnextchar[{\@glspl@{#1}{#2}}{\@glspl@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glspl@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\ifglsused{#2}{\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\glsentryplural{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text}%
%    \end{macrocode}
% Indicate that this entry has now been used, and add a space if
% appropriate
%    \begin{macrocode}
\glsunset{#2}}%
\xspace}
%    \end{macrocode}
%
% \cs{Glspl} behaves in the same way as \icmdname{glspl}, except
% that the first letter of the link text is converted to uppercase
% (as with \icmdname{Gls}, if the first letter has an accent, it
% will need to be grouped.)
%\begin{macro}{\Glspl}
%    \begin{macrocode}
\newcommand*{\Glspl}{\@ifstar\@sGlspl\@Glspl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlspl}[1][]{\@Glspl[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glspl}[2][]{%
\@ifnextchar[{\@Glspl@{#1}{#2}}{\@Glspl@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glspl@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\ifglsused{#2}{\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\glsentryplural{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\expandafter\MakeUppercase\@glo@text}%
%    \end{macrocode}
% Indicate that this entry has now been used, and add a space if
% appropriate
%    \begin{macrocode}
\glsunset{#2}}%
\xspace}
%    \end{macrocode}
%
% \cs{GLSpl} behaves like \icmdname{glspl} except that all the
% link text is converted to uppercase.
%\begin{macro}{\GLSpl}
%    \begin{macrocode}
\newcommand*{\GLSpl}{\@ifstar\@sGLSpl\@GLSpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSpl}[1][]{\@GLSpl[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSpl}[2][]{%
\@ifnextchar[{\@GLSpl@{#1}{#2}}{\@GLSpl@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSpl@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\ifglsused{#2}{\protected@edef\@glo@text{%
\csname gls@\@glo@type @display\endcsname
{\glsentryplural{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}{%
\protected@edef\@glo@text{%
\csname gls@\@glo@type @displayfirst\endcsname
{\glsentryfirstplural{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
%    \end{macrocode}
% Indicate that this entry has now been used, and add a space if
% appropriate
%    \begin{macrocode}
\glsunset{#2}}%
\xspace}
%    \end{macrocode}
%
% \subsubsection{Displaying entry details without adding
% information to the glossary}
% 
% These commands merely display entry information without adding
% entries in the associated file or having hyperlinks.
%
% Get the entry name (as specified by the \gloskey{name} key
% when the entry was defined.) The argument
% is the label associated with the entry. Note that unless you
% used \texttt{name=false} in the \pkgopt{sanitize} package option 
% you may get unexpected results if the \gloskey{name} key contained 
% any commands.
%\begin{macro}{\glsentryname}
%    \begin{macrocode}
\newcommand*{\glsentryname}[1]{\csname glo@#1@name\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryname}
%    \begin{macrocode}
\newcommand*{\Glsentryname}[1]{\expandafter
\MakeUppercase\csname glo@#1@name\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Get the entry description (as specified by the 
% \gloskey{description} when the entry was defined.) The argument
% is the label associated with the entry. Note that unless you
% used \texttt{description=false} in the \pkgopt{sanitize} package 
% option you may get unexpected results if the \gloskey{description} 
% key contained any commands.
%\begin{macro}{\glsentrydesc}
%    \begin{macrocode}
\newcommand*{\glsentrydesc}[1]{\csname glo@#1@desc\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrydesc}
%    \begin{macrocode}
\newcommand*{\Glsentrydesc}[1]{\expandafter
\MakeUppercase\csname glo@#1@desc\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Get the entry text, as specified by the \gloskey{text} key when
% the entry was defined. The argument
% is the label associated with the entry:
%\begin{macro}{\glsentrytext}
%    \begin{macrocode}
\newcommand*{\glsentrytext}[1]{\csname glo@#1@text\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrytext}
%    \begin{macrocode}
\newcommand*{\Glsentrytext}[1]{\expandafter
\MakeUppercase\csname glo@#1@text\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Get the plural form:
%\begin{macro}{\glsentryplural}
%    \begin{macrocode}
\newcommand*{\glsentryplural}[1]{\csname glo@#1@plural\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryplural}
%    \begin{macrocode}
\newcommand*{\Glsentryplural}[1]{\expandafter
\MakeUppercase\csname glo@#1@plural\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Get the symbol associated with this entry. The argument
% is the label associated with the entry. Note that unless you
% used \texttt{symbol=false} in the \pkgopt{sanitize} package 
% option you may get unexpected results if the \gloskey{symbol} 
% key contained any commands.
%\begin{macro}{\glsentrysymbol}
%    \begin{macrocode}
\newcommand*{\glsentrysymbol}[1]{\csname glo@#1@symbol\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrysymbol}
%    \begin{macrocode}
\newcommand*{\Glsentrysymbol}[1]{\expandafter
\MakeUppercase\csname glo@#1@symbol\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Get the entry text to be used when the entry is first used in
% the document (as specified by the \gloskey{first} key when
% the entry was defined.)
%\begin{macro}{\glsentryfirst}
%    \begin{macrocode}
\newcommand*{\glsentryfirst}[1]{\csname glo@#1@first\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfirst}
%    \begin{macrocode}
\newcommand*{\Glsentryfirst}[1]{\expandafter
\MakeUppercase\csname glo@#1@first\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Get the plural form (as specified by the \gloskey{firstplural}
% key when the entry was defined.)
%\begin{macro}{\glsentryfirstplural}
%    \begin{macrocode}
\newcommand*{\glsentryfirstplural}[1]{%
\csname glo@#1@firstpl\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfirstplural}
%    \begin{macrocode}
\newcommand*{\Glsentryfirstplural}[1]{%
\expandafter\MakeUppercase\csname glo@#1@firstpl\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Display the glossary type with which this entry is associated
% (as specified by the \gloskey{type} key used when the entry was 
% defined)
%\begin{macro}{\glsentrytype}
%    \begin{macrocode}
\newcommand*{\glsentrytype}[1]{\csname glo@#1@type\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Display the sort text used for this entry. Note that the 
% \gloskey{sort} key is sanitize, so unexpected results may 
% occur if the \gloskey{sort} key contained commands.
%\begin{macro}{\glsentrysort}
%    \begin{macrocode}
\newcommand*{\glsentrysort}[1]{\csname glo@#1@sort\endcsname}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Adding an entry to the glossary without generating
% text}
% The following keys are provided for \cs{glsadd} and 
% \cs{glsaddall}:
%    \begin{macrocode}
\define@key{glossadd}{counter}{\def\@glo@counter{#1}}
\define@key{glossadd}{format}{\def\@glo@format{#1}}
%    \end{macrocode}
% This key is only used by \cs{glsaddall}:
%    \begin{macrocode}
\define@key{glossadd}{types}{\def\@glo@type{#1}}
%    \end{macrocode}
%\vskip5pt
%\cs{glsadd}\oarg{options}\marg{label}\\[10pt]
% Add a term to the glossary without generating any link text. 
% The optional argument indicates which counter to use, 
% and how to format it (using a key-value list)
% the second argument is the entry label. Note that \meta{options}
% only has two keys: \gloskey[glsadd]{counter} and \gloskey[glsadd]{format} (the \gloskey[glsaddall]{types} key will be ignored).
%\begin{macro}{\glsadd}
%\changes{1.07}{2007 Sep 13}{fixed bug caused by \cs{theglsentrycounter} setting the page number too soon}
%    \begin{macrocode}
\newcommand*{\glsadd}[2][]{%
\glsdoifexists{#2}{%
\def\@glo@format{glsnumberformat}%
\edef\@glo@counter{\csname glo@#2@counter\endcsname}%
\setkeys{glossadd}{#1}%
\edef\theglsentrycounter{\expandafter\noexpand\csname the\@glo@counter\endcsname}%
\protected@edef\@glo@sort{\csname glo@#2@sort\endcsname}%
\@gls@checkmkidxchars\@glo@sort
\protected@edef\@@glo@name{\csname glo@#2@name\endcsname}%
\@gls@checkmkidxchars\@@glo@name
\protected@edef\@glo@name{\string\glsnamefont{\@@glo@name}}%
\protected@edef\@glo@desc{\csname glo@#2@desc\endcsname}%
\@gls@checkmkidxchars\@glo@desc
\protected@edef\@glo@symbol{\csname glo@#2@symbol\endcsname}%
\@gls@checkmkidxchars\@glo@symbol
\@set@glo@numformat\@glo@numfmt\@glo@counter\@glo@format
\glossary[\csname glo@#2@type\endcsname]{%
\@glo@sort\@gls@actualchar\string\glossaryentryfield
{#2}{\@glo@name}{\@glo@desc}{\@glo@symbol}\@gls@encapchar
\@glo@numfmt}%
}}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
%\cs{glsaddall}\oarg{glossary list}\\[10pt]
% Add all terms defined for the listed glossaries (without displaying
% any text.) If \gloskey[glsaddall]{types} key is omitted, apply to all
% glossary types.
%\begin{macro}{\glsaddall}
%    \begin{macrocode}
\newcommand*{\glsaddall}[1][]{%
\def\@glo@type{\@glo@types}%
\setkeys{glossadd}{#1}%
\forallglsentries[\@glo@type]{\@glo@entry}{%
\glsadd[#1]{\@glo@entry}}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Creating associated files}
% The \cs{writeist} command creates the associated 
% customized \filetype{ist} \appname{makeindex} style file.
% While defining this command, some characters have their 
% catcodes temporarily changed to ensure they get written to 
% the \filetype{ist} file correctly. The \appname{makeindex} 
% actual character (usually "@") is redefined to be a "?", to allow 
% internal commands to be written to the glossary file output file.
%
% The special characters\mkidxspch\ are stored in \cs{@gls@actualchar},
% \cs{@gls@encapchar}, \cs{@glsl@levelchar} and
% \cs{@gls@quotechar} to make them easier to use later,
% but don't change these values, because the characters are
% encoded in the command definitions that are used to escape
% the special characters (which means that the user no longer
% needs to worry about \appname{makeindex} special characters.)
%
% The symbols and numbers label for group headings are hardwired into
% the \filetype{ist} file as \texttt{glssymbols} and 
% \texttt{glsnumbers}, the group titles can be translated 
% (so that \icmdname{glssymbolsgroupname} replaces \texttt{glssymbols}
% and \icmdname{glsnumbersgroupname} replaces \texttt{glsnumbers})
% using the command \icmdname{glsgetgrouptitle} which is
% defined in \styname{glossary-hypernav}. This is done to prevent
% any problem characters in \icmdname{glssymbolsgroupname}
% and \icmdname{glsnumbersgroupname} from breaking hyperlinks.
%
% Some of these lines are too long to fit on the page, but as I 
% have temporarily disabled the comment character, I can't split
% the lines. If you want to see the code in full, have a look at
% \texttt{glossaries.sty}.
%\changes{1.01}{2007 May 17}{Added spaces after 'delimN and 'delimR in ist file}%
%\begin{macro}{\writeist}
%    \begin{macrocode}
\newwrite\istfile
\bgroup
\catcode`\%12\relax
\catcode`\"12\relax
\catcode`\|12\relax
\catcode`\!12\relax
\catcode`\?12\relax
\gdef\@gls@actualchar{?}
\gdef\@gls@encapchar{|}
\gdef\@gls@levelchar{!}
\gdef\@gls@quotechar{"}
\gdef\writeist{\relax
\protected@write\@auxout{}{\string\@istfilename{\istfilename}}
\openout\istfile=\istfilename
\write\istfile{% makeindex style file created by the glossaries package}
\write\istfile{% for document '\jobname' on \the\year-\the\month-\the\day}
\write\istfile{actual '\@gls@actualchar'}
\write\istfile{encap '\@gls@encapchar'}
\write\istfile{level '\@gls@levelchar'}
\write\istfile{quote '\@gls@quotechar'}
\write\istfile{keyword "\string\\glossaryentry"}
\write\istfile{preamble "\string\\glossarysection[\string\\glossarytoctitle]{\string\\glossarytitle}\string\\glossarypreamble\string\n\string\\begin{theglossary}\string\\glossaryheader\string\n"}
\write\istfile{postamble "\string\n\string\\end{theglossary}\string\n\string\\glossarypostamble\string\n"}
\write\istfile{group_skip "\string\\glsgroupskip\string\n"}
\write\istfile{item_0 "\string\n"}
\write\istfile{delim_0 "\{\string\\glossaryentrynumbers\{\string\\relax "}
\write\istfile{delim_t "\}\}"}
\write\istfile{delim_n "\string\\delimN "}
\write\istfile{delim_r "\string\\delimR "}
\write\istfile{headings_flag 1}
\write\istfile{heading_prefix "\string\\glsgroupheading\{"}
\write\istfile{heading_suffix "\}"}
\write\istfile{symhead_positive "glssymbols"}
\write\istfile{numhead_positive "glsnumbers"}
\write\istfile{page_compositor "\glscompositor"}
\noist}
\egroup
%    \end{macrocode}
%\end{macro}
%
%The command \cs{noist} will suppress the creation of
% the \filetype{ist} file (it simply redefines 
% \cs{writeist} to do nothing.) Obviously you need to use this
% command before \cs{writeist} to have any effect. Since
% the \filetype{ist} file should only be created once, \cs{noist}
% is called at the end of \cs{writeist}.
%\begin{macro}{\noist}
%    \begin{macrocode}
\newcommand{\noist}{\let\writeist\relax}
%    \end{macrocode}
%\end{macro}
%
% \cs{@makeglossary} is an internal command that takes an 
% argument indicating the glossary type. This command will 
% create the glossary file required by \appname{makeindex} for the
% given glossary type, using the extension supplied by the
% \meta{out-ext} parameter used in \icmdname{newglossary} 
% (and it will also activate the \icmdname{glossary} command, 
% and create the customized \filetype{ist} \appname{makeindex} 
% style file.) 
%
% Note that you can't use \cs{@makeglossary} for only some of the
% defined glossaries. You either need to have a \cs{makeglossary}
% for all glossaries or none (otherwise you will end up with a
% situation where \TeX\ is trying to write to a non-existant
% file.) The relevant glossary must be
% defined prior to using \cs{@makeglossary}.
%\begin{macro}{\@makeglossary}
%    \begin{macrocode}
\newcommand*{\@makeglossary}[1]{%
\ifglossaryexists{#1}{%
\edef\glo@out{\csname @glotype@#1@out\endcsname}%
\expandafter\newwrite\csname glo@#1@file\endcsname
\edef\@glo@file{\csname glo@#1@file\endcsname}%
\immediate\openout\@glo@file=\jobname.\glo@out
\@gls@renewglossary
\PackageInfo{glossaries}{Writing glossary file \jobname.\glo@out}
\writeist
}{\PackageError{glossaries}{%
Glossary type `#1' not defined}{New glossaries must be defined before
using \string\makeglossary}}}
%    \end{macrocode}
%\end{macro}
%
% \cs{makeglossaries} will use \cs{@makeglossary}
% for each glossary type that has been defined.  New glossaries
% need to be defined before using \cs{makeglossary}, so
% have \cs{makeglossaries} redefine \cs{newglossary}
% to prevent it being used afterwards.
%\begin{macro}{\makeglossaries}
%    \begin{macrocode}
\newcommand*{\makeglossaries}{%
\@for\@glo@type:=\@glo@types\do{%
\ifthenelse{\equal{\@glo@type}{}}{}{%
\@makeglossary{\@glo@type}}}%
\renewcommand*\newglossary[4][]{%
\PackageError{glossaries}{New glossaries
must be created before \string\makeglossaries}{You need
to move \string\makeglossaries\space after all your 
\string\newglossary\space commands}}%
\let\@makeglossary\empty
\let\makeglossary\empty}
%    \end{macrocode}
%\end{macro}
%
% The \cs{makeglossary} command is redefined to be
% identical to \cs{makeglossaries}. (This is done to 
% reinforce the message that you must either use 
% \cs{@makeglossary} for all the glossaries or for none 
% of them.)
%\begin{macro}{\makeglossary}
%    \begin{macrocode}
\let\makeglossary\makeglossaries
%    \end{macrocode}
%\end{macro}
%
%\subsection{Writing information to associated files}
% The \cs{glossary} command is redefined so that it takes an 
% optional argument \meta{type} to specify the glossary type (use 
% \cs{glsdefaulttype} glossary by default). 
% This shouldn't be used at user level
% as \cs{glslink} sets the correct format. The associated 
% number should be stored in \cs{theglsentrycounter}
% before using \cs{glossary}.
%\begin{macro}{\glossary}
%    \begin{macrocode}
\renewcommand*{\glossary}[1][\glsdefaulttype]{%
\@glossary[#1]}
%    \end{macrocode}
%\end{macro}
%
% Define internal \cs{@glossary} to ignore its argument.
% This gets redefined in \cs{@makeglossary}.
%\begin{macro}{\@glossary}
%    \begin{macrocode}
\def\@glossary[#1]{\@bsphack\begingroup\@sanitize\@index}
%    \end{macrocode}
%\end{macro}
% This is a convenience command to set \cs{@glossary}.
% It is used by \cs{@makeglossary} and then redefined to
% do nothing, as it only needs to be done once.
%\begin{macro}{@gls@renewglossary}
%    \begin{macrocode}
\newcommand{\@gls@renewglossary}{%
\gdef\@glossary[##1]{\@bsphack\begingroup\@wrglossary{##1}}%
\let\@gls@renewglossary\@empty
}
%    \end{macrocode}
%\end{macro}
% The \cs{@wrglossary} command is redefined to have
% two arguments. The first argument is the glossary type, 
% the second argument is the glossary entry 
% (the format of which is set in \cs{glslink}.)
%\begin{macro}{\@wrglossary}
%    \begin{macrocode}
\renewcommand*{\@wrglossary}[2]{%
\expandafter\protected@write\csname glo@#1@file\endcsname{}{%
\string\glossaryentry{#2}{\theglsentrycounter}}\endgroup\@esphack}
%    \end{macrocode}
%\end{macro}
%
% \subsection{Displaying the glossary}\label{sec:printglos}
% An individual glossary is displayed in the text using
% \cs{printglossary}\oarg{key-val list}. If the 
% \gloskey[printglossary]{type} key is omitted, the default glossary is displayed.
% The optional argument can be used to specify an alternative
% glossary, and can also be used to set the style, title and
% entry in the table of contents. Available keys are defined below.
%\begin{macro}{\printglossary}
%    \begin{macrocode}
\newcommand*{\printglossary}[1][type=\glsdefaulttype]{%
\def\@glo@type{\glsdefaulttype}%
\def\glossarytitle{\csname @glotype@\@glo@type @title\endcsname}%
\def\glossarytoctitle{\glossarytitle}%
\def\@glossarystyle{}%
\setkeys{printgloss}{#1}%
\bgroup
\@glossarystyle
\makeatletter
\@input@{\jobname.\csname @glotype@\@glo@type @in\endcsname}%
\egroup
}
%    \end{macrocode}
%\end{macro}
%
% The \cs{printglossaries} command will do \cs{printglossary}
% for each glossary type that has been defined. It is better
% to use \cs{printglossaries} rather than individual
% \cs{printglossary} commands to ensure that you don't forget
% any new glossaries you may have created. It also makes it easier to
% chop and change the value of the \pkgopt{acronym} package option.
% However, if you want to list the glossaries in a different order,
% or if you want to set the title or table of contents entry, or
% if you want to use different glossary styles for each glossary, you
% will need to use \cs{printglossary} explicitly for each
% glossary type.
%\begin{macro}{\printglossaries}
%    \begin{macrocode}
\newcommand*{\printglossaries}{%
\forallglossaries{\@@glo@type}{\printglossary[type=\@@glo@type]}}
%    \end{macrocode}
%\end{macro}
% The keys that can be used in the optional argument to
% \icmdname{printglossary} are as follows:
% The \gloskey[printglossary]{type} key sets the glossary type.
%    \begin{macrocode}
\define@key{printgloss}{type}{\def\@glo@type{#1}}
%    \end{macrocode}
% The \gloskey[printglossary]{title} key sets the title used in the glossary section
% header. This overrides the title used in \icmdname{newglossary}.
%    \begin{macrocode}
\define@key{printgloss}{title}{\def\glossarytitle{#1}}
%    \end{macrocode}
% The \gloskey[printglossary]{toctitle} sets the text used for the relevant entry 
% in the table of contents.
%    \begin{macrocode}
\define@key{printgloss}{toctitle}{\def\glossarytoctitle{#1}}
%    \end{macrocode}
% The \gloskey[printglossary]{style} key sets the glossary style (but only for
% the given glossary.)
%    \begin{macrocode}
\define@key{printgloss}{style}{%
\@ifundefined{@glsstyle@#1}{\PackageError{glossaries}{Glossary 
style `#1' undefined}{}}{%
\def\@glossarystyle{\csname @glsstyle@#1\endcsname}}}
%    \end{macrocode}
%
%\DescribeEnv{theglossary}
% If the \envname{theglossary} environment has 
% already been defined, a warning will be issued. 
% This environment should be redefined by glossary styles.
%    \begin{macrocode}
\@ifundefined{theglossary}{%
\newenvironment{theglossary}{}{}}{%
\PackageWarning{glossaries}{overriding `theglossary' environment}%
\renewenvironment{theglossary}{}{}}
%    \end{macrocode}
%
% The glossary header is given by \cs{glossaryheader}. 
% This forms part of the glossary style, and
% must indicate what should appear immediately after the start of the
% \envname{theglossary} environment. (For example, if the glossary
% uses a tabular-like environment, it may be used to set the
% header row.) Note that if you don't want a header row, the glossary
% style must redefine \cs{glossaryheader} to do nothing.
%\begin{macro}{\glossaryheader}
%    \begin{macrocode}
\newcommand*{\glossaryheader}{}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
% \cs{glossaryentryfield}\marg{label}\marg{name}\marg{description}\marg{symbol}\marg{page-list}\\[10pt]
% This command governs how each entry row should be formatted 
% in the glossary. Glossary styles need to redefine this command.
% Most of the predefined styles ignore \meta{symbol}.
%\begin{macro}{\glossaryentryfield}
%    \begin{macrocode}
\newcommand*{\glossaryentryfield}[5]{%
\@glstarget{glo:#1}{#2} #4 #3. #5\par}
%    \end{macrocode}
%\end{macro}
%
% Within each glossary, the entries form 28 distinct groups
% which are determined by the first character of the \gloskey{sort} 
% key. There will be a maximum of 28 groups: symbols, numbers,
% and the 26 alphabetical groups A, \ldots, Z\@. 
% The command \cs{glsgroupskip} 
% specifies what to do between glossary groups. Glossary styles
% must redefine this command. (Note that \cs{glsgroupskip}
% only occurs between groups, not at the start or end of the
% glossary.)
%\begin{macro}{\glsgroupskip}
%    \begin{macrocode}
\newcommand*{\glsgroupskip}{}
%    \end{macrocode}
%\end{macro}
%
% Each of the 28 glossary groups described above is preceded by a 
% group heading.
% This is formatted by the command \cs{glsgroupheading}
% which takes one argument which is the \emph{label} assigned to that
% group (not the title). The corresponding labels are: \texttt{glssymbols},
% \texttt{glsnumbers}, \texttt{A}, \ldots, \texttt{Z}. 
% Glossary styles must redefined this command. (In between groups,
% \cs{glsgroupheading} comes immediately after \cs{glsgroupskip}.)
%\begin{macro}{\glsgroupheading}
%    \begin{macrocode}
\newcommand*{\glsgroupheading}[1]{}
%    \end{macrocode}
%\end{macro}
% It is possible to ``trick'' \appname{makeindex} into
% treating entries as though they belong to the same group, 
% even if the terms don't start with the same letter, by
% modifying the \gloskey{sort} key. For example, all entries 
% belonging to one
% group could be defined so that the \gloskey{sort} key starts with an
% "a", while entries belonging to another group could be defined
% so that the \gloskey{sort} key starts with a "b", and so on. If
% you want each group to have a heading, you would then need to
% modify the translation control sequences \cs{glsgetgrouptitle}
% and \cs{glsgetgrouplabel} so that the label is translated
% into the required title (and vice-versa.)
%\\[10pt]
%\cs{glsgetgrouptitle}\marg{label}\\[10pt]
% This command produces the title for the glossary group
% whose label is given by \meta{label}. By default, the group
% labelled \texttt{glssymbols} produces 
% \icmdname{glssymbolsgroupname}, the group labelled 
% \texttt{glsnumbers} produces \icmdname{glsnumbersgroupname}
% and all the other groups simply produce their label.
% As mentioned above, the group labels are: \texttt{glssymbols}, \texttt{glsnumbers},
% \texttt{A}, \ldots, \texttt{Z}\@. If you want to redefine
% the group titles, you will need to redefine this command.
%\begin{macro}{\glsgetgrouptitle}
%    \begin{macrocode}
\newcommand*{\glsgetgrouptitle}[1]{%
\@ifundefined{#1groupname}{#1}{\csname #1groupname\endcsname}}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
%\cs{glsgetgrouplabel}\marg{title}\\[10pt]
%This command does the reverse to the previous command. The
% argument is the group title, and it produces the group label.
% Note that if you redefine \cs{glsgetgrouptitle}, you
% will also need to redefine \cs{glsgetgrouplabel}.
%\begin{macro}{\glsgetgrouplabel}
%    \begin{macrocode}
\newcommand*{\glsgetgrouplabel}[1]{%
\ifthenelse{\equals{#1}{\glssymbolsgroupname}}{glssymbols}{%
\ifthenelse{\equals{#1}{\glsnumbersgroupname}}{glsnumbers}{#1}}}
%    \end{macrocode}
%\end{macro}
%
% The command \cs{setentrycounter} sets the entry's 
% associated counter (required by 
% \cs{glshypernumber} etc.) \icmdname{glslink} and
% \icmdname{glsadd} encode the
% \icmdname{glossary} argument so that the relevant counter is
% set prior to the formatting command.
%\begin{macro}{\setentrycounter}
%    \begin{macrocode}
\newcommand*{\setentrycounter}[1]{\def\glsentrycounter{#1}}
%    \end{macrocode}
%\end{macro}
%
% The current glossary style can be set using
% \cs{glossarystyle}\marg{style}.
%\begin{macro}{\glossarystyle}
%    \begin{macrocode}
\newcommand*{\glossarystyle}[1]{%
\@ifundefined{@glsstyle@#1}{\PackageError{glossaries}{Glossary 
style `#1' undefined}{}}{%
\csname @glsstyle@#1\endcsname}}
%    \end{macrocode}
%\end{macro}
%
% New glossary styles can be defined using:\\[10pt]
% \cs{newglossarystyle}\marg{name}\marg{definition}\\[10pt]
% The \meta{definition} argument should redefine 
% \envname{theglossary}, \icmdname{glossaryheader}, 
% \icmdname{glsgroupheading}, \icmdname{glossaryentryfield} and
% \icmdname{glsgroupskip} (see \autoref{sec:styles} for the
% definitions of predefined styles.) Glossary styles should not 
% redefine \icmdname{glossarypreamble} and 
% \icmdname{glossarypostamble}, as
% the user should be able to switch between styles without affecting
% the pre- and postambles.
%\begin{macro}{\newglossarystyle}
%    \begin{macrocode}
\newcommand*{\newglossarystyle}[2]{%
\@ifundefined{@glsstyle@#1}{%
\expandafter\def\csname @glsstyle@#1\endcsname{#2}}{%
\PackageError{glossaries}{Glossary style `#1' is already defined}{}}}
%    \end{macrocode}
%\end{macro}
%
% Glossary entries are encoded so that the second argument
% to \icmdname{glossaryentryfield} is always specified as
% \cs{glsnamefont}\marg{name}. This allows the
% user to change the font used to display the name term
% without having to redefine \icmdname{glossaryentryfield}.
% The default uses the surrounding font, so in the list type
% styles (which place the name in the optional argument to
% \icmdname{item}) the name will appear in bold.
%\begin{macro}{\glsnamefont}
%    \begin{macrocode}
\newcommand*{\glsnamefont}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
% Each glossary entry has an associated number list (usually page
% numbers) that indicate where in the document the entry has been
% used. The format for these number lists can be changed using the
% \gloskey[glslink]{format}\igloskey[glsadd]{format} key in commands like \icmdname{glslink}.
% The default format is given by \cs{glshypernumber}. This takes
% a single argument which may be a single number, a number range
% or a number list. The number ranges are delimited with 
% \icmdname{delimR}, the number lists are delimited with 
% \icmdname{delimN}.
%
% If the document doesn't have hyperlinks, the numbers can be
% displayed just as they are, but if the document supports 
% hyperlinks, the numbers should link to the relevant location.
% This means extracting the individual numbers from the list or
% ranges. The \styname{hyperref} package does this with the
% \icmdname{hyperpage} command, but this is encoded for comma and
% dash delimiters and only for the page counter, but this code needs
% to be more general. So I have adapted the code used in the
% \styname{hyperref} package.
%\begin{macro}{\glshypernumber}
%    \begin{macrocode}
\@ifundefined{hyperlink}{%
\def\glshypernumber#1{#1}}{%
\def\glshypernumber#1{%
\@delimR#1\delimR\delimR\\}}
%    \end{macrocode}
%\end{macro}
% \cs{@delimR} displays a range of numbers for the counter 
% whose name is given by 
% \cs{@gls@counter} (which must be set prior to using
% \cs{glshypernumber}.)
%\begin{macro}{\@delimR}
%    \begin{macrocode}
\def\@delimR#1\delimR #2\delimR #3\\{%
\ifx\\#2\\%
  \@delimN{#1}%
\else
  \@gls@numberlink{#1}\delimR\@gls@numberlink{#2}%
\fi}
%    \end{macrocode}
%\end{macro}
% \cs{@delimN} displays a list of individual numbers, 
% instead of a range:
%\begin{macro}{\@delimN}
%    \begin{macrocode}
\def\@delimN#1{\@@delimN#1\delimN \delimN\\}
\def\@@delimN#1\delimN #2\delimN#3\\{%
\ifx\\#3\\%
  \@gls@numberlink{#1}%
\else
  \@gls@numberlink{#1}\delimN\@gls@numberlink{#2}%
\fi
}
%    \end{macrocode}
%\end{macro}
% The following code is modified from hyperref's 
% \cs{HyInd@pagelink} where
% the name of the counter being used is given by 
% \cs{@gls@counter}.
%    \begin{macrocode}
\def\@gls@numberlink#1{%
\begingroup
 \toks@={}%
 \@gls@removespaces#1 \@nil
\endgroup}
%    \end{macrocode}
%    \begin{macrocode}
\def\@gls@removespaces#1 #2\@nil{%
 \toks@=\expandafter{\the\toks@#1}%
 \ifx\\#2\\%
   \edef\x{\the\toks@}%
   \ifx\x\empty
   \else
     \hyperlink{\glsentrycounter.\the\toks@}{\the\toks@}%
   \fi
 \else
   \@gls@ReturnAfterFi{%
     \@gls@removespaces#2\@nil
   }%
 \fi
}
\long\def\@gls@ReturnAfterFi#1\fi{\fi#1}
%    \end{macrocode}
%
% The following commands will switch to the
% appropriate font, and create a hyperlink, if hyperlinks are
% supported. If hyperlinks are not supported, they will just
% display their argument in the appropriate font.
%\begin{macro}{\hyperrm}
%    \begin{macrocode}
\newcommand*{\hyperrm}[1]{\textrm{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypersf}
%    \begin{macrocode}
\newcommand*{\hypersf}[1]{\textsf{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypertt}
%    \begin{macrocode}
\newcommand*{\hypertt}[1]{\texttt{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperbf}
%    \begin{macrocode}
\newcommand*{\hyperbf}[1]{\textbf{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypermd}
%    \begin{macrocode}
\newcommand*{\hypermd}[1]{\textmd{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperit}
%    \begin{macrocode}
\newcommand*{\hyperit}[1]{\textit{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypersl}
%    \begin{macrocode}
\newcommand*{\hypersl}[1]{\textsl{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperup}
%    \begin{macrocode}
\newcommand*{\hyperup}[1]{\textup{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypersc}
%    \begin{macrocode}
\newcommand*{\hypersc}[1]{\textsc{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperemph}
%    \begin{macrocode}
\newcommand*{\hyperemph}[1]{\emph{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Acronyms}\label{sec:acronym}
%If the \pkgopt{acronym} package option is used, a 
% new glossary called "acronym" is created
%    \begin{macrocode}
\ifglsacronym
\newglossary[alg]{acronym}{acr}{acn}{\acronymname}
%    \end{macrocode}
%and \icmdname{acronymtype} is set to the name of this new glossary.
%    \begin{macrocode}
\renewcommand{\acronymtype}{acronym}
%    \end{macrocode}
% In the event that the user redefines \icmdname{glsdisplay}
% and \icmdname{glsdisplayfirst}, the relevant commands for
% the new acronym glossary are set to match the format
% given by \icmdname{newacronym}. If you redefine 
% \icmdname{newacronym} you may need to set these to something
% else.
%    \begin{macrocode}
\defglsdisplay[acronym]{#1#4}\defglsdisplayfirst[acronym]{#1#4}
\fi
%    \end{macrocode}
%\vskip5pt
% \cs{newacronym}\oarg{key-val list}\marg{label}\marg{abbrev}\marg{long}\\[10pt]
% This is a quick way of defining acronyms, all it does
% is call \icmdname{newglossaryentry} with the appropriate
% values. It sets the
% glossary type to \icmdname{acronymtype} which will be
% "acronym" if the package option \pkgopt{acronym} has
% been used, otherwise it will be the default glossary.
% Since \cs{newacronym} merely calls \icmdname{newglossaryentry},
% the acronym is treated like any other glossary entry.
%
% If you prefer a different format, you
% can redefine \cs{newacronym} as required. The optional 
% argument can be used to override any of the settings.
%\begin{macro}{\newacronym}
%    \begin{macrocode}
\newcommand{\newacronym}[4][]{%
\newglossaryentry{#2}{type=\acronymtype,%
name={#3},description={#4},text={#3},%
first={#4 (#3)},plural={#3s},firstplural={#4s (#3s)},#1}}
%    \end{macrocode}
%\end{macro}
% New acronyms can only be defined in the preamble:
%    \begin{macrocode}
\@onlypreamble{\newacronym}
%    \end{macrocode}
%
% \subsection{Predefined Styles}\label{sec:styles}
% The \styname{glossaries} bundle comes with some predefined glossary styles which
% are defined in the following packages:
%    \begin{macrocode}
\RequirePackage{glossary-hypernav}
\RequirePackage{glossary-list}
\RequirePackage{glossary-long}
\RequirePackage{glossary-super}
%    \end{macrocode}
% The default glossary style is set according to the \pkgopt{style} package
% option, but can be overridden by \icmdname{glossarystyle}.
%    \begin{macrocode}
\glossarystyle{\@glossary@default@style}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-hypernav.sty>
%    \end{macrocode}
%\fi
% \subsubsection{Glossary hyper-navigation definitions (glossary-hypernav package)}
% Package Definition:
%    \begin{macrocode}
\ProvidesPackage{glossary-hypernav}[2007/07/04 v1.01 (NLCT)]
%    \end{macrocode}
%
% The commands defined in this package are provided to 
% help navigate around the groups within a glossary 
% (see \autoref{sec:printglos}.)
% \icmdname{printglossary} (and \icmdname{printglossaries})
% set \cs{@glo@type} to the label of the current
% glossary. This is used to create a unique hypertarget in
% the event of multiple glossaries.
%\\[10pt]
% \cs{glsnavhyperlink}\oarg{type}\marg{label}\marg{text}\\[10pt]
% This command makes \meta{text} a hyperlink to the glossary group
% whose label is given by \meta{label} for the glossary given
% by \meta{type}.
%\begin{macro}{\glsnavhyperlink}
%    \begin{macrocode}
\@ifundefined{hyperlink}{%
\newcommand*{\glsnavhyperlink}[3][]{#3}}{%
\newcommand*{\glsnavhyperlink}[3][\@glo@type]{%
\edef\gls@grplabel{#2}\edef\@gls@grptitle{#3}%
\hyperlink{glsn:#1@#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
% \cs{glsnavhypertarget}\oarg{type}\marg{label}\marg{text}\\[10pt]
% This command makes \meta{text} a hypertarget for the glossary group
% whose label is given by \meta{label} in the glossary given
% by \meta{type}.
%\begin{macro}{\glsnavhypertarget}
%    \begin{macrocode}
\@ifundefined{hypertarget}{%
\newcommand*{\glsnavhypertarget}[3][]{#3}}{%
\newcommand*{\glsnavhypertarget}[3][\@glo@type]{%
\hypertarget{glsn:#1@#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%
% The \cs{glsnavigation} command displays a simple glossary 
% group navigation. 
% The symbol and number elements are defined separately, 
% so that they can be suppressed if need be. Note that this 
% command will produce a link to all 28 groups, but some groups
% may not be defined if there are groups that do not contain any
% terms, in which case you will get an undefined hyperlink warning.
% Now for the whole navigation bit:
%\begin{macro}{\glsnavigation}
%    \begin{macrocode}
\newcommand*{\glsnavigation}{%
\glssymbolnav
\glsnavhyperlink{A}{\glsgetgrouptitle{A}} \textbar\
\glsnavhyperlink{B}{\glsgetgrouptitle{B}} \textbar\ 
\glsnavhyperlink{C}{\glsgetgrouptitle{C}} \textbar\
\glsnavhyperlink{D}{\glsgetgrouptitle{D}} \textbar\
\glsnavhyperlink{E}{\glsgetgrouptitle{E}} \textbar\
\glsnavhyperlink{F}{\glsgetgrouptitle{F}} \textbar\
\glsnavhyperlink{G}{\glsgetgrouptitle{G}} \textbar\
\glsnavhyperlink{H}{\glsgetgrouptitle{H}} \textbar\
\glsnavhyperlink{I}{\glsgetgrouptitle{I}} \textbar\
\glsnavhyperlink{J}{\glsgetgrouptitle{J}} \textbar\
\glsnavhyperlink{K}{\glsgetgrouptitle{K}} \textbar\
\glsnavhyperlink{L}{\glsgetgrouptitle{L}} \textbar\
\glsnavhyperlink{M}{\glsgetgrouptitle{M}} \textbar\
\glsnavhyperlink{N}{\glsgetgrouptitle{N}} \textbar\
\glsnavhyperlink{O}{\glsgetgrouptitle{O}} \textbar\
\glsnavhyperlink{P}{\glsgetgrouptitle{P}} \textbar\
\glsnavhyperlink{Q}{\glsgetgrouptitle{Q}} \textbar\
\glsnavhyperlink{R}{\glsgetgrouptitle{R}} \textbar\
\glsnavhyperlink{S}{\glsgetgrouptitle{S}} \textbar\
\glsnavhyperlink{T}{\glsgetgrouptitle{T}} \textbar\
\glsnavhyperlink{U}{\glsgetgrouptitle{U}} \textbar\
\glsnavhyperlink{V}{\glsgetgrouptitle{V}} \textbar\
\glsnavhyperlink{W}{\glsgetgrouptitle{W}} \textbar\
\glsnavhyperlink{X}{\glsgetgrouptitle{X}} \textbar\
\glsnavhyperlink{Y}{\glsgetgrouptitle{Y}} \textbar\
\glsnavhyperlink{Z}{\glsgetgrouptitle{Z}}}
%    \end{macrocode}
%\end{macro}
% The \cs{glssymbolnav} produces a simple navigation set of
% links for just the symbol and number groups. This is used at
% the start of \cs{glsnavigation}. If your glossary doesn't
% contain any symbol or navigation groups, you can redefine this
% command to do nothing.
%\begin{macro}{\glssymbolnav}
%    \begin{macrocode}
\newcommand*{\glssymbolnav}{%
\glsnavhyperlink{glssymbols}{\glsgetgrouptitle{glssymbols}} \textbar\
\glsnavhyperlink{glsnumbers}{\glsgetgrouptitle{glsnumbers}} \textbar\ 
}
%    \end{macrocode}
%\end{macro}
%\iffalse
%    \begin{macrocode}
%</glossary-hypernav.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-list.sty>
%    \end{macrocode}
%\fi
% \subsubsection{List Style (glossary-list package)}
% The \styname{glossary-list} package defines glossary styles
% that use the \envname{description} environment. Note that since
% the entry name is placed in the optional argument to the
% \icmdname{item} command, it will appear in a bold font by
% default.
%    \begin{macrocode}
\ProvidesPackage{glossary-list}[2007/07/04 v1.01 (NLCT)]
%    \end{macrocode}
% The \glostyle{list} glossary style 
% uses the \envname{description} environment. The group separator
% \icmdname{glsgroupskip} is redefined as \cs{indexspace}
% which produces a gap between groups. The glossary heading
% and the group headings do nothing. This is used as the default
% style for the \styname{glossaries} package.
%    \begin{macrocode}
\newglossarystyle{list}{%
\renewenvironment{theglossary}{\begin{description}}{\end{description}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossaryentryfield}[5]{%
\item[\@glstarget{glo:##1}{##2}] ##3\glspostdescription\space ##5}%
\renewcommand*{\glsgroupskip}{\indexspace}}
%    \end{macrocode}
% The \glostyle{listgroup} style is like the \glostyle{list}
% style, but the glossary groups have headings.
%    \begin{macrocode}
\newglossarystyle{listgroup}{%
\glossarystyle{list}%
\renewcommand*{\glsgroupheading}[1]{\item[##1]}}
%    \end{macrocode}
% The \glostyle{listhypergroup} style is like the \glostyle{listgroup}
% style, but has a set of links to the groups at the
% start of the glossary.
%    \begin{macrocode}
\newglossarystyle{listhypergroup}{%
\glossarystyle{list}%
\renewcommand*{\glossaryheader}{%
\item[]\glsnavigation}%
\renewcommand*{\glsgroupheading}[1]{%
\item[\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}]}}
%    \end{macrocode}
% The \glostyle{altlist} glossary style is like the \glostyle{list}
% style, but places the description on a new line.
%    \begin{macrocode}
\newglossarystyle{altlist}{%
\glossarystyle{list}%
\renewcommand*{\glossaryentryfield}[5]{%
\item[\@glstarget{glo:##1}{##2}]\mbox{}\newline ##3\glspostdescription\space ##5}%
}
%    \end{macrocode}
% The \glostyle{altlistgroup} glossary style is like the
% \glostyle{altlist} style, but the glossary groups have headings.
%    \begin{macrocode}
\newglossarystyle{altlistgroup}{%
\glossarystyle{altlist}%
\renewcommand*{\glsgroupheading}[1]{\item[##1]}}
%    \end{macrocode}
% The \glostyle{altlisthypergroup} glossary style is like the
% \glostyle{altlisthypergroup} style, but has a 
% set of links to the groups at the start of the glossary.
%    \begin{macrocode}
\newglossarystyle{altlisthypergroup}{%
\glossarystyle{altlist}%
\renewcommand*{\glossaryheader}{%
\item[]\glsnavigation}%
\renewcommand*{\glsgroupheading}[1]{%
\item[\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}]}}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossary-list.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-long.sty>
%    \end{macrocode}
%\fi
% \subsubsection{Glossary Styles using longtable (the glossary-long
% package)}
% The glossary styles defined in the \styname{glossary-long} package
% used the \envname{longtable} environment in the glossary.
%    \begin{macrocode}
\ProvidesPackage{glossary-long}[2007/07/04 v1.01 (NLCT)]
%    \end{macrocode}
% Requires the \styname{longtable} package:
%    \begin{macrocode}
\RequirePackage{longtable}
%    \end{macrocode}
% This is a length that governs the width of the description column.
%\begin{macro}{\glsdescwidth}
%    \begin{macrocode}
\newlength\glsdescwidth
%    \end{macrocode}
%\end{macro}
% This is a length that governs the width of the page list column.
%\begin{macro}{\glspagelistwidth}
%    \begin{macrocode}
\newlength\glspagelistwidth
%    \end{macrocode}
%\end{macro}
% Default values:
%    \begin{macrocode}
\setlength{\glsdescwidth}{0.6\linewidth}
\setlength{\glspagelistwidth}{0.1\linewidth}
%    \end{macrocode}
% 
% The \glostyle{long} glossary style command which 
% uses the \envname{longtable} environment:
%    \begin{macrocode}
\newglossarystyle{long}{%
\renewenvironment{theglossary}{\begin{longtable}{lp{\glsdescwidth}}}{%
\end{longtable}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossaryentryfield}[5]{%
\@glstarget{glo:##1}{##2} & ##3\glspostdescription\space ##5\\}%
\renewcommand*{\glsgroupskip}{ & \\}}
%    \end{macrocode}
% The \glostyle{longborder} style is like the above, but with horizontal and
% vertical lines:
%    \begin{macrocode}
\newglossarystyle{longborder}{%
\glossarystyle{long}%
\renewenvironment{theglossary}{%
\begin{longtable}{|l|p{\glsdescwidth}|}}{\end{longtable}}%
\renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
% The \glostyle{longheader} style is like the
% \glostyle{long} style but with a header:
%    \begin{macrocode}
\newglossarystyle{longheader}{%
\glossarystyle{long}%
\renewcommand*{\glossaryheader}{%
\bfseries \entryname & \bfseries \descriptionname\\
\endhead}}
%    \end{macrocode}
% The \glostyle{longheaderborder} style is
% like the \glostyle{long} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{longheaderborder}{%
\glossarystyle{longborder}%
\renewcommand*{\glossaryheader}{%
\hline\bfseries \entryname & \bfseries \descriptionname\\\hline
\endhead
\hline\endfoot}}
%    \end{macrocode}
% The \glostyle{long3col} style is like \glostyle{long} but with 3 columns
%    \begin{macrocode}
\newglossarystyle{long3col}{%
\renewenvironment{theglossary}{\begin{longtable}{lp{\glsdescwidth}p{\glspagelistwidth}}}{%
\end{longtable}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossaryentryfield}[5]{%
\@glstarget{glo:##1}{##2} & ##3 & ##5\\}%
\renewcommand*{\glsgroupskip}{ & &\\}}
%    \end{macrocode}
% The \glostyle{long3colborder} style is like the
% \glostyle{long3col} style but with a border:
%    \begin{macrocode}
\newglossarystyle{long3colborder}{%
\glossarystyle{long3col}%
\renewenvironment{theglossary}{%
\begin{longtable}{|l|p{\glsdescwidth}|p{\glspagelistwidth}|}}{%
\end{longtable}}%
\renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
% The \glostyle{long3colheader} style is like \glostyle{long3col} but with a header row:
%    \begin{macrocode}
\newglossarystyle{long3colheader}{%
\glossarystyle{long3col}%
\renewcommand*{\glossaryheader}{%
\bfseries\entryname&\bfseries\descriptionname&
\bfseries\pagelistname\\\endhead}%
}
%    \end{macrocode}
% The \glostyle{long3colheaderborder} style is like the above but with a border
%    \begin{macrocode}
\newglossarystyle{long3colheaderborder}{%
\glossarystyle{long3colborder}%
\renewcommand*{\glossaryheader}{%
\hline
\bfseries\entryname&\bfseries\descriptionname&
\bfseries\pagelistname\\\hline\endhead
\hline\endfoot}%
}
%    \end{macrocode}
% The \glostyle{long4col} style has four columns where the third column contains the value of the associated \gloskey{symbol} key.
%    \begin{macrocode}
\newglossarystyle{long4col}{%
\renewenvironment{theglossary}{%
\begin{longtable}{llll}}{%
\end{longtable}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossaryentryfield}[5]{%
\@glstarget{glo:##1}{##2} & ##3 & ##4 & ##5\\}%
\renewcommand*{\glsgroupskip}{ & & &\\}}
%    \end{macrocode}
% The \glostyle{long4colheader} style is like \glostyle{long4col} but with a header row.
%    \begin{macrocode}
\newglossarystyle{long4colheader}{%
\glossarystyle{long4col}%
\renewcommand*{\glossaryheader}{%
\bfseries\entryname&\bfseries\descriptionname&
\bfseries \symbolname&
\bfseries\pagelistname\\\endhead}%
}
%    \end{macrocode}
% The \glostyle{long4colborder} style is like \glostyle{long4col} but with a border.
%    \begin{macrocode}
\newglossarystyle{long4colborder}{%
\glossarystyle{long4col}%
\renewenvironment{theglossary}{%
\begin{longtable}{|l|l|l|l|}}{%
\end{longtable}}%
\renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
% The \glostyle{long4colheaderborder} style is like the above but with a border.
%    \begin{macrocode}
\newglossarystyle{long4colheaderborder}{%
\glossarystyle{long4col}%
\renewenvironment{theglossary}{%
\begin{longtable}{|l|l|l|l|}}{%
\end{longtable}}%
\renewcommand*{\glossaryheader}{%
\hline\bfseries\entryname&\bfseries\descriptionname&
\bfseries \symbolname&
\bfseries\pagelistname\\\hline\endhead\hline\\\endfoot}%
}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossary-long.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-super.sty>
%    \end{macrocode}
%\fi
% \subsubsection{Glossary Styles using supertabular environment (glossary-super package)}
% The glossary styles defined in the \styname{glossary-super} package
% use the \envname{supertabular} environment.
%    \begin{macrocode}
\ProvidesPackage{glossary-super}[2007/07/04 v1.01 (NLCT)]
%    \end{macrocode}
% Requires the \styname{supertabular} package:
%    \begin{macrocode}
\RequirePackage{supertabular}
%    \end{macrocode}
% The \glostyle{super} glossary style uses the
% \envname{supertabular} environment
% (it uses lengths defined in the \styname{glossary-long} package.)
%    \begin{macrocode}
\newglossarystyle{super}{%
\renewenvironment{theglossary}{%
\tablehead{}\tabletail{}%
\begin{supertabular}{lp{\glsdescwidth}}}{%
\end{supertabular}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossaryentryfield}[5]{%
\@glstarget{glo:##1}{##2} & ##3\glspostdescription\space ##5\\}%
\renewcommand*{\glsgroupskip}{ & \\}}
%    \end{macrocode}
% The \glostyle{superborder} style is like the above, but with horizontal and
% vertical lines:
%    \begin{macrocode}
\newglossarystyle{superborder}{%
\glossarystyle{super}%
\renewenvironment{theglossary}{%
\tablehead{\hline}\tabletail{\hline}%
\begin{supertabular}{|l|p{\glsdescwidth}|}}{\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{superheader} style is like the
% \glostyle{super} style, but with a header:
%    \begin{macrocode}
\newglossarystyle{superheader}{%
\glossarystyle{super}%
\renewenvironment{theglossary}{%
\tablehead{\bfseries \entryname & \bfseries \descriptionname\\}%
\tabletail{}%
\begin{supertabular}{lp{\glsdescwidth}}}{\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{superheaderborder} style is like
% the \glostyle{super} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{superheaderborder}{%
\glossarystyle{super}%
\renewenvironment{theglossary}{%
\tablehead{\hline\bfseries \entryname & \bfseries \descriptionname\\\hline}%
\tabletail{\hline}
\begin{supertabular}{|l|p{\glsdescwidth}|}}{\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{super3col} style is like the \glostyle{super} style, but with 3 columns:
%    \begin{macrocode}
\newglossarystyle{super3col}{%
\renewenvironment{theglossary}{%
\tablehead{}\tabletail{}%
\begin{supertabular}{lp{\glsdescwidth}p{\glspagelistwidth}}}{%
\end{supertabular}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossaryentryfield}[5]{%
\@glstarget{glo:##1}{##2} & ##3 & ##5\\}%
\renewcommand*{\glsgroupskip}{ & &\\}}
%    \end{macrocode}
% The \glostyle{super3colborder} style is like the
% \glostyle{super3col} style, but with a border:
%    \begin{macrocode}
\newglossarystyle{super3colborder}{%
\glossarystyle{super3col}%
\renewenvironment{theglossary}{%
\tablehead{\hline}\tabletail{\hline}%
\begin{supertabular}{|l|p{\glsdescwidth}|p{\glspagelistwidth}|}}{%
\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{super3colheader} style is like 
% the \glostyle{super3col} style but with a header row:
%    \begin{macrocode}
\newglossarystyle{super3colheader}{%
\glossarystyle{super3col}%
\renewenvironment{theglossary}{%
\tablehead{\bfseries\entryname&\bfseries\descriptionname&
\bfseries\pagelistname\\}\tabletail{}%
\begin{supertabular}{lp{\glsdescwidth}p{\glspagelistwidth}}}{%
\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{super3colheaderborder} style is like
% the \glostyle{super3col} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{super3colheaderborder}{%
\glossarystyle{super3colborder}%
\renewenvironment{theglossary}{%
\tablehead{\hline
\bfseries\entryname&\bfseries\descriptionname&
\bfseries\pagelistname\\\hline}%
\tabletail{\hline}%
\begin{supertabular}{|l|p{\glsdescwidth}|p{\glspagelistwidth}|}}{%
\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{super4col} glossary style has four columns,
% where the third column contains the value of the
% corresponding \gloskey{symbol} key used when that entry
% was defined.
%    \begin{macrocode}
\newglossarystyle{super4col}{%
\renewenvironment{theglossary}{%
\tablehead{}\tabletail{}%
\begin{supertabular}{llll}}{%
\end{supertabular}}%
\renewcommand*{\glossaryheader}{}%
\renewcommand*{\glsgroupheading}[1]{}%
\renewcommand*{\glossaryentryfield}[5]{%
\@glstarget{glo:##1}{##2} & ##3 & ##4 & ##5\\}%
\renewcommand*{\glsgroupskip}{ & & &\\}}
%    \end{macrocode}
% The \glostyle{super4colheader} style is like
% the \glostyle{super4col} but with a header row.
%    \begin{macrocode}
\newglossarystyle{super4colheader}{%
\glossarystyle{super4col}%
\renewenvironment{theglossary}{%
\tablehead{\bfseries\entryname&\bfseries\descriptionname&
\bfseries\symbolname &
\bfseries\pagelistname\\}\tabletail{}%
\begin{supertabular}{llll}}{%
\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{super4colborder} style is like
% the \glostyle{super4col} but with a border.
%    \begin{macrocode}
\newglossarystyle{super4colborder}{%
\glossarystyle{super4col}%
\renewenvironment{theglossary}{%
\tablehead{\hline}\tabletail{\hline}%
\begin{supertabular}{|l|l|l|l|}}{%
\end{supertabular}}%
}
%    \end{macrocode}
% The \glostyle{super4colheaderborder} style is like
% the \glostyle{super4col} but with a header and border.
%    \begin{macrocode}
\newglossarystyle{super4colheaderborder}{%
\glossarystyle{super4col}%
\renewenvironment{theglossary}{%
\tablehead{\hline\bfseries\entryname&\bfseries\descriptionname&
\bfseries\symbolname &
\bfseries\pagelistname\\}\tabletail{\hline}%
\begin{supertabular}{|l|l|l|l|}}{%
\end{supertabular}}%
}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossary-super.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries.perl>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
# File          : glossaries.perl
# Author        : Nicola L.C. Talbot
# Date          : 14th June 2007
# Last Modified : 21st Aug 2007
# Version       : 1.02
# Description   : LaTeX2HTML (limited!) implementation of glossaries 
#                  package. Note that not all the glossaries.sty
#                  macros have been implemented.

# This is a LaTeX2HTML style implementing the glossaries package, and
# is distributed as part of that package.
# Copyright 2007 Nicola L.C. Talbot
# This work may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.3
# of this license of (at your option) any later version.
# The latest version of this license is in
#   http://www.latex-project.org/lppl.txt
# and version 1.3 or later is part of all distributions of LaTeX
# version 2005/12/01 or later.
#
# This work has the LPPL maintenance status `maintained'.
#
# The Current Maintainer of this work is Nicola Talbot.

# This work consists of the files glossaries.dtx and glossaries.ins 
# and the derived files glossaries.sty, glossary-hypernav.sty, 
# glossary-list.sty, glossary-long.sty, glossary-super.sty, 
# glossaries.perl. Also makeglossaries and makeglossaries.bat


package main;

# These are the only package options implemented.

sub do_glossaries_style_altlist{
}

sub do_glossaries_toc{
}

sub do_glossaries_toc_true{
}

$GLSCURRENTFORMAT="textrm";

sub do_cmd_glossaryname{
   "Glossary$_[0]"
}

$gls_mark{'main'} = "<tex2html_gls_main_mark>";
$gls_file_mark{'main'} = "<tex2html_gls_main_file_mark>";
$gls_title{'main'} = "\\glossaryname";
$delimN{'main'} = ", ";
$glsnumformat{'main'} = $GLSCURRENTFORMAT;
@{$gls_entries{'main'}} = ();
$gls_displayfirst{'main'} = "glsdisplayfirst";
$gls_display{'main'} = "glsdisplay";

%glsentry = ();

$acronymtype = 'main';

sub do_glossaries_acronym{
   &do_glossaries_acronym_true
}

sub do_glossaries_acronym_true{
   &make_newglossarytype("acronym", "\\acronymname");
   $acronymtype = 'acronym';
}

sub do_glossary_acronym_false{
   $acronymtype = 'main';
}

sub do_cmd_acronymname{
   join('', 'Acronyms', $_[0]);
}

sub do_cmd_acronymtype{
   join('', $acronymtype, $_[0]);
}

# modify set_depth_levels so that glossary is added

sub replace_glossary_markers{
   foreach $type (keys %gls_mark)
   {
      if (defined &add_gls_hook)
        {&add_gls_hook if (/$gls_mark{$type}/);}
      else
        {&add_gls($type) if (/$gls_mark{$type}/);}

      s/$gls_file_mark{$type}/$glsfile{$type}/g;
   }
}

# there must be a better way of doing this
# other than copying the orginal code and adding to it.
sub replace_general_markers {
    if (defined &replace_infopage_hook) {&replace_infopage_hook if (/$info_page_mark/);}
    else { &replace_infopage if (/$info_page_mark/); }
    if (defined &add_idx_hook) {&add_idx_hook if (/$idx_mark/);}
    else {&add_idx if (/$idx_mark/);}
    &replace_glossary_markers;

    if ($segment_figure_captions) {
s/$lof_mark/$segment_figure_captions/o
    } else { s/$lof_mark/$figure_captions/o }
    if ($segment_table_captions) {
s/$lot_mark/$segment_table_captions/o
    } else { s/$lot_mark/$table_captions/o }
    &replace_morelinks();
    if (defined &replace_citations_hook) {&replace_citations_hook if /$bbl_mark/;}
    else {&replace_bbl_marks if /$bbl_mark/;}
    if (defined &add_toc_hook) {&add_toc_hook if (/$toc_mark/);}
    else {&add_toc if (/$toc_mark/);}
    if (defined &add_childs_hook) {&add_childs_hook if (/$childlinks_on_mark/);}
    else {&add_childlinks if (/$childlinks_on_mark/);}
    &remove_child_marks;

    if (defined &replace_cross_references_hook) {&replace_cross_references_hook;}
    else {&replace_cross_ref_marks if /$cross_ref_mark||$cross_ref_visible_mark/;}
    if (defined &replace_external_references_hook) {&replace_external_references_hook;}
    else {&replace_external_ref_marks if /$external_ref_mark/;}
    if (defined &replace_cite_references_hook) {&replace_cite_references_hook;}
    else { &replace_cite_marks if /$cite_mark/; }
    if (defined &replace_user_references) {
  &replace_user_references if /$user_ref_mark/; }

}

sub add_gls{
    local($sidx_style, $eidx_style) =('<STRONG>','</STRONG>');
    if ($INDEX_STYLES) {
if ($INDEX_STYLES =~/,/) {
local(@styles) = split(/\s*,\s*/,$INDEX_STYLES);
    $sidx_style = join('','<', join('><',@styles) ,'>');
    $eidx_style = join('','</', join('></',reverse(@styles)) ,'>');
} else {
    $sidx_style = join('','<', $INDEX_STYLES,'>');
    $eidx_style = join('','</', $INDEX_STYLES,'>');
}
    }
    &add_real_gls
}

sub gloskeysort{
   local($x, $y) = ($a, $b);
   $x=~s/^(.*)###(\d+)$/\l\1/;
   local($x_id) = $2;
   $y=~s/^(.*)###(\d+)$/\l\1/;
   local($y_id) = $2;

   local($n) = ($x cmp $y);

   if ($n == 0)
   {
      $n = ($x_id <=> $y_id);
   }

   $n;
}

sub add_real_gls{
   local($type) = @_;
   print "\nDoing glossary '$type' ...";
   local($key, $str, @keys, $glossary, $level, $count,
   @previous, @current, $id, $linktext, $delimN);

   @keys = keys %{$glossary{$type}};

   @keys = sort gloskeysort @keys;

   $level = 0;

   $delimN = $delimN{$type};

   foreach $key (@keys)
   {
      $current = $key;
      $str = $current;
      $str =~ s/\#\#\#\d+$//o; # Remove the unique id's
      #$linktext = $cross_ref_visible_mark;
      $id = ++$global{'max_id'};
      $linktext = "\\$glossary_format{$type}{$key}${OP}$id${CP}$glossary_linktext{$type}{$key}${OP}$id${CP}";
      $linktext = &translate_commands($linktext);

      local($entry) = $glossary_entry{$type}{$key};

      $id = ++$global{'max_id'};
      local($name) = &translate_commands(
         "\\glsnamefont $OP$id$CP$glsentry{$entry}{name}$OP$id$CP");

      local($symbol) = ($glsentry{$entry}{'symbol'} ?
                     " $glsentry{$entry}{symbol}" : '');

      $glossary .=
      # If it's the same string don't start a new line
         (&index_key_eq($current, $previous) ?
               $delimN
               . $glossary{$type}{$key}
               . $linktext
               . "</A>\n"
            : "<DT>"
                   . $name
                   . "<DD>"
                   . $glsentry{$entry}{'description'} 
                   . $symbol . '. '
                   . $glossary{$type}{$key}
         . $linktext. "</A>\n");
      $previous = $current;
   }
    $glossary = '<DD>'.$glossary unless ($glossary =~ /^\s*<D(T|D)>/);

    $glossary =~ s/(<A [^>]*>)(<D(T|D)>)/$2$1/g;

    $str = &translate_commands("\\glossarypostamble");
    s/$gls_mark{$type}/$preglossary\n<DL COMPACT>\n$glossary<\/DL>$str\n/s;
}

sub set_depth_levels {
    # Sets $outermost_level
    local($level);
    # scan the document body, not the preamble, for use of sectioning commands
    my ($contents) = $_;
    if ($contents =~ /\\begin\s*((?:$O|$OP)\d+(?:$C|$CP))document\1|\\startdocument/s) {
$contents = $';
    }
    foreach $level ("part", "chapter", "section", "subsection",
    "subsubsection", "paragraph") {
last if (($outermost_level) = $contents =~ /\\($level)$delimiter_rx/);
last if (($outermost_level) = $contents =~ /\\endsegment\s*\[\s*($level)\s*\]/s);
if ($contents =~ /\\segment\s*($O\d+$C)[^<]+\1\s*($O\d+$C)\s*($level)\s*\2/s)
{ $outermost_level = $3; last };
    }
    $level = ($outermost_level ? $section_commands{$outermost_level} :
      do {$outermost_level = 'section'; 3;});

    if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
$MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
    } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };

    %unnumbered_section_commands = (
          'tableofcontents', $level
, 'listoffigures', $level
, 'listoftables', $level
, 'bibliography', $level
, 'textohtmlindex', $level
, 'textohtmlglossary', $level
, 'textohtmlglossaries', $level
        , %unnumbered_section_commands
        );

    %section_commands = (
  %unnumbered_section_commands
        , %section_commands
        );
}

sub add_bbl_and_idx_dummy_commands {
    local($id) = $global{'max_id'};

    s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
    ## if ($bbl_cnt == 1) {
s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo;
    #}
    $global{'max_id'} = $id;
    s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
    s/[\\]printindex/\\textohtmlindex /o;
    &add_gls_dummy_commands;
    &lib_add_bbl_and_idx_dummy_commands() if defined(&lib_add_bbl_and_idx_dummy_commands);
}

sub add_gls_dummy_commands{
   s/[\\]printglossary/\\textohtmlglossary/sg;
   s/[\\]printglossaries/\\textohtmlglossaries/sg;
}

sub get_firstkeyval{
   local($key,$_) = @_;
   local($value);

   s/\b$key\s*=$OP(\d+)$CP(.*)$OP\1$CP\s*(,|$)/$value=$2;','/es;
   undef($value) if $`=~/\b$key\s*=/;

   unless (defined($value))
   {
      s/(^|,)\s*$key\s*=\s*([^,]*)\s*(,|$)/,/s;
      $value=$2;
   }

   ($value,$_);
}

# need to get the value of the last key of a given name
# in the event of multiple occurences.
sub get_keyval{
   local($key,$_) = @_;
   local($value);

   while (/\b$key\s*=/)
   {
      ($value,$_) = &get_firstkeyval($key, $_);
      last unless defined($value);
   }

   ($value,$_);
}

# This is modified from do_cmd_textohtmlindex

sub do_cmd_textohtmlglossary{
   local($_) = @_;

   local($keyval,$pat) = &get_next_optional_argument;

   local($type,$title,$toctitle,$style);

   ($type,$keyval) = &get_keyval('type', $keyval);
   ($title,$keyval) = &get_keyval('title', $keyval);
   ($toctitle,$keyval) = &get_keyval('toctitle', $keyval);
   ($style,$keyval) = &get_keyval('style', $keyval);

   &make_textohtmlglossary($type,$toctitle,$title,$style).$_;
}

sub make_textohtmlglossary{
   local($type,$toctitle,$title,$style) = @_;

   unless (defined($type)) {$type = 'main';}

   unless (defined $gls_mark{$type})
   {
      &write_warnings("glossary type '$type' not implemented");
   }

   unless (defined($title) and $title) {$title = $gls_title{$type};}
   unless (defined($toctitle) and $toctitle) {$toctitle = $title;}

   $toc_sec_title = $toctitle;
   $glsfile{$type} = $CURRENT_FILE;

   $TITLE=&translate_commands($toctitle);

   if (%glossary_labels) { &make_glossary_labels(); }

   if (($SHORT_INDEX) && (%glossary_segment))
   {
      &make_preglossary();
   }
   else
   {
      $preglossary = &translate_commands("\\glossarypreamble");
   }

   local $idx_head = $section_headings{'textohtmlindex'};
   local($heading) = join(''
        , &make_section_heading($title, $idx_head)
        , $gls_mark{$type} );
   local($pre,$post) = &minimize_open_tags($heading);
   join('',"<BR>\n" , $pre);
}

sub do_cmd_textohtmlglossaries{
   local($_) = @_;

   foreach $type (keys %gls_mark)
   {
      $id = ++$global{'max_id'};
      $_ = &make_textohtmlglossary($type,$gls_title{'main'}).$_;
   }

   $_;
}

sub make_glossary_labels {
    local($key, @keys);
    @keys = keys %glossary_labels;
    foreach $key (@keys) {
        if (($ref_files{$key}) && !($ref_files{$key} eq "$glsfile{'main'}")) {
            local($tmp) = $ref_files{$key};
            &write_warnings("\nmultiple label $key , target in $glsfile{'main'} masks $tmp ");
        }
        $ref_files{$key} .= $glsfile{'main'};
    }
}

sub make_preglossary{ &make_real_preglossary }
sub make_real_preglossary{
    local($key, @keys, $head, $body);
    $head = "<HR>\n<H4>Legend:</H4>\n<DL COMPACT>";
    @keys = keys %glossary_segment;
    foreach $key (@keys) {
        local($tmp) = "segment$key";
        $tmp = $ref_files{$tmp};
        $body .= "\n<DT>$key<DD>".&make_named_href('',$tmp,$glossary_segment{$key});
    }
    $preglossary = join('', $head, $body, "\n</DL>") if ($body);
}

sub do_cmd_glossary { &do_real_glossary(@_) }
sub do_real_glossary {
   local($_) = @_;
   local($type) = "main";
   local($anchor,$entry);

   local($type,$pat) = &get_next_optional_argument;

   $entry = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($entry=$2));

   $anchor = &make_glossary_entry($entry,$anchor_invisible_mark,$type);

   join('', $anchor, $_);
}

sub make_glossary_entry { &make_real_glossary_entry(@_) }
sub make_real_glossary_entry {
    local($entry,$text,$type) = @_;
    local($this_file) = $CURRENT_FILE;
    $TITLE = $saved_title if (($saved_title)&&(!($TITLE)||($TITLE eq $default_title)));

    local($sort) = $glsentry{$entry}{'sort'};

    # Save the reference
    local($str) = "$sort###" . ++$global{'max_id'}; # Make unique
    # concatenate multiple spaces into a single space
    # otherwise keys won't sort properly
    $str=~s/\s+/ /gs;
    local($br_id) = ++$global{'max_id'};
    $glossary{$type}{$str} .= &make_half_href($this_file."#$br_id");
    $glossary_format{$type}{$str} = $GLSCURRENTFORMAT;
    $glossary_entry{$type}{$str} = $entry;
    $glossary_linktext{$type}{$str} = $TITLE;
    "<A HREF=$gls_file_mark{$type}#tex2html$href_name NAME=\"$br_id\">$text<\/A>";
}

sub do_cmd_newglossary{
   local($_) = @_;
   local($type,$out,$in,$opt,$pat,$title);

   ($opt,$pat) = &get_next_optional_argument;

   $type = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($type=$2));
   $in = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($in=$2));
   $out = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($out=$2));
   $title = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($title=$2));

   ($opt,$pat) = &get_next_optional_argument;

   &make_newglossarytype($type, $title);

   $_;
}

sub make_newglossarytype{
   local($type, $title) = @_;

   $gls_mark{$type} = "<tex2html_gls_${type}_mark>";
   $gls_file_mark{$type} = "<tex2html_gls_${type}_file_mark>";
   $gls_title{$type} = $title;
   $delimN{$type} = ", ";
   $glsnumformat{$type} = $GLSCURRENTFORMAT;
   @{$gls_entries{$type}} = ();
   $gls_displayfirst{$type} = "glsdisplayfirst";
   $gls_display{$type} = "glsdisplay";
}

sub do_cmd_glsdisplay{
   local($_) = @_;
   local($text,$description,$symbol,$insert);

   $text = &missing_braces unless
        (s/$next_pair_pr_rx/$text=$2;''/eo);

   $description = &missing_braces unless
        (s/$next_pair_pr_rx/$description=$2;''/eo);

   $symbol = &missing_braces unless
        (s/$next_pair_pr_rx/$symbol=$2;''/eo);

   $insert = &missing_braces unless
        (s/$next_pair_pr_rx/$insert=$2;''/eo);

   "$text$insert" . $_;
}

sub do_cmd_glsdisplayfirst{
   local($_) = @_;
   local($text,$description,$symbol,$insert);

   $text = &missing_braces unless
        (s/$next_pair_pr_rx/$text=$2;''/eo);

   $description = &missing_braces unless
        (s/$next_pair_pr_rx/$description=$2;''/eo);

   $symbol = &missing_braces unless
        (s/$next_pair_pr_rx/$symbol=$2;''/eo);

   $insert = &missing_braces unless
        (s/$next_pair_pr_rx/$insert=$2;''/eo);

   "$text$insert" . $_;
}

sub gls_get_displayfirst{
   local($type) = @_;
   local($display)= $gls_displayfirst{$type};

   if (not defined($display))
   {
      &write_warnings("Glossary '$type' is not defined");
      $display='';
   }
   elsif ($display eq '')
   {
      &write_warnings("glsdisplayfirst not set for glossary '$type'");
   }
   else
   {
      $display = "\\$display ";
   }

   $display;
}

sub gls_get_display{
   local($type) = @_;
   local($display)= $gls_display{$type};

   if (not defined($display))
   {
      &write_warnings("Glossary '$type' is not defined");
      $display = '';
   }
   elsif ($display eq '')
   {
      &write_warnings("glsdisplay not set for glossary '$type'");
   }
   else
   {
      $display = "\\$display ";
   }

   $display;
}

sub do_cmd_glsnamefont{
   local($_) = @_;
   local($text);

   $text = &missing_braces unless
        (s/$next_pair_pr_rx/$text=$2;''/eo);

   "<B>$text</B>$_";
}

sub do_cmd_newacronym{
   local($_) = @_;
   local($label,$abbrev,$long,$opt);

   ($opt,$pat) = &get_next_optional_argument;

   $label = &missing_braces unless
        (s/$next_pair_pr_rx/$label=$2;''/eo);
   $abbrv = &missing_braces unless
        (s/$next_pair_pr_rx/$abbrv=$2;''/eo);
   $long = &missing_braces unless
        (s/$next_pair_pr_rx/$long=$2;''/eo);

   local($cmd) = "\\newglossaryentry";
   local($id);
   $id = ++$global{'max_id'};
   $cmd .= "$OP$id$CP$label$OP$id$CP";
   $id = ++$global{'max_id'};
   local($entry) = "type=$OP$id$CP\\acronymtype$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "name=$OP$id$CP$abbrv$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "description=$OP$id$CP$long$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "text=$OP$id$CP$abbrv$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "first=$OP$id$CP$long ($abbrv)$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "plural=$OP$id$CP${abbrv}s$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "firstplural=$OP$id$CP${long}s (${abbrv}s)$OP$id$CP";

   $id = ++$global{'max_id'};
   $cmd .= "$OP$id$CP$entry,$opt$OP$id$CP";

   &translate_commands($cmd).$_;
}

sub gls_entry_init{
   local($label, $type, $name, $desc) = @_;

   %{$glsentry{$label}} = 
     ( type => $type,
       name => $name,
       'sort' => $name,
       description => $description,
       text => $name,
       first => $name,
       plural => "${name}s",
       firstplural => "${name}s",
       symbol => '',
       flag => 0
     );
}

sub gls_get_type{
   local($label) = @_;
   local($type) = '';

   if (&gls_entry_defined($label))
   {
      $type = $glsentry{$label}{'type'};
   }
   else
   {
      &write_warnings("gls_get_type: glossary entry '$label' has not been defined");
   }

   $type;
}

sub gls_set_type{
   local($label, $type) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'type'} = $type;
   }
   else
   {
      &write_warnings("gls_set_type: glossary entry '$label' has not been defined");
   }
}

sub gls_get_name{
   local($label) = @_;
   local($name) = '';

   if (&gls_entry_defined($label))
   {
      $name = $glsentry{$label}{'name'};
   }
   else
   {
      &write_warnings("gls_get_name: glossary entry '$label' has not been defined");
   }

   $name;
}

sub gls_set_name{
   local($label, $name) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'name'} = $name;
   }
   else
   {
      &write_warnings("gls_set_name: glossary entry '$label' has not been defined");
   }
}

sub gls_get_description{
   local($label) = @_;
   local($description) = '';

   if (&gls_entry_defined($label))
   {
      $description = $glsentry{$label}{'description'};
   }
   else
   {
      &write_warnings("gls_get_description: glossary entry '$label' has not been defined");
   }

   $description;
}

sub gls_set_description{
   local($label, $description) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'description'} = $description;
   }
   else
   {
      &write_warnings("gls_set_description: glossary entry '$label' has not been defined");
   }
}

sub gls_get_symbol{
   local($label) = @_;
   local($symbol) = '';

   if (&gls_entry_defined($label))
   {
      $symbol = $glsentry{$label}{'symbol'};
   }
   else
   {
      &write_warnings("gls_get_symbol: glossary entry '$label' has not been defined");
   }

   $symbol;
}

sub gls_set_symbol{
   local($label, $symbol) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'symbol'} = $symbol;
   }
   else
   {
      &write_warnings("gls_set_symbol: glossary entry '$label' has not been defined");
   }
}

sub gls_get_sort{
   local($label) = @_;
   local($sort) = '';

   if (&gls_entry_defined($label))
   {
      $sort = $glsentry{$label}{'sort'};
   }
   else
   {
      &write_warnings("gls_get_sort: glossary entry '$label' has not been defined");
   }

   $sort;
}

sub gls_set_sort{
   local($label, $sort) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'sort'} = $sort;
   }
   else
   {
      &write_warnings("gls_set_sort: glossary entry '$label' has not been defined");
   }
}

sub gls_get_text{
   local($label) = @_;
   local($text) = '';

   if (&gls_entry_defined($label))
   {
      $text = $glsentry{$label}{'text'};
   }
   else
   {
      &write_warnings("gls_get_text: glossary entry '$label' has not been defined");
   }

   $text;
}

sub gls_set_text{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'text'} = $text;
   }
   else
   {
      &write_warnings("gls_set_text: glossary entry '$label' has not been defined");
   }
}

sub gls_get_plural{
   local($label) = @_;
   local($plural) = '';

   if (&gls_entry_defined($label))
   {
      $plural = $glsentry{$label}{'plural'};
   }
   else
   {
      &write_warnings("gls_get_plural: glossary entry '$label' has not been defined");
   }

   $plural;
}

sub gls_set_plural{
   local($label, $plural) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'plural'} = $plural;
   }
   else
   {
      &write_warnings("gls_set_plural: glossary entry '$label' has not been defined");
   }
}

sub gls_get_firstplural{
   local($label) = @_;
   local($firstplural) = '';

   if (&gls_entry_defined($label))
   {
      $firstplural = $glsentry{$label}{'firstplural'};
   }
   else
   {
      &write_warnings("gls_get_firstplural: glossary entry '$label' has not been defined");
   }

   $firstplural;
}

sub gls_set_firstplural{
   local($label, $firstplural) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'firstplural'} = $firstplural;
   }
   else
   {
      &write_warnings("gls_set_firstplural: glossary entry '$label' has not been defined");
   }
}

sub gls_get_first{
   local($label) = @_;
   local($first) = '';

   if (&gls_entry_defined($label))
   {
      $first = $glsentry{$label}{'first'};
   }
   else
   {
      &write_warnings("gls_get_first: glossary entry '$label' has not been defined");
   }

   $first;
}

sub gls_set_first{
   local($label, $first) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'first'} = $first;
   }
   else
   {
      &write_warnings("gls_set_first: glossary entry '$label' has not been defined");
   }
}

sub gls_used{
   local($label) = @_;
   local($flag) = 0;

   if (&gls_entry_defined($label))
   {
      $flag = $glsentry{$label}{'flag'};
   }
   else
   {
      &write_warnings("gls_used: glossary entry '$label' has not been defined");
   }

   $flag;
}

sub gls_entry_defined{
   local($label) = @_;

   defined(%{$glsentry{$label}});
}

sub do_cmd_newglossaryentry{
   local($_) = @_;
   local($label,$name,$description,$symbol,$sort,$text,$first,
     $plural,$firstplural,$type,$keyval);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   $keyval = &missing_braces unless
              s/$next_pair_pr_rx/$keyval=$2;''/eo;

   ($name,$keyval) = &get_keyval('name', $keyval);
   ($description,$keyval) = &get_keyval('description', $keyval);
   ($symbol,$keyval) = &get_keyval('symbol', $keyval);
   ($sort,$keyval) = &get_keyval('sort', $keyval);
   ($text,$keyval) = &get_keyval('text', $keyval);
   ($first,$keyval) = &get_keyval('first', $keyval);
   ($firstplural,$keyval) = &get_keyval('firstplural', $keyval);
   ($plural,$keyval) = &get_keyval('plural', $keyval);
   ($type,$keyval) = &get_keyval('type', $keyval);

   if (defined($type))
   {
      $type = &translate_commands($type);
   }
   else
   {
      $type = 'main';
   }

   &gls_entry_init($label, $type, $name, $description);

   &gls_set_symbol($label, defined($symbol)?$symbol:'');

   $sort = "$name $description" unless (defined($sort) and $sort);

   &gls_set_sort($label, $sort);

   $text = $name unless (defined($text) and $text);

   &gls_set_text($label, $text);

   $first = $text unless (defined($first) and $first);

   &gls_set_first($label, $first);

   $plural = "${text}s" unless (defined($plural) and $plural);

   &gls_set_plural($label, $plural);

   $firstplural = "${first}s" unless (defined($firstplural) and $firstplural);

   &gls_set_firstplural($label, $firstplural);

   push @{$gls_entries{$type}}, $label;

   $_;
}

sub reset_entry{
   local($label) = @_;

   $glsentry{$label}{'flag'} = 0;
}

sub unset_entry{
   local($label) = @_;

   $glsentry{$label}{'flag'} = 1;
}

sub do_cmd_glsreset{
   local($_) = @_;
   local($label);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   &reset_entry($label);

   $_;
}

sub do_cmd_glsunset{
   local($_) = @_;
   local($label);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   &unset_entry($label);

   $_;
}

sub do_cmd_ifglsused{
   local($_) = @_;
   local($label,$true,$false);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   $true = &missing_braces unless
              s/$next_pair_pr_rx/$true=$2;''/eo;

   $false = &missing_braces unless
              s/$next_pair_pr_rx/$false=$2;''/eo;

   (&gls_used($label) ? $true : $false) . $_;
}

sub do_cmd_ifglsentryexists{
   local($_) = @_;
   local($label,$true,$false);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   $true = &missing_braces unless
              s/$next_pair_pr_rx/$true=$2;''/eo;

   $false = &missing_braces unless
              s/$next_pair_pr_rx/$false=$2;''/eo;

   (&gls_entry_defined($label) ? $true : $false) . $_;
}

sub gls_add_entry{
   local($type, $label, $format, $text) = @_;

   local($oldfmt) = $GLSCURRENTFORMAT;

   if (defined($format) and $format)
   {
      $GLSCURRENTFORMAT=$format;
   }

   $id = ++$global{'max_id'};

   local($str) = &make_real_glossary_entry($label,$text,$type);
   $GLSCURRENTFORMAT = $oldfmt;

   $str;
}

sub do_cmd_glsadd{
   local($_) = @_;
   local($optarg,$pat,$label,$str,$id,$type,$format);
   ($optarg,$pat) = &get_next_optional_argument;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   $type = &gls_get_type($label);

   if (defined $type)
   {
      ($format,$optarg) = &get_keyval('format', $optarg);
      $format='' unless(defined($format));

      &gls_add_entry($type,$label,$format,"");
   }
   else
   {
      &write_warnings("gls_add: glossary entry '$label' undefined");
      $str = '';
   }

   $str . $_;
}

sub do_cmd_glsaddall{
   local($_) = @_;
   local($optarg,$pat) = &get_next_optional_argument;

   local($format,$types);

   ($type,$optarg) = &get_keyval('types', $optarg);

   ($format,$optarg) = &get_keyval('format', $optarg);
   $format='' unless(defined($format));

   local(@types) = keys(%gls_mark);

   if (defined($types))
   {
      @types = split /,/, $types;
   }

   foreach $type (@types)
   {
      # strip leasing and trailing spaces
      $type=~s/^\s*([^\s]+)\s*$/\1/;

      foreach $label (@{$gls_entries{$type}})
      {
         &gls_add_entry($type,$label,$format,"");
      }
   }

   $_;
}

sub do_cmd_glsresetall{
   local($_) = @_;
   local($types,$pat) = &get_next_optional_argument;

   local(@types) = keys(%gls_mark);

   if (defined($types) and $types)
   {
      @types = split /,/, $types;
   }

   foreach $type (@types)
   {
      # strip leasing and trailing spaces
      $type=~s/^\s*([^\s]+)\s*$/\1/;

      foreach $label (@{$gls_entries{$type}})
      {
         &reset_entry($label);
      }
   }

   $_;
}

sub do_cmd_glsunsetall{
   local($_) = @_;
   local($types,$pat) = &get_next_optional_argument;

   local(@types) = keys(%gls_mark);

   if (defined($types) and $types)
   {
      @types = split /,/, $types;
   }

   foreach $type (@types)
   {
      # strip leasing and trailing spaces
      $type=~s/^\s*([^\s]+)\s*$/\1/;

      foreach $label (@{$gls_entries{$type}})
      {
         &reset_entry($label);
      }
   }

   $_;
}

sub make_glslink{
   local($type,$label,$format,$text) = @_;
   local($str) = '';

   if (defined $type)
   {
      $str = &gls_add_entry($type,$label,$format,$text);
   }
   else
   {
      &write_warnings("glossary '$type' undefined");
   }

   $str;
}

sub do_cmd_glslink{
   local($_) = @_;
   local($optarg,$pat,$label,$text,$type,$format,$str);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   $text = &missing_braces unless
             (s/$next_pair_pr_rx/$text=$2;''/eo);

   # v1.01 removed following lines (\glslink doesn't have
   # a final optional argument!
   #local ($space) = '';
   #if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}
   #($optarg,$pat) = &get_next_optional_argument;

   $type = &gls_get_type($label);

   #&make_glslink($type, $label, $format, $text).$space . $_;
   &make_glslink($type, $label, $format, $text) . $_;
}

sub do_cmd_glsentrydesc{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_description($label).$_;
}

sub do_cmd_Glsentrydesc{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   ucfirst(&gls_get_description($label)).$_;
}

sub do_cmd_glsentrytext{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_text($label).$_;
}

sub do_cmd_Glsentrytext{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   ucfirst(&gls_get_text($label)).$_;
}

sub do_cmd_glsentryname{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_name($label).$_;
}

sub do_cmd_Glsentryname{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   ucfirst(&gls_get_name($label)).$_;
}

sub do_cmd_glsentryfirst{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_first($label).$_;
}

sub do_cmd_Glsentryfirst{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   ucfirst(&gls_get_first($label)).$_;
}

sub do_cmd_glsentryplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_plural($label).$_;
}

sub do_cmd_Glsentryplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   ucfirst(&gls_get_plural($label)).$_;
}

sub do_cmd_glsentryfirstplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local($text)=$glsentry{$label}{'firstplural'};

   unless (defined($text))
   {
      &write_warnings("glossary entry '$label' has not been defined");
      $text = '';
   }

   "$text$_";
   &gls_get_firstplural($label).$_;
}

sub do_cmd_Glsentryfirstplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   ucfirst(&gls_get_firstplural($label)).$_;
}

sub do_cmd_glsentrysymbol{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_symbol($label).$_;
}

sub do_cmd_Glsentrysymbol{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   ucfirst(&gls_get_symbol($label)).$_;
}

sub do_cmd_gls{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &make_glslink($type, $label, $format, $link_text) .$space . $_;
}

sub do_cmd_glspl{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &make_glslink($type, $label, $format, $link_text) . $space . $_;
}

sub do_cmd_Gls{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &make_glslink($type, $label, $format, ucfirst($link_text)). $space . $_;
}

sub do_cmd_Glspl{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &make_glslink($type, $label, $format, ucfirst($link_text)).$space . $_;
}

sub do_cmd_GLS{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &make_glslink($type, $label, $format, uc($link_text)).$space . $_;
}

sub do_cmd_GLSpl{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &make_glslink($type, $label, $format, uc($link_text)).$space . $_;
}

sub do_cmd_glossarypreamble{
   local($_) = @_;
   $_[0];
}

sub do_cmd_glossarypostamble{
   local($_) = @_;
   $_[0];
}

sub do_cmd_glsnumformat{
   local($_) = @_;

   $_;
}

sub do_cmd_hyperit{
   join('', "\\textit ", $_[0]);
}

sub do_cmd_hyperrm{
   join('', "\\textrm ", $_[0]);
}

sub do_cmd_hypertt{
   join('', "\\texttt ", $_[0]);
}

sub do_cmd_hypersf{
   join('', "\\textsf ", $_[0]);
}

sub do_cmd_hyperbf{
   join('', "\\textbf ", $_[0]);
}

&ignore_commands( <<_IGNORED_CMDS_ );
makeglossary
makeglossaries
_IGNORED_CMDS_

1;
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</glossaries.perl>
%    \end{macrocode}
%\fi
%\Finale
\endinput