summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/support/bib2gls/src/bib2gls.tex
blob: b26599e0a0e47e178914ee292ee8bf350ae0bdd8 (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
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
6237
6238
6239
6240
6241
6242
6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
6264
6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
6307
6308
6309
6310
6311
6312
6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
6336
6337
6338
6339
6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
6364
6365
6366
6367
6368
6369
6370
6371
6372
6373
6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
6408
6409
6410
6411
6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
6425
6426
6427
6428
6429
6430
6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
6448
6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
6468
6469
6470
6471
6472
6473
6474
6475
6476
6477
6478
6479
6480
6481
6482
6483
6484
6485
6486
6487
6488
6489
6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
6630
6631
6632
6633
6634
6635
6636
6637
6638
6639
6640
6641
6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
6758
6759
6760
6761
6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
6772
6773
6774
6775
6776
6777
6778
6779
6780
6781
6782
6783
6784
6785
6786
6787
6788
6789
6790
6791
6792
6793
6794
6795
6796
6797
6798
6799
6800
6801
6802
6803
6804
6805
6806
6807
6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
6842
6843
6844
6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
6855
6856
6857
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
6982
6983
6984
6985
6986
6987
6988
6989
6990
6991
6992
6993
6994
6995
6996
6997
6998
6999
7000
7001
7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
7018
7019
7020
7021
7022
7023
7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
7067
7068
7069
7070
7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
7087
7088
7089
7090
7091
7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
7124
7125
7126
7127
7128
7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
7147
7148
7149
7150
7151
7152
7153
7154
7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
7174
7175
7176
7177
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187
7188
7189
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199
7200
7201
7202
7203
7204
7205
7206
7207
7208
7209
7210
7211
7212
7213
7214
7215
7216
7217
7218
7219
7220
7221
7222
7223
7224
7225
7226
7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337
7338
7339
7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
7353
7354
7355
7356
7357
7358
7359
7360
7361
7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392
7393
7394
7395
7396
7397
7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
7411
7412
7413
7414
7415
7416
7417
7418
7419
7420
7421
7422
7423
7424
7425
7426
7427
7428
7429
7430
7431
7432
7433
7434
7435
7436
7437
7438
7439
7440
7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
7451
7452
7453
7454
7455
7456
7457
7458
7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
7478
7479
7480
7481
7482
7483
7484
7485
7486
7487
7488
7489
7490
7491
7492
7493
7494
7495
7496
7497
7498
7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
7510
7511
7512
7513
7514
7515
7516
7517
% arara: pdflatex
% arara: makeindex: {style: bib2gls.ist}
% arara: pdflatex
\documentclass[titlepage=false,index=totoc,12pt]{scrreprt}

\usepackage[T1]{fontenc}
\usepackage{tgtermes}
\usepackage[x11names]{xcolor}
\usepackage{alltt}
\usepackage{upquote}
\usepackage{etoolbox}
\usepackage{filecontents}

\newcommand*{\actual}{=}

\begin{filecontents*}{\jobname.ist}
actual '='
\end{filecontents*}

\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{accents}
\usepackage{makeidx}
\usepackage{datetime2}
\usepackage[hidelinks]{hyperref}
\usepackage{glossaries-extra}
\glsdisablehyper

\makeindex

\newabbreviation{IETF}{IETF}{Internet Engineering Task Force}

\DTMsavetimestamp{creation}{2017-01-20T15:39:00Z}

\IfFileExists{../java/Bib2Gls.java}
{
  \DTMsavefilemoddate{moddate}{../java/Bib2Gls.java}
}
{
  \DTMsavenow{moddate}
}

\newif\ifmainmatter

\newcommand{\frontmatter}{%
 \clearpage\pagenumbering{roman}%
 \mainmatterfalse
}
\newcommand{\mainmatter}{%
 \clearpage\pagenumbering{arabic}%
 \mainmattertrue
}

\newcommand{\bibgls}{\appfmt{bib2gls}}

\newcommand*{\sectionref}[1]{\hyperref[#1]{section~\ref*{#1}}}
\newcommand*{\Sectionref}[1]{\hyperref[#1]{Section~\ref*{#1}}}

\newcommand{\langxml}{\hyperref[sec:lang.xml]{language resource file}}

\newcommand{\qt}[1]{``#1''}

\newcommand{\qtt}[1]{\qt{\,\texttt{#1}\,}}

\newcommand{\dequals}{%
 \texorpdfstring
 {\discretionary{}{}{}\texttt{=}\discretionary{}{}{}}%
 {=}%
}

\newcommand{\dcomma}{%
 \texorpdfstring
 {\texttt{,}\discretionary{}{}{}}%
 {,}%
}

\newcommand{\dcolon}{%
 \texorpdfstring
 {\texttt{:}\discretionary{}{}{}}%
 {:}%
}

% put page break before dash to avoid confusion with a hyphen
\newcommand{\dhyphen}{%
 \texorpdfstring
 {\discretionary{}{}{}\texttt{-}}%
 {-}%
}

\pdfstringdefDisableCommands{%
  \def\dhyphen{-}%
  \def\dcolon{:}%
  \def\dcomma{,}%
  \def\dequals{,}%
}

\newcommand*{\filefmt}[1]{\texorpdfstring{\nolinkurl{#1}}{#1}}
\newcommand*{\metafilefmt}[3]{%
  \filefmt{#1}\discretionary{}{}{}\meta{#2}\discretionary{}{}{}\filefmt{#3}%
}

\newcommand*{\primaryresourcefmt}{%
 \texorpdfstring
  {\texttt{\char`\\ jobname.glstex}}%
  {\string\\jobname.glstex}%
}

\newcommand*{\suppresourcefmt}[1]{%
 \texorpdfstring
  {\texttt{\char`\\ jobname-#1.glstex}}%
  {\string\\jobname-1.glstex}%
}


\newcommand*{\appfmt}[1]{\texorpdfstring{\texttt{#1}}{#1}}
\newcommand*{\styfmt}[1]{\texorpdfstring{\textsf{#1}}{#1}}
\newcommand*{\csfmt}[1]{\texorpdfstring{\texttt{\char`\\ #1}}{\string\\#1}}
\newcommand*{\envfmt}[1]{\texorpdfstring{\textsf{#1}}{#1}}
\newcommand*{\optfmt}[1]{\texorpdfstring{\texttt{#1}}{#1}}
\newcommand*{\csoptfmt}[1]{\texorpdfstring{\textcolor{DarkSeaGreen4}{\optfmt{#1}}}{#1}}
\newcommand*{\styoptfmt}[1]{\texorpdfstring{\textcolor{DarkOrchid4}{\optfmt{#1}}}{#1}}
\newcommand*{\fieldfmt}[1]{\texorpdfstring{\texttt{\color{DarkSlateGray4}#1}}{#1}}
\newcommand*{\entryfmt}[1]{\texorpdfstring{\texttt{\color{SteelBlue4}#1}}{#1}}
\newcommand*{\abbrstylefmt}[1]{\texorpdfstring{\textsf{#1}}{#1}}
\newcommand*{\glostylefmt}[1]{\texorpdfstring{\textsf{#1}}{#1}}
\newcommand*{\catattrfmt}[1]{\texorpdfstring{\textsf{#1}}{#1}}
\newcommand*{\counterfmt}[1]{\texorpdfstring{\textsf{#1}}{#1}}
\newcommand*{\idprefixfmt}[1]{%
 \texorpdfstring{\texttt{#1\spacefactor999 .}}{#1.}}

\newcommand*{\argor}{\texorpdfstring{\protect\textbar}{\string\|}}

\newrobustcmd*{\texmeta}[1]{{\normalfont\normalcolor$\langle$\emph{#1}$\rangle$}}

\newcommand*{\meta}[1]{%
 \texorpdfstring{\texmeta{#1}}{#1}%
}

\newcommand*{\oarg}[1]{[#1]}
\newcommand*{\oargm}[1]{\oarg{\meta{#1}}}

\newcommand*{\marg}[1]{\texorpdfstring
 {\discretionary{}{}{}\char`\{#1\char`\} }%
 {\{#1\}}%
}

\newcommand*{\margm}[1]{\marg{\meta{#1}}}

\newcommand*{\file}[1]{%
 \texorpdfstring
 {\filefmt{#1}\index{#1\actual\filefmt{#1}}}%
 {#1}%
}

\newcommand*{\ext}[1]{%
 \texorpdfstring
 {\filefmt{.#1}\index{file formats!#1\actual\filefmt{.#1}}}%
 {.#1}%
}

\newcommand*{\app}[1]{%
 \texorpdfstring
 {\appfmt{#1}\index{#1\actual\appfmt{#1}}}%
 {#1}%
}

\newcommand*{\sty}[1]{%
  \texorpdfstring
  {\styfmt{#1}\index{#1\actual\styfmt{#1}}}%
  {#1}%
}

\newcommand*{\env}[1]{%
  \texorpdfstring
  {\envfmt{#1}\index{#1 environment\actual\envfmt{#1} environment}}%
  {#1}%
}

\newcommand*{\abbrstyle}[1]{%
  \texorpdfstring
  {\abbrstylefmt{#1}\index{abbreviation style!#1\actual\abbrstylefmt{#1}}}%
  {#1}%
}

\newcommand*{\glostyle}[1]{%
  \texorpdfstring
  {\glostylefmt{#1}\index{glossary style!#1\actual\glostylefmt{#1}}}%
  {#1}%
}

\newcommand*{\catattr}[1]{%
  \texorpdfstring
  {\catattrfmt{#1}\index{category attributes!#1\actual\catattrfmt{#1}}}%
  {#1}%
}

\newcommand*{\counter}[1]{%
  \texorpdfstring
  {\counterfmt{#1}\index{#1 counter\actual\counterfmt{#1} counter}}%
  {#1}%
}

\newcommand*{\idprefix}[1]{%
 \texorpdfstring
 {\idprefixfmt{#1}\index{label prefixes!#1\actual\protect\idprefixfmt{#1}}}%
 {#1}%
}

\newcommand*{\cs}[1]{% 
 \texorpdfstring
 {\csfmt{#1}\index{#1\actual\protect\csfmt{#1}}}
 {\string\\#1}%
}

\newcommand*{\styopt}[2][]{%
  \texorpdfstring%
  {%
    \styoptfmt{#2\ifblank{#1}{}{\dequals\marg{#1}}}%
    \index{package options!#2\actual\protect\styoptfmt{#2}}%
    \index{#2\actual\protect\styoptfmt{#2}}%
  }%
  {#2\ifblank{#1}{}{=#1}}%
}

\newcommand*{\keyvallist}{%
 \texorpdfstring
 {key\dequals value list}%
 {key=value list}%
}

\newcommand*{\csopt}[2][]{\gencsopt[#1]{glsxtrresourcefile}{#2}}%
\newcommand*{\glsopt}[2][]{\gencsopt[#1]{gls}{#2}}%
\newcommand*{\glsaddopt}[2][]{\gencsopt[#1]{glsadd}{#2}}%

\newcommand*{\csoptnv}[1]{%
 \texorpdfstring
  {\protect\gencsopt{glsxtrresourcefile}{#1}}%
  {#1}%
}%

\newcommand*{\csopteqval}[1]{\csoptfmt{=\margm{#1}}}

\newcommand*{\gencsopt}[3][]{%
  \texorpdfstring%
  {%
    \csoptfmt{#3\ifblank{#1}{}{\dequals\marg{#1}}}%
    \ifmainmatter
      {\def\dhyphen{-}\index{#2\actual\protect\csfmt{#2}!#3\actual\protect\csoptfmt{#3}}}%
    \fi
  }%
  {#3\ifblank{#1}{}{=#1}}%
}

\newcommand*{\field}[1]{%
 \texorpdfstring
 {\fieldfmt{#1}%
   \index{fields!#1\actual\protect\fieldfmt{#1}}%
   \index{#1 field\actual\protect\fieldfmt{#1} field}%
 }%
 {#1}%
}

\newcommand*{\entry}[1]{%
 \texorpdfstring
 {\entryfmt{#1}%
   \index{entry types!#1\actual\protect\entryfmt{@#1}}%
   \index{#1 entry type\actual\protect\entryfmt{@#1} entry type}%
 }%
 {#1}%
}

\newcommand*{\atentry}[1]{%
 \texorpdfstring
 {\entryfmt{@#1}%
   \index{entry types!#1\actual\protect\entryfmt{@#1}}%
   \index{#1 entry type\actual\protect\entryfmt{@#1} entry type}%
 }%
 {@#1}%
}

\newrobustcmd{\longswitch}{\string-{}\string-}

\newcommand*{\longargfmt}[1]{%
 \texorpdfstring{\texttt{\longswitch #1}}%
 {\string-\string-#1}%
}

\newcommand*{\shortargfmt}[1]{%
 \texorpdfstring{\texttt{\string-#1}}%
 {\string-#1}%
}

\newrobustcmd{\longargindex}[1]{%
  \ifmainmatter
   {\def\dhyphen{-}%
    \index{command line options!#1\actual\protect\longargfmt{#1}}%
   }%
  \fi
}

\newcommand*{\longarg}[1]{%
  \texorpdfstring
  {\longargfmt{#1}\longargindex{#1}}%
  {\string-\string-#1}%
}

\newrobustcmd{\shortargindex}[1]{%
  \ifmainmatter
   {\def\dhyphen{-}%
    \index{command line options!#1\actual\protect\shortargfmt{#1}}%
   }%
  \fi
}

\newcommand*{\shortarg}[1]{%
  \texorpdfstring
  {\shortargfmt{#1}\shortargindex{#1}}%
  {\string-#1}%
}

\newcommand*{\keyword}[1]{%
  \texorpdfstring{\emph{#1}\index{#1}}{#1}%
}

\definecolor{defbackground}{rgb}{1,1,0.75}
\newsavebox\defsbox
\newlength\defwidth

\newenvironment{definition}%
{%
  \setlength{\fboxsep}{4pt}\setlength{\fboxrule}{1.25pt}%
  \begin{lrbox}{\defsbox}%
   \setlength\defwidth\linewidth
   \addtolength\defwidth{-2\fboxrule}%
   \addtolength\defwidth{-2\fboxsep}%
   \begin{minipage}{\defwidth}
   \flushleft\ttfamily\ignorespaces
}%
{%
   \end{minipage}%
  \end{lrbox}\par\medskip\noindent
  \fcolorbox{black}{defbackground}{\usebox\defsbox}%
  \medskip\par\noindent
  \ignorespacesafterend
}

% This is a bit fiddly. Need to represent \vec{v} in typewriter
% font for the interpreter examples. ($\mathtt{\vec{v}}$ doesn't
% work)
\newsavebox\varrow
\sbox\varrow{$\mathtt{\accentset{\to}{v}}$}

\newcommand*{\mtx}[1]{\boldsymbol{#1}}
\newcommand*{\set}[1]{\mathcal{#1}}
\newcommand*{\card}[1]{|\set{#1}|}
\newcommand*{\imaginary}{i}

\newcommand{\addr}[1]{\\\url{#1}}
\title{\appfmt{bib2gls}: a command line Java application to convert
\filefmt{.bib} files to \filefmt{glossaries-extra.sty} resource
files}
\author{Nicola Talbot\addr{http://www.dickimaw-books.com/}}
\date{\DTMusedate{moddate}}

\makeatletter
\begingroup
 \renewcommand{\addr}[1]{}
 \let\texorpdfstring\@secondoftwo
 \DTMsetstyle{pdf}
 \protected@edef\x{\endgroup
   \noexpand\hypersetup{%
   pdftitle={\@title},
   pdfauthor={\@author}}%
   \noexpand\pdfinfo{/CreationDate (\DTMuse{creation})
   /ModDate (\DTMuse{moddate})
   }%
 }\x

\newcommand*{\labelarg}[1]{%
 {\def\@currentlabelname{\protect\longarg{#1}}\label{arg.#1}}%
}
\newcommand*{\argref}[1]{\nameref{arg.#1}}

\newcommand*{\labelopt}[1]{%
 {\def\dhyphen{\string\dhyphen\space}%
  \protected@edef\@currentlabelname{\protect\csoptfmt{#1}}%
  \def\dhyphen{-}\label{opt.#1}}%
}
\newrobustcmd*{\optref}[2][]{%
 \nameref{opt.#2}%
 \ifblank{#1}{}{\csoptfmt{\dequals\marg{#1}}}}

\newcommand*{\labelatentry}[1]{%
 {\def\@currentlabelname{\protect\atentry{#1}}\label{at.#1}}%
}
\newcommand*{\atentryref}[1]{\nameref{at.#1}}

\newcommand*{\labelcs}[1]{%
 {\def\@currentlabelname{\protect\cs{#1}}\label{cs.#1}}%
}
\newcommand*{\csref}[1]{\nameref{cs.#1}}

\newcounter{phantom}
\newcommand*{\plabel}[2][]{\refstepcounter{phantom}%
 {\def\@currentlabelname{#1}\label{#2}}%
}
\newcommand{\plabelcs}[1]{\plabel[\protect\cs{#1}]{cs.#1}}

\makeatother

\begin{document}
\maketitle
\pagenumbering{alph}
\thispagestyle{empty}

\begin{abstract}
The \bibgls\ command line application can be used to extract
glossary information stored in a \filefmt{.bib} file and convert it
into glossary entry definition commands that can be read using
\styfmt{glossaries-extra}'s \csfmt{GlsXtrLoadResources} command. When used
in combination with the \styopt{record} package option, \bibgls\
can select only those entries that have been used in the document,
as well as any dependent entries, which reduces the \TeX\ resources
required by not defining unnecessary commands.

Since \bibgls\ can also sort and collate the recorded locations
present in the \filefmt{.aux} file, it can simultaneously by-pass the
need to use \appfmt{makeindex} or \appfmt{xindy}, although \bibgls\ 
can be used together with an external indexing application if required. (For
example, if a custom \appfmt{xindy} rule is needed.)

An additional build may be required to ensure the locations are
up-to-date as the page-breaking may be slightly different on the
first \LaTeX\ run due to the unknown references being replaced with
?? which can be significantly shorter than the actual text produced
when the reference is known. 

Note that \bibgls\ is a Java application, so it requires the
Java Runtime Environment (at least JRE~7). Additionally,
\styfmt{glossaries-extra} must be at least version 1.12.
(Although the latest version is recommended.)
This application was developed in response to the question
\href{http://tex.stackexchange.com/q/342544}{Is there a program for
managing glossary tags?} on \TeX\ on StackExchange. The \ext{bib}
file can be managed in an application such as JabRef.

If you already have a \ext{tex} file containing 
entry definitions using commands like \cs{newglossaryentry}
then you can use the supplementary tool \appfmt{convertgls2bib}
to convert the entries to the \ext{bib} format required by
\bibgls. See \sectionref{sec:gls2bib} for further details.
\end{abstract}

\frontmatter

\tableofcontents

\mainmatter
\chapter{Introduction}

If you have extensively used the \styfmt{glossaries} or
\styfmt{glossaries-extra} package, you may have found yourself
creating a large \ext{tex} file containing many definitions that
you frequently use in documents. This file can then simply be
loaded using \cs{input} or \cs{loadglsentries}, but a large file
like this can be difficult to maintain and if the document only
actually uses a small proportion of those entries, the document
build is unnecessarily slow due to the time and resources taken on
defining the unwanted entries.

The aim of \bibgls\ is to allow the entries to be stored in a
\ext{bib} file, which can be maintained using a reference system
such as JabRef. The document build process
can now be analogous to that used with \app{bibtex} (or
\appfmt{biber}), where only those entries that have been recorded in the
document (and possibly their dependent entries) will be extracted
from the \ext{bib} file. Since \bibgls\ can also perform
hierarchical sorting and can collate location lists, it doubles as
an indexing application, which means that the \app{makeglossaries}
step can be skipped.

You can't use \cs{glsaddall} with this method as that command works
by iterating over all defined entries and calling
\cs{glsadd}\margm{label}. On the first \LaTeX\ run there are no
entries defined, so \cs{glsaddall} does nothing. If you want to
select all entries, just use \optref[all]{selection} instead (which
has the advantage over \cs{glsaddall} in that it doesn't create a
redundant location for each entry).

Note that \bibgls\ requires the extension package
\sty{glossaries-extra} and can't be used with just the base
\sty{glossaries} package, since it requires some of the extension
commands. See the \sty{glossaries-extra} user manual for information
on the differences between the basic package and the extended
package, as some of the default settings are different.

Since the information used by \bibgls\ is
written to the \ext{aux} file, it's not possible to run \bibgls\
through \TeX's shell escape while the \ext{aux} file is open for
write access. (The \ext{aux} file is closed \emph{after} the end
document hook, so it can't be deferred with \cs{AtEndDocument}.) 
This means that if you really want to run \bibgls\
through \cs{write18} it must be done in the preamble with
\cs{immediate}. For example:
\begin{verbatim}
\immediate\write18{bib2gls \jobname}
\end{verbatim}
As from version 1.14 of \sty{glossaries-extra}, this can be done
automatically with the \styopt{automake} option if the \ext{aux}
file exists. (Remember that this will require the shell escape to be
enabled.)

\section{Example Use}
The glossary entries are stored in a \ext{bib} file. For
example, the file \filefmt{entries.bib} might contain:
\begin{verbatim}
@entry{bird,
  name={bird},
  description = {feathered animal}
}

@abbreviation{html,
  short="html",
  long={hypertext markup language}
}

@symbol{v,
  name={$\vec{v}$},
  text={\vec{v}},
  description={a vector}
}

@index{goose,plural="geese"}
\end{verbatim}
Here's an example document that uses this data:
\begin{verbatim}
\documentclass{article}

\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[
  src={entries},% data in entries.bib
  sort={en-GB}% sort according to 'en-GB' locale
]

\begin{document}
\Gls{bird} and \gls{goose}.
Symbol: $\gls{v}$.
Abbreviation: \gls{html}.

\printunsrtglossaries
\end{document}
\end{verbatim}
If this document is called \filefmt{myDoc.tex}, the build 
process is:
\begin{verbatim}
pdflatex myDoc
bib2gls myDoc
pdflatex myDoc
\end{verbatim}
(This manual assumes \appfmt{pdflatex} for simplicity. Replace
with \appfmt{latex}, \appfmt{xelatex} or \appfmt{lualatex} as
appropriate.)

You can have multiple instances of \cs{GlsXtrLoadResources}. For
example:
\begin{verbatim}
\documentclass{article}

\usepackage[record,index,abbreviations,symbols]{glossaries-extra}

\GlsXtrLoadResources[
  src={entries},% data in entries.bib
  sort={en-GB},% sort according to 'en-GB' locale
  match={entrytype={entry}},% only select @entry
  type={main}% put these entries in the 'main' glossary
]

\GlsXtrLoadResources[
  src={entries},% data in entries.bib
  sort={en-GB},% sort according to 'en-GB' locale
  match={entrytype={abbreviation}},% only select @abbreviation
  type={abbreviations}% put these entries in the 'abbreviations' glossary
]

\GlsXtrLoadResources[
  src={entries},% data in entries.bib
  sort={letter-case},% case-sensitive letter sort
  match={entrytype={symbol}},% only select @symbol
  type={symbols}% put these entries in the 'symbols' glossary
]

\GlsXtrLoadResources[
  src={entries},% data in entries.bib
  sort={en-GB},% sort according to 'en-GB' locale
  match={entrytype={index}},% only select @index
  type={index}% put these entries in the 'index' glossary
]

\begin{document}
\Gls{bird} and \gls{goose}.
Symbol: $\gls{v}$.
Abbreviation: \gls{html}.

\printunsrtglossaries
\end{document}
\end{verbatim}

Note that there's no need to called \app{xindy} or \app{makeindex}
since \bibgls\ automatically sorts the entries and collates the locations
after selecting the required entries from the \ext{bib} file and
before writing the temporary file that's input with \cs{glsxtrresourcefile}
(or the more convenient shortcut
\cs{GlsXtrLoadResources}).\footnote{This document will mostly use
the more convenient \cs{GlsXtrLoadResources}.}  This
means the entries are already defined in the correct order, and only
those entries that are required in the document are defined, so
\cs{printunsrtglossary} (or \cs{printunsrtglossaries}) may be used.
(The \qtt{unsrt} part of the command name indicates that all
defined entries should be listed in the order of definition from
\sty{glossaries-extra}'s point of view.)

If you additionally want to use an indexing application, such
as \app{xindy}, you need the package option
\styopt[alsoindex]{record} and use \cs{makeglossaries}
and \cs{printglossary} (or the iterative \cs{printglossaries}) as usual.
This requires a more complicated build process:
\begin{verbatim}
pdflatex myDoc
bib2gls myDoc
pdflatex myDoc
makeglossaries myDoc
pdflatex myDoc
\end{verbatim}
(The entries aren't defined until the second \LaTeX\ run, so the
indexing files required by \app{makeindex} or \app{xindy} can't be
created until then.)

\section{Security}

\TeX\ Live come with security settings
\texttt{openin\_any} and \texttt{openout\_any} that, respectively,
govern read and write file access (in addition to the operating
system's file permissions). \bibgls\ uses \app{kpsewhich} to
determine these values and honours them. MikTeX doesn't use these
settings, so if these values are unset, \bibgls\ will default to
\texttt{a} (any) for \texttt{openin\_any} and \texttt{p} (paranoid) for
\texttt{openout\_any}.

\section{Localisation}
\label{sec:lang.xml}

The messages produced by \bibgls\ are fetched from a resource file
called \metafilefmt{bib2gls-}{lang}{.xml}, where \meta{lang} is a
valid \gls{IETF} language tag.

The appropriate file is searched for in the following order, where
\meta{locale} is the operating system's locale or the value supplied
by the \argref{locale} switch:
\begin{enumerate}
\item \meta{lang} exactly matches \meta{locale}.
For example, my locale is \texttt{en-GB}, so \bibgls\ will first search
for \filefmt{bib2gls-en-GB.xml}. This file doesn't exist, so it will
try again.

\item If \meta{locale} has an associated script, the
next try is with \meta{lang} set to \meta{lang
code}\texttt{-}\meta{script} where \meta{lang code} is the two
letter ISO language code and \meta{script} is the script code.
For example, if \meta{locale} is \texttt{sr-RS-Latn}
then \bibgls\ will search for \filefmt{bib2gls-sr-Latn.xml} if
\filefmt{bib2gls-sr-RS-Latn.xml} doesn't exist.

\item The final attempt is with \meta{lang} set to just the two
letter ISO language code. For example, \filefmt{bib2gls-sr.xml}.
\end{enumerate}

If there is no match, \bibgls\ will fallback on the English resource file
\file{bib2gls-en.xml}.
(Currently only \file{bib2gls-en.xml} exists as my language skills aren't up
to translating it. Any volunteers who want to provide other language
resource files would be much appreciated.)

Note that if you use the \optref[true]{loc-prefix} option, the
textual labels (\qt{Page} and \qt{Pages} in English) will be taken
from the resource file. In the event that the loaded resource file
doesn't match the document language, you will have to manually set
the correct translation (in English, this would be
\csopt[Page\dcomma Pages]{loc-prefix}). The default definition of
\csref{bibglspassim} is also obtained from the resource file.

\section{Manual Installation}

If you are unable to install \bibgls\ through your \TeX\ package
manager, you can install manually using the instructions below.
Replace \meta{TEXMF} with the path to your local or home TEXMF tree 
(for example, \filefmt{~/texmf}).

Copy the files provided to the following locations:
\begin{itemize}
\item \meta{TEXMF}\filefmt{/scripts/bib2gls/bib2gls.jar}
(Java application.)
\item \meta{TEXMF}\filefmt{/scripts/bib2gls/convertgls2bib.jar}
(Java application.)
\item \meta{TEXMF}\filefmt{/scripts/bib2gls/texparserlib.jar}
(Java library.)
\item \meta{TEXMF}\filefmt{/scripts/bib2gls/resources/bib2gls-en.xml}
(English resource file.)
\item \meta{TEXMF}\filefmt{/doc/support/bib2gls/bib2gls.pdf}
(This document.)
\end{itemize}

If you are using a Unix-like system, there are also bash scripts
provided called \file{bib2gls.sh} and \file{convertgls2bib.sh}. 
Either copy then directly to somewhere on your path without the \ext{sh} 
extension, for example:
\begin{verbatim}
cp bib2gls.sh ~/bin/bib2gls
cp convertgls2bib.sh ~/bin/convertgls2bib
\end{verbatim}
or copy the files to
\meta{TEXMF}\filefmt{/scripts/bib2gls/} and create a
symbolic link to them called just \filefmt{bib2gls} and
\filefmt{convertgls2bib} from somewhere on
your path, for example:
\begin{verbatim}
cp bib2gls.sh ~/texmf/scripts/bib2gls/
cp convertgls2bib.sh ~/texmf/scripts/bib2gls/
cd ~/bin
ln -s ~/texmf/scripts/bib2gls/bib2gls.sh bib2gls
ln -s ~/texmf/scripts/bib2gls/convertgls2bib.sh convertgls2bib
\end{verbatim}
The \file{texparserlib.jar} file isn't an application but is a
library used by both \file{bib2gls.jar} and
\file{convertgls2bib.jar}, and so needs to be in the same class path. 
(The library is in a separate
\href{https://github.com/nlct/texparser}{GitHub repository} as it's
also used by some of my other applications.)

Windows users can create a \ext{bat} file that works in a
similar way to the bash scripts. To do this, create a file called
\file{bib2gls.bat} that contains the following:
\begin{verbatim}
@ECHO OFF
FOR /F "tokens=*" %%I IN ('kpsewhich --progname=bib2gls --format=texmfscripts
bib2gls.jar') DO SET JARPATH=%%I
java -Djava.locale.providers=CLDR,JRE -jar "%JARPATH%" %*
\end{verbatim}
Save this file to somewhere on your system's path.
(Similarly for \filefmt{convertgls2bib}.) Note that \TeX\
distributions for Windows usually convert \ext{jar} files to
executables.

You may need to refresh \TeX's database to ensure that
\app{kpsewhich} can find the \ext{jar} files.

To test that the application has been successfully installed, open a
command prompt or terminal and run the following command:
\begin{verbatim}
bib2gls --version
convertgls2bib --version
\end{verbatim}
This should display the version information for both applications.

\chapter{\texorpdfstring{\TeX}{TeX}\ Parser Library}
\label{sec:texparserlib}

The \bibgls\ application requires the \TeX\ Parser Library
\file{texparserlib.jar}\footnote{\url{https://github.com/nlct/texparser}} which is used to parse the \ext{aux}
and \ext{bib} files.

With the \argref{interpret} switch on (default), this library is
also used to interpret the sort value when it contains
a backslash \verb|\| or a dollar symbol \verb|$| or braces \verb|{|
\verb|}| (and when the \optref{sort} option is not \optfmt{unsrt} or
\optfmt{none} or \optfmt{use}). The other case is with
\optref{set-widest} when determining the width of the \field{name}
field. The \argref{no-interpret} switch will turn off this function,
but the library will still be used to parse the \ext{aux} and
\ext{bib} files.

The \file{texparserlib.jar} library is not a
\TeX\ engine and there are plenty of situations where it doesn't
work. In particular, in this case it's being used in a fragmented
context without knowing most of the packages used by the
document\footnote{\bibgls\ can detect from the log file a small
number of packages that the parser can support, such as
\sty{pifonts}, \sty{wasysym}, \sty{amssymb}, \sty{stix}, \sty{mhchem}
and \sty{bpchem}. There's also partial support for \sty{siunitx}'s
\cs{si} command.}\ or any custom
commands or environments provided within the document.

\TeX\ syntax can be quite complicated and, in some cases, far too
complicated for simple regular expressions. The library performs
better than a simple pattern match, and that's the purpose of
\file{texparserlib.jar} and why it's used by \bibgls\ (and by
\appfmt{convertgls2bib}). When
the \argref{debug} mode is on, any warnings or errors triggered by
the \argref{interpret} mode will be written to the transcript
prefixed with \texttt{texparserlib:} (the results of the conversions
will be included in the transcript as informational messages
prefixed with \texttt{texparserlib:} even with \argref{no-debug}).

For example, suppose the \ext{bib} file includes:
\begin{verbatim}
@preamble{
"\providecommand{\mtx}[1]{\boldsymbol{#1}}
\providecommand{\set}[1]{\mathcal{#1}}
\providecommand{\card}[1]{|\set{#1}|}
\providecommand{\imaginary}{i}"}

@entry{M,
  name={{}$\mtx{M}$},
  text={\mtx{M}},
  description={a matrix}
}

@entry{v,
  name={{}$\vec{v}$},
  text={\vec{v}},
  description={a vector}
}

@entry{S,
  name={{}$\set{S}$},
  text={\set{S}},
  description={a set}
}

@entry{card,
  name={{}$\card{S}$},
  text={\card{S}},
  description={the cardinality of the set $\set{S}$}
}

@entry{i,
  name={{}$\imaginary$},
  text={\imaginary},
  description={square root of minus one ($\sqrt{-1}$)}
}
\end{verbatim}
(The empty group at the start of the \field{name} fields
protects against the possibility that the \catattr{glossname}
category attribute might be set to \optfmt{firstuc}, which
automatically converts the first letter of the name to 
upper case when displaying the glossary. See also
\argref{mfirstuc-protection} and
\argref{mfirstuc-math-protection}.)

None of these entries have a \field{sort} field so the \field{name}
is used. If the entry type had been \atentryref{symbol} instead,
the fallback would be the entry's label.
This means that with \entry{symbol} instead of \entry{entry}, and the default
\optref[sort]{sort-field}, and with
\optref[letter-case]{sort}, these entries will be defined in
the order: \texttt{M}, \texttt{S}, \texttt{card}, \texttt{i}, \texttt{v} (since
this is the case-sensitive letter order of the labels) whereas
with \optref[letter-nocase]{sort-field}, the order will be:
\texttt{card}, \texttt{i}, \texttt{M}, \texttt{S}, \texttt{v} (since this
is the case-insensitive letter order of the labels).

However, with \atentryref{entry}, the fallback field will
be taken from the \field{name} which in the above example contains \TeX\ code, so
\bibgls\ will use \file{texparserlib.jar} to interpret this code.
The library has several different ways of writing the processed
code. For simplicity, \bibgls\ uses the library's HTML output and then 
strips the HTML markup and trims any leading or trailing
spaces. The library method that writes non-ASCII
characters using \qtt{\&x\meta{hex};} markup is overridden
by \bibgls\ to just write the Unicode character, which means
that the letter-based sorting options will sort according
to the integer value \meta{hex} rather than the string
\qtt{\&x\meta{hex};}.

The interpreter is first passed the code provided with
\atentryref{preamble}:
\begin{verbatim}
\providecommand{\mtx}[1]{\boldsymbol{#1}}
\providecommand{\set}[1]{\mathcal{#1}}
\providecommand{\card}[1]{|\set{#1}|}
\providecommand{\imaginary}{i}
\end{verbatim}
(unless \optref[false]{interpret-preamble}).
This means that the provided commands are now recognised by the
interpreter when it has to parse the fields later.

In the case of the \texttt{M} entry in the example above, the 
code that's passed to the interpreter is:
\begin{verbatim}
{}$\mtx{M}$
\end{verbatim}
The transcript (\ext{glg}) file will show the results of the
conversion:\footnote{The \argref{debug} mode will show additional
information.}
\begin{verbatim}
texparserlib: {}$\mtx{M}$ -> M
\end{verbatim}
So the \field{sort} value for this entry is set to \qtt{M}. The font
change (caused by math-mode and \cs{boldsymbol}) has been 
ignored. The sort value therefore consists of a single Unicode
character 0x4D (Latin upper case letter \qtt{M}, decimal value 77).

For the \texttt{v} entry, the code is:
\begin{verbatim}
{}$\vec{v}$
\end{verbatim}
The transcript shows:
\begin{alltt}
texparserlib: \marg{}\$\csfmt{vec}\marg{v}\$ -> \usebox\varrow
\end{alltt}
So the \field{sort} value for this entry is set to \qtt{\usebox\varrow},
which consists of two Unicode characters 0x76
(Latin lower case letter \qtt{v}, decimal value 118) and 
0x20D7 (combining right arrow above, decimal value 8407).

For the \texttt{set} entry, the code is:
\begin{verbatim}
{}$\set{S}$
\end{verbatim}
The transcript shows:
\begin{verbatim}
texparserlib: {}$\set{S}$ -> S
\end{verbatim}
So the \field{sort} value for this entry is set to \qtt{S} (again
ignoring the font change). This consists of a single Unicode
character 0x53 (Latin upper case letter \qtt{S}, decimal value~83).

For the \texttt{card} entry, the code is:
\begin{verbatim}
{}$\card{S}$
\end{verbatim}
The transcript shows:
\begin{verbatim}
texparserlib: {}$\card{S}$ -> |S|
\end{verbatim}
So the \field{sort} value for this entry is set to \qtt{|S|}
(the \textbar\ characters from the definition of \csfmt{card} provided
in \atentry{preamble} have been included, but the
font change has been discarded). In this case the sort value
consists of three Unicode characters 0x7C (vertical line, decimal
value 124),
0x53 (Latin upper case letter \qtt{S}, decimal value 83) and 0x7C again.
If \optref[false]{interpret-preamble} had been used, \csfmt{card}
wouldn't be recognised and would be discarded leaving just \qtt{S}
as the sort value.

For the \texttt{i} entry, the code is:
\begin{verbatim}
{}$\imaginary$
\end{verbatim}
The transcript shows:
\begin{verbatim}
texparserlib: {}$\imaginary$ -> i
\end{verbatim}
So the \field{sort} value for this entry is set to \qtt{i}.

This means that in the case of the default \optref[sort]{sort-field} with
\optref[letter-case]{sort}, these entries will be defined in
the order: \texttt{M} ($\mtx{M}$), \texttt{S} ($\set{S}$),
\texttt{i} ($\imaginary$), \texttt{v} ($\vec{v}$) and
\texttt{card} ($\card{S}$).
In this case, the entries have been sorted according to
the character codes. If you run \bibgls\ with \argref{verbose}
the decimal character codes will be included in the transcript.
For this example:
\begin{alltt}
i -> 'i' [105]
card -> '|S|' [124 83 124]
M -> 'M' [77]
S -> 'S' [83]
v -> '\usebox\varrow' [118 8407]
\end{alltt}

The \argref{group} option (in addition to \argref{verbose}) 
will place the letter group in 
parentheses before the character code list:
\begin{alltt}
i -> 'i' (i) [105]
card -> '|S|' [124 83 124]
M -> 'M' (M) [77]
S -> 'S' (S) [83]
v -> '\usebox\varrow' (v) [118 8407]
\end{alltt}
(Note that the \texttt{card} entry doesn't have a letter
group since the vertical bar character isn't considered a 
letter.)

If \optref[letter-nocase]{sort} is used instead then, after conversion
by the interpreter, the sort values will all be changed to
lower case. The order is now: \texttt{i} ($\imaginary$), 
\texttt{M} ($\mtx{M}$), \texttt{S} ($\set{S}$),
\texttt{v} ($\vec{v}$) and \texttt{card} ($\card{S}$).
The transcript (with \argref{verbose}) now shows
\begin{alltt}
i -> 'i' [105]
card -> '|s|' [124 115 124]
M -> 'm' [109]
S -> 's' [115]
v -> '\usebox\varrow' [118 8407]
\end{alltt}
With \argref{group} (in addition to \argref{verbose}) 
the letter groups are again included:
\begin{alltt}
i -> 'i' (I) [105]
card -> '|s|' [124 115 124]
M -> 'm' (M) [109]
S -> 's' (S) [115]
v -> '\usebox\varrow' (V) [118 8407]
\end{alltt}
Note that the letter groups are upper case not lower case.
Again the \texttt{card} entry doesn't have an associated
letter group.

If a locale-based sort is used, the ordering will follow the
locale's alphabet rules. For example, with \optref[en]{sort}
(English, no region or variant), the order becomes:
\texttt{card} ($\card{S}$), \texttt{i} ($\imaginary$), 
\texttt{M} ($\mtx{M}$), \texttt{S} ($\set{S}$) and
\texttt{v} ($\vec{v}$). The transcript (with \argref{verbose}) 
shows the collation keys instead:
\begin{alltt}
i -> 'i' [0 92 0 0 0 0]
card -> '|S|' [0 66 0 102 0 66 0 0 0 0]
M -> 'M' [0 96 0 0 0 0]
S -> 'S' [0 102 0 0 0 0]
v -> '\usebox\varrow' [0 105 0 0 0 0]
\end{alltt}
Again the addition of the \argref{group} switch will show
the letter groups.\footnote{For more information on collation keys see the
\href{http://docs.oracle.com/javase/8/docs/api/java/text/CollationKey.html}{CollationKey}
class in Java's API.}

Suppose I add a new symbol to my \ext{bib} file:
\begin{verbatim}
@symbol{angstrom,
  name={\AA},
  description={\AA ngstr\"om}
}
\end{verbatim}
and I also use this entry in the document. Then with
\optref[en]{sort}, the order is: \texttt{card} ($\card{S}$),
\texttt{angstrom} (\AA), \texttt{i} ($\imaginary$), \texttt{M}
($\mtx{M}$), \texttt{S} ($\set{S}$), and \texttt{v} ($\vec{v}$).
The \argref{group} switch shows that the \texttt{angstrom} entry
(\AA) has been placed in the \qt{A} letter group.

However, if I change the locale to \optref[sv]{sort}, the
\texttt{angstrom} entry is moved to the end of the list and the
\argref{group} switch shows that it's been placed in the \qt{\AA}
letter group.

If you are using Java~8, you can set the
\texttt{java.locale.providers} property to \texttt{CLDR,JRE} to use
the Common Locale Data Repository, which has more extensive
support for locales than the native Java Runtime Environment.
This isn't available for Java~7, and should be enabled by default
for the proposed Java~9.

\chapter{Command Line Options}
\label{sec:switches}

\edef\resetsecnumdepth{\noexpand\setcounter{secnumdepth}{\arabic{secnumdepth}}}
\setcounter{secnumdepth}{0}

The syntax of \bibgls\ is:
\begin{alltt}
bib2gls \oargm{options} \meta{filename}
\end{alltt}
where \meta{filename} is the name of the \ext{aux} file. (The
extension may be omitted.) Only one \meta{filename} is permitted.

Available options are listed below.

\section{\longarg{help} (or \shortarg{h})}
\labelarg{help}

Display the help message and quit.

\section{\longarg{version} (or \shortarg{v})}
\labelarg{version}

Display the version information and quit.

\section{\longarg{debug} \oargm{n}}
\labelarg{debug}

Switch on debugging mode. If \meta{n} is present, it must be a
non-negative integer indicating the debugging level. If omitted 1 is
assumed. This option also switches on the verbose mode. A value of 0
is equivalent to \longargfmt{no-debug}.

\section{\longarg{no-debug} (or \longarg{nodebug})}
\labelarg{no-debug}

Switches off the debugging mode.

\section{\longarg{verbose}}
\labelarg{verbose}

Switches on the verbose mode. This writes extra information to the
terminal and transcript file.

\section{\longarg{no-verbose} (or \longarg{noverbose})}
\labelarg{no-verbose}

Switches off the verbose mode. This is the default behaviour.
Some messages are written to the terminal. To completely suppress
all messages (except errors), switch on the silent mode.
For additional information messages, switch on the verbose mode.

\section{\longarg{silent}}
\labelarg{silent}

Suppresses all messages except for errors that would normally be
written to the terminal. Warnings and informational messages are
written to the transcript file, which can be inspected afterwards.

\section{\longarg{locale} \meta{lang} (or \shortarg{l} \meta{lang})}
\labelarg{locale}

Specify the preferred \langxml, where \meta{lang} is a valid \gls{IETF} language tag.
This option requires an appropriate \metafilefmt{bib2gls-}{lang}{.xml}
resource file otherwise \bibgls\ will fallback on English.

\section{\longarg{log-file} \meta{filename} (or \shortarg{t}
\meta{filename})}
\labelarg{log-file}

Sets the name of the transcript file. By default, the name is the
same as the \ext{aux} file but with a \ext{glg} extension. Note that
if you use \bibgls\ in combination with \app{xindy} or
\app{makeindex}, you will need to change the transcript file name to
prevent interference.

\section{\longarg{dir} \meta{dirname} (or \shortarg{d}
\meta{dirname})}
\labelarg{dir}

By default \bibgls\ assumes that the output files should be written
in the current working directory. The input \ext{bib} files are assumed to be
either in the current working directory or on \TeX's path (in which
case \app{kpsewhich} will be used to find them).

If your \ext{aux} file isn't in the current working directory (for
example, you have run \TeX\ with \shortargfmt{output-directory})
then you need to take care how you invoke \bibgls.

Suppose I have a file called \filefmt{test-entries.bib} that
contains my entry definitions and a document called
\filefmt{mydoc.tex} that selects the \ext{bib} file using:
\begin{verbatim}
\GlsXtrLoadResources[src={test-entries}]
\end{verbatim}
(\filefmt{test-entries.bib} is in the same directory as
\filefmt{mydoc.tex}).
If I compile this document using
\begin{verbatim}
pdflatex -output-directory tmp mydoc
\end{verbatim}
then the auxiliary file \filefmt{mydoc.aux} will be written to the
\filefmt{tmp} sub-directory. The resource information is listed in
the \ext{aux} file as
\begin{verbatim}
\glsxtr@resource{src={test-entries}}{mydoc}
\end{verbatim}
If I run \bibgls\ from the \filefmt{tmp} directory, then it won't
be able to find the \filefmt{test-entries.bib} file (since it's in
the parent directory).

If I run \bibgls\ from the same directory as \filefmt{mydoc.tex}
using
\begin{verbatim}
bib2gls tmp/mydoc
\end{verbatim}
then the \ext{aux} file is found and the transcript file is
\filefmt{tmp/mydoc.glg} (since the default is the same as the
\ext{aux} file but with the extension changed to \ext{glg}) but the
output file \filefmt{mydoc.glstex} will be written to the current
directory.

This works fine from \TeX's point of view as it can find the
\ext{glstex} file, but it may be that you'd rather the \ext{glstex}
file was tidied away into the \filefmt{tmp} directory along with all
the other files.  In this case you need to invoke \bibgls\ with the
\longarg{dir} or \shortarg{d} option:
\begin{verbatim}
bib2gls -d tmp mydoc
\end{verbatim}

\section{\longarg{interpret}}
\labelarg{interpret}

Switch on the interpreter mode (default). See \sectionref{sec:texparserlib}
for more details.

\section{\longarg{no-interpret}}
\labelarg{no-interpret}

Switch off the interpreter mode. See \sectionref{sec:texparserlib}
for more details.

\section{\longarg{mfirstuc-protection} (or \shortarg{u})}
\labelarg{mfirstuc-protection}

Commands like \cs{Gls} use \cs{makefirstuc} provided by the
\sty{mfirstuc} package. This command has limitations and one of the
things that can break it is the use of a referencing command 
at the start of its argument. The \sty{glossaries-extra} package has
more detail about the problem in the \qt{Nested Links} section of
the user manual. If a glossary field starts with one of these
problematic commands, the recommended method (if the command can't
be replaced) is to insert an empty group in front of it.

For example, the following definition
\begin{verbatim}
\newabbreviation{shtml}{shtml}{\glsps{ssi} enabled \glsps{short}{html}}
\end{verbatim}
will cause a problem for \verb|\Gls{shtml}| on first use.

The above example, would be written in a \ext{bib} file as:
\begin{verbatim}
@abbreviation{shtml,
  short={shtml},
  long={\glsps{ssi} enabled \glsps{html}}
}
\end{verbatim}

With the \longarg{mfirstuc-protection} switch on (the default
behaviour), \bibgls\ will automatically insert an empty group at the
start of the \field{long} field to guard against this problem. A
warning will be written to the transcript.

\section{\longarg{no-mfirstuc-protection}}
\labelarg{no-mfirstuc-protection}

Switches off the \sty{mfirstuc} protection mechanism described
above.

\section{\longarg{mfirstuc-math-protection}}
\labelarg{mfirstuc-math-protection}

This works in the same way as \argref{mfirstuc-protection} but
guards against fields starting with inline maths
(\verb|$|\ldots\verb|$|). For example, if the \field{name} field
starts with \verb|$x$| and the glossary style automatically tries to
convert the first letter of the name to upper case, then this will
cause a problem.

With \longarg{mfirstuc-math-protection} set, \bibgls\ will
automatically insert an empty group at the start of the field and
write a warning in the transcript. This setting is on by default.

\section{\longarg{no-mfirstuc-math-protection}}
\labelarg{no-mfirstuc-math-protection}

Switches off the above.

\section{\longarg{nested-link-check} \meta{list}\argor\texttt{none}}
\labelarg{nested-link-check}

By default, \bibgls\ will parse certain fields for potential nested links.
(See the section \qt{Nested Links} in the \sty{glossaries-extra}
user manual.)

The default set of fields to check are: \field{name}, \field{text},
\field{plural}, \field{first}, \field{firstplural}, \field{long},
\field{longplural}, \field{short}, \field{shortplural} and
\field{symbol}.

You can change this set of fields using
\longarg{nested-link-check} \meta{value} where \meta{value} may be
\optfmt{none} (don't parse any of the fields) or a comma-separated
list of fields to be checked.

\section{\longarg{no-nested-link-check}}
\labelarg{no-nested-link-check}

Equivalent to \longarg{nested-link-check} \optfmt{none}.

\section{\longarg{shortcuts} \meta{value}}
\labelarg{shortcuts}

Some entries may reference another entry within a field, using
commands like \cs{gls}, so \bibgls\ parses the fields for these
commands to determine dependent entries to allow them to be selected
even if they haven't been used within the document.
The \styopt{shortcuts} package option provided by
\styfmt{glossaries-extra} defines various synonyms, such as \cs{ac}
which is equivalent to \cs{gls}. By default the value of the
\styopt{shortcuts} option will be picked up by \bibgls\ when parsing the
\ext{aux} file. This then allows \bibgls\ to additionally search for
those shortcut commands while parsing the fields.

You can override the \styopt{shortcuts} setting using
\longarg{shortcuts} \meta{value} (where \meta{value} may take
any of the allowed values for the \styopt{shortcuts} package option), 
but in general there is little need to use this switch.

\section{\longarg{map-format} \meta{format1}:\meta{format2}
or \shortarg{m} \meta{format1}:\meta{format2}}
\labelarg{map-format}

This sets up the rule of precedence for partial location
matches (see \sectionref{sec:locationopts}). For example, 
\begin{verbatim}
bib2gls --map-format "emph:hyperbf" mydoc
\end{verbatim}
This essentially means that if there's a record conflict
involving \texttt{emph}, try replacing \texttt{emph} with
\texttt{hyperbf} and see if that resolves the conflict.

Note that if the conflict includes a range formation, the
range takes precedence.

If you have multiple mappings, you can either use a single
\longarg{map-format} with a comma separated list of
\meta{format1}\dcolon\meta{format2} or you can have multiple instances of 
\longarg{map-format} \meta{format1}\dcolon\meta{format2}.

Note that the mapping tests are applied as the records are
read. For example, suppose the records are listed in the \ext{aux}
file as:
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{emph}{3}
\glsxtr@record{gls.sample}{}{page}{hypersf}{3}
\glsxtr@record{gls.sample}{}{page}{hyperbf}{3}
\end{verbatim}
and \bibgls\ is invoked with
\begin{verbatim}
bib2gls --map-format "emph:hyperbf,hypersf:hyperit" mydoc
\end{verbatim}
or
\begin{verbatim}
bib2gls --map-format emph:hyperbf --map-format hypersf:hyperit mydoc
\end{verbatim}
then \bibgls\ will process these records as follows:
\begin{enumerate}
\item Accept the first record (\texttt{emph}) since there's
currently no conflict. (This is the first record for page~3 for the
entry given by \texttt{gls.sample}.)
\item The second record (\texttt{hypersf}) conflicts 
with the existing record (\texttt{emph}). Neither has
the format \texttt{glsnumberformat} or \texttt{glsignore} so \bibgls\ consults
the mappings provided by \longargfmt{map-format}.
\begin{itemize}
\item The \texttt{hypersf} format (from the new record) is mapped to \texttt{hyperit},
so \bibgls\ checks if the existing record
has this format. In this case it doesn't (the format is
\texttt{emph}). So \bibgls\ moves onto the next test:

\item The \texttt{emph} format (from the existing record) is mapped to \texttt{hyperbf},
so \bibgls\ checks if the new record has this format.
In this case it doesn't (the format is \texttt{hypersf}).

Since the provided mappings haven't resolved this conflict,
the new record is discarded with a warning. Note that there's 
no look ahead to the next record. (There may be other 
records for other entries also used on page~3 interspersed between these records.)
\end{itemize}
\item The third record (\texttt{hyperbf}) conflicts 
with the existing record (\texttt{emph}). Neither has
the format \texttt{glsnumberformat} or \texttt{glsignore} so \bibgls\ again consults
the mappings provided by \longargfmt{map-format}.
\begin{itemize}
\item  The new record's \texttt{hyperbf} format has no mapping provided,
so \bibgls\ moves onto the next test:

\item The existing record's \texttt{emph} format has a mapping
provided (\texttt{hyperbf}). This matches the new record's format,
so the new record takes precedence.

This means that the location list ends up with the \texttt{hyperbf}
location for page~3.
\end{itemize}
\end{enumerate}

If, on the other hand, the mappings are given as
\begin{verbatim}
--map-format "emph:hyperit,hypersf:hyperit,hyperbf:hyperit"
\end{verbatim}
then all the three conflicting records (\texttt{emph},
\texttt{hypersf} and \texttt{hyperbf}) will end up being replaced
by a single record with \texttt{hyperit} as the format.

Multiple conflicts will typically be rare as there's usually little
reason for more than two or three different location formats within
the same list. (For example, \texttt{glsnumberformat} as the default
and \texttt{hyperbf} or \texttt{hyperit} for a primary reference.)

\section{\longarg{group}}
\labelarg{group}

The \styfmt{glossaries-extra} \styopt{record} package option automatically creates a new field
called \field{group}. If the \longarg{group} switch is used then, when
sorting, \bibgls\ will try to determine the letter group for each
entry and add it to the \field{group} field.  (Some \optref{sort}
options ignore this setting.) This value will be picked up by
\cs{printunsrtglossary} if group headings are required (for
example with the \glostyle{indexgroup} style). If you're not using
a glossary style that displays the group headings, there's no need
to use this switch. Note that this switch doesn't automatically
select an appropriate glossary style.

There are four basic types of groups:
\begin{itemize}
\item \keyword{letter groups} where the group title indicates the
first letter of all the sort values within that group.
The group title is set with \csref{bibglslettergroup}.

\item \keyword{non-letter groups} (or \keyword{symbol groups})
where the first characters of all the sort values within that group
are non-alphabetical. The group title is set with \csref{bibglsothergroup}.

\item \keyword{number groups} for all entries sorted by a numeric
comparison (such as \optref[integer]{sort}). 
The group title is set with \csref{bibglsnumbergroup}.

\item \keyword{custom groups} for all entries that have had the
group title explicitly set using the \optref[\meta{title}]{group} 
resource option.
\end{itemize}

The letter group titles will typically have the first character
converted to upper case for the rule-based comparisons
(\optref[custom]{sort} and \optref[\meta{lang-tag}]{sort}). A
\qt{letter} may not necessarily be a single character (depending on
the sort rule), but may be composed of multiple characters, such as
a \keyword{digraph} (two characters) or \keyword{trigraph} (three
characters).

For example, if the sort rule recognises the digraph \qt{dz} as a
letter, then it will be converted to \qt{Dz} for the group title. 
There are some exceptions to this. For example, the Dutch digraph 
\qt{ij} should be \qt{IJ} rather than \qt{Ij}. This is indicated 
by the following line in the \langxml:
\begin{verbatim}
<entry key="grouptitle.case.ij">IJ</entry>
\end{verbatim}
If there isn't a \texttt{grouptitle.case.\meta{lc}} key (where 
\meta{lc} is the lower case version), then only the first character
will be converted to upper case otherwise the value supplied by the
resource file is used. This resource key is only checked for
the locale and custom rule comparisons. If the initial part of
the sort value isn't recognised as a letter according to the sort rule, 
then the entry will be in a non-letter group (even if the character
is alphabetical).

The locale-independent character code comparisons (such as
\optref[letter-nocase]{sort}) only select the first character of the
sort value for the group. If the character is
alphabetical\footnote{according to Java's
\texttt{Character.isAlphabetic(int)} method} then it will be a
letter group otherwise it's a non-letter group.  The
case-insensitive ordering (such as \optref[letter-nocase]{sort})
will convert the letter group character to upper case. The
case-sensitive ordering (such as \optref[letter-case]{sort}) won't
change the case.

Glossary styles with navigational links to groups (such as
\glostyle{indexhypergroup}) require an extra run for the ordinary
\csfmt{makeglossaries} and \csfmt{makenoidxglossaries} methods. For
example, for the document \filefmt{myDoc.tex}:
\begin{verbatim}
pdflatex myDoc
makeglossaries myDoc
pdflatex myDoc
pdflatex myDoc
\end{verbatim}
On the first \appfmt{pdflatex} call, there's no glossary. On the second
\appfmt{pdflatex}, there's a glossary but the glossary must be
processed to find the group information, which is written to the
\ext{aux} file as
\begin{alltt}
\cs{@gls@hypergroup}\margm{type}\margm{group id}
\end{alltt}
The third \appfmt{pdflatex} reads this information and is then able
to create the navigation links.

With \bibgls, if the \optfmt{type} is provided (through the
\field{type} field or via options such as \optref{type} and
\optref{dual-type}) then this information can be determined when
\bibgls\ is ready to write the \ext{glstex} file, which means that
the extra \LaTeX\ run isn't necessary.

For example:
\begin{verbatim}
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[record,abbreviations,style=indexhypergroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries},% data in entries.bib
  type={main}% put these entries in the 'main' glossary
]

\GlsXtrLoadResources[src={abbrvs},% data in abbrvs.bib
  type={abbreviations}% put these entries in the 'abbreviations' glossary
]
\end{verbatim}
Here the \optref{type} is set and \bibgls\ can detect that
\sty{hyperref} has been loaded, so if the \longargfmt{group} switch
is used, then the group hyperlinks can be set (using
\csref{bibglshypergroup}). This means that the build process is
just:
\begin{verbatim}
pdflatex myDoc
bibtex --group myDoc
pdflatex myDoc
\end{verbatim}
Note that this requires \sty{glossaries} v4.32+. If your version of
\sty{glossaries} is too old then \bibgls\ can't override
the default behaviour of \sty{glossary-hypernav}'s
\cs{glsnavhypertarget}.

If \sty{hyperref} isn't loaded or the \longargfmt{group} switch
isn't used or the \field{type} isn't set or your version of
\sty{glossaries} is too old, then the information isn't saved.

For example:
\begin{verbatim}
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[record,abbreviations,style=indexhypergroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries}]% data in entries.bib

\GlsXtrLoadResources[src={abbrvs}]% data in abbrvs.bib
\end{verbatim}
This requires the build process:
\begin{verbatim}
pdflatex myDoc
bibtex --group myDoc
pdflatex myDoc
pdflatex myDoc
\end{verbatim}
because the group hyperlink information can't be determined by
\bibgls, so it's best to always set the \optfmt{type} if you want
hyper-group styles, and make sure you have an up-to-date version of 
\sty{glossaries} (and \sty{glossaries-extra}).

\section{\longarg{no-group}}
\labelarg{no-group}

Don't use the \field{group} field. (Default.)
The glossary won't have groups even if a group style, such as
\glostyle{indexgroup}, is used.

\section{\longarg{tex-encoding} \meta{name}}
\labelarg{tex-encoding}

\bibgls\ tries to determine the character encoding to use for the
output files. If the document has loaded the \sty{inputenc} package then
\bibgls\ can obtain the value of the encoding from the
\ext{aux} file. This then needs to be converted to a name
recognised by Java. For example, \texttt{utf8} will be mapped to
\texttt{UTF-8}. If the \sty{fontspec} package has been loaded,
\sty{glossaries-extra} will assume the encoding is \texttt{utf8} and
write that value to the \ext{aux} file.

If neither package has been loaded, \bibgls\ will assume the
operating system's default encoding. If this is incorrect or if
\bibgls\ can't work out the appropriate mapping then you can specify
the correct encoding using \longargfmt{tex-encoding} \meta{name}
where \meta{name} is the encoding name.

\section{\longarg{trim-fields}}
\labelarg{trim-fields}

Trim leading and trailing spaces from field values. For example,
if the \ext{bib} file contains:
\begin{verbatim}
@entry{sample,
  name = { sample },
  description = {
    an example
  }
}
\end{verbatim}
This will cause spurious spaces. Using \longarg{trim-fields} will
automatically trim the values before writing the \ext{glstex} file.

\section{\longarg{no-trim-fields}}
\labelarg{no-trim-fields}

Don't trim any leading or trailing spaces from field values. 
This is the default setting.

\chapter{\ext{bib} Format}
\label{sec:bib}

\bibgls\ recognises certain entry types. Any unrecognised types will
be ignored and a warning will be written to the transcript file.
Entries are defined in the usual \ext{bib} format:
\begin{alltt}
@\meta{entry-type}\marg{\meta{id},
  \meta{field-name-1} = \margm{text},
  ...
  \meta{field-name-n} = \margm{text}
}
\end{alltt}
where \meta{entry-type} is the entry type (listed below),
\meta{field-name-1}, \ldots, \meta{field-name-n} are the field names
(same as the keys available with \cs{newglossaryentry}) and
\meta{id} is a unique label. The label can't contain any spaces or
commas. In general it's best to stick with alpha-numeric labels.
The field values may be delimited by braces \margm{text} or
double-quotes \texttt{"\meta{text}"}.

\bibgls\ allows you to insert prefixes to the labels when the data
is read through the \optref{label-prefix} option. Remember to use
these prefixes when you reference the entries in the document, but
don't include them when you reference them in the \ext{bib} file.
There are some special prefixes that have a particular meaning to
\bibgls: \qt{\idprefix{dual}} and \qt{\idprefix{ext\meta{n}}} where
\meta{n} is a positive integer.  In the first case,
\idprefix{dual} references the dual element of a dual entry (see
\atentryref{dualentry}). This prefix will be replaced by the value of
the \csopt{dual-prefix} option. The \idprefix{ext\meta{n}} prefix
is used to reference an entry from a different set of resources
(loaded by another \cs{GlsXtrLoadResources} command). This prefix is
replaced by the corresponding element of the list supplied by
\optref{ext-prefixes}.

In the event that the \field{sort} value falls back on the label,
the original label supplied in the \ext{bib} file is used, not the
prefixed label.

Avoid non-ASCII characters in the \meta{id} if your document uses the 
\sty{inputenc} package.
You can set the character encoding in the \ext{bib} file using:
\begin{alltt}
\% Encoding: \meta{encoding-name}
\end{alltt}
where \meta{encoding-name} is the name of the character encoding.
For example:
\begin{verbatim}
% Encoding: UTF-8
\end{verbatim}
You can also set the encoding using the \optref{charset} option,
but it's simpler to include the above comment on the first line of
the \ext{bib} file. (This comment is also searched for by JabRef
to determine the encoding, so it works for both applications.) 
If you don't use either method \bibgls\ will
have to search the entire \ext{bib} file, which is inefficient and
you may end up with a mismatched encoding.

Each entry type may have required fields and optional fields. For the
optional fields, any key recognised by \cs{newglossaryentry} may be
used as a field. However, note that if you add
any custom keys in your document using \cs{glsaddkey} or \cs{glsaddstoragekey}, those
commands must be placed before the first use of
\cs{GlsXtrLoadResources}.

Any unrecognised fields will be ignored.
This is more convenient than using \cs{input} or \cs{loadglsentries}, which
requires all the keys used in the file to be defined, regardless of
whether or not you actually need them in the document.

If an optional field is missing and \bibgls\ needs to access it for
some reason (for example, for sorting), \bibgls\ will try to
fallback on another value. The actual fallback value depends on the
entry type.

Other entries can be cross-referenced using the \field{see},
\field{seealso} or \field{alias} fields or
by using commands like \cs{gls} or \cs{glsxtrp} in any of the
recognised fields. These will automatically be selected if the
\csopt{selection} setting includes dependencies, but you may need to
rebuild the document to ensure the location lists are correct.
If an entry has the \field{see} field set, any instance of
\cs{glssee} in the document for that entry will be ignored,
otherwise the reference from \cs{glssee} will be transferred to the
\field{see} field (provided you have at least v1.14 of
\sty{glossaries-extra}). In general, it's best just to use the \field{see}
field and not use \cs{glssee}.

The \field{seealso} key was only added to \sty{glossaries-extra}
v1.16, but this field may be used with \bibgls\ even if you only
have version 1.14 or 1.15. If the key isn't available,
\texttt{seealso=\margm{xr-list}} will be treated as
\texttt{see=\marg{[\cs{seealsoname}]\meta{xr-list}}} (the resource
option \optref{seealso} won't have an effect).  You can't use both
\field{see} and \field{seealso} for the same entry with \bibgls.
Note that the \field{seealso} field doesn't allow for the optional
\oargm{tag} part. If you need a different tag, either use \field{see}
or change the definition of \cs{seealsoname} or
\cs{glsxtruseseealsoformat}.  Note that, unless you are using
\app{xindy}, \cs{glsxtrindexseealso} just does
\cs{glssee}[\cs{seealsoname}], and so will be treated as \field{see}
rather than \field{seealso} by \bibgls. Again, it's better to just
use the \field{seealso} field directly.

\section{\atentry{string}}
\labelatentry{string}

The standard \atentry{string} is available and can be used to define
variables that may be used in field values.
For example:
\begin{verbatim}
@string{ssi={server-side includes}}
@string{html={hypertext markup language}}

@abbreviation{shtml,
  short="shtml",
  long= ssi # " enabled " # html,
  see={ssi,html}
}

@abbreviation{html,
  short ="html",
  long  = html
}

@abbreviation{ssi,
  short="ssi",
  long = ssi
}
\end{verbatim}

\section{\atentry{preamble}}
\labelatentry{preamble}

The standard \atentry{preamble} is available and can be used to
provide command definitions used within field values.
For example:
\begin{verbatim}
@preamble{"\providecommand{\mtx}[1]{\boldsymbol{#1}}"}

@entry{matrix,
  name={matrix},
  plural={matrices},
  description={rectangular array of values, denoted $\mtx{M}$}
}
\end{verbatim}

The \TeX\ parser library used by \bibgls\ will parse the contents of
\atentry{preamble} before trying to interpret the field value used
as a fallback when \field{sort} is omitted (unless
\optref[false]{interpret-preamble} is set in the resource options).
For example:
\begin{verbatim}
@preamble{"\providecommand{\set}[1]{\mathcal{#1}}
\providecommand{\card}[1]{|\set{#1}|}"}

@entry{S,
  name={{}$\set{S}$},
  text={\set{S}},
  description={a set}
}
@entry{card,
  name={{}$\card{S}$},
  text={\card{S}},
  description={the cardinality of \gls{S}}
}
\end{verbatim}
Neither entry has the \field{sort} field, so \bibgls\ has to fall
back on the \field{name} field and, since this contains the special
characters \verb|\| \verb|$| \verb|{| and \verb|}|, the \TeX\ parser
library is used to interpret it. The definitions provided by
\atentry{preamble} allow \bibgls\ to deduce that the \field{sort}
value of the \texttt{S} entry is just \texttt{S} and the \field{sort}
value of the \texttt{card} entry is \verb"|S|" (see
\sectionref{sec:texparserlib}).

What happens if you also need to use these commands in the document?
The definitions provided in \atentry{preamble} won't be available
until the \ext{glstex} file has been created, which means the
commands won't be defined on the first \LaTeX\ run.

There are several approaches:
\begin{enumerate}
\item Just define the commands in the document. This means the
commands are available, but \bibgls\ won't be able to correctly
interpret the \field{name} fields.

\item Define the commands in both the document and in
\atentry{preamble}. For example:
\begin{verbatim}
\newcommand{\set}[1]{\mathcal{#1}}
\newcommand{\card}[1]{|\set{#1}|}
\GlsXtrLoadResources[src={my-data}]
\end{verbatim}
Alternatively:
\begin{verbatim}
\GlsXtrLoadResources[src={my-data}]
\providecommand{\set}[1]{\mathcal{#1}}
\providecommand{\card}[1]{|\set{#1}|}
\end{verbatim}
If the provided definitions match those given in the \ext{bib} file,
there's no difference. If they don't match then in the first example 
the document definitions will take precedence (but the interpreter
will use the \atentry{preamble} definitions) and in the second
example the \atentry{preamble} definitions will take precedence.

\item Make use of \cs{glsxtrfmt} provided by
\sty{glossaries-extra}\footnote{Introduced in version 1.12.}\ which
allows you to store the name of the formatting command in a field.
The default is the \field{user1} field, but this can be changed to 
another field by redefining \cs{GlsXtrFmtField}.

The \ext{bib} file can now look like this:
\begin{verbatim}
@preamble{"\providecommand{\set}[1]{\mathcal{#1}}
\providecommand{\card}[1]{|\set{#1}|}"}

@symbol{S,
  name={{}$\set{S}$},
  text={\set{S}},
  user1={set},
  description={a set}
}
@symbol{cardS,
  name={{}$\card{S}$},
  text={\card{S}},
  user1={card},
  description={the cardinality of \gls{S}}
}
\end{verbatim}
Within the document, you can format \meta{text} using the formatting
command provided in the \field{user1} field with:
\begin{definition}
\cs{glsxtrfmt}\oargm{options}\margm{label}\margm{text}
\end{definition}
(which internally uses \cs{glslink}) or
\begin{definition}
\cs{glsxtrentryfmt}\margm{label}\margm{text}
\end{definition}
which just applies the appropriate formatting command to
\meta{text}. If the entry given by \meta{label} hasn't been defined,
then this just does \meta{text} and a warning is issued. (It 
just does \meta{text} without a warning if the field hasn't been set.)
The \meta{options} are as for \cs{glslink} but \cs{glslink} will
actually be using
\begin{alltt}
\cs{glslink}\oarg{\meta{def-options},\meta{options}}\margm{label}\marg{\csfmt{}\meta{csname}\margm{text}}
\end{alltt}
where the default options \meta{def-options} are given by
\cs{GlsXtrFmtDefaultOptions}. The default definition of this is
just \texttt{noindex} which suppresses the automatic indexing or
recording action. (See the \sty{glossaries-extra} manual
for further details.)

This means that the document doesn't need to actually provide
\verb|\set| or \verb|\card| but can instead use, for example,
\begin{alltt}
\cs{glsxtrfmt}\marg{S}\marg{A}
\cs{glsxtrentryfmt}\marg{cardS}\marg{B}
\end{alltt}
instead of
\begin{verbatim}
\set{A}
\card{B}
\end{verbatim}
The first \LaTeX\ run will simply ignore the formatting and produce
a warning.

Since this is a bit cumbersome to write, you can provide shortcut
commands. For example:
\begin{verbatim}
\GlsXtrLoadResources[src={my-data}]
\newcommand{\gset}[2][]{\glsxtrfmt[#1]{S}{#2}}
\newcommand{\gcard}[2][]{\glsxtrfmt[#1]{cardS}{#2}}
\end{verbatim}
Whilst this doesn't seem a great deal different from simply
providing the definitions of \csfmt{set} and \csfmt{card} in the
document, this means you don't have to worry about remembering 
the names of the actual commands provided in the \ext{bib} file
(just the entry labels) and the use of \cs{glsxtrfmt} will
automatically produce a hyperlink to the glossary entry if the
\sty{hyperref} package has been loaded.
\end{enumerate}

Here's an alternative \ext{bib} that defines entries with a term, a
description and a symbol:
\begin{verbatim}
@preamble{"\providecommand{\setfmt}[1]{\mathcal{#1}}
\providecommand{\cardfmt}[1]{|\setfmt{#1}|}"}

@entry{set,
  name={set},
  symbol={\setfmt{S}},
  user1={setfmt},
  description={collection of values}
}
@entry{cardinality,
  name={cardinality},
  symbol={\cardfmt{S}},
  user1={cardfmt},
  description={the number of elements in the \gls{set} $\glssymbol{set}$}
}
\end{verbatim}
I've changed the entry labels and the names of the formatting commands.
The definitions in the document need to reflect the change in label
but not the change in the formatting commands:
\begin{verbatim}
\newcommand{\gset}[2][]{\glsxtrfmt[#1]{set}{#2}}
\newcommand{\gcard}[2][]{\glsxtrfmt[#1]{cardinality}{#2}}
\end{verbatim}

Here's another approach that allows for a more complicated argument
for the cardinality. (For example, if the argument is an expression
involving set unions or intersections.)
The \ext{bib} file is now:
\begin{verbatim}
@preamble{"\providecommand{\setfmt}[1]{\mathcal{#1}}
\providecommand{\cardfmt}[1]{|#1|}"}

@entry{set,
  name={set},
  symbol={\setfmt{S}},
  user1={setfmt},
  description={collection of values}
}
@entry{cardinality,
  name={cardinality},
  symbol={\cardfmt{\setfmt{S}}},
  user1={cardfmt},
  description={the number of elements in the \gls{set} $\glssymbol{set}$}
}
\end{verbatim}
This has removed the \csfmt{setfmt} command from the definition of
\csfmt{cardfmt}. Now the definitions in the document:
\begin{verbatim}
\newcommand{\gset}[1]{\glsxtrentryfmt{set}{#1}}
\newcommand{\gcard}[2][]{\glsxtrfmt[#1]{cardinality}{#2}}
\end{verbatim}
This allows for code such as:
\begin{verbatim}
\[ \gcard{\gset{A} \cap \gset{B}} \]
\end{verbatim}
which will link back to the \texttt{cardinality} entry in the
glossary and avoids any hyperlinking with \csfmt{gset}.
Alternatively to avoid links with \csfmt{gcard} as well:
\begin{verbatim}
\newcommand{\gset}[1]{\glsxtrentryfmt{set}{#1}}
\newcommand{\gcard}[1]{\glsxtrentryfmt{cardinality}{#1}}
\end{verbatim}
Now \csfmt{gset} and \csfmt{gcard} are simply formatting commands,
but their actual definitions are determined in the \ext{bib} file.

\section{\atentry{entry}}
\labelatentry{entry}

Regular terms are defined by the \atentry{entry} field. This requires the
\field{description} field and either \field{name} or \field{parent}.

For example:
\begin{verbatim}
@preamble{"\providecommand{\mtx}[1]{\boldsymbol{#1}}"}

@entry{matrix,
  name={matrix},
  plural={matrices},
  description={rectangular array of values, denoted \gls{M}},
  seealso={vector}
}

@entry{M,
  name={\ensuremath{M}},
  description={a \gls{matrix}}
}

@entry{vector,
  name = "vector",
  description = {column or row of values, denoted \gls{v}},
  seealso={matrix}
}

@entry{v,
  name={\ensuremath{\vec{v}}},
  description={a \gls{vector}}
}
\end{verbatim}
If the \field{name} field is omitted it will be set from the
parent's \field{name}. If the \field{sort} field is missing the
default is obtained from the \field{name} field.
(This can be overridden with \optref{sort-field}.)

Terms defined using \atentry{entry} will be written to the output
(\ext{glstex}) file using the command \csref{bibglsnewentry}.

\section{\atentry{symbol}}
\labelatentry{symbol}

The \atentry{symbol} entry type is much like \atentry{entry}, but it's
designed specifically for symbols, so in the previous example, the
\texttt{M} and \texttt{v} terms would be better defined using the
\atentry{symbol} entry type instead. For example:
\begin{verbatim}
@symbol{M,
  name={\ensuremath{M}},
  description={a \gls{matrix}}
}
\end{verbatim}

The required fields are \field{name} or \field{parent}. The
\field{description} field is required if the \field{name} field is
missing. If the \field{sort} field is omitted, the default sort is
given by the entry label. Note that this is different from
\atentry{entry} where the sort defaults to \field{name} if omitted.

Terms that are defined using \atentry{symbol} will be written to
the output file using the command \csref{bibglsnewsymbol}.

\section{\atentry{number}}
\labelatentry{number}

The \atentry{number} entry type is like \atentry{symbol}, but it's for
numbers. The numbers don't have to be explicit digits and may have a
symbolic representation. There's no real difference between the
behaviour of \atentry{number} and \atentry{symbol} except that terms
defined using \atentry{number} will be written to the output file
using the command \csref{bibglsnewnumber}.

For example, the file \filefmt{constants.bib} might define
mathematical constants like this:
\begin{verbatim}
@number{pi,
   name={\ensuremath{\pi}},
   description={the ratio of the length of the circumference
    of a circle to its diameter},
   user1={3.14159}
}

@number{e,
  name={\ensuremath{e}},
  description={base of natural logarithms},
  user1={2.71828}
}
\end{verbatim}
This stores the approximate value in the \field{user1} field. This
can be used to sort the entries in numerical order according to the
values rather than the symbols:
\begin{verbatim}
\GlsXtrLoadResources[
  src={constants},% constants.bib
  category={number},% set the category for all selected entries
  sort={double},% numerical double-precision sort
  sort-field={user1}% sort according to 'user1' field
]
\end{verbatim}
The \optref[number]{category} option makes it easy to adjust the
glossary format to include the \field{user1} field:
\begin{verbatim}
\renewcommand{\glsxtrpostdescnumber}{%
  \ifglshasfield{useri}{\glscurrententrylabel}
  { (approximate value: \glscurrentfieldvalue)}%
  {}%
}
\end{verbatim}

\section{\atentry{index}}
\labelatentry{index}

The \atentry{index} entry type is designed for entries that don't
have a description. Only the label is required. If \field{name} is
omitted, it's assumed to be the same as the label, even if
\field{parent} is present. (Note this is different to the fallback
behaviour of \atentry{entry}, which fetches the name from the parent
entry.) However, this means that if the name contains any characters
that can't be used in the label, you will need the \field{name}
field. If the \field{sort} field is missing the
default is obtained from the \field{name} field.

Example:
\begin{verbatim}
@index{duck}

@index{goose,plural={geese}}

@index{sealion,name={sea lion}}

@index{facade,name={fa\c{c}ade}}
\end{verbatim}

Terms that are defined using \atentry{index} will be written to the output
file using the command \csref{bibglsnewindex}.

\section{\atentry{abbreviation}}
\labelatentry{abbreviation}

The \atentry{abbreviation} entry type is designed for abbreviations.
The required fields are \field{short} and \field{long}. If the
\field{sort} key is missing, \bibgls\ will use the value of the
\field{short} field.
You can also use \optref{short-case-change} to convert the case of
the \field{short} field.

Note that you must set the abbreviation style before loading the
resource file to ensure that the abbreviations are defined
correctly, however \bibgls\ has no knowledge of the abbreviation
style so it doesn't know if the \field{description} field must be
included or if the default \field{sort} value isn't simply the value
of the \field{short} field.

You can instruct \bibgls\ to sort by the \field{long} field instead
using \optref[long]{sort-field}. You can also tell \bibgls\ to
ignore certain fields using \optref{ignore-fields}, so you can
include a \field{description} field in the \ext{bib} file if
you sometimes need it, and then instruct \bibgls\ to ignore it when
you don't want it.

For example:
\begin{verbatim}
@abbreviation{html,
  short ="html",
  long  = {hypertext markup language},
  description={a markup language for creating web pages}
}
\end{verbatim}
If you want the \abbrstyle{long-noshort-desc} style, then you can put
the following in your document (where the \ext{bib} file is called
\filefmt{entries-abbrv.bib}):
\begin{verbatim}
\setabbreviationstyle{long-noshort-desc}
\GlsXtrLoadResources[src={entries-abbrv.bib},sort-field={long}]
\end{verbatim}
Whereas, if you want the \abbrstyle{long-short-sc} style, then you can
instead do:
\begin{verbatim}
\setabbreviationstyle{long-short-sc}
\GlsXtrLoadResources[src={entries-abbrv.bib},ignore-fields={description}]
\end{verbatim}
or to convert the short value to upper case and use the
\abbrstyle{long-short-sm} style instead:
\begin{verbatim}
\setabbreviationstyle{long-short-sm}
\GlsXtrLoadResources[src={entries-abbrv.bib},
 short-case-change={uc},% convert short value to upper case
 ignore-fields={description}]
\end{verbatim}
(If you want an equivalent of \csfmt{newdualentry}, use
\atentryref{dualentryabbreviation} instead.)

Terms defined using \atentry{abbreviation} will be written to the output
file using the command \csref{bibglsnewabbreviation}.

\section{\atentry{acronym}}
\labelatentry{acronym}

The \atentry{acronym} entry type is like \atentry{abbreviation} except that
the term is written to the output file using the command
\csref{bibglsnewacronym}.

\section{\atentry{dualentry}}
\labelatentry{dualentry}

The \atentry{dualentry} entry type is similar to \atentry{entry} but
actually defines two entries: the primary entry and the dual entry.
The dual entry contains the same information as the primary entry
but some of the fields are swapped around. The dual entry is given
the prefix set by the \optref{dual-prefix} option.

Note that the \field{alias} field will never be copied to the dual
entry, nor can it be mapped. The alias will only apply to the
primary entry.

By default, the \field{name} and \field{description} fields and the
\field{plural} and \field{descriptionplural} fields are swapped.

For example:
\begin{verbatim}
@dualentry{child,
  name={child},
  plural={children},
  description={enfant}
}
\end{verbatim}
Is like
\begin{verbatim}
@entry{child,
  name={child},
  plural={children},
  description={enfant}
  descriptionplural={enfants}
}

@entry{dual.child,
  description={child},
  descriptionplural={children},
  name={enfant}
  plural={enfants}
}
\end{verbatim}
where \idprefix{dual} is replaced by the value of the
\csopt{dual-prefix} option. However, instead of defining the entries
with \csfmt{bibglsnewentry} both the primary and dual entries are
defined using \csref{bibglsnewdualentry}. The \field{category} 
and \field{type} fields can be set for the dual entry using the
\optref{dual-category} and \optref{dual-type} options.

If \optref[combine]{dual-sort} then the dual entries will be sorted
along with the primary entries, otherwise the \csopt{dual-sort}
indicates how to sort the dual entries and the dual entries will be
appended to the end of the \ext{glstex} file. The
\optref{dual-sort-field} determines what field to use for the sort
value if the dual entries should be sorted separately.

For example:
\begin{verbatim}
\newglossary*{english}{English}
\newglossary*{french}{French}

\GlsXtrLoadResources[
 src           = {entries-dual},% data in entries-dual.bib
 type          = {english},% put primary entries in glossary 'english'
 dual-type     = {french},% put dual entries in glossary 'french'
 category      = {dictionary},% set the primary category to 'dictionary'
 dual-category = {dictionary},% set the dual category to 'dictionary'
 sort          = {en},% sort primary entries according to language 'en'
 dual-sort     = {fr}% sort dual entries according to language 'fr'
]
\end{verbatim}

Note that there's no dual equivalent to \atentry{index}
since that entry type doesn't have required fields and
there's nothing obvious to swap with that type that would
differentiate it from a normal entry.

\section{\atentry{dualentryabbreviation}}
\labelatentry{dualentryabbreviation}

The \atentry{dualentryabbreviation} entry type is similar to 
\atentry{dualentry}, but by default the
field mappings are:
\begin{itemize}
\item \field{long} $\mapsto$ \field{name}
\item \field{short} $\mapsto$ \field{text}
\end{itemize}
You may need to add a mapping from \field{shortplural} to
\field{plural} if the default is inappropriate.

The required fields are: \field{short}, \field{long} and
\field{description}. This entry type is designed to emulate the
example \cs{newdualentry} command given in the \sty{glossaries}
user manual. The primary entry is an abbreviation with the given
\field{short} and \field{long} fields (but not the 
\field{description}) and the secondary entry is a regular entry with
the \field{name} copied from the \field{long} field.

For example:
\begin{verbatim}
@dualentryabbreviation{svm,
   long = {support vector machine},
   short = {SVM},
   description = {statistical pattern recognition technique}
}
\end{verbatim}
is rather like doing
\begin{verbatim}
@abbreviation{svm,
   long = {support vector machine},
   short = {SVM}
}

@entry{dual.svm,
   name = {support vector machine},
   description = {statistical pattern recognition technique}
}
\end{verbatim}
but \texttt{dual.svm} will automatically be selected if \texttt{svm}
is indexed in the document. If \texttt{dual.svm} isn't explicitly
indexed, it won't have a location list.

As with \atentry{dualentry}, the \field{alias} field will never
be copied to the dual entry, nor can it be mapped. The alias will
only apply to the primary entry.

If the \field{sort} field is missing \bibgls\ by default falls back
on the \field{name} field. If this is missing, this sort value will
fallback on the \field{short} field. This means that if \field{name}
isn't explicitly given in \atentry{dualentryabbreviation}, then the 
primary entry will be sorted according to \field{short} but the dual
will be sorted according its \field{name} (which has been copied
from the primary \field{long}).

Entries provided using \atentry{dualentryabbreviation} will be defined
with
\begin{alltt}
\csref{bibglsnewdualentryabbreviation}
\end{alltt}
(which uses \cs{newabbreviation}) for the primary entries and with 
\begin{alltt}
\csref{bibglsnewdualentryabbreviationsecondary}
\end{alltt}
(which uses \cs{longnewglossaryentry}) for the secondary entries.
This means that if the \styopt{abbreviations}
package option is used, this will put the primary entry in the
\optfmt{abbreviations} glossary and the secondary entry in the
\optfmt{main} glossary.  Use the \optref{type} and
\optref{dual-type} options to override this.

\section{\atentry{dualsymbol}}
\labelatentry{dualsymbol}

This is like \atentryref{dualentry} but the default mappings
swap the \field{name} and \field{symbol} fields (and the
\field{plural} and \field{symbolplural} fields). The \field{name}
and \field{symbol} are required.

As with \atentry{dualentry}, the \field{alias} field will never
be copied to the dual entry, nor can it be mapped. The alias will
only apply to the primary entry.

For example:
\begin{verbatim}
@dualsymbol{pi,
   name={pi},
   symbol={\ensuremath{\pi}},
   description={the ratio of the length of the circumference
    of a circle to its diameter}
}
\end{verbatim}

Entries are defined using \csref{bibglsnewdualsymbol}, which by 
default sets the \field{category} to \optfmt{symbol}.

\section{\atentry{dualnumber}}
\labelatentry{dualnumber}

This is much the same as \atentryref{dualsymbol} but entries are
defined using \csref{bibglsnewdualnumber}, which by default sets
the \field{category} to \optfmt{number}.

The above example could be defined as a number since $\pi$ is a
constant:
\begin{verbatim}
@dualnumber{pi,
   name={pi},
   symbol={\ensuremath{\pi}},
   description={the ratio of the length of the circumference
    of a circle to its diameter},
   user1={3.14159}
}
\end{verbatim}

This has stored the approximate value in the \field{user1} field.
The post-description hook could then be adapted to show this.
\begin{verbatim}
\renewcommand{\glsxtrpostdescnumber}{%
  \ifglshasfield{useri}{\glscurrententrylabel}
  { (approximate value: \glscurrentfieldvalue)}%
  {}%
}
\end{verbatim}

This use of the \field{user1} field means that the dual entries
could be sorted numerically according to the approximate value:
\begin{verbatim}
\usepackage[record,postdot,numbers,style=index]{glossaries-extra}

\GlsXtrLoadResources[
  src={entries},% entries.bib
  dual-type={numbers},
  dual-sort={double},% decimal sort
  dual-sort-field={user1}
]
\end{verbatim}

\section{\atentry{dualabbreviation}}
\labelatentry{dualabbreviation}

The required fields are: \field{short}, \field{long}, 
\field{dualshort} and \field{duallong}.
This includes some new fields: \field{dualshort},
\field{dualshortplural}, \field{duallong} and
\field{duallongplural}. If these aren't already defined, they
will be provided in the \ext{glstex} file with
\begin{alltt}
\cs{glsxtrprovidestoragekey}\margm{key}\marg{}\marg{}
\end{alltt}
This command is defined by the \sty{glossaries-extra} package.
Note that this use with an empty third argument prevents
the creation of a field access command (analogous to
\cs{glsentrytext}). You can fetch the value with
\cs{glsxtrusefield}.  (See the \sty{glossaries-extra} manual for
further details.) Remember that the field won't be
available until the \ext{glstex} file has been created.

As with \atentry{dualentry}, the \field{alias} field will never
be copied to the dual entry, nor can it be mapped. The alias will
only apply to the primary entry.

Note that \bibgls\ doesn't know what abbreviation styles
are in used, so if the \field{sort} field is missing
it will fallback on the \field{short} field. If the abbreviations
need to be sorted according to the \field{long} field instead,
use \optref[long]{sort-field}.

The \atentry{dualabbreviation} entry type is similar to 
\atentry{dualentry}, but by default the
field mappings are:
\begin{itemize}
\item \field{short} $\mapsto$ \field{dualshort}
\item \field{shortplural} $\mapsto$ \field{dualshortplural}
\item \field{long} $\mapsto$ \field{duallong}
\item \field{longplural} $\mapsto$ \field{duallongplural}
\item \field{dualshort} $\mapsto$ \field{short}
\item \field{dualshortplural} $\mapsto$ \field{shortplural}
\item \field{duallong} $\mapsto$ \field{long}
\item \field{duallongplural} $\mapsto$ \field{longplural}
\end{itemize}
Terms that are defined using \atentry{dualabbreviation} will be
written to the output file using \csref{bibglsnewdualabbreviation}.

If the \optref{dual-abbrv-backlink} option is on, the default field
used for the backlinks is the \field{dualshort} field, so you'll need
to make sure you adapt the glossary style to show that field. The
simplest way to do this is through the category post description
hook.

For example, if the entries all have the \field{category} set
to \optfmt{abbreviation}, then this requires redefining
\cs{glsxtrpostdescabbreviation}.

Here's an example dual abbreviation for a document where English is
the primary language and German is the secondary language:
\begin{alltt}
@dualabbreviation\marg{rna,
  short=\marg{RNA},
  dualshort=\marg{RNS},
  long=\marg{ribonucleic acid},
  duallong=\marg{Ribonukleins\"aure}
}
\end{alltt}
If the abbreviation is in the file called
\filefmt{entries-dual-abbrv.bib}, then here's an example document:
\begin{verbatim}
\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[ngerman,main=english]{babel}
\usepackage[colorlinks]{hyperref}
\usepackage[record,nomain]{glossaries-extra}

\newglossary*{english}{English}
\newglossary*{german}{German}

\setabbreviationstyle{long-short}

\renewcommand*{\glsxtrpostdescabbreviation}{%
  \ifglshasfield{dualshort}{\glscurrententrylabel}
  {%
    \space(\glscurrentfieldvalue)%
  }%
  {}%
}

\GlsXtrLoadResources[
 src={entries-dual-abbrv},% entries-dual-abbrv.bib
 type=english,% put primary entries in glossary 'english'
 dual-type=german,% put primary entries in glossary 'german'
 label-prefix={en.},% primary label prefix
 dual-prefix={de.},% dual label prefix
 sort=en,% sort primary entries according to language 'en'
 dual-sort=de-1996,% sort dual entries according to 'de-1996'
                   % (German new orthography)
 dual-abbrv-backlink% add links in the glossary to the opposite
                    %entry
]

\begin{document}

English: \gls{en.rna}; \gls{en.rna}.

German: \gls{de.rna}; \gls{de.rna}.

\printunsrtglossaries
\end{document}
\end{verbatim}
If the \optref{label-prefix} is omitted, then only the dual entries
will have a prefix:
\begin{verbatim}
English: \gls{rna}; \gls{rna}.

German: \gls{de.rna}; \gls{de.rna}.
\end{verbatim}
Another variation is to use the \abbrstyle{long-short-user}
abbreviation style and modify the associated \cs{glsxtruserfield} so that
the \field{duallong} field is selected for the parenthetical
material:
\begin{verbatim}
\renewcommand*{\glsxtruserfield}{duallong}
\end{verbatim}
This means that the first use of the primary entry is displayed as
\begin{quote}
ribonucleic acid (RNA, Ribonukleins\"aure)
\end{quote}
and the first use of the dual entry is displayed as:
\begin{quote}
Ribonukleins\"aure (RNS, ribonucleic acid)
\end{quote}

Here's an example to be used with the \abbrstyle{long-short-desc}
style:
\begin{alltt}
@dualabbreviation\marg{rna,
  short=\marg{RNA},
  dualshort=\marg{RNS},
  long=\marg{ribonucleic acid},
  duallong=\marg{Ribonukleins\"aure}
  description=\marg{a polymeric molecule},
  user1=\marg{Ein polymeres Molek\"ul}
}
\end{alltt}
This stores the dual description in the \field{user1} field,
so this needs a mapping.
The new example document is much the same as the previous one, except
that the \optref{dual-abbrv-map} option is needed to include the 
mapping between the \field{description} and \field{user1} fields:
\begin{verbatim}
\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage[ngerman,main=english]{babel}
\usepackage[colorlinks]{hyperref}
\usepackage[record,nomain]{glossaries-extra}

\newglossary*{english}{English}
\newglossary*{german}{German}

\setabbreviationstyle{long-short-desc}

\renewcommand*{\glsxtrpostdescabbreviation}{%
  \ifglshasfield{dualshort}{\glscurrententrylabel}
  {%
    \space(\glscurrentfieldvalue)%
  }%
  {}%
}

\GlsXtrLoadResources[
 src={entries-dual-abbrv-desc},% entries-dual-abbrv-desc.bib
 type=english,% put primary entries in glossary 'english'
 dual-type=german,% put primary entries in glossary 'german'
 label-prefix={en.},% primary label prefix
 dual-prefix={de.},% dual label prefix
 sort=en,% sort primary entries according to language 'en'
 sort-field={long},% sort by the 'long' field
 dual-sort=de-1996,% sort dual entries according to 'de-1996'
                   % (German new orthography)
 dual-abbrv-backlink,% add links in the glossary to the opposite
                     % entry
% dual key mappings:
 dual-abbrv-map={%
   {short,shortplural,long,longplural,dualshort,dualshortplural,
     duallong,duallongplural,description,user1},
   {dualshort,dualshortplural,duallong,duallongplural,short,shortplural,
     long,longplural,user1,description}
 }
]

\begin{document}

English: \gls{en.rna}; \gls{en.rna}.

German: \gls{de.rna}; \gls{de.rna}.

\printunsrtglossaries
\end{document}
\end{verbatim}
Note that since this document uses the \abbrstyle{long-short-desc}
abbreviation style, the \optref{sort-field} needs to be changed
to \optfmt{long}, since the fallback if the \field{sort} field is
missing is the \field{short} field.

If I change the order of the mapping to:
\begin{verbatim}
 dual-abbrv-map={%
   {long,longplural,short,shortplural,dualshort,dualshortplural,
     duallong,duallongplural,description,user1},
   {duallong,duallongplural,dualshort,dualshortplural,short,shortplural,
     long,longplural,user1,description}
\end{verbatim}
Then the back-link field will switch to \field{duallong}. The
post-description hook can be modified to allow for this:
\begin{verbatim}
\renewcommand*{\glsxtrpostdescabbreviation}{%
  \ifglshasfield{duallong}{\glscurrententrylabel}
  {%
    \space(\glscurrentfieldvalue)%
  }%
  {}%
}
\end{verbatim}

An alternative is to use the \abbrstyle{long-short-user-desc} style
without the post-description hook:
\begin{verbatim}
\setabbreviationstyle{long-short-user-desc}

\renewcommand*{\glsxtruserfield}{duallong}
\end{verbatim}
However be careful with this approach as it can cause nested
hyperlinks. In this case it's better to use the
\abbrstyle{long-postshort-user-desc} style which defers the
parenthetical material until after the link-text:
\begin{verbatim}
\setabbreviationstyle{long-postshort-user-desc}

\renewcommand*{\glsxtruserfield}{duallong}
\end{verbatim}
If the back-link field has been switched to \field{duallong} then
the post-description hook is no longer required.

\section{\atentry{dualacronym}}
\labelatentry{dualacronym}

As \atentry{dualabbreviation} but defines the entries with
\csref{bibglsnewdualacronym}.

\chapter{Resource File Options}
\label{sec:resourceopts}
\setcounter{secnumdepth}{1}

Make sure that you load \sty{glossaries-extra} with the
\styopt{record} package option. This ensures that \bibgls\ can pick
up the required information from the \ext{aux} file. (You may omit
this option if you use \optref[all]{selection} and you don't require
the location lists.)

The \ext{glstex} resource files created by \bibgls\ are loaded in
the document using
\begin{definition}\plabelcs{glsxtrresourcefile}
\cs{glsxtrresourcefile}\oargm{options}\margm{filename}
\end{definition}
where \meta{filename} is the name of the resource file without the
\ext{glstex} extension.
You can have multiple \cs{glsxtrresourcefile} commands within your
document, but each \meta{filename} must be unique, otherwise \LaTeX\
would attempt to input the same \ext{glstex} file multiple times.
\bibgls\ checks for non-unique file names.

There's a shortcut command that uses
\cs{jobname} in the \meta{filename}:
\begin{definition}
\cs{GlsXtrLoadResources}\oargm{options}
\end{definition}
The first instance of this command is equivalent to
\begin{alltt}
\cs{glsxtrresourcefile}\oargm{options}\marg{\cs{jobname}}
\end{alltt}
Any additional use of \cs{GlsXtrLoadResources} is equivalent to
\begin{alltt}
\cs{glsxtrresourcefile}\oargm{options}\marg{\cs{jobname}-\meta{n}}
\end{alltt}
where \meta{n} is number. For example:
\begin{verbatim}
\GlsXtrLoadResources[src=entries-en,sort={en}]
\GlsXtrLoadResources[src=entries-fr,sort={fr}]
\GlsXtrLoadResources[src=entries-de,sort={de-1996}]
\end{verbatim}
This is equivalent to:
\begin{verbatim}
\glsxtrresourcefile[src=entries-en,sort={en}]{\jobname}
\glsxtrresourcefile[src=entries-fr,sort={fr}]{\jobname-1}
\glsxtrresourcefile[src=entries-de,sort={de-1996}]{\jobname-2}
\end{verbatim}
In general, it's simplest just to use \cs{GlsXtrLoadResources}.

The optional argument \meta{options} is a comma-separated \keyvallist. 
Allowed options are listed below.
The option list applies only to that specific
\meta{filename}\ext{glstex} and are not carried over to the next
instance of \cs{glsxtrresourcefile}. The \sty{glossaries-extra}
package doesn't parse the options, but just writes the information to the
\ext{aux} file. This means that any invalid options will be reported
by \bibgls\ not by \sty{glossaries-extra}.

If you have multiple \ext{bib} files you can either select them all
using \optref[\meta{bib list}]{src} in a single
\cs{glsxtrresourcefile} call, if they all require the same settings,
or you can load them separately with different settings applied.

For example, if the files \filefmt{entries-terms.bib} and
\filefmt{entries-symbols.bib} have the same settings:
\begin{verbatim}
\GlsXtrLoadResources[src={entries-terms,entries-symbols}]
\end{verbatim}
Alternatively, if they have different settings:
\begin{verbatim}
\GlsXtrLoadResources[src={entries-terms},type=main]
\GlsXtrLoadResources[src={entries-symbols},sort=use,type=symbols]
\end{verbatim}

Note that the sorting is applied to each resource call independently
of other resources. This means that if you have multiple instances
of \cs{glsxtrresourcefile} but only one glossary type, the glossary
will effectively contain blocks of sorted entries. For example, if
\filefmt{file1.bib} contains:
\begin{verbatim}
@index{duck}
@index{zebra}
@index{aardvark}
\end{verbatim}
and \filefmt{file2.bib} contains:
\begin{verbatim}
@index{caterpillar}
@index{bee}
@index{wombat}
\end{verbatim}
then
\begin{verbatim}
\GlsXtrLoadResources[src={file1,file2}]
\end{verbatim}
will result in the list: aardvark, bee, caterpillar, duck, wombat,
zebra. These six entries are all defined when
\csfmt{jobname}\filefmt{.glstex} is read.
Whereas
\begin{verbatim}
\GlsXtrLoadResources[src={file1}]
\GlsXtrLoadResources[src={file2}]
\end{verbatim}
will result in the list: aardvark, duck, zebra, bee, caterpillar,
wombat. The first three (aardvark, duck, zebra) are defined when 
\csfmt{jobname}\filefmt{.glstex} is read. The second three (bee,
caterpillar, wombat) are defined when \csfmt{jobname}\filefmt{-1.glstex}
is read. Since \cs{printunsrtglossary} simply iterates over all
defined entries, this is the ordering used.

\plabelcs{strong}%
Note \bibgls\ allows \ext{bib} files that don't provide any entries.
This can be used to provide commands in \atentryref{preamble}.
For example, suppose I have \filefmt{defs.bib} that just contains
\begin{verbatim}
@preamble{"\providecommand{\strong}[1]{\textbf{\color{red}#1}}
\providecommand{\test}[2]{#2 (#1)}"}
\end{verbatim}
This provides two commands: \csfmt{strong} (which sets the font
weight and colour) and \csfmt{test} (which just displays its second
argument followed by the first in parentheses).

Suppose I also have \filefmt{entries.bib} that contains:
\begin{verbatim}
@index{example,
  name={\strong{\test{stuff}{example}}}
}
@index{sample}
@index{test}
@index{foo}
@index{bar}
\end{verbatim}
This contains an entry that requires the commands provided in
\filefmt{defs.bib}, so to ensure those commands are defined, I can
do:
\begin{verbatim}
\GlsXtrLoadResources[src={defs,entries}]
\end{verbatim}
Unfortunately this results in the sort value for \texttt{example} being
set to \texttt{redexample (stuff)} because the interpreter has
detected the provided commands and expanded 
\begin{verbatim}
\strong{\test{stuff}{example}}
\end{verbatim}
to
\begin{verbatim}
\textbf{\color{red}example (stuff)}
\end{verbatim}
It discards font changes, so \csfmt{textbf} is ignored, but it doesn't 
recognise \cs{color} and so doesn't know that the first argument is
just the colour specifier and therefore doesn't discard it.
This means that \qt{\textbf{\color{red}example (stuff)}} is placed
between \qt{foo} and \qt{sample} instead of between \qt{bar} and
\qt{foo}.

I can prevent the interpreter from parsing \atentryref{preamble}:
\begin{verbatim}
\GlsXtrLoadResources[src={defs,entries},interpret-preamble=false]
\end{verbatim}
Now when the sort value for \texttt{example} is obtained from
\begin{verbatim}
\strong{\test{stuff}{example}}
\end{verbatim}
no expansion occurs (since \csfmt{strong} and \csfmt{test} are
unrecognised) so the sort value ends up as
\texttt{stuffexample}
which places \qt{\textbf{\color{red}example (stuff)}} between 
\qt{sample} and \qt{test}, which is again incorrect.

The best thing to do in this situation is to split the provided
commands into two \ext{bib} files: one that shouldn't be interpreted
and one that should.

For example, \filefmt{defs-nointerpret.bib}:
\begin{verbatim}
@preamble{"\providecommand{\strong}[1]{\textbf{\color{red}#1}}"}
\end{verbatim}
and \filefmt{defs-interpret.bib}:
\begin{verbatim}
@preamble{"\providecommand{\test}[2]{#2 (#1)}"}
\end{verbatim}
Now the first one can be loaded with \optref[false]{interpret-preamble}:
\begin{verbatim}
\GlsXtrLoadResources[src={defs-nointerpret},interpret-preamble=false]
\end{verbatim}
This creates a \ext{glstex} file that provides \csfmt{strong} but
doesn't define any entries. The other file \filefmt{defs-interpret.bib} can
then be loaded with the default \optref[true]{interpret-preamble}:
\begin{verbatim}
\GlsXtrLoadResources[src={defs-interpret,entries}]
\end{verbatim}
The provided commands are remembered by the interpreter, so you can
also do:
\begin{verbatim}
\GlsXtrLoadResources[src={defs-interpret}]
\GlsXtrLoadResources[src={entries}]
\end{verbatim}
The \emph{contents} of \atentryref{preamble} are only written to the
associated \ext{glstex} file, but the definitions contained within
the \atentry{preamble} are retained by the interpreter for subsequent
resource sets.

\section{General Options}
\label{sec:generalopts}

\subsection{\csoptnv{charset}\csopteqval{encoding-name}}
\labelopt{charset}

If the character encoding hasn't been supplied in the \ext{bib} file
with the encoding comment
\begin{alltt}
\% Encoding: \meta{encoding-name}
\end{alltt}
then you can supply the correct encoding using
\csopt[encoding-name]{charset}. In general, it's better to include
the encoding in the \ext{bib} file where it can also be read by
a \ext{bib} managing systems, such as JabRef.

See \argref{tex-encoding} for the encoding used to write the \ext{glstex}
file.

\subsection{\csoptnv{interpret-preamble}\csopteqval{boolean}}
\labelopt{interpret-preamble}

This is a boolean option that determines whether or not the
interpreter should parse the contents of \atentryref{preamble}.
The default is \optfmt{true}. If \optfmt{false}, the preamble
contents will still be written to the \ext{glstex} file, but any
commands provided in the preamble won't be recognised if the
interpreter is needed to determine an entry's sort value.

\subsection{\csoptnv{set-widest}\csopteqval{boolean}}
\labelopt{set-widest}

The \glostyle{alttree} glossary style needs to know the widest
\field{name} (for each level, if hierarchical). This can
be set using \cs{glssetwidest} provided by the \sty{glossaries}
package, but this requires knowing which name is the widest.

The boolean option \csopt[true]{set-widest} will try to calculate
the widest names for each hierarchical level. Since it doesn't know
the fonts that will be used in the document or if there are any
non-standard commands that aren't provided in the \ext{bib} files
preamble, this option may not work. The transcript file will 
include the message
\begin{alltt}
Calculated width of '\meta{text}': \meta{number}
\end{alltt}
where \meta{text} is \bibgls's interpretation of the contents
of the \field{name} field and \meta{number} is a rough guide
to the width of \meta{text} assuming the operating system's
default serif font. The entry that has the largest \meta{number}
is the one that will be selected. This will then be implemented
using:
\begin{alltt}
\cs{glssetwidest}\oargm{level}\marg{\cs{glsentryname}\margm{id}}
\end{alltt}
where \meta{id} is the entry's label. This leaves \TeX\ to
compute the width according to the document fonts.

If \optref{type} has been set, the \cs{glssetwidest} command
will be appended to the glossary preamble for that type, otherwise
it's simply set in the \ext{glstex} file and may be overridden
later in the document if required.

\subsection{\csoptnv{secondary}\csopteqval{list}}
\labelopt{secondary}

It may be that you want to display a glossary multiple times
but with a different order. For example, the first time
alphabetically and the second time by category.

You can do this with the \csopt{secondary} option. The value
(which must be supplied) is a comma-separated list where each
item in the list is in the format 
\begin{definition}
\meta{sort}:\meta{field}:\meta{type}
\end{definition}
or
\begin{definition}
\meta{sort}:\meta{type}
\end{definition}
If the
\meta{field} is omitted, the value of \optref{sort-field} is used.
The value of \meta{sort} is as for \optref{sort}, but note that in this case the sort value \optfmt{unsrt} or
\optfmt{none} means to use the same ordering as the primary
entries. So with \optref[de-CH-1996]{sort},
\optref[none:copies]{secondary} the \texttt{copies}
list will be ordered according to \texttt{de-CH-1996} and not
according to the order in which they were read when the \ext{bib}
file or files were parsed.
If \meta{sort} is \optfmt{custom}, then the rule should be
provided with \optref{secondary-sort-rule}.

This will copy all the selected entries into the glossary labelled
\meta{type} sorted according to \meta{sort} using \meta{field} as
the sort value.

(If the glossary \meta{type} doesn't exist, it will be
defined with \cs{provideignoredglossary*}\margm{type}.)
Note that if the glossary already exists and contains entries,
the existing entries aren't re-ordered. The new entries are
simply appended to the list.

For example, suppose the \ext{bib} file contains entries like:
\begin{verbatim}
@entry{quartz,
  name={quartz},
  description={hard mineral consisting of silica},
  category={mineral}
}

@entry{cabbage,
  name={cabbage},
  description={vegetable with thick green or purple leaves},
  category={vegetable}
}

@entry{waterfowl,
  name={waterfowl},
  description={any bird that lives in or about water},
  category={animal}
}
\end{verbatim}
and the document preamble contains:
\begin{verbatim}
\GlsXtrLoadResources[src={entries},sort={en-GB},
  secondary={en-GB:category:topic}
]
\end{verbatim}
This sorts the primary entries according to the default
\optref{sort-field} and then sorts the entries according
to the \field{category} field and copies this list to
the \texttt{topic} glossary (which will be provided if not defined.)

The secondary list can be displayed with the hypertargets switched
off to prevent duplicates. The cross-references will link to the
original glossary.

For example:
\begin{verbatim}
\printunsrtglossary[title={Summary (alphabetical)}]
\printunsrtglossary[title={Summary (by topic)},target=false]
\end{verbatim}

The alternative (or if more than two lists are required) is to
reload the same \ext{bib} file with different label prefixes.
For example, if the entries are stored in \filefmt{entries.bib}:
\begin{verbatim}
\newglossary*{nosort}{Symbols (Unsorted)}
\newglossary*{byname}{Symbols (Letter Order)}
\newglossary*{bydesc}{Symbols (Ordered by Description)}
\newglossary*{byid}{Symbols (Ordered by Label)}

\GlsXtrLoadResources[
  src={entries},% entries.bib
  sort={unsrt},
  type={nosort}
]

\GlsXtrLoadResources[
  src={entries},% entries.bib
  sort={letter-case},
  type={byname},
  label-prefix={byname.}
]

\GlsXtrLoadResources[
  src={entries},% entries.bib
  sort={locale},
  sort-field={description},
  type={bydesc},
  label-prefix={bydesc.}
]

\GlsXtrLoadResources[
  src={entries},% entries.bib
  sort={letter},
  sort-field={id},
  type={byid},
  label-prefix={byid.}
]
\end{verbatim}

\subsection{\csoptnv{secondary-sort-rule}\csopteqval{value}}
\labelopt{secondary-sort-rule}

As \optref{sort-rule} but for secondary custom sorting.

\section{Selection Options}
\label{sec:selectionopts}

\subsection{\csoptnv{src}\csopteqval{list}}
\labelopt{src}

This identifies the \ext{bib} files containing the entry
definitions.  The value should be a comma-separated list of the
required \ext{bib} files. These may either be in the current working
directory or in the directory given by the \argref{dir} switch or on
\TeX's path (in which case \app{kpsewhich} will be used to find
them).  The \ext{bib} extension may be omitted.  Remember that if
\meta{list} contains multiple files it must be grouped to protect
the comma from the \meta{options} list.

For example
\begin{verbatim}
\GlsXtrLoadResources[src={entries-terms,entries-symbols}]
\end{verbatim}
indicates that \bibgls\ must read the files
\filefmt{entries-terms.bib} and \filefmt{entries-symbols.bib} and
create the file given by \cs{jobname}\ext{glstex} on the first
instance or \cs{jobname}\texttt{-}\meta{n}\ext{glstex} on subsequent
use.

With \csref{glsxtrresourcefile}\oargm{options}\margm{filename}, if 
the \csopt{src} option is omitted, 
the \ext{bib} file is assumed to be \meta{filename}\ext{bib}. For example:
\begin{verbatim}
\glsxtrresourcefile{entries-symbols}
\end{verbatim}
indicates that \bibgls\ needs to read the file
\filefmt{entries-symbols.bib}, which contains the entry data, and create the file
\filefmt{entries-symbols.glstex}. If the \ext{bib} file is
different or if you have multiple \ext{bib} files, you need to use
the \csopt{src} option.

\cs{GlsXtrLoadResources} uses \cs{jobname} as the argument of 
\cs{glsxtrresourcefile} on the first instance, so  
\begin{verbatim}
\GlsXtrLoadResources[]
\end{verbatim}
will assume \optfmt{src=\cs{jobname}}. Remember that subsequent uses
of \cs{GlsXtrLoadResources} append a suffix, so in general it's
best to always supply \csopt{src}.

\subsection{\csoptnv{selection}\csopteqval{value}}
\labelopt{selection}

By default all entries that have records in the \ext{aux} file will
be selected as well as all their dependent entries. The dependent
entries that don't have corresponding records on the first \LaTeX\
run, may need an additional build to ensure their location lists
are updated.

Remember that on the first \LaTeX\ run the \ext{glstex} files don't
exist. This means that the entries can't be defined. The
\styopt{record} package option additionally switches on the
\styopt[warn]{undefaction} option, which means that you'll only get
warnings rather than errors when you reference entries in the
document. This means that you can't use \cs{glsaddall} with
\bibgls\ because the glossary lists are empty on the first run, so
there's nothing for \cs{glsaddall} to iterate over.
Instead, if you want to add all defined entries, you need to
instruct \bibgls\ to do this with the \csopt{selection} option. The
following values are allowed:
\begin{itemize}
\item \optfmt{recorded and deps}: add all recorded entries and
their dependencies (default).
\item \optfmt{recorded and deps and see}: as above but will also
add unrecorded entries whose \field{see} or \field{seealso} field refers to a recorded entry.
\item \optfmt{recorded no deps}: add all recorded entries but not
their dependencies. The dependencies include those referenced in the
\field{see} or \field{seealso} field, \field{parent} entries and those found referenced
with commands like \cs{gls} in the field values that are parsed by
\bibgls. With this setting, parents will be omitted unless they've
been referenced in the document through commands like \cs{gls}.
\item \optfmt{recorded and ancestors}: this is like the previous
setting but parents are added even if they haven't been referenced
in the document. The other dependent entries are omitted if they
haven't been referenced in the document.
\item \optfmt{all}: add all entries found in the \ext{bib} files
supplied in the \csopt{src} option.
\end{itemize}
The \meta{value} must be supplied.

For example, suppose the file \filefmt{entries.bib} contains:
\begin{verbatim}
@index{run}

@index{sprint,see={run}}

@index{dash,see={sprint}}
\end{verbatim}
If the document only references the \qt{run} entry (for example,
using \verb|\gls{run}|) then:
\begin{itemize}
\item If \csopt[recorded and deps]{selection}, only the \qt{run}
entry is selected. The \qt{run} entry has a record, so it's
selected, but it has no dependencies. Neither \qt{sprint} nor 
\qt{dash} have records, so they're not selected.
\item If \csopt[recorded and deps and see]{selection}, the \qt{run}
and \qt{sprint} entries are selected, but not the \qt{dash} entry.
The \qt{run} entry is selected because it has a record. The
\qt{sprint} entry doesn't have a record but its \field{see} field
includes \qt{run}, which does have a record, so \qt{sprint} is also
selected. The \qt{dash} entry doesn't have a record. Its
\field{see} field references \qt{sprint}. Although \qt{sprint} has
been selected, it doesn't have any records, so \qt{dash} isn't
selected.
\end{itemize}
The above is just an example. The circuitous redirection of
\qt{dash} to \qt{sprint} to \qt{run} is unhelpful to the reader and
is best avoided. A better method would be:
\begin{verbatim}
@index{run}

@index{sprint,see={run}}

@index{dash,see={run}}
\end{verbatim}
The \csopt[recorded and deps and see]{selection} in this case will
select all three entries, and the document won't send the reader on a
long-winded detour.
\subsection{\csoptnv{match}\csopteqval{\keyvallist}}
\labelopt{match}

It's possible to filter the selection by matching field values.
If \meta{\keyvallist} is empty no filtering will be applied, otherwise
\meta{\keyvallist} should be a \meta{key}=\meta{regexp} list, where
\meta{key} is the name of a field or \optfmt{id} for the entry's
label or \optfmt{entrytype} for the entry's \ext{bib} type (as in
the part after \verb|@| in the \ext{bib} file not the \field{type}
field identifying the glossary label).

The \meta{regex} part should be a regular expression conforming
to
\href{http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html}{Java's
Pattern class}. The pattern is anchored (\texttt{oo.*} matches
\texttt{oops} but not \texttt{loops}) and \meta{regexp} can't be
empty. Remember that \TeX\ will expand the option list as
it writes the information to the \ext{aux} file so take
care with special characters. For example, to match a literal
period use \verb|\string\.| not \verb|\.| (backslash dot).

If the field is missing its value it is assumed to be empty for
the purposes of the pattern match even if it will be assigned a
non-empty default value when the entry is defined.

If a field is listed multiple times, the pattern for that
field is concatenated using
\begin{alltt}
(?:\meta{pattern-1})|(?:\meta{pattern-2})
\end{alltt}
where \meta{pattern-1} is the current pattern for that field
and \meta{pattern-2} is the new pattern. This means it performs a
logical OR\@. For the non-duplicate
fields the logical operator is given by \optref{match-op}.
For example:
\begin{verbatim}
match-op={and},
match={
  {category=animals},
  {topic=biology},
  {category=vegetables}
}
\end{verbatim}
This will keep all the selected entries that satisfy:
\begin{itemize}
\item \field{category} matches \verb"(?:animals)|(?:vegetables)"

(the \field{category} is either \optfmt{animals} or
\optfmt{vegetables})

\item[AND]

\item \field{topic} is \texttt{biology}.
\end{itemize}
and will discard any entries that don't satisfy this condition.
A message will be written to the log file for each entry
that's discarded.

Patterns for unknown fields will be ignored. If the entire
list consists of patterns for unknown fields it will be
treated as \csopt[\empty]{match}. That is, no filtering will be
applied.

\subsection{\csoptnv{match-op}\csopteqval{value}}
\labelopt{match-op}

If the value of \optref{match} contains more than one 
\meta{key}=\meta{pattern} element, the \csopt{match-op}
determines whether to apply a logical AND or a logical OR.
The \meta{value} may be either \optfmt{and} or \optfmt{or}.
The default is \csopt[and]{match-op}.

\subsection{\csoptnv{flatten}\csopteqval{boolean}}
\labelopt{flatten}

This is a boolean option. The default value is
\csopt[false]{flatten}. 
If \csopt[true]{flatten}, the sorting will ignore hierarchy and
the \field{parent} field will be omitted when writing
the definitions to the \ext{glstex} file, but the parent entries
will still be considered a dependent ancestor from the 
\optref{selection} point of view.

Note the difference between this option and using
\csopt[parent]{ignore-fields} which will remove the dependency
(unless a dependency is established through another field).

\subsection{\csoptnv{flatten-lonely}\csopteqval{value}}
\labelopt{flatten-lonely}

This may take one of three values: \optfmt{false} (default),
\optfmt{presort} and \optfmt{postsort}. The value must be supplied. 

Unlike the \optref{flatten} option, which completely
removes the hierarchy, the \csopt{flatten-lonely} option can be used
to selectively alter the hierarchy.  In this case only those entries
that have a parent but have no siblings are checked. This option
is affected by the \optref{flatten-lonely-rule} setting. The conditions for
moving a child up one hierarchical level are as follows:
\begin{itemize}
\item The child must have a parent, and
\item the child can't have any selected siblings, and
\item if \csopt[only unrecorded parents]{flatten-lonely-rule}
      then the parent can't have a location list, where the location list
      includes records and \field{see} or \field{seealso}
      cross-references (for the other rules the parent may have a location
      list as long as it only has the one child selected).
\end{itemize}
If the child is selected for hierarchical adjustment, the parent
will be removed if:
\begin{itemize}
\item The parent has no location list, and
\item \csopt{flatten-lonely-rule} isn't set to \optfmt{no discard}.
\end{itemize}

The value of \csopt{flatten-lonely} determines whether the
adjustment should be made before sorting (\optfmt{presort})
or after sorting (\optfmt{postsort}). To disable this function
use \csopt[false]{flatten-lonely}.

For example, suppose the file \filefmt{entries.bib} contains:
\begin{verbatim}
@index{birds}
@index{duck,parent={birds}}
@index{goose,plural={geese},parent={birds}}
@index{swan,parent={birds}}
@index{chicken,parent={birds}}

@index{vegetable}
@index{cabbage,parent={vegetable}}

@index{minerals}
@index{quartz,parent={minerals}}
@index{corundum,parent={minerals}}
@index{amber,parent={minerals}}
@index{gypsum,parent={minerals}}

@index{aardvark}
@index{bard}
@index{buzz}

@index{item}
@index{subitem,parent={item}}
@index{subsubitem,parent={subitem}}
\end{verbatim}
and suppose the document contains:
\begin{verbatim}
\documentclass{article}

\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries.bib}]

\begin{document}
\gls{duck}.
\gls{quartz}, \gls{corundum}, \gls{amber}.
\gls{aardvark}, \gls{bard}, \gls{buzz}.
\gls{vegetable}, \gls{cabbage}.
\gls{subsubitem}.

\printunsrtglossaries
\end{document}
\end{verbatim}
Although the \texttt{duck} entry has siblings in the
\filefmt{entries.bib} file, none of them have been recorded
(indexed) in the document, nor has the parent \texttt{birds} entry.

This document hasn't used \csopt{flatten-lonely}, so the default
\csopt[false]{flatten-lonely} is assumed. This results in the
hierarchical structure:
\begin{description}\setlength\itemsep{0pt}%
\item[A] \null
\item[aardvark] 1
\item[B] \null
\item[bard] 1
\item[birds] \mbox{}
  \begin{description}\setlength\itemsep{0pt}%
  \item[duck] 1
  \end{description}
\item[buzz] 1
\item[I] \null
\item[item] \mbox{}
  \begin{description}\setlength\itemsep{0pt}%
  \item[subitem] \mbox{}
    \begin{description}\setlength\itemsep{0pt}%
    \item[subsubitem] 1
    \end{description}
  \end{description}
\item[M] \null
\item[minerals] \mbox{}
  \begin{description}\setlength\itemsep{0pt}%
  \item[amber] 1
  \item[corundum] 1
  \item[quartz] 1
  \end{description}
\item[V] \null
\item[vegetable] 1
  \begin{description}\setlength\itemsep{0pt}%
  \item[cabbage] 1
  \end{description}
\end{description}
(The \qt{1} in the above indicates the page number.)
There are some entries here that look a little odd: \texttt{duck},
\texttt{cabbage} and \texttt{subsubitem}. In each case they are a
lone child entry. It would look better if they could be compressed,
but I don't want to use the \optref{flatten} option, as I still want
to keep the mineral hierarchy.

If I now add \csopt[postsort]{flatten-lonely}:
\begin{verbatim}
\GlsXtrLoadResources[src={entries.bib},flatten-lonely=postsort]
\end{verbatim}
the hierarchy becomes:
\begin{description}\setlength\itemsep{0pt}%
\item[A] \null
\item[aardvark] 1
\item[B] \null
\item[bard] 1
\item[birds, duck] 1
\item[buzz] 1
\item[I] \null
\item[item, subitem, subsubitem] 1
\item[M] \null
\item[minerals] \mbox{}
  \begin{description}\setlength\itemsep{0pt}%
  \item[amber] 1
  \item[corundum] 1
  \item[quartz] 1
  \end{description}
\item[V] \null
\item[vegetable] 1
  \begin{description}\setlength\itemsep{0pt}%
  \item[cabbage] 1
  \end{description}
\end{description}
The \field{name} field of the \texttt{duck} entry has been
set to
\begin{verbatim}
name={\bibglsflattenedchildpostsort{birds}{duck}}
\end{verbatim}
the \field{text} field has been set to
\begin{verbatim}
text={duck}
\end{verbatim}
the \field{group} field is copied over from the parent entry (\qt{B}),
and the \field{parent} field has been adjusted, moving \texttt{duck}
up one hierarchical level.
Finally, the former parent \texttt{birds} entry has been removed (the default
\optref[only unrecorded parents]{flatten-lonely-rule} is in effect).

The default definition of \csref{bibglsflattenedchildpostsort}
formats its arguments so that they are separated by a comma and
space (\qt{birds, duck}). If the \field{text} field had been set
in the original \atentryref{index} definition of \text{duck}, it
wouldn't have been altered. This adjustment ensures that in the
document \verb|\gls{duck}| still produces \qt{duck} rather than
\qt{birds, duck}.
(If the child and parent \field{name} fields are identical,
the terms are considered homographs. See below for further details.)

The \texttt{subsubitem} entry has also been adjusted. This was done
in a multi-stage process, starting with sub-items and then moving down
the hierarchical levels:
\begin{itemize}
\item The \texttt{subitem} entry was adjusted, moving it from a
sub-entry to a top-level entry. The \field{name} field was then
modified to
\begin{verbatim}
name={\bibglsflattenedchildpostsort{item}{subitem}}
\end{verbatim}
This now means that the \texttt{subsubitem} entry is now a sub-entry
(rather than a sub-sub-entry). The \texttt{subitem} entry now has no
parent, but at this stage the \texttt{subsubitem} entry still has
\texttt{subitem} as its parent.
\item The \texttt{subsubitem} entry is then adjusted moving from a
sub-entry to a top-level entry. The \field{name} field was then
modified to
\begin{verbatim}
name=
{%
 \bibglsflattenedchildpostsort
 {%
   % name from former parent
   \bibglsflattenedchildpostsort{item}{subitem}%
 }%
 {subsubitem}% original name
}
\end{verbatim}
The first argument of \csref{bibglsflattenedchildpostsort} is
obtained from the \field{name} field of the entry's former parent
(which is removed from the child's set of ancestors). This field
value was changed in the previous step, and the change is
reflected here.

This means that the name for \texttt{subitem} will be displayed as
\qt{item, subitem} and the name for \texttt{subsubitem} will be
displayed as \qt{item, subitem, subsubitem}.

\item The parent entries \texttt{item} and \texttt{subitem}
are removed from the selection as they have no location lists.
\end{itemize}

Note that the \texttt{cabbage} sub-entry hasn't been adjusted. It
doesn't have any siblings but its parent entry (\texttt{vegetable})
has a location list so it can't be discarded.
If I change the rule:
\begin{verbatim}
\GlsXtrLoadResources[src={entries.bib},
 flatten-lonely-rule=discard unrecorded,
 flatten-lonely=postsort]
\end{verbatim}
then this will move the \texttt{cabbage} entry up a level but the
original parent entry \texttt{vegetable} will remain:
\begin{description}\setlength\itemsep{0pt}%
\item[A] \null
\item[aardvark] 1
\item[B] \null
\item[bard] 1
\item[birds, duck] 1
\item[buzz] 1
\item[I] \null
\item[item, subitem, subsubitem] 1
\item[M] \null
\item[minerals] \mbox{}
  \begin{description}\setlength\itemsep{0pt}%
  \item[amber] 1
  \item[corundum] 1
  \item[quartz] 1
  \end{description}
\item[V] \null
\item[vegetable] 1
\item[vegetable, cabbage] 1
\end{description}

Remember that \csopt[postsort]{flatten-lonely} performs the
adjustment after sorting. This means that the entries are still in
the same relative location that they were in with the original
\csopt[false]{flatten-lonely} setting. For example, \texttt{duck}
remains in the B letter group before \qt{buzz}.

With \csopt[presort]{flatten-lonely} the adjustments are made before
the sorting is performed. For example, using:
\begin{verbatim}
\GlsXtrLoadResources[src={entries.bib},
 flatten-lonely-rule=discard unrecorded,
 flatten-lonely=presort]
\end{verbatim}
the hierarchical order is now:
\begin{description}\setlength\itemsep{0pt}%
\item[A] \null
\item[aardvark] 1
\item[B] \null
\item[bard] 1
\item[buzz] 1
\item[C] \null
\item[cabbage] 1
\item[D] \null
\item[duck] 1
\item[M] \null
\item[minerals] \mbox{}
  \begin{description}\setlength\itemsep{0pt}%
  \item[amber] 1
  \item[corundum] 1
  \item[quartz] 1
  \end{description}
\item[S] \null
\item[subsubitem] 1
\item[V] \null
\item[vegetable] 1
\end{description}
This method uses a different format for the modified \field{name}
field. For example, the \texttt{duck} entry now has:
\begin{verbatim}
name={\bibglsflattenedchildpresort{duck}{birds}}
\end{verbatim}
The default definition of \csref{bibglsflattenedchildpresort} simply
does the first argument and ignores the second. The sorting is then
performed, but the interpreter recognises this command and can
deduce that the sort value for this entry should be \texttt{duck},
so \qt{duck} now ends up in the D letter group.

If you provide a definition of \cs{bibglsflattenedchildpresort} in
the \atentryref{preamble}, it will be picked up by the interpreter.
For example:
\begin{verbatim}
@preamble{"\providecommand{\bibglsflattenedchildpresort}[2]{#1 (#2)}"}
\end{verbatim}

Note that the \field{text} field is only changed if not already set.
This option may have unpredictable results for abbreviations as the
\field{name} field (and sometimes the \field{text} field) is
typically set by the abbreviation style.  Remember that
if the parent entry doesn't have a location list and the rule isn't
set to \optfmt{no discard} then the parent entry will be discarded
after all relevant entries and their dependencies have been
selected, so any cross-references within the parent entry (such as
\cs{gls} occurring in the description) may end up being selected
even if they wouldn't be selected if the parent entry didn't exist.

With both \optfmt{presort} and \optfmt{postsort},
if the parent \field{name} is the same as the child's \field{name}
then the child is considered a homograph and
the child's name is set to 
\begin{alltt}
\csref{bibglsflattenedhomograph}\margm{name}\margm{parent label}
\end{alltt}
instead of the corresponding \csfmt{bibglsflattenedchild...sort}. 
This defaults to just \meta{name}.


\subsection{\csoptnv{flatten-lonely-rule}\csopteqval{value}}
\labelopt{flatten-lonely-rule}

This option governs the rule used by \csopt{flatten-lonely} to
determine which sub-entries (that have no siblings) to adjust and 
which parents to remove. The value may be one of the following:
\begin{description}
\item[\optfmt{only unrecorded parents}] Only the sub-entries
that have a parent without a location list will be altered.
The parent entry will be removed from the selection.
This value is the default setting.
\item[\optfmt{discard unrecorded}] This setting will adjust all
sub-entries that have no siblings regardless of whether or not the
parent has a location list.
Only the parent entries that don't have a location list will be
removed from the selection.
\item[\optfmt{no discard}] This setting will adjust all
sub-entries that have no siblings regardless of whether or not the
parent has a location list. No entries will be discarded, so parent
entries that don't have a location list will still appear in the
glossary.
\end{description}
In the above, the location list includes records and
cross-references obtained from the \field{see} or \field{seealso}
fields. See \optref{flatten-lonely} for further details.

\section{Master Documents}
\label{sec:master}

Suppose you have two documents \filefmt{mybook.tex} and
\filefmt{myarticle.tex} that share a common glossary that's shown
in \filefmt{mybook.pdf} but not in \filefmt{myarticle.pdf}.
Furthermore, you'd like to use \sty{hyperref} and be able to click
on a term in \filefmt{myarticle.pdf} and be taken to the relevant 
page in \filefmt{mybook.pdf} where the term is listed in the
glossary.

This can be achieved with the \catattr{targeturl} and
\catattr{targetname} category attributes. For example, without
\bibgls\ the file \filefmt{mybook.tex} might look like:
\begin{verbatim}
\documentclass{book}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

\makeglossaries

\newglossaryentry{sample}{name={sample},description={an example}}

\begin{document}
\chapter{Example}
\gls{sample}.

\printglossaries
\end{document}
\end{verbatim}
The other document \filefmt{myarticle.tex} might look like:
\begin{verbatim}
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries-extra}

\newignoredglossary*{external}
\glssetcategoryattribute{external}{targeturl}{mybook.pdf}
\glssetcategoryattribute{external}{targetname}{\glolinkprefix\glslabel}

\newglossaryentry{sample}{type=external,category=external,
 name={sample},description={an example}}

\begin{document}
\gls{sample}.
\end{document}
\end{verbatim}
In this case the \optfmt{main} glossary isn't used, but the category 
attributes allow a mixture of internal and external references, so
the \optfmt{main} glossary could be used for the internal
references. (In which case, \csfmt{makeglossaries} and
\csfmt{printglossaries} would need to be added back to
\filefmt{myarticle.tex}.)

Note that both documents had to define the common terms. The above
documents can be rewritten to work with \bibgls. First a \ext{bib}
file needs to be created:
\begin{verbatim}
@entry{sample,
  name={sample},
  description={an example}
}
\end{verbatim}
Assuming this file is called \filefmt{myentries.bib}, then
\filefmt{mybook.tex} can be changed to:
\begin{verbatim}
\documentclass{book}
\usepackage[colorlinks]{hyperref}
\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[src={myentries}]

\begin{document}
\chapter{Example}
\gls{sample}.

\printunsrtglossaries
\end{document}
\end{verbatim}
and \filefmt{myarticle.tex} can be changed to:
\begin{verbatim}
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[record]{glossaries-extra}

\newignoredglossary*{external}
\glssetcategoryattribute{external}{targeturl}{mybook.pdf}
\glssetcategoryattribute{external}{targetname}{\glolinkprefix\glslabel}

\GlsXtrLoadResources[
 src={myentries},
 sort=none,
 type=external,
 category=external]

\begin{document}
\gls{sample}.
\end{document}
\end{verbatim}
Most of the options related to sorting and the glossary format are
unneeded here since the glossary isn't being displayed. This may be
sufficient for your needs, but it may be that the book has changed
various settings that have been written to \filefmt{mybook.glstex}
but aren't present in the \ext{bib} file (such as
\optref[uc]{short-case-change}). In this case, you could just remember to copy
over the settings from \filefmt{mybook.tex} to
\filefmt{myarticle.tex}, but
another possibility is to simply make \filefmt{myarticle.tex} input
\filefmt{mybook.glstex} instead of using \cs{GlsXtrLoadResources}. This
can work but it's not so convenient to set the label prefix, the
type and the category.  The \optfmt{master} option allows this, but
it has limitations (see below), so in complex cases (in particular
different label prefixes combined with hierarchical entries or cross-references) you'll have to use
the method shown in the example code above.

\subsection{\csoptnv{master}\csopteqval{name}}
\labelopt{master}

This option will disable most of the options that relate to
parsing and processing data contained in \ext{bib} files
(since this option doesn't actually read any \ext{bib} files).

The use of \optfmt{master} isn't always suitable. In particular
if any of the terms cross-reference each other, such as through
the \field{see} or \field{seealso} field or the \field{parent} field or
using commands like \cs{gls} in any of the other fields when
the labels have been assigned prefixes. In this
case you will need to use the method described in the example above.

The \meta{name} is the name of the \ext{aux} file for the master
document without the extension (in this case, \filefmt{mybook}). It
needs to be relative to the document referencing it or an absolute
path using forward slashes as the directory divider. Remember that
if it's a relative path, the PDF files (\filefmt{mybook.pdf} and
\filefmt{myarticle.pdf}) will also need to be located in the same
relative position.

When \bibgls\ detects the \csopt{master} option, it won't search for
entries in any \ext{bib} files (for that particular resource set)
but will create a \ext{glstex} file that inputs the master
document's
\ext{glstex} files, but it will additionally temporarily
adjust the internal commands used to define entries so that
the prefix given by \optref{label-prefix}, the glossary type and the
category type are all automatically inserted. If the \optref{type}
or \optref{category} options haven't been used, the corresponding
value will default to \optfmt{master}. The \catattr{targeturl}
and \catattr{targetname} category attributes will automatically be
set, and the glossary type will be provided using
\cs{provideignoredglossary*}\margm{type}.

The above \filefmt{myarticle.tex} can be changed to:
\begin{verbatim}
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[
 label-prefix={book.},
 master={mybook}]

\begin{document}
\gls{book.sample}.
\end{document}
\end{verbatim}

There are some settings from the master document that you 
still need to repeat in the other document. These include
the label prefixes set when the master document loaded
the resource files, and any settings in the master document
that relate to the master document's entries.

For example, if the master document loaded a resource file
with \optref[term.]{label-prefix} then you also need this
prefix when you reference the entries in the dependent document
in addition to the \optfmt{label-prefix} for the dependent document.
Suppose \filefmt{mybook.tex} loads the resources using
\begin{verbatim}
\GlsXtrLoadResources[src={myentries},label-prefix={term.}]
\end{verbatim}
and \filefmt{myarticle.tex} loads the resources using:
\begin{verbatim}
\GlsXtrLoadResources[
 label-prefix={book.},
 master={mybook}]
\end{verbatim}
Then the entries referenced in \filefmt{myarticle.tex} need
to use the prefix \optfmt{book.term.}\ as in:
\begin{verbatim}
This is a \gls{book.term.sample} term.
\end{verbatim}

Remember that the category labels will need adjusting to reflect the
change in category label in the dependent document.

For example, if \filefmt{mybook.tex} included:
\begin{verbatim}
\setabbreviationstyle{long-short-sc}
\end{verbatim}
then \filefmt{myarticle.tex} will need:
\begin{verbatim}
\setabbreviationstyle[master]{long-short-sc}
\end{verbatim}
(change \optfmt{master} to \meta{value} if you have used
\optref[\meta{value}]{category}). You can, of course, choose
a different abbreviation style for the dependent document, 
but the category in the optional argument needs to be correct.

\subsection{\csoptnv{master-resources}\csopteqval{list}}
\labelopt{master-resources}

If the master document has multiple resource files
then by default all that document's
\ext{glstex} files will be input. If you don't want them all
you can use \optfmt{master-resources} to specify
only those files that should be included. The value \meta{list} is 
a comma-separated list of names, where each name corresponds
to the final argument of \csref{glsxtrresourcefile}.
Remember that \cs{GlsXtrLoadResources} is just a shortcut
for \cs{glsxtrresourcefile} that bases the name on \cs{jobname}.
(Note that, as with the argument of \cs{glsxtrresourcefile},
the \ext{glstex} extension should not be included.) The file
\primaryresourcefmt\ is considered the primary
resource file and the files \suppresourcefmt{\meta{n}}
(starting with \meta{n} equal to 1) are considered the supplementary resource files.

For example, to just select the first and third of the
supplementary resource files (omitting the primary
\filefmt{mybook.glstex}):
\begin{verbatim}
\GlsXtrLoadResources[
  master={mybook},
  master-resources={mybook-1,mybook-3}
]
\end{verbatim}

\section{Field and Label Options}
\label{sec:labelopts}

\subsection{\csoptnv{ignore-fields}\csopteqval{list}}
\labelopt{ignore-fields}

The \csopt{ignore-fields} key indicates that you want \bibgls\ to
skip the fields listed in the supplied comma-separated \meta{list} of field
labels. Remember that unrecognised fields will always be skipped.

For example, suppose my \ext{bib} file contains
\begin{verbatim}
@abbreviation{html,
  short ="html",
  long  = {hypertext markup language},
  description={a markup language for creating web pages},
  seealso={xml}
}
\end{verbatim}
but I want to use the \abbrstyle{short-long} style and I don't want
the cross-referenced term, then I can use
\csopt[seealso,description]{ignore-fields}.

Note that \csopt[parent]{ignore-fields} removes the \field{parent}
before determining the dependency lists. This means that
\optref[recorded and deps]{selection} and 
\optref[recorded and ancestors]{selection} won't pick up the
label in the \field{parent} field.

If you want to maintain the dependency and ancestor relationship but
omit the \field{parent} field when writing the entries to the
\ext{glstex} file, you need to use \optref{flatten} instead.

\subsection{\csoptnv{category}\csopteqval{value}}
\labelopt{category}

The selected entries may all have their \field{category} field
changed before writing their definitions to the \ext{glstex} file.
The \meta{value} may be:
\begin{itemize}
\item \optfmt{same as entry}: set the
\field{category} to the \ext{bib} entry type used to define it
(without the leading \texttt{@});
\item \optfmt{same as type}: set the \field{category} to the same
value as the \field{type} field (if that field has been provided
either in the \ext{bib} file or through the \optref{type} option);
\item \meta{label}: the \field{category} is set to
\meta{label} (which mustn't contain any special characters).
\end{itemize}
This will override any
\field{category} fields supplied in the \ext{bib} file.

For example, if the \ext{bib} file contains:
\begin{verbatim}
@entry{bird,
  name={bird},
  description = {feathered animal}
}

@index{duck}

@index{goose,plural="geese"}

@dualentry{dog,
  name={dog},
  description={chien}
}
\end{verbatim}
then if the document contains
\begin{verbatim}
\GlsXtrLoadResources[category={same as entry},src={entries}]
\end{verbatim}
this will set the \field{category} of the \texttt{bird} field to
\optfmt{entry} (since it was defined with \cs{entry}), the \field{category} of the \texttt{duck} and
\texttt{goose} entries to \optfmt{index} (since they were defined
with \atentry{index}), and the \field{category} of the \texttt{dog}
entry to \optfmt{dualentry} (since it was
defined with \atentry{dualentry}). Note that the dual entry
\texttt{dual.dog} doesn't have the category set, since that's
governed by \optref{dual-category} instead.

If, instead, the document contains
\begin{verbatim}
\GlsXtrLoadResources[category={animals},src={entries}]
\end{verbatim}
then the \field{category} of all the primary selected entries will 
be set to \optfmt{animals}. Again the dual entry \texttt{dual.dog}
doesn't have the \field{category} set.

Note that the categories may be overridden by the commands,
such as \csref{bibglsnewindex}, that are used to actually define the
entries.

For example, if the document contains
\begin{verbatim}
\newcommand{\bibglsnewdualentry}[4]{%
 \longnewglossaryentry*{#1}{name={#3},#2,category={dual}}{#4}%
}

\GlsXtrLoadResources[category={animals},src={entries}]
\end{verbatim}
then both the \texttt{dog} and \texttt{dual.dog} entries will
have their \field{category} field set to \optfmt{dual} since the
new definition of \cs{bibglsnewdualentry} has overridden
the \csopt[animals]{category} option.

\subsection{\csoptnv{type}\csopteqval{value}}
\labelopt{type}

The \meta{value} may be \optfmt{same as entry} or a glossary label.
This is similar to the \optref{category} option except that
it sets the \field{type} field. As with the \csopt{category} option,
\csopt[same as entry]{type} indicates that the entry
type should be used. There is no \meta{value} analogous to
\csopt[same as type]{category}.

Make sure that the glossary type has already been defined. 

Note that this setting only changes the \field{type} field for
primary entries. Use \optref{dual-type} for dual entries.

For example:
\begin{verbatim}
\usepackage[record,symbols]{glossaries-extra}

\GlsXtrLoadResources[src={entries-symbols},type=symbols]
\end{verbatim}

Remember that you can use the starred version of \cs{newglossary}
if you don't want to worry about the extensions needed by
\app{makeindex} or \app{xindy}. For example:
\begin{verbatim}
\usepackage[record,nomain]{glossaries-extra}

\newglossary*{dictionary}{Dictionary}

\GlsXtrLoadResources[src={entries-symbols},type=dictionary]
\end{verbatim}
(The \styopt{nomain} option was added to suppress the
creation of the default \texttt{main} glossary.)

Alternatively you can use \cs{newignoredglossary} if you don't
want the glossary picked up by \cs{printunsrtglossaries}.


\subsection{\csoptnv{label-prefix}\csopteqval{tag}}
\labelopt{label\dhyphen prefix}

The \csopt{label-prefix} option prepends \meta{tag} to each
entry's label. This \meta{tag} will also be inserted in front of any
cross-references, unless they start with \idprefix{dual} or
\idprefix{ext\meta{n}} (where \meta{n} is an integer).

For example, if the \ext{bib} file contains
\begin{verbatim}
@entry{bird,
  name={bird},
  description = {feathered animal, such as a \gls{duck} or \gls {goose}}
}

@entry{waterfowl,
  name={waterfowl},
  description={Any \gls{bird} that lives in or about water},
  see={[see also]{duck,goose}}
}

@index{duck}

@index{goose,plural="geese"}
\end{verbatim}
Then if this \ext{bib} file is loaded with \csopt[gls.]{label-prefix}
it's as though the entries had been defined as:
\begin{verbatim}
@entry{gls.bird,
  name={bird},
  description = {feathered animal, such as a \gls{gls.duck} or 
\gls{gls.goose}}
}

@entry{gls.waterfowl,
  name={waterfowl},
  description={Any \gls{gls.bird} that lives in or about water},
  see={[see also]{gls.duck,gls.goose}}
}

@index{gls.duck,name={duck}}

@index{gls.goose,name={goose},plural="geese"}
\end{verbatim}

Remember to use this prefix when you reference the terms in the
document with commands like \cs{gls}.

\subsection{\csoptnv{ext-prefixes}\csopteqval{list}}
\labelopt{ext-prefixes}

Any cross-references in the \ext{bib} file that start with
\idprefix{ext\meta{n}} (where \meta{n} is a positive integer) will be 
substituted with the \meta{n}th tag listed in the comma-separated
\meta{list}. If there aren't that many items in the list, the
\idprefix{ext\meta{n}} will simply be removed. The default setting is
an empty list, which will strip all \idprefix{ext\meta{n}} prefixes.

For example, suppose the file \filefmt{entries-terms.bib} contains:
\begin{verbatim}
@entry{set,
  name={set},
  description={collection of values, denoted \gls{ext1.set}}
}
\end{verbatim}
and the file \filefmt{entries-symbols.bib} contains:
\begin{verbatim}
@symbol{set,
  name={\ensuremath{\mathcal{S}}},
  description={a \gls{ext1.set}}
}
\end{verbatim}

These files both contain an entry with the label \texttt{set}
but the description includes \verb|\gls{ext1.set}| which is
referencing the entry from the other file. These
two files can be loaded without conflict using:
\begin{verbatim}
\usepackage[record,symbols]{glossaries-extra}

\GlsXtrLoadResources[src={entries-terms},
 label-prefix={gls.},
 ext-prefixes={sym.}
]

\GlsXtrLoadResources[src={entries-symbols},
 type=symbols,
 label-prefix={sym.},
 ext-prefixes={gls.}
]
\end{verbatim}

Now the \texttt{set} entry from \filefmt{entries-terms.bib}
will be defined with the label \texttt{gls.set} and the
description will be
\begin{verbatim}
collection of values, denoted \gls{sym.set}
\end{verbatim}
The \texttt{set} entry
from \filefmt{entries-symbols.bib} will be defined with the label
\texttt{sym.set} and the description will be 
\begin{verbatim}
a \gls{gls.set}
\end{verbatim}

Note that in this case the \ext{bib} files have to be loaded 
as two separate resources. They can't be combined into a 
single \optref{src} list as the labels aren't unique. 

If you want to allow the flexibility to choose between 
loading them together or separately, you'll have to give them
unique labels. For example, \filefmt{entries-terms.bib} could
contain:
\begin{verbatim}
@entry{set,
  name={set},
  description={collection of values, denoted \gls{ext1.S}}
}
\end{verbatim}
and \filefmt{entries-symbols.bib} could contain:
\begin{verbatim}
@symbol{S,
  name={\ensuremath{\mathcal{S}}},
  description={a \gls{ext1.set}}
}
\end{verbatim}
Now they can be combined with:
\begin{verbatim}
\GlsXtrLoadResources[src={entries-terms,entries-symbols}]
\end{verbatim}
which will simply strip the \idprefixfmt{ext1} prefix from the
cross-references. Alternatively:
\begin{verbatim}
\GlsXtrLoadResources[src={entries-terms,entries-symbols},
 label-prefix={gls.},
 ext-prefixes={gls.}
]
\end{verbatim}
which will insert the supplied \optref{label-prefix} at the
start of the labels in the entry definitions and will replace
the \idprefix{ext1} prefix with \idprefixfmt{gls} in the
cross-references.

\subsection{\csoptnv{short-case-change}\csopteqval{value}}
\labelopt{short-case-change}

The value of the \field{short} field may be automatically converted
to upper or lower case. This option may take one of the following
values:
\begin{itemize}
\item \optfmt{none}: don't apply any case-changing (default);
\item \optfmt{lc}: convert to lower case;
\item \optfmt{uc}: convert to upper case;
\item \optfmt{lc-cs}: convert to lower case using
\cs{MakeTextLowercase};
\item \optfmt{uc-cs}: convert to upper case using
\cs{MakeTextUppercase}.
\end{itemize}

For example, if the \ext{bib} file contains
\begin{verbatim}
@abbreviation{html,
  short = "html",
  long  = "hypertext markup language"
}
\end{verbatim}
then \csopt[uc]{short-case-change} would convert the value of the
\field{short} field into
\begin{verbatim}
HTML
\end{verbatim}
whereas \csopt[uc-cs]{short-case-change} would convert it to
\begin{verbatim}
\MakeTextUppercase{html}
\end{verbatim}
In the case of \csopt[uc]{short-case-change} and \csopt[lc]{short-case-change}
only tokens that are recognised as characters will be converted.
For example, suppose I have a slightly more eccentric definition:
\begin{verbatim}
@abbreviation{html,
  short = "ht\emph{ml}",
  long  = "hypertext markup language"
}
\end{verbatim}
then \csopt[uc]{short-case-change} would convert the value of the
\field{short} field into:
\begin{verbatim}
HT\emph{ML}
\end{verbatim}
Note that \cs{emph} isn't modified as it's recognised as a command.
There's no attempt at interpreting the contents at this point (but
the value may later be interpreted during sorting).

For example, suppose an abbreviation is defined using:
\begin{verbatim}
short = "z\ae\oe",
\end{verbatim}
then with \csopt[uc]{short-case-change}, this would be converted to
\begin{verbatim}
Z\ae\oe
\end{verbatim}
since the interpreter isn't being used at this stage. If the
interpreter is later used during sorting, the sort value will be set to 
\texttt{Z\ae\oe}.

However, with \csopt[uc-cs]{short-case-change}, the \field{short}
value would be converted to
\begin{verbatim}
\MakeTextUppercase{z\ae\oe}
\end{verbatim}
If the interpreter is used during sorting, the sort value will be set to 
\texttt{Z\AE\OE}.

You can use \cs{NoCaseChange}\margm{text} to prevent the given \meta{text}
from having the case changed. For example, if the \field{short}
field is defined as
\begin{verbatim}
short = {a\NoCaseChange{bc}d}
\end{verbatim}
then with  \csopt[uc]{short-case-change}, this would be converted to
\begin{verbatim}
A\NoCaseChange{bc}D
\end{verbatim}
(This command is provided by \sty{textcase}, which is automatically
loaded by \sty{glossaries}.)

If you have a command that takes a label or identifier as an argument then it's
best to hide the label in a custom command. For example, if the
\field{short} field in the \ext{bib} definition is defined as:
\begin{verbatim}
  short = "ht\textcolor{red}{ml}",
\end{verbatim}
then with \csopt[uc]{short-case-change} this would end up as:
\begin{verbatim}
HT\textcolor{RED}{ML}
\end{verbatim}
which is incorrect. Instead, provide a command that hides the label
(such as the \csfmt{strong} example described on page~\pageref{cs.strong}).

See \optref{dual-short-case-change} to adjust the \field{dualplural}
field.

\subsection{\csoptnv{group}\csopteqval{value}}
\labelopt{group}

This option may only be used with the \argref{group} switch.
This will set the \field{group} field to \meta{value} unless
\meta{value} is \optfmt{auto}, in which case the value is
set automatically during the sorting. 
For example:
\begin{verbatim}
\GlsXtrLoadResources[sort=integer,group={Constants},
 src={entries-constants}% data in entries-constants.bib
]
\GlsXtrLoadResources[sort=letter-case,group={Variables},
 src={entries-variables}% data in entries-variables.bib
]
\end{verbatim}
If the \field{type} field hasn't been set in the \ext{bib} files,
these entries will be added to the same glossary, but will
be grouped according to each instance of \cs{GlsXtrLoadResources},
with the provided group label.
The default behaviour is \csopt[auto]{group}.

\subsection{\csoptnv{save-child-count}\csopteqval{boolean}}
\labelopt{save-child-count}

This is a boolean option. The default setting is
\csopt[false]{save-child-count}. 
If \csopt[true]{save\dhyphen child\dhyphen count},
each entry will be assigned a field called \texttt{childcount} with
the value equal to the number of child entries that have been
selected.

The assignment is done using \cs{GlsXtrSetField} so there's
no associated key.
For example, suppose \filefmt{entries.bib} contains:
\begin{verbatim}
@index{birds}
@index{duck,parent={birds}}
@index{goose,plural={geese},parent={birds}}
@index{swan,parent={birds}}

@index{minerals}
@index{quartz,parent={minerals}}
@index{corundum,parent={minerals}}
@index{amber,parent={minerals}}
@index{gypsum,parent={minerals}}
@index{gold,parent={minerals}}
\end{verbatim}
and the document contains:
\begin{verbatim}
\documentclass{article}

\usepackage[record,style=indexgroup]{glossaries-extra}

\GlsXtrLoadResources[src={entries},save-child-count]

\begin{document}
\gls{duck} and \gls{goose}.
\gls{quartz}, \gls{corundum}, \gls{amber}.

\printunsrtglossaries
\end{document}
\end{verbatim}
Then the \ext{glstex} file will contain:
\begin{verbatim}
\GlsXtrSetField{birds}{childcount}{2}
\GlsXtrSetField{duck}{childcount}{0}
\GlsXtrSetField{goose}{childcount}{0}
\GlsXtrSetField{minerals}{childcount}{3}
\GlsXtrSetField{amber}{childcount}{0}
\GlsXtrSetField{corundum}{childcount}{0}
\GlsXtrSetField{quartz}{childcount}{0}
\end{verbatim}
Note that although \texttt{birds} has three children defined in the
\ext{bib} file, only two have been selected, so the child count is
set to 2. Similarly the \texttt{minerals} entry has five children
defined in the \ext{bib} file, but only three have been selected, so
the child count is 3.

The following uses the post-description hook to show the child count
in parentheses:
\begin{verbatim}
\GlsXtrLoadResources[src={entries},category=general,save-child-count]

\renewcommand{\glsxtrpostdescgeneral}{%
  \glsxtrifhasfield{childcount}{\glscurrententrylabel}
  { (child count: \glscurrentfieldvalue.)}%
  {}%
}
\end{verbatim}
(\cs{glsxtrifhasfield} requires at least \sty{glossaries-extra} v1.19.
It's slightly more efficient that \cs{ifglshasfield} provided by
the base \sty{glossaries} package, and it doesn't complain if the
entry or field don't exist, but note that \cs{glsxtrifhasfield}
implicitly scopes its content. Use the starred version to omit the
grouping.)

\section{Plurals}
\label{sec:plurals}

Some languages, such as English, have a general rule that plurals
are formed from the singular with a suffix appended. This isn't 
an absolute rule. There are plenty of exceptions (for example,
geese, children, churches, elves, fairies, sheep, mice), so a
simplistic approach of just doing \texttt{\cs{gls}\margm{label}[s]}
will sometimes produce inappropriate results, so the \sty{glossaries}
package provides a \field{plural} key with the corresponding command
\cs{glspl}.

In some cases a plural may not make any sense (for example, if the
term is a verb or symbol), so the \field{plural} key is optional, but to
make life easier for languages where the majority of plurals can
simply be formed by appending a suffix to the singular, the
\sty{glossaries} package lets the \field{plural} field default
to the value of the \field{text} field with \cs{glspluralsuffix}
appended. This command is defined to be just the letter \qt{s}.
This means that the majority of terms in such languages don't need to have the
\field{plural} supplied as well, and you only need to use it for the
exceptions.

For languages that don't have this general rule, the \field{plural}
field will always need to be supplied for nouns.

There are other plural fields, such as \field{firstplural},
\field{longplural} and \field{shortplural}. Again, if you are using
a language that doesn't have a simple suffix rule, you'll have to
supply the plural forms if you need them (and if a plural makes
sense in the context).

If these fields are omitted, the \sty{glossaries} package follows
these rules:
\begin{itemize}
\item If \field{firstplural} is missing, then \cs{glspluralsuffix}
is appended to the \field{first} field, if that field has been
supplied. If the \field{first} field hasn't been supplied but the
\field{plural} field has been supplied, then the \field{firstplural}
field defaults to the \field{plural} field. If the \field{plural}
field hasn't been supplied, then both the \field{plural} and
\field{firstplural} fields default to the \field{text} field (or
\field{name}, if no \field{text} field) with \cs{glspluralsuffix}
appended.

\item If the \field{longplural} field is missing, then 
\cs{glspluralsuffix} is appended to the \field{long} field, if the
\field{long} field has been supplied.

\item If the \field{shortplural} field is missing then, \emph{with
the base \sty{glossaries} acronym mechanism}, \cs{acrpluralsuffix}
is appended to the \field{short} field.

\end{itemize}

The last case is different with the \sty{glossaries-extra} extension 
package. The \field{shortplural} field defaults to the \field{short}
field with \cs{abbrvpluralsuffix} appended \emph{unless overridden
by category attributes}. This suffix command is set by the
abbreviation styles. This means that every time an abbreviation
style is implemented, \cs{abbrvpluralsuffix} is redefined. Most
styles simply define this command as:
\begin{verbatim}
\renewcommand*{\abbrvpluralsuffix}{\glsxtrabbrvpluralsuffix}
\end{verbatim}
where \cs{glsxtrabbrvpluralsuffix} expands to \cs{glspluralsuffix}.
The \qt{sc} styles (such as \abbrstyle{long-short-sc}) use a different
definition:
\begin{verbatim}
\renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}
\end{verbatim}
This allows the suffix to be reverted back to the upright font,
counter-acting the affect of the small-caps font.

This means that if you want to change or strip the suffix used for
the plural short form, it's usually not sufficient to redefine
\cs{abbrvpluralsuffix}, as the change will be undone the next time
the style is applied. Instead, for a document-wide solution, you
need to redefine \cs{glsxtrabbrvpluralsuffix}. Alternatively you can
use the category attributes.

There are two attributes that affect the short plural suffix
formation. The first is \catattr{aposplural} which uses the suffix
\begin{verbatim}
'\abbrvpluralsuffix
\end{verbatim}
That is, an apostrophe followed by \cs{abbrvpluralsuffix} is
appended. The second attribute is \catattr{noshortplural} which
suppresses the suffix and simply sets \field{shortplural} to the
same as \field{short}.

With \bibgls, if you have some abbreviations where the plural should
have a suffix and some where the plural shouldn't have a suffix
(for example, the document has both English and French abbreviations)
then there are two approaches.

The first approach is to use the category attributes. For example:
\begin{verbatim}
\glssetcategoryattribute{french}{noshortplural}
\end{verbatim}
Now just make sure all the French abbreviations are have their
\field{category} field set to \optfmt{french}:
\begin{verbatim}
\GlsXtrLoadResources[src={fr-abbrvs},category={french}]
\end{verbatim} 

The other approach is to use the options listed below.

\subsection{\csoptnv{short-plural-suffix}\csopteqval{value}}
\labelopt{short-plural-suffix}

Sets the plural suffix for the default \field{shortplural} to \meta{value}.  If
this option is omitted or if
\csopt[use-default]{short\dhyphen plural-suffix}, then \bibgls\ will leave
it to \sty{glossaries-extra} to determine the appropriate default.
If the \meta{value} is omitted or empty, the suffix is set to empty.

\subsection{\csoptnv{dual-short-plural-suffix}\csopteqval{value}}
\labelopt{dual-short-plural-suffix}

Sets the plural suffix for the default \field{dualshortplural} field to
\meta{value}.  If this option is omitted or if
\csopt[use-default]{dual-short-plural-suffix}, then \bibgls\ will leave it to
\sty{glossaries-extra} to determine the appropriate default.
If the \meta{value} is omitted or empty, the suffix is set to empty.

\section{Location List Options}
\label{sec:locationopts}

The \styopt{record} package option automatically adds two new keys: 
\field{loclist} and \field{location}. These two fields are set by
\bibgls\ from the information supplied in the \ext{aux} file (unless
the option \optref[false]{save-locations} is used). The
\field{loclist} field has the syntax of an \sty{etoolbox} internal list
and includes every location (except for the discarded duplicates and
ignored formats).
Each item in the list is provided in the form
\begin{alltt}
\cs{glsseeformat}\oargm{tag}\margm{label list}\marg{}
\end{alltt}
for the cross-reference supplied by the \field{see} field,
\begin{alltt}
\cs{glsxtruseseealsoformat}\margm{label list}
\end{alltt}
for the cross-reference supplied by the \field{seealso} field,
and
\begin{alltt}
\cs{glsnoidxdisplayloc}\margm{prefix}\margm{counter}\margm{format}\margm{location}
\end{alltt}
for the locations. You can iterate through the \field{loclist} value
using one of \sty{etoolbox}'s internal list loops (either
by first fetching the list using \cs{glsfieldfetch}
or through \sty{glossaries-extra}'s \cs{glsxtrfielddolistloop}
or \cs{glsxtrfieldforlistloop} shortcuts).

The \meta{format} is that supplied by the \gencsopt{gls}{format} key
when using commands like \cs{gls} or \cs{glsadd} (the encapsulator or encap in
\appfmt{makeindex} parlance). If omitted,
\gencsopt[glsnumberformat]{gls}{format} is assumed (unless this
default value is changed with \cs{GlsXtrSetDefaultNumberFormat},
provided by \sty{glossaries-extra} v1.19+).

Ranges can be explicitly formed using the parenthetical encap
syntax \glsopt[(]{format} and
\glsopt[)]{format} or \glsopt[(\meta{csname}]{format} and
\glsopt[)\meta{csname}]{format} (where \meta{csname} is the name of 
a text-block command without the initial backslash) in the optional
argument of commands like \cs{gls} or \cs{glsadd}. These will always
form a range, regardless of \optref{min-loc-range}, and will be
encapsulated by \csref{bibglsrange}. (This command is not used with
ranges that are formed by collating consecutive locations.)

Explicit ranges don't merge with neighbouring locations, but will
absorb any single locations within the range that don't conflict.
(Conflicts will be moved to the start of the explicit range.)
For example, if \verb|\gls{sample}| is used on page~1,
\verb|\gls[format=(]{sample}| is used on page~2, 
\verb|\gls{sample}| is used on page~3, and
\verb|\gls[format=)]{sample}| is used on page~4, then the location
list will be 1, 2--4. The entry on page~3 is absorbed into the
explicit range, but the range can't be expanded to include page~1.
If the entry on page~3 had a different format to the explicit range,
for example \verb|\gls[format=textbf]{sample}| then it would cause a
warning and be moved before the start of the range so that the
location list would then be 1, \textbf{3}, 2--4. 

The special format \gencsopt[glsignore]{glsadd}{format} is provided
by the \styfmt{glossaries} package for cases where the location
should be ignored. (The command \cs{glsignore} simply ignores its
argument.) This works reasonably well if an entry only has the one
location, but if the entry happens to be indexed again, it can lead
to an odd empty gap in the location list with a spurious comma. If
\bibgls\ encounters a record with this special format, the entry
will be selected but the record will be discarded.

This means that the location list will be empty if the entry was
only indexed with \optfmt{glsignore}, but if the entry was also
indexed with another format then the location list won't include the
ignored record.  (This format is used by \cs{glsaddallunused} but
remember that iterative commands like this don't work with \bibgls.
Instead, just use \optref[all]{selection} to select all entries.)

For example, suppose you only want main matter locations in the
number list, but you want entries that only appear in the back matter 
to still appear in the glossary (without a location list), then you could do:
\begin{verbatim}
\backmatter
\GlsXtrSetDefaultNumberFormat{glsignore}
\end{verbatim}
(This command requires v1.19 of \sty{glossaries-extra}.) If you also
want to drop front matter locations as well:
\begin{verbatim}
\frontmatter
\GlsXtrSetDefaultNumberFormat{glsignore}
...
\mainmatter
\GlsXtrSetDefaultNumberFormat{glsnumberformat}
...
\backmatter
\GlsXtrSetDefaultNumberFormat{glsignore}
\end{verbatim}

Note that explicit range formations aren't discarded, so if
\optfmt{glsignore} is used in a range, such as
\begin{verbatim}
\glsadd[format=(glsignore]{sample}
... 
\glsadd[format=)glsignore]{sample} 
\end{verbatim}
then the range will be included in the location list (encapsulated
with \cs{glsignore}), but this case would be a rather odd use of
this special format and is not recommended.

The locations are always listed in the order in which they were indexed,
(except for the cross-reference which may be placed at the start or
end of the list or omitted).
This is different to \app{xindy} and \app{makeindex} where you can
specify the ordering (such as lower case Roman first, then digits,
etc), but unlike those applications, \bibgls\ allows any location,
although it may not be able to work out an integer representation.
(With \app{xindy}, you can define new location formats, but you need
to remember to add the appropriate code to the custom module.)

It's possible to define a custom glossary style where 
\cs{glossentry} (and the child form \cs{subglossentry}) ignore the
final argument (which will be the \field{location} field)
and instead parse the \field{loclist} field and re-order the
locations or process them in some other way. Remember that you can also use \cs{glsnoidxloclist}
provided by \sty{glossaries}. For example:
\begin{verbatim}
\glsfieldfetch{gls.sample}{loclist}{\loclist}% fetch location list
\glsnoidxloclist{\loclist}% iterate over locations
\end{verbatim}
This uses \cs{glsnoidxloclisthandler} as the list's handler
macro, which simply displays each location separated by \cs{delimN}.
(See also
\href{http://www.dickimaw-books.com/latex/admin/html/foreachtips.shtml}{Iteration
Tips and Tricks}.)

Each location is listed in the \ext{aux} file in the form:
\begin{alltt}
\cs{glsxtr@record}\margm{label}\margm{prefix}\margm{counter}\margm{format}\margm{location}
\end{alltt}
Exact duplicates are discarded. For example, if \texttt{cat}
is indexed twice on page 1:
\begin{verbatim}
\glsxtr@record{cat}{}{page}{glsnumberformat}{1}
\glsxtr@record{cat}{}{page}{glsnumberformat}{1}
\end{verbatim}
then the second record is discarded. Only the first record is added
to the location list.

Partial duplicates, where all arguments match except for
\meta{format}, may be discarded depending on the value
of \meta{format}. For example, if page~1 of the document
uses \verb|\gls{cat}| and \verb|\gls[format=hyperbf]{cat}|
then the \ext{aux} file will contain:
\begin{verbatim}
\glsxtr@record{cat}{}{page}{glsnumberformat}{1}
\glsxtr@record{cat}{}{page}{hyperbf}{1}
\end{verbatim}
This is a partial record match. In this case, \bibgls\ 
makes the following tests:
\begin{itemize}
\item If one of the formats includes a range formation, the
range takes precedence.

\item If one of the formats is \texttt{glsnumberformat} (as in the
above example) or \texttt{glsignore}, that format will be skipped.
So in the above example, the second record will be added to the
location list, but not the first. (A message will only be written to
the transcript if the \longarg{debug} switch is used.) The default
\texttt{glsnumberformat} will take precedence over the ignored
format \texttt{glsignore}.

\item If a mapping has been set with the \argref{map-format}
switch that mapping will be checked.
\item Otherwise the duplicate record will be discarded with a
warning.
\end{itemize}

The \field{location} field is used to store the formatted location
list. The code for this list is generated by \bibgls\ based on the
information provided in the \ext{aux} file, the presence of the
\field{see} or \field{seealso} field and the various settings described in this
chapter. When you display the glossary using \cs{printunsrtglossary},
if the \field{location} field is present it will be displayed
according to the glossary style (and other factors, such as whether the
\styopt{nonumberlist} option has been used, either as a package
option or supplied in the optional argument of \cs{printunsrtglossary}).
For more information on adjusting the formatting see the
\sty{glossaries} and \sty{glossaries-extra} user manuals.

\subsection{\csoptnv{save-locations}\csopteqval{boolean}}
\labelopt{save-locations}

By default, the locations will be processed and stored in the
\field{location} and \field{loclist} fields. However, if you don't
want the location lists (for example, you are using the
\styopt{nonumberlist} option or you are using \app{xindy} with a
custom location rule), then there's no need for \bibgls\ to process
the locations. To switch this function off, just use
\csopt[false]{save-locations}. Note that with this setting, if
you're not additionally using \app{makeindex} or \app{xindy}, then
the locations won't be available even if you don't have the
\styopt{nonumberlist} option set.

\subsection{\csoptnv{min-loc-range}\csopteqval{value}}
\labelopt{min-loc-range}

By default, three or more consecutive locations \meta{loc-1},
\meta{loc-2}, \ldots, \meta{loc-n} are compressed into
the range \texttt{\meta{loc-1}\cs{delimR} \meta{loc-n}} (where
\cs{delimR} is provided by the \sty{glossaries} package). Otherwise
the locations are separated by \cs{delimN} (again provided by
\sty{glossaries}). As mentioned above, these aren't merged with
explicit range formations.

You can change this with the \csopt{min-loc-range} setting where
\meta{value} is either \optfmt{none} (don't form ranges) or an
integer greater than one indicating how many consecutive locations should be
converted into a range.

\bibgls\ determines if one location
\margm{prefix-2}\margm{counter-2}\margm{format-2}\margm{location-2}
is one unit more than another location
\margm{prefix-1}\margm{counter-1}\margm{format-1}\margm{location-1} 
according to the following:
\begin{enumerate}
\item\label{itm:pre} If \meta{prefix-1} is not equal to \meta{prefix-2} or
\meta{counter-1} is not equal to \meta{counter-2} or \meta{format-1}
is not equal to \meta{format-2}, then the locations aren't
considered consecutive.
\item\label{itm:emptyloc} If either \meta{location-1} or \meta{location-2} are empty,
then the locations aren't considered consecutive.
\item\label{itm.csmatch} If both \meta{location-1} and \meta{location-2} match the
pattern (line break for clarity only)\footnote{The Java class \texttt{\csfmt{p}\marg{javaDigit}}
used in the regular expression will not only match the Western
Arabic digits 0,\ldots, 9 but also digits in other scripts.
Similarly the alphabetic classes will match alphabetic characters
outside the Basic Latin set.}
\begin{verbatim}
(.*?)(?:\\protect\s*)?(\\[\p{javaAlphabetic}@]+)\s*\{([\p{javaDigit}
\p{javaAlphabetic}]+)\}
\end{verbatim}
then:
  \begin{itemize}
  \item if the control sequence matched by group 2 isn't the same for
  both locations, the locations aren't considered consecutive;
  \item if the argument of the control sequence (group 3) is the same for
  both locations, then the test is retried with \meta{location-1}
set to group 1 of the first pattern match and \meta{location-2}
set to group 1 of the second pattern match;
  \item otherwise the test is retried with \meta{location-1} set to
group 3 of the first pattern match and \meta{location-2} set to
group 3 of the second pattern match.
  \end{itemize}
\item\label{itm:decmatch} If both \meta{location-1} and \meta{location-2} match the
pattern
\begin{verbatim}
(.*?)([^\p{javaDigit}]?)(\p{javaDigit}+)
\end{verbatim}
then:
  \begin{enumerate}
  \item\label{itm:decgrp3eq} if group 3 of both pattern matches are
equal then:
  \begin{enumerate}
   \item\label{itm:decgrp3nz} if group 3 isn't zero, the locations
aren't considered consecutive;
   \item if the separators (group 2) are different the test is
retried with \meta{location-1} set to the concatenation of the first
two groups \meta{group-1}\meta{group-2} of the first pattern match 
and \meta{location-2} set to the concatenation of the first two groups
\meta{group-1}\meta{group-2} of the second pattern
match;
   \item\label{itm:decgrp3eqsepeq} if the separators (group 2) are the same the test is
retried with \meta{location-1} set to the first
group \meta{group-1} of the first pattern match 
and \meta{location-2} set to the first group
\meta{group-1} of the second pattern match.
  \end{enumerate}
  \item If \meta{group-1} of the first pattern match (of
\meta{location-1}) doesn't equal
\meta{group-1} of the second pattern match (of \meta{location-2})
or \meta{group-2} of the first pattern match (of
\meta{location-1}) doesn't equal
\meta{group-2} of the second pattern match (of \meta{location-2})
then the locations aren't considered consecutive;
   \item\label{itm:decgrp3} If $0 < l_2 - l_1 \leq d $
where $l_2$ is \meta{group 3} of the second pattern match,
$l_1$ is \meta{group 3} of the first pattern match and
$d$ is the value of \optfmt{max-loc-diff} then the locations
are consecutive otherwise they're not consecutive.
  \end{enumerate}
\item\label{itm:rommatch} The next pattern matches for \meta{prefix}\meta{sep}\meta{n}
where \meta{n} is a lower case Roman numeral, which is converted to
a decimal value and the test is performed in the same way as the 
above \hyperref[itm:decmatch]{decimal test}.
\item\label{itm:Rommatch} The next pattern matches for \meta{prefix}\meta{sep}\meta{n}
where \meta{n} is an upper case Roman numeral, which is converted to
a decimal value and the test is performed
in the same way as the above \hyperref[itm:decmatch]{decimal test}.
\item\label{itm:alphmatch} The next pattern matches for \meta{prefix}\meta{sep}\meta{c}
where \meta{c} is either a lower case letter from \texttt{a} to
\texttt{z} or an upper case letter from \texttt{A} to \texttt{Z}.
The character is converted to its code point and the test is
performed in the same way as the \hyperref[itm:decmatch]{decimal pattern} above.
\item\label{itm:nomatch} If none of the above, the locations aren't considered
consecutive.
\end{enumerate} 

Examples:
\begin{enumerate}
\item
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{1}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{2}
\end{verbatim}
These records are consecutive. The prefix, counter and format are
identical (so the test passes step~\ref{itm:pre}), the locations match
the \hyperref[itm:decmatch]{decimal pattern} and the test in
step~\ref{itm:decgrp3} passes.

\item
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{1}
\glsxtr@record{gls.sample}{}{page}{textbf}{2}
\end{verbatim}
These records aren't consecutive since the formats are different.

\item
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{A.i}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{A.ii}
\end{verbatim}
These records are consecutive. The prefix, counter and format are
identical (so it passes step~\ref{itm:pre}). The locations match
the \hyperref[itm:rommatch]{lower case Roman numeral pattern}, where
\texttt{A} is considered a prefix and the dot is consider a
separator. The Roman numerals i and ii are converted to decimal and
the test is retried with the locations set to 1 and 2, respectively.
This now passes the decimal pattern test (step~\ref{itm:decgrp3}).

\item
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{i.A}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{ii.A}
\end{verbatim}
These records aren't consecutive. They match the
\hyperref[itm:alphmatch]{alpha pattern}. The first location is
considered to consist of the prefix \texttt{i}, the separator
\texttt{.} (dot) and the number given by the character code of A. 
The second location is considered to consist of the prefix
\texttt{ii}, the separator \texttt{.} (dot) and the number 
given by the character code of A.

The test fails because the numbers are equal and the prefixes are
different.

\item
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{1.0}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{2.0}
\end{verbatim}
These records are consecutive. They match the \hyperref[itm:decmatch]{decimal
pattern}, and then step~\ref{itm:decgrp3eq} followed by
step~\ref{itm:decgrp3eqsepeq}. The \texttt{.0} part is discarded and
the test is retried with the first location set to 1 and the second
location set to 2.

\item
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{1.1}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{2.1}
\end{verbatim}
These records aren't consecutive as the test branches off into
step~\ref{itm:decgrp3nz}.

\item
\begin{verbatim}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{\@alph{1}}
\glsxtr@record{gls.sample}{}{page}{glsnumberformat}{\@alph{2}}
\end{verbatim}
These records are consecutive. The locations match the 
\hyperref[itm.csmatch]{control sequence pattern}. The control
sequences are the same, so the test is retried with the first
location set to 1 and the second location set to 2.
(Note that \csref{glsxtrresourcefile} changes the category code of
\texttt{@} to allow for internal commands in locations.)
\end{enumerate}

\subsection{\csoptnv{max-loc-diff}\csopteqval{value}}
\labelopt{max-loc-diff}

This setting is used to determine whether two locations are
considered consecutive.
The value must be an integer greater than or equal to 1.
(The default is \optfmt{1}.)

For two locations, \meta{location-1} and \meta{location-2},
that have numeric values $n_1$ and $n_2$ (and identical prefix,
counter and format), then the sequence \meta{location-1},
\meta{location-2} is considered consecutive if
\[
0 < n_2 - n_1 \leq \text{\meta{max-loc-diff}}
\]
The default value of 1 means that \meta{location-2} immediately
follows \meta{location-1} if $n_2 = n_1+1$.

For example, if \meta{location-1} is \qt{B} and \meta{location-2} 
is \qt{C}, then $n_1 = 66$ and $n_2 = 67$. Since $n_2 = 67 = 66+1=
n_1+1$ then \meta{location-2} immediately follows \meta{location-1}.

This is used in the range formations within the location lists.
So, for example, the list \qt{1, 2, 3, 5, 7, 8, 10, 11, 12, 58, 59,
61} becomes
\qt{1--3, 5, 7, 8, 10--12, 58, 59, 61}.

The automatically indexing of commands like \cs{gls} means that
the location lists can become long and ragged. You could
deal with this by switching off the automatic indexing and
only explicitly index pertinent use or you can adjust
the value of \optfmt{max-loc-diff} so that a range can be formed even
there are one or two gaps in it.
By default, any location ranges that have skipped gaps in this
manner will be followed by \csref{bibglspassim}. The default
definition of this command is obtained from the resource file.
For English, this is \verb*| passim| (space followed by \qt{passim}).

So with the above set of locations, if \csopt[2]{max-loc-diff} then 
the list becomes \qt{1--12 passim, 58--61 passim} which now highlights that
there are two blocks within the document related to that
term.

\subsection{\csoptnv{suffixF}\csopteqval{value}}
\labelopt{suffixF}

If set, a range consisting of two consecutive locations 
\meta{loc-1} and \meta{loc-2} will be
displayed in the location list as \meta{loc-1}\meta{value}.

Note that \csopt[\empty]{suffixF} sets the suffix to the
empty string. To remove the suffix formation use
\csopt[none]{suffixF}.

The default is \csopt[none]{suffixF}.

\subsection{\csoptnv{suffixFF}\csopteqval{value}}
\labelopt{suffixFF}

If set, a range consisting of three or more consecutive locations 
\meta{loc-1} and \meta{loc-2} will be
displayed in the location list as \meta{loc-1}\meta{value}.

Note that \csopt[\empty]{suffixFF} sets the suffix to the
empty string. To remove the suffix formation use
\csopt[none]{suffixFF}.

The default is \csopt[none]{suffixFF}.

\subsection{\csoptnv{see}\csopteqval{value}}
\labelopt{see}

If an entry has a \field{see} field, this can be placed before or
after the location list, or completely omitted (but the value will
still be available in the \field{see} field for use with
\cs{glsxtrusesee}). This option may take the following values:
\begin{itemize}
\item \optfmt{omit}: omit the see reference from the location
list.
\item \optfmt{before}: place the see reference before the location
list.
\item \optfmt{after}: place the see reference after the location
list (default).
\end{itemize}
The \meta{value} part is required.

The separator between the location list and the cross-reference is
provided by \csref{bibglsseesep}. This separator is omitted if the
location list is empty. The cross-reference is written to the
\field{location} field using \cs{glsxtrusesee}\margm{label}.

\subsection{\csoptnv{seealso}\csopteqval{value}}
\labelopt{seealso}

This is like \optref{see} but governs the location of the cross-references
provided by the \field{seealso} field. You need at least v1.16
of \sty{glossaries-extra} for this option. The values are the
same as for \optref{see} but the separator is given by
\csref{bibglsseealsosep}. The cross-reference is written to the
\field{location} field using \cs{glsxtruseseealso}\margm{label}.

\subsection{\csoptnv{alias-loc}\csopteqval{value}}
\labelopt{alias-loc}

If an entry has an \field{alias} field, the location list
may be retained or omitted or transferred to the target entry.
The \meta{value} may be one of:
\begin{itemize}
\item\optfmt{keep}: keep the location list;
\item\optfmt{transfer}: transfer the location list;
\item\optfmt{omit}: omit the location list.
\end{itemize}
The default setting is \csopt[transfer]{alias-loc}.
In all cases, the target entry will be added to the \field{see}
field of the entry with the \field{alias} field, unless it
already has a \field{see} field (in which case the \field{see} value
is left unchanged).

Note that with \csopt[transfer]{alias-loc}, both the aliased
entry and the target entry must be in the same resource set.
(That is, both entries have been selected by the same instance of
\csref{glsxtrresourcefile}.) If you have \sty{glossaries-extra} version
1.12, you may need to redefine \cs{glsxtrsetaliasnoindex} to do
nothing if the location lists aren't showing correctly
with aliased entries. (This was corrected in version 1.13.)

\subsection{\csoptnv{loc-prefix}\csopteqval{value}}
\labelopt{loc-prefix}

The \csopt{loc-prefix} setting indicates that the location lists
should begin with \csref{bibglslocprefix}\margm{n}. The \meta{value} may
be one of the following:
\begin{itemize}
\item \optfmt{false}: don't insert \cs{bibglslocprefix}\margm{n} at the start
of the location lists (default).
\item \optfmt{\margm{prefix-1},\margm{prefix-2},\ldots,\margm{prefix-n}}:
insert \cs{bibglslocprefix}\margm{n} (where \meta{n} is the number of
locations in the list) at the start of each location list and the
definition of \cs{bibglslocprefix} will be appended to the glossary
preamble providing an \cs{ifcase} condition:
\begin{alltt}
\cs{providecommand}\marg{\cs{bibglslocprefix}}[1]\marg{\%
  \cs{ifcase}\string#1
  \csfmt{or} \meta{prefix-1}\csref{bibglspostlocprefix}
  \csfmt{or} \meta{prefix-2}\csfmt{bibglspostlocprefix}
  \ldots
  \csfmt{else} \meta{prefix-n}\csfmt{bibglspostlocprefix}
  \csfmt{fi}
}
\end{alltt}

\item \optfmt{list}: equivalent to \csopt[\cs{pagelistname} ]{loc-prefix}.
\item \optfmt{true}: equivalent to 
\csopt[\csref{bibglspagename},\csref{bibglspagesname}]{loc-prefix},
where the definitions of \cs{bibglspagename} and
\cs{bibglspagesname} are obtained from the \texttt{tag.page} and
\texttt{tag.pages} entries in \bibgls's \langxml.
This setting works best if the document's language matches the 
language file. However, you can redefine these commands within
the document's language hooks or in the glossary preamble.
\end{itemize}

If \meta{value} is omitted, \optfmt{true} is assumed. Take care not
to mix different values of \csopt{loc-prefix} for entries for the
same \csopt{type} setting. It's okay to mix \csopt[false]{loc-prefix} with 
another value, but don't mix non-\optfmt{false} values. 
See the description of \csref{bibglslocprefix} for
further details.

For example:
\begin{verbatim}
\GlsXtrLoadResources[type=main,src={entries1},loc-prefix=false]
\GlsXtrLoadResources[type=main,src={entries2},loc-prefix]
\GlsXtrLoadResources[type=symbols,src={entries3},loc-prefix={p.,pp.}]
\end{verbatim}
This works since the conflicting \csopt[p.,pp.]{loc-prefix} and
\csopt[true]{loc-prefix} are in different glossaries (assigned through the
\optref{type} key). The entries fetched from \texttt{entries1.bib}
won't have a location prefix. The entries fetched from
\texttt{entries2.bib} will have the location prefix obtained from
the language resource file. The entries fetched from
\texttt{entries3.bib} will have the location prefix \qt{p.}\ or
\qt{pp.} (Note that using the \csopt{type} option isn't the same as
setting the \field{type} field for each entry in the \ext{bib}
file.)

If the \csopt{type} option isn't used:
\begin{verbatim}
\GlsXtrLoadResources[src={entries1},loc-prefix=false]
\GlsXtrLoadResources[src={entries2},loc-prefix]
\GlsXtrLoadResources[src={entries3},loc-prefix={p.,pp.}]
\end{verbatim}
then \csopt[true]{loc-prefix} takes precedence over
\csopt[p.,pp.]{loc-prefix} (since it was used first). The entries fetched from
\texttt{entries1.bib} still won't have a location prefix, but the entries
fetched from both \texttt{entries2.bib} and \texttt{entries3.bib}
have the location prefixes obtained from the language resource file.

\subsection{\csoptnv{loc-suffix}\csopteqval{value}}
\labelopt{loc-suffix}

This is similar to \optref{loc-prefix} but there are some subtle
differences. In this case \meta{value} may either be the keyword 
\optfmt{false} (in which case the location suffix is omitted)
or a comma-separated list
\optfmt{\meta{suffix-0}\dcomma\meta{suffix-1}\dcomma\ldots\dcomma\meta{suffix-n}}
where \meta{suffix-0} is the suffix to use when the location list
only has a cross-reference with no locations, \meta{suffix-1} is the suffix to use
when the location list has one location (optionally with a
cross-reference), and so on. The final \meta{suffix-n} in the list
is the suffix when the location list has \meta{n} or more locations
(optionally with a cross-reference).

This option will append \csref{bibglslocsuffix}\margm{n} to location
lists that either have a cross-reference or have at least one location.
Unlike \cs{bibglslocprefix}, this command isn't used when the
location list is completely empty. Also, unlike
\cs{bibglslocprefix}, this suffix command doesn't have an equivalent
to \cs{bibglspostlocprefix}.

If \meta{value} omitted, \csopt[\cs{@}.]{loc-suffix} is assumed.
The default is \csopt[false]{loc-suffix}.

As with \optref{loc-prefix}, take care not to mix different values
of \csopt{loc-suffix} for entries in the same glossary type.

\subsection{\csoptnv{loc-counters}\csopteqval{list}}
\labelopt{loc-counters}

Commands like \cs{gls} allow you to select a different 
counter to use for the location for that specific instance
(overriding the default counter for the entry's glossary type).
This is done with the \glsopt{counter} option. For example,
consider the following document:
\begin{verbatim}
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[record,style=tree]{glossaries-extra}

\GlsXtrLoadResources[
  src={entries}% data in entries.bib
]

\begin{document}

\gls{pi}.

\begin{equation}
\gls[counter=equation]{pi}
\end{equation}

\begin{equation}
\gls[counter=equation]{pi}
\end{equation}

\newpage

\begin{equation}
\gls[counter=equation]{pi}
\end{equation}


\newpage

\gls{pi}.

\newpage

\gls{pi}.

\newpage

\gls{pi}.

\newpage

\printunsrtglossaries
\end{document}
\end{verbatim}
This results in the location list \qt{1, 1--3, 3--5}. This
looks a little odd and it may seem as though the range formation
hasn't worked, but the locations are actually: page~1, equation~1,
equation~2, equation~3, page~3, page~4 and page~5. Ranges can't
be formed across different counters.

The \csopt[\meta{list}]{loc-counters} option instructs \bibgls\ 
to group the locations according to the counters given in
the comma-separated \meta{list}. If a location has a counter
that's not listed in \meta{list}, then the location is discarded.

For example:
\begin{verbatim}
\GlsXtrLoadResources[
  loc-counters={equation,page},% group locations by counter
  src={entries}% data in entries.bib
]
\end{verbatim}
This will first list the locations for the \counter{equation}
counter and then the locations for the \counter{page} counter.
Each group of locations is encapsulated within the command
\csref{bibglslocationgroup}\margm{n}\margm{counter}\margm{locations}.
The groups are separated by \csref{bibglslocationgroupsep}
(which defaults to \cs{delimN}).

The \meta{list} value must be non-empty.  Use
\csopt[as-use]{loc-counters} to restore the default behaviour, where
the locations are listed in the document order of use, or
\csopt[false]{save-locations} to omit the location lists.  Note that
you can't form counter groups from
\hyperref[sec:supplementalopts]{supplemental location lists}.

\section{Supplemental Locations}
\label{sec:supplementalopts}

\emph{These options require at least version 1.14 of \sty{glossaries-extra}.}

\subsection{\csoptnv{supplemental-locations}\csopteqval{basename}}
\labelopt{supplemental-locations}

The \sty{glossaries-extra} package (from v1.14) provides a way of
manually adding locations in supplemental documents through the use
of the \glsaddopt{thevalue} option in the optional argument of
\cs{glsadd}.  Setting values manually is inconvenient and can result
in errors, so \bibgls\ provides a way of doing this automatically.
Both the main document and the supplementary document need to use
the \styopt{record} option. The entries provided in the \csopt{src}
set must have the same labels as those used in the supplementary
document. (The simplest way to achieve this is to ensure that both
documents use the same \ext{bib} files and the same prefixes.)

For example, suppose the file \filefmt{entries.bib} contains:
\begin{verbatim}
@entry{sample,
  name={sample},
  description="an example entry"
}

@abbreviation{html,
  short="html",
  long={hypertext markup language}
}
@abbreviation{ssi,
  short="ssi",
  long="server-side includes"
}

@index{goose,plural="geese"}
\end{verbatim}
Now suppose the supplementary document is contained in the file
\filefmt{suppl.tex}:
\begin{verbatim}
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[record,counter=section]{glossaries-extra}

\GlsXtrLoadResources[src=entries]

\renewcommand{\thesection}{S\arabic{section}}
\renewcommand{\theHsection}{\thepart.\thesection}

\begin{document}
\part{Sample Part}
\section{Sample Section}
\gls{goose}. \gls{sample}.

\part{Another Part}
\section{Another Section}
\gls{html}.
\gls{ssi}.

\printunsrtglossaries
\end{document}
\end{verbatim}
This uses the \counter{section} counter for the locations and has a
prefix (\verb|\thepart.|) for the section hyperlinks.

Now let's suppose I have another document called \filefmt{main.tex}
that uses the \texttt{sample} entry, but also needs to include the
location (S1) from the supplementary document. The manual approached
offered by \sty{glossaries-extra} is quite cumbersome and requires
setting the \catattr{externallocation} attribute and using
\cs{glsadd} with \glsaddopt[S1]{thevalue}, \glsaddopt[I.S1]{theHvalue}
and \glsaddopt[glsxtrsupphypernumber]{format}.

This can be simplified with \bibgls\ by using the
\optfmt{supplemental-locations} option. The value should be the base
name (without the extension) of the supplementary document
(\optfmt{suppl} in the above example). For example:
\begin{verbatim}
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[
 supplemental-locations=suppl,% fetch records from suppl.aux
 src=entries]

\begin{document}
\Gls{sample} document.

\printunsrtglossaries

\end{document}
\end{verbatim}
The location list for \texttt{sample} will now be \qt{1, S1} (page~1
from the main document and S1 from the supplementary document). Note
that the original location format from the supplementary document
will be replaced by \optfmt{glsxtrsupphypernumber}, which will
produce an external hyperlink if the main document loads the
\sty{hyperref} package. (Note that not all PDF viewers can handle
external hyperlinks, and some that can open the external PDF file may not 
recognise the destination within that file.)

The supplementary locations lists are encapsulated within
\cs{bibglssupplemental}.

\subsection{\csoptnv{supplemental-selection}\csopteqval{value}}
\labelopt{supplemental-selection}

In the above example, only the \texttt{sample} entry is listed in
the main document, even though the supplementary document also
references the \texttt{goose}, \texttt{html} and \texttt{ssi}
entries. By default, only those entries that are referenced in the
main document will have supplementary locations added (if found in
the supplementary document's \ext{aux} file). You can additionally
include other entries that are referenced in the supplementary
document but not in the main document using
\optfmt{supplemental-selection}. The \meta{value} may be one of the
following:
\begin{itemize}
\item \optfmt{all}: add all the entries in the supplementary
document that have been defined in the \ext{bib} files listed in
\optref{src} for this resource set in the main document.
\item \optfmt{selected}: only add supplemental locations for entries
that have already been selected by this resource set.
\item \meta{label-1},\ldots,\meta{label-2}: in addition to all those
entries that have already been selected by this resource set, also
add the entries identified in the comma-separated list. If a label
in this list doesn't have a record in the supplementary document's
\ext{aux} file, it will be ignored.
\end{itemize}
Any records in the supplementary \ext{aux} file that aren't defined
by the current resource set (through the \ext{bib} files listed in
\optref{src}) will be ignored. Entry aliases aren't taken into
account when including supplementary locations.

For example:
\begin{verbatim}
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[
 supplemental-locations=suppl,
 supplemental-selection={html,ssi},
 src=entries]

\begin{document}
\Gls{sample} document.

\printunsrtglossaries

\end{document}
\end{verbatim}
This will additionally add the \texttt{html} and \texttt{ssi} entries
even though they haven't been used in this document. The
\texttt{goose} entry used in the supplementary document won't be
included.

If an entry has both a main location list and a supplementary
location list (such as the \texttt{sample} entry above), the lists
will be separated by \csref{bibglssupplementalsep}.

\subsection{\csoptnv{supplemental-category}\csopteqval{value}}
\labelopt{supplemental-category}

The \optfmt{category} for entries containing supplemental location
lists may be set using \optfmt{supplemental\dhyphen category}. If unset,
\meta{value} defaults to the same as that given by the
\optref{category} option. The \meta{value} may either be a known
identifier (as per \optref{category}) or the category label. For example:
\begin{verbatim}
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[
 supplemental-locations=suppl,
 supplemental-selection={html,ssi},
 supplemental-category={supplemental},
 src=entries]

\begin{document}
\Gls{sample} document.

\printunsrtglossaries

\end{document}
\end{verbatim}

\section{Sorting}
\label{sec:sortingopts}

Entries are typically sorted (for example, alphabetically
or in order of use), but the \sty{glossaries-extra} package
is versatile enough to be used in wider contexts than simple
terms, symbols or abbreviations. For example, entries could
contain theorems or problems where the \field{name} supplies
the title and the \field{description} provides a description
of the theorem or problem. Another field might then contain
the proof or solution. Therefore, somewhat unusually for
an indexing application, \bibgls\ also provides the option
to shuffle the entries instead of sorting them.

\subsection{\csoptnv{sort}\csopteqval{value}}
\labelopt{sort}

The \csopt{sort} key indicates how entries should be sorted. The
\meta{value} may be one of:
\begin{itemize}

\item \optfmt{none} (or \optfmt{unsrt}): don't sort the entries.
(The entries will be in the order they were processed when parsing
the data.)

\item \optfmt{random}: shuffles rather than sorts the entries.
This won't work if there are hierarchical entries, so it's best
to use this option with \optref{flatten}. The seed for the
random generator can be set using \optref{shuffle} (which
also automatically sets \csopt[random]{sort} and \csopt{flatten}).

\item \meta{lang tag}: sort according to the rules of the locale
given by the \gls{IETF} language tag \meta{lang tag}. (Use with
\optref{break-at} to determine whether or not to split at word
boundaries.)

\item \optfmt{locale}: equivalent to 
\csopt[\meta{lang tag}]{sort} where \meta{lang tag} is obtained
from the operating system (or Java Runtime Environment).

\item \optfmt{doc}: sort the entries according to the document
language. This is equivalent to \optref[\meta{lang tag}]{sort}
where \meta{lang tag} is the locale associated with the document
language. In the case of a multi-lingual document, \meta{lang tag}
is the locale of the last language resource file to be loaded through
\sty{tracklang}'s interface. It's best to explicitly set the locale
for multi-lingual documents to avoid confusion. If no languages have been tracked, this
option is equivalent to \csopt[locale]{sort}.

\item \optfmt{custom}: sort the entries according to the 
rule provided by \optref{sort-rule}.

\item \optfmt{use}: sort in order of use. (This order is determined
by the records written to the \ext{aux} file by the \styopt{record}
package option.)

\item \optfmt{letter-case}: case-sensitive letter (character code) sort.

\item \optfmt{letter-case-reverse}: reverse case-sensitive letter (character code) sort.

\item \optfmt{letter-nocase}: case-insensitive letter (character code) sort.
Use \csopt[\meta{lang tag}]{sort} with \csopt[none]{break-at} to
emulate \app{xindy}'s locale letter ordering.

\item \optfmt{letter-nocase-reverse}: reverse case-insensitive letter (character code) sort.

\item \optfmt{integer}: integer sort. This is for integer sort
values. Any value that isn't an integer is treated as 0.

\item \optfmt{integer-reverse}: as above but reverses the order.

\item \optfmt{hex}: hexadecimal integer sort. This is for
hexadecimal sort values. Any value that isn't a hexadecimal number 
is treated as 0.

\item \optfmt{hex-reverse}: as above but reverses the order.

\item \optfmt{octal}: octal integer sort. This is for
octal sort values. Any value that isn't a octal number 
is treated as 0.

\item \optfmt{octal-reverse}: as above but reverses the order.

\item \optfmt{binary}: binary integer sort. This is for binary sort
values. Any value that isn't a binary number is treated as 0.

\item \optfmt{binary-reverse}: as above but reverses the order.

\item \optfmt{float}: single-precision sort. This is for
decimal sort values. Any value that isn't a decimal is treated as 0.0.

\item \optfmt{float-reverse}: as above but reverses the order.

\item \optfmt{double}: double-precision sort. This is for
decimal sort values. Any value that isn't a decimal is treated as 0.0.

\item \optfmt{float-reverse}: as above but reverses the order.

\end{itemize}
If the \meta{value} is omitted, \csopt[doc]{sort} is assumed. If the
\csopt{sort} option isn't used then \csopt[locale]{sort} is assumed.

Note that \csopt[locale]{sort} can provide more detail about the
locale than \csopt[doc]{sort}, depending on how the document
language has been specified.

For example, with:
\begin{verbatim}
\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[record]{glossaries}
\GlsXtrLoadResources[src={german-terms}]
\end{verbatim}
the language tag will be \texttt{de-1996}, which doesn't have an
associated region. Whereas with
\begin{verbatim}
\documentclass[de-DE-1996]{article}
\usepackage[ngerman]{babel}
\usepackage[record]{glossaries}
\GlsXtrLoadResources[src={german-terms}]
\end{verbatim}
the language tag will be \texttt{de-DE-1996} because \sty{tracklang}
has picked up the locale from the document class options. This is
only likely to cause a difference if a language has different
sorting rules according to the region or if the language may be
written in multiple scripts.

A multilingual document will need to have the \csopt{sort} specified
when loading the resource to ensure the correct language is chosen. 
For example:
\begin{verbatim}
\GlsXtrLoadResources[src={english-terms},sort={en-GB}]
\GlsXtrLoadResources[src={german-terms},sort={de-DE-1996}]
\end{verbatim}

\subsection{\csoptnv{sort-rule}\csopteqval{value}}
\labelopt{sort-rule}

If the \optref[custom]{sort} option is used, the sort rule
must be provided with \optfmt{sort-rule}. In this case
the collation is performed using Java's
\href{http://docs.oracle.com/javase/8/docs/api/java/text/RuleBasedCollator.html}{RuleBasedCollator}
class. Remember that the options will be expanded as they
are written to the \ext{aux} file, so be careful of
any special characters that occur in the rule. You can
use \cs{string}\cs{u}\meta{hex} (where \meta{hex} is a hexadecimal
code) to represent a Unicode character. For example:
\begin{verbatim}
\GlsXtrLoadResources[
  sort={custom},
  sort-rule={< a,A < b,B < c,C < ch,Ch,CH < d,D
   < dd,Dd,DD < e,E < f,F < ff,Ff,FF
   < g,G < ng,Ng,NG < h,H < ij,Ij,IJ
   < i,I < j,J < k,K < l,L < ll,Ll,LL < m,M
   < n,N < o,O < p,P < ph,Ph,PH < q,Q < r,R < rh,Rh,RH
   < s,S < t,T < th,Th,TH < u,U < v,V < w,W < x,X < y,Y < z,Z
   < \string\u00E6,\string\u00C6}
]
\end{verbatim}
You can also use \cs{protect} instead of \cs{string}. This will
cause a space to appear between \cs{u} and the hexadecimal
value in the \ext{aux} file (if \meta{hex} starts with a decimal
digit), but \bibgls\ will accept a single space between \cs{u} and
\meta{hex} to allow for this.  However it's safer to just use
\cs{string} (in case \meta{hex} start with a letter).

If \optref{sort} is not set to \optfmt{custom}, the
\optfmt{sort-rule} setting will be ignored.

\subsection{\csoptnv{break-at}\csopteqval{option}}
\labelopt{break-at}

The rule-based sort options (\csopt[\meta{lang tag}]{sort}
and \csopt[custom]{sort}) typically list punctuation characters
(such as space) before alphabetical characters. This means that
the rule-based sort options are naturally in a letter order, similar
to \app{xindy}'s \texttt{ord/letorder} module. This isn't the same
as \csopt[letter-nocase]{sort} as the locale letter ordering is rule-based
rather than according to the Unicode value.

In order to replicate \app{makeindex} and \app{xindy}'s default word
order, \bibgls\ splits up the sort value at word boundaries and
inserts a marker (identified by \optref{break-marker}).

For example, if the sort value is \qt{sea lion} then it's actually
converted to \verb"sea|lion|" whereas \qt{sea} becomes \verb"sea|"
and \qt{seal} becomes \verb"seal|". The default marker is \verb"|"
which is commonly placed in collation rules before digits but 
after the ignored characters, such as spaces and hyphens.

You can change where the break points are inserted with
\csopt[\meta{option}]{break-at} where \meta{option} may be one of:
\begin{itemize}
\item \optfmt{word}: break at word boundaries (default).
For example, the sort value \qt{Tom, Dick, and Harry} becomes 
\verb"Tom|Dick|and|Harry".
\item \optfmt{character}: break after each character.
\item \optfmt{sentence}: break after each sentence.
\item \optfmt{none}: don't create break points. Use this option to
emulate \app{makeindex} or \app{xindy}'s letter ordering.
\end{itemize}

This option is ignored when used with the non-locale \csopt{sort} options.
Use the \argref{debug} switch to show the break points.
(This will also show the collation rule.)

\subsection{\csoptnv{break-marker}\csopteqval{marker}}
\labelopt{break-marker}

The break marker can be changed using
\csopt[\meta{marker}]{break-marker}, where \meta{marker} is 
the character to use. For example, \csopt[-]{break-marker} will use a
hyphen. The marker may be empty, which effectively strips the
inter-word punctuation. For example, with
\csopt[\empty]{break-marker}, \qt{Tom, Dick, and Harry} becomes
\texttt{TomDickandHarry} and \qt{sea lion} simply becomes
\texttt{sealion}. If \meta{marker} is omitted,
\csopt[\empty]{break-marker} is assumed.

\subsection{\csoptnv{sort-field}\csopteqval{field}}
\labelopt{sort-field}

The \csopt{sort-field} key indicates which field provides the sort
value. The default is the \field{sort} field. For example
\begin{verbatim}
\GlsXtrLoadResources[
 src={entries-terms},% data in entries-terms.bib
 sort-label=category,% sort by 'category' field
 sort=letter-case% case-sensitive letter sort
]
\end{verbatim}
This sorts the entries according to the \field{category} field using
a case-sensitive letter comparison.
You may also use \csopt[id]{sort-field} to sort according to
the label.

If an entry is missing a value for \meta{field}, then the value of
the fallback field will be used instead. For example, with the
default \csopt[sort]{sort-field}, then for an entry defined with
\atentry{entry}, if the \field{sort} field is missing the fallback
field will be the \field{name} or the \field{parent} field if the
\field{name} field is missing. If the entry is instead defined with
\atentry{abbreviation} (or \atentry{acronym}) then if the
\field{sort} field is missing, \bibgls\ will start with the same
fallback as for \atentry{entry} but if neither the \field{name} or
\field{parent} field is set, it will fallback on the \field{short}
field.

If no fallback field can be found, the entry's label will be used.

\subsection{\csoptnv{shuffle}\csopteqval{seed}}
\labelopt{shuffle}

Automatically sets \csopt[random]{sort} and \csopt{flatten}.
The value \meta{seed} may be omitted. If present, it should
be an integer used as a seed for the random number generator.

\subsection{\csoptnv{strength}\csopteqval{value}}
\labelopt{strength}

The collation strength used by \csopt[\meta{locale}]{sort} can be set
to the following values: \optfmt{primary} (default),
\optfmt{secondary}, \optfmt{tertiary} or \optfmt{identical}. These
indicate the difference between two characters, but the exact
assignment is locale dependent. See the documentation for Java's
\href{http://docs.oracle.com/javase/8/docs/api/java/text/Collator.html}{\texttt{Collator}
class} for further details.

For example, suppose the file \filefmt{entries.bib} contained:
\begin{verbatim}
@index{resume}

@index{RESUME}

@index{resumee,
 name={r\'esum\'e}}

@index{rat}

@index{rot}

@index{aardvark}

@index{zoo}
\end{verbatim}
and the document contained:
\begin{verbatim}
\documentclass{article}

\usepackage[record]{glossaries-extra}

\GlsXtrLoadResources[sort={en},src={entries}]

\begin{document}
\gls{resumee}, \gls{resume}, \gls{RESUME},
\gls{aardvark}, \gls{rat}, \gls{rot}, \gls{zoo}.

\printunsrtglossaries
\end{document}
\end{verbatim}
then this uses the default \csopt[primary]{strength}, so the entries
are listed as aardvark, rat, r\'esum\'e, resume, RESUME, rot, zoo.

If the strength is changed to \optfmt{secondary}:
\begin{verbatim}
\GlsXtrLoadResources[sort={en},src={entries},strength=secondary]
\end{verbatim}
then the entries are listed as aardvark, rat, resume, RESUME,
r\'esum\'e, rot, zoo.

If the strength is changed to \optfmt{tertiary} or
\optfmt{identical}, there's no difference from
\csopt[secondary]{strength} for this particular example.

This option is ignored by non-locale sorts (such as letter or numeric).

\subsection{\csoptnv{decomposition}\csopteqval{value}}
\labelopt{decomposition}

The collation decomposition used by \csopt[\meta{locale}]{sort} can be set
to the following values: \optfmt{canonical} (default),
\optfmt{full} or \optfmt{none}. This determines how Unicode composed
characters are handled. The fastest mode is \optfmt{none} but is
only appropriate for languages without accents. The slowest mode is
\optfmt{full} but is the most complete for languages with non-ASCII
characters. See the documentation for Java's
\href{http://docs.oracle.com/javase/8/docs/api/java/text/Collator.html}{\texttt{Collator}
class} for further details.
This option is ignored by non-locale sorts (such as letter or numeric).

\section{Dual Entries}

\subsection{\csoptnv{dual-sort}\csopteqval{value}}
\labelopt{dual-sort}

This option indicates how to sort the dual entries. The primary
entries are sorted with the normal entries according to
\optref{sort}, and the dual entries are sorted according to
\csopt{dual-sort} unless \csopt[combine]{dual-sort} in which case the dual
entries will be combined with the primary entries and all the
entries will sorted together according to the \optref{sort} option.

If \meta{value} isn't set to \optfmt{combine} then the dual
entries are sorted separately according to \meta{value} (as per
\optref{sort}) and the dual entries will be appended at the end of
the \ext{glstex} file. The field used by the comparator is given by
\optref{dual-sort-field}.
If \csopt[custom]{dual-sort}, then the dual entries according to the 
rule provided by \optref{dual-sort-rule}.


For example:
\begin{verbatim}
\GlsXtrLoadResources[
 src={entries-dual},
 sort={en},
 dual-sort={de-CH-1996}
]
\end{verbatim}
This will sort the primary entries according to \optfmt{en}
(English) and the secondary entries according to \optfmt{de-CH-1996} 
(Swiss German new orthography) whereas:
\begin{verbatim}
\GlsXtrLoadResources[
 src={entries-dual},
 sort={en-GB},
 dual-sort={combine}
]
\end{verbatim}
will combine the dual entries with the primary entries and sort them
all according to the \optfmt{en-GB} locale (British English).

If not set, \csopt{dual-sort} defaults to \optfmt{combine}. If
\meta{value} is omitted, \optfmt{locale} is assumed.

\subsection{\csoptnv{dual-sort-field}\csopteqval{value}}
\labelopt{dual-sort-field}

This option indicates the field to use when sorting dual entries
(when they haven't been combined with the primary entries). The
default value is the same as the \optref{sort-field} value.

\subsection{\csoptnv{dual-sort-rule}\csopteqval{value}}
\labelopt{dual-sort-rule}

As \optref{sort-rule} but for \csopt[custom]{dual-sort}.

\subsection{\csoptnv{dual-prefix}\csopteqval{value}}
\labelopt{dual-prefix}

This option indicates the prefix to use for the dual entries. The
default value is \idprefix{dual} (including the terminating period). 
Any references to dual entries within the \ext{bib} file should use
the prefix \idprefix{dual} which will be replaced by \meta{value}
when the \ext{bib} file is parsed.

\subsection{\csoptnv{dual-type}\csopteqval{value}}
\labelopt{dual-type}

This option sets the \field{type} field for all dual
entries. (The primary entries obey the \optref{type} option.) This
will override any value of \field{type} provided in the \ext{bib}
file (or created through a mapping). The \meta{value} is required.

The \meta{value} may be:
\begin{itemize}
\item \optfmt{same as entry}: sets the
\field{type} to the entry type. For example, if the entry
was defined with \atentryref{dualentry}, the \field{type} will be
set to \optfmt{dualentry}.
\item \optfmt{same as primary}: sets the \field{type} to the same
as the corresponding primary entry's \field{type} (which may
have been set with \optref{type}). If the primary entry doesn't
have the \field{type} field set, the dual's \field{type} will
remain unchanged.
\item \meta{label}: sets the \field{type} field to \meta{label}.
\end{itemize}

Remember that the glossary with that label must have already 
been defined.

For example:
\begin{verbatim}
\newglossary*{english}{English}
\newglossary*{french}{French}

\GlsXtrLoadResources[src={entries},sort={en},dual-sort={fr},
 type=english,
 dual-type=french]
\end{verbatim}

Alternatively:
\begin{verbatim}
\newglossary*{dictionary}{Dictionary}

\GlsXtrLoadResources[src={entries},sort={en},dual-sort={fr},
 type=dictionary,
 dual-type={same as primary}]
\end{verbatim}

\subsection{\csoptnv{dual-category}\csopteqval{value}}
\labelopt{dual-category}

This option sets the \field{category} field for all dual
entries. (The primary entries obey the \optref{category} option.) This
will override any value of \field{category} provided in the \ext{bib}
file (or created through a mapping). The \meta{value} may be empty.

The \meta{value} may be:
\begin{itemize}
\item \optfmt{same as entry}: sets the
\field{category} to the entry type. For example, if the entry
was defined with \atentryref{dualentry}, the \field{category} will be
set to \optfmt{dualentry}.
\item \optfmt{same as primary}: sets the \field{category} to the same
as the corresponding primary entry's \field{category} (which may
have been set with \optref{category}). If the primary entry doesn't
have the \field{category} field set, the dual's \field{category} will
remain unchanged.
\item \optfmt{same as type}: sets the \field{category} to the same
as the value of the entry's \field{type} field (which may have been
set with \optref{dual-type}). If the entry doesn't
have the \field{type} field set, the \field{category} will
remain unchanged.
\item \meta{label}: sets the \field{category} field to \meta{label}.
\end{itemize}

\subsection{\csoptnv{dual-short-case-change}\csopteqval{value}}
\labelopt{dual-short-case-change}

As \optref{short-case-change} but applies to the \field{dualshort}
field instead.

\subsection{\csoptnv{dual-entry-map}=\marg{\margm{list1},\margm{list2}}}
\labelopt{dual-entry-map}

This setting governs the behaviour of \atentry{dualentry}
definitions. The value consists of two comma-separated lists of
equal length identifying the field mapping used to create the dual
entry from the primary one. Note that the \field{alias} field
can't be mapped.

The default setting is:
\begin{verbatim}
dual-entry-map=
{
  {name,plural,description,descriptionplural},
  {description,descriptionplural,name,plural}
}
\end{verbatim}
The dual entry is created by copying the value of the field in the
first list \meta{list1} to the field in the corresponding place in the second
list \meta{list2}. Any additional fields are copied over to the same
field.

For example:
\begin{verbatim}
@dualentry{cat,
  name={cat},
  description={chat},
  see={dog}
}
\end{verbatim}
defines two entries. The primary entry is essentially like
\begin{verbatim}
@entry{cat,
  name={cat},
  plural={cat\glspluralsuffix },
  description={chat},
  descriptionplural={chat\glspluralsuffix },
  see={dog}
}
\end{verbatim}
and the dual entry is essentially like
\begin{verbatim}
@entry{dual.cat,
  description={cat},
  descriptionplural={cat\glspluralsuffix },
  name={chat},
  plural={chat\glspluralsuffix },
  see={dog}
}
\end{verbatim}
(except they're defined using \cs{bibglsnewdualentry} instead of
\cs{bibglsnewentry}, and each is considered dependent on the other.)

The \field{see} field isn't listed in \csopt{dual-entry-map} so its
value is simply copied directly over to the \field{see} field in the
dual entry. Note that the missing plural fields (\field{plural} and
\field{descriptionplural}) have been filled in.

In general \bibgls\ doesn't try to supply missing fields, but in the
dual entry cases it needs to do this for the mapped fields. This is
because the shuffled fields might have different default values from
the \sty{glossaries-extra} package's point of view. For example, 
\cs{longnewglossaryentry} doesn't provide a default for
\field{descriptionplural} if if hasn't been set.

\subsection{\csoptnv{dual-abbrv-map}=\marg{\margm{list1},\margm{list2}}}
\labelopt{dual-abbrv-map}

This is like \csopt{dual-entry-map} but applies to
\atentry{dualabbreviation} rather than \atentry{dualentry}. 
Note that the \field{alias} field can't be mapped. The
default setting is:
\begin{verbatim}
dual-abbrv-map=
{
  {short,shortplural,long,longplural,dualshort,dualshortplural,
   duallong,duallongplural},
  {dualshort,dualshortplural,duallong,duallongplural,short,shortplural,
   long,longplural}
}
\end{verbatim}

This essentially flips the \field{short} field with the
\field{dualshort} field and the \field{long} field with the
\field{duallong} field. See \atentryref{dualabbreviation}
for further details.

\subsection{\csoptnv{dual-entryabbrv-map}=\marg{\margm{list1},\margm{list2}}}
\labelopt{dual-entryabbrv-map}

This is like \csopt{dual-entry-map} but applies to
\atentry{dualentryabbreviation} rather than \atentry{dualentry}. 
Note that the \field{alias} field can't be mapped. The
default setting is:
\begin{verbatim}
dual-entryabbrv-map=
{
  {long,short,shortplural},
  {name,text,plural}
}
\end{verbatim}
See \atentryref{dualentryabbreviation} for further details.


\subsection{\csoptnv{dual-symbol-map}=\marg{\margm{list1},\margm{list2}}}
\labelopt{dual-symbol-map}

This is like \csopt{dual-entry-map} but applies to
\atentry{dualsymbol} rather than \atentry{dualentry}. 
Note that the \field{alias} field can't be mapped. The
default setting is:
\begin{verbatim}
dual-symbol-map=
{
  {name,plural,symbol,symbolplural},
  {symbol,symbolplural,name,plural}
}
\end{verbatim}

This essentially flips the \field{name} field with the
\field{symbol} field.

\subsection{\csoptnv{dual-entry-backlink}\csopteqval{boolean}}
\labelopt{dual-entry-backlink}

This is a boolean setting.
When used with \atentry{dualentry}, if \meta{boolean} is
\optfmt{true}, this will wrap the contents of first mapped field
with \cs{glshyperlink}. If \meta{boolean} is missing \optfmt{true}
is assumed.

The field is obtained from the first mapping
listed in \csopt{dual-entry-map}.

For example, if the document contains:
\begin{verbatim}
\GlsXtrLoadResource[dual-entry-backlink,
dual-entry-map={
  {name,plural,description,descriptionplural},
  {description,descriptionplural,name,plural}
},
src={entries-dual}]
\end{verbatim}
and if the \ext{bib} file contains
\begin{verbatim}
@dualentry{child,
  name={child},
  plural={children},
  description={enfant}
}
\end{verbatim}
Then the definition of the primary entry (\texttt{child}) in the
\ext{glstex} file will have the \field{description} field set to
\begin{verbatim}
{\glshyperlink[enfant]{dual.child}}
\end{verbatim}
and the dual entry (\texttt{dual.child}) will have the
\field{description} field set to
\begin{verbatim}
{\glshyperlink[child]{child}}
\end{verbatim}

The reason the \field{description} field is chosen for the modification is
because the first field listed in the first list in \csopt{dual-entry-map} 
is the \field{name} field which maps to \field{description} (the
first field in the second list). This means that the hyperlink for
the dual entry should be put in the \field{description} field.

For the primary entry, the \field{name} field is looked up in the
second list from the \csopt{dual-entry-map} setting. This is the
third item in this second list, so the third item in the first list
is selected, which also happens to be the \field{description} field,
so the hyperlink for the primary entry is put in the
\field{description} field.

\subsection{\csoptnv{dual-abbrv-backlink}\csopteqval{boolean}}
\labelopt{dual-abbrv-backlink}

This is analogous to \csopt{dual-entry-backlink} but for entries
defined with \atentry{dualabbreviation} instead of
\atentry{dualentry}.

\subsection{\csoptnv{dual-symbol-backlink}\csopteqval{boolean}}
\labelopt{dual-symbol-backlink}

This is analogous to \csopt{dual-entry-backlink} but for entries
defined with \atentry{dualsymbol} instead of \atentry{dualentry}.

\subsection{\csoptnv{dual-entryabbrv-backlink}\csopteqval{boolean}}
\labelopt{dual-entryabbrv-backlink}

This is analogous to \csopt{dual-entry-backlink} but for entries
defined with \atentry{dualentryabbreviation} instead of
\atentry{dualentry}.

\subsection{\csoptnv{dual-backlink}\csopteqval{boolean}}
\labelopt{dual-backlink}

Shortcut for \csopt[\meta{boolean}]{dual-entry-backlink}, 
\csopt[\meta{boolean}]{dual-entryabbrv-backlink}, 
\csopt[\meta{boolean}]{dual-abbrv-backlink}, and
\csopt[\meta{boolean}]{dual-symbol-backlink}.

\subsection{\csoptnv{dual-field}\csopteqval{value}}
\labelopt{dual-field}

If this option is used, this will add \cs{glsxtrprovidestoragekey}
to the start of the \ext{glstex} file providing the key given by
\meta{value}.  Any entries defined using \atentry{dualentry}
will be written to the \ext{glstex} file with an extra field called
\meta{value} that is set to the mirror entry. If \meta{value} is
omitted \texttt{dual} is assumed.

For example, if the \ext{bib} file contains
\begin{verbatim}
@dualentry{child,
  name={child},
  plural={children},
  description={enfant}
}
\end{verbatim}
Then with \csopt[dualid]{dual-field} this will first add the line
\begin{verbatim}
\glsxtrprovidestoragekey{dualid}{}{}
\end{verbatim}
at the start of the file and will include the line
\begin{verbatim}
dualid={dual.child},
\end{verbatim}
for the primary entry (\texttt{child}) and the line
\begin{verbatim}
dualid={child},
\end{verbatim}
for the dual entry (\texttt{dual.child}). It's then possible to
reference one entry from the other. For example, the post-description 
hook could contain:
\begin{verbatim}
 \ifglshasfield{dualid}{\glscurrententrylabel}
 {%
   \space
   (\glshyperlink{\glsxtrusefield{\glscurrententrylabel}{dualid}})%
 }%
 {}%
\end{verbatim}
Note that this new field won't be available for use within the
\ext{bib} file (unless it was previously defined in the document
before \csref{glsxtrresourcefile}).

\chapter{Provided Commands}
\label{sec:bibglscs}

When \bibgls\ creates the \ext{glstex} file, it writes some
definitions for custom commands in the form \csfmt{bibgls...} which
may be changed as required. The command definitions all use
\cs{providecommand} which means that you can define the command with
\cs{newcommand} before the resource file is loaded.

\section{Entry Definitions}
\label{sec:newentrydefs}

This section lists the commands (\csfmt{bibglsnew...}) used to
define entries.  Note that the entry definition commands are
actually used when \TeX\ inputs the resource file, so redefining
them after the resource file is loaded won't have an effect on the
entries defined in that resource file (but will affect entries defined
in subsequent resource files). Each provided command is defined in
the \ext{glstex} file immediately before the first entry that
requires it, so only the commands that are actually needed are
provided.

After each entry is defined, if it has any associated locations, the
locations are added using
\begin{alltt}
\cs{glsxtrfieldlistadd}\margm{label}\marg{loclist}\margm{record}
\end{alltt}
This command is provided by \sty{glossaries-extra} (v1.12).


\subsection{\csfmt{bibglsnewentry}}
\labelcs{bibglsnewentry}

\begin{definition}
\cs{bibglsnewentry}\margm{label}\margm{options}\margm{name}\margm{description}
\end{definition}
This command is used to define terms identified with the
\atentryref{entry} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewentry}[4]{%
 \longnewglossaryentry*{#1}{name={#3},#2}{#4}%
}
\end{verbatim}
This uses the starred form of \cs{longnewglossaryentry} that
doesn't automatically append \cs{nopostdesc} (which interferes with
the post-description hooks provided by category attributes).

\subsection{\csfmt{bibglsnewsymbol}}
\labelcs{bibglsnewsymbol}

\begin{definition}
\cs{bibglsnewsymbol}\margm{label}\margm{options}\margm{name}\margm{description}
\end{definition}
This command is used to define terms identified with the
\atentryref{symbol} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewsymbol}[4]{%
 \longnewglossaryentry*{#1}{name={#3},sort={#1},category={symbol},#2}{#4}%
}
\end{verbatim}
Note that this sets the \field{sort} field to the label, but this
may be overridden by the \meta{options} if the \field{sort} field
was supplied or if \bibgls\ has determined the value whilst sorting
the entries.

This also sets the \field{category} to \optfmt{symbol}, but again this may
be overridden by \meta{options} if the entry had the \field{category}
field set in the \ext{bib} file or if the \field{category} was
overridden with \optref[\meta{value}]{category}.

\subsection{\csfmt{bibglsnewnumber}}
\labelcs{bibglsnewnumber}

\begin{definition}
\cs{bibglsnewnumber}\margm{label}\margm{options}\margm{name}\margm{description}
\end{definition}
This command is used to define terms identified with the
\atentryref{number} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewnumber}[4]{%
 \longnewglossaryentry*{#1}{name={#3},sort={#1},category={number},#2}{#4}%
}
\end{verbatim}
This is much the same as \cs{bibglsnewsymbol} above but sets the 
\field{category} to \optfmt{number}. Again the \field{sort} and
\field{category} keys may be overridden by \meta{options}.

\subsection{\csfmt{bibglsnewindex}}
\labelcs{bibglsnewindex}

\begin{definition}
\cs{bibglsnewindex}\margm{label}\margm{options}
\end{definition}
This command is used to define terms identified with the
\atentryref{index} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand*{\bibglsnewindex}[2]{%
 \newglossaryentry{#1}{name={#1},description={},#2}%
}
\end{verbatim}
This makes the \field{name} default to the \meta{label} and sets
an empty \field{description}. These settings may be overridden by
\meta{options}. Note that the \field{description} doesn't include
\cs{nopostdesc} to allow for the post-description hook used by
category attributes.

\subsection{\csfmt{bibglsnewabbreviation}}
\labelcs{bibglsnewabbreviation}

\begin{definition}
\cs{bibglsnewabbreviation}\margm{label}\margm{options}\margm{short}\margm{long}
\end{definition}
This command is used to define terms identified with the
\atentryref{abbreviation} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewabbreviation}[4]{%
  \newabbreviation[#2]{#1}{#3}{#4}%
}
\end{verbatim}
Since this uses \cs{newabbreviation}, it obeys the current
abbreviation style for its given \field{category} (which may have
been set in \meta{options}, either from the \field{category} field
in the \ext{bib} file or through the \optref{category} option).
Similarly the \field{type} will obey \cs{glsxtrabbrvtype} unless 
the value is supplied in the \ext{bib} file or through the
\optref{type} option.

\subsection{\csfmt{bibglsnewacronym}}
\labelcs{bibglsnewacronym}

\begin{definition}
\cs{bibglsnewacronym}\margm{label}\margm{options}\margm{short}\margm{long}
\end{definition}
This command is used to define terms identified with the
\atentryref{acronym} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewacronym}[4]{%
  \newacronym[#2]{#1}{#3}{#4}%
}
\end{verbatim}
This works in much the same way as \cs{bibglsnewabbreviation}.
Remember that with the \sty{glossaries-extra} package \cs{newacronym}
is redefined to just use \cs{newabbreviation} with the default \field{type}
set to \cs{acronymtype} and the default \field{category} set to
\cs{acronym}.

\subsection{\csfmt{bibglsnewdualentry}}
\labelcs{bibglsnewdualentry}

\begin{definition}
\cs{bibglsnewdualentry}\margm{label}\margm{options}\margm{name}\margm{description}
\end{definition}
This command is used to define terms identified with the
\atentryref{dualentry} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewdualentry}[4]{%
 \longnewglossaryentry*{#1}{name={#3},#2}{#4}%
}
\end{verbatim}

\subsection{\csfmt{bibglsnewdualentryabbreviation}}
\labelcs{bibglsnewdualentryabbreviation}

\begin{definition}
\cs{bibglsnewdualentryabbreviation}\margm{label}\margm{options}\margm{short}\margm{long}\margm{description}
\end{definition}
This command is used to define primary terms identified with the
\atentryref{dualentryabbreviation} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewdualentryabbreviation}[5]{%
  \newabbreviation[#2]{#1}{#3}{#4}%
}
\end{verbatim}
Note that this definition ignores the \meta{description} argument.

\subsection{\csfmt{bibglsnewdualentryabbreviationsecondary}}
\labelcs{bibglsnewdualentryabbreviationsecondary}

\begin{definition}
\cs{bibglsnewdualentryabbreviationsecondary}\margm{label}\margm{options}\margm{short}\margm{long}\margm{description}
\end{definition}
This command is used to define secondary terms identified with the
\atentryref{dualentryabbreviation} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewdualentryabbreviationsecondary}[5]{%
  \longnewglossaryentry*{#1}{#2}{#5}%
}
\end{verbatim}
Note that this definition ignores the \meta{short} and \meta{long}
arguments (which will typically be empty unless the default mappings
are changed).

\subsection{\csfmt{bibglsnewdualsymbol}}
\labelcs{bibglsnewdualsymbol}

\begin{definition}
\cs{bibglsnewdualsymbol}\margm{label}\margm{options}\margm{name}\margm{description}
\end{definition}
This command is used to define terms identified with the
\atentryref{dualsymbol} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewdualsymbol}[4]{%
 \longnewglossaryentry*{#1}{name={#3},sort={#1},category={symbol},#2}{#4}}
\end{verbatim}

\subsection{\csfmt{bibglsnewdualnumber}}
\labelcs{bibglsnewdualnumber}

\begin{definition}
\cs{bibglsnewdualnumber}\margm{label}\margm{options}\margm{name}\margm{description}
\end{definition}
This command is used to define terms identified with the
\atentryref{dualnumber} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewdualnumber}[4]{%
 \longnewglossaryentry*{#1}{name={#3},sort={#1},category={symbol},#2}{#4}}
\end{verbatim}

\subsection{\csfmt{bibglsnewdualabbreviation}}
\labelcs{bibglsnewdualabbreviation}

\begin{definition}
\cs{bibglsnewdualabbreviation}\margm{label}\margm{options}\margm{short}\margm{long}
\end{definition}
This command is used to define terms identified with the
\atentryref{dualabbreviation} type where the \field{duallong} field
is swapped with the \field{long} field and the \field{dualshort}
field is swapped with the \field{short} field. The definition provided in the
\ext{glstex} file is:
\begin{verbatim}
\providecommand{\bibglsnewdualabbreviation}[4]{%
  \newabbreviation[#2]{#1}{#3}{#4}%
}
\end{verbatim}

\subsection{\csfmt{bibglsnewdualacronym}}
\labelcs{bibglsnewdualacronym}

\begin{definition}
\cs{bibglsnewdualacronym}\margm{label}\margm{options}\margm{short}\margm{long}
\end{definition}
This command is used to define terms identified with the
\atentryref{dualacronym} type. The definition provided in the \ext{glstex}
file is:
\begin{verbatim}
\providecommand{\bibglsnewdualacronym}[4]{%
  \newacronym[#2]{#1}{#3}{#4}%
}
\end{verbatim}
This works in much the same way as \cs{bibglsnewdualabbreviation}.
Remember that with the \sty{glossaries-extra} package \cs{newacronym}
is redefined to just use \cs{newabbreviation} with the default \field{type}
set to \cs{acronymtype} and the default \field{category} set to
\cs{acronym}.

\section{Location Lists and Cross-References}
\label{sec:loclistdefs}

These commands deal with the way the location lists and cross
references are formatted. The commands typically aren't used until
the entry information is displayed in the glossary, so you may
redefine these commands after the resource file has been loaded.

\subsection{\csfmt{bibglsseesep}}
\labelcs{bibglsseesep}

\begin{definition}
\cs{bibglsseesep}
\end{definition}

Any entries that provide a \field{see} field (and that field hasn't
be omitted from the location list with \csopt[omit]{see}) will
have \cs{bibglsseesep} inserted between the \field{see} part and the
location list (unless there are no locations, in which case just
the \field{see} part is displayed without \cs{bibglsseesep}).

This command is provided with:
\begin{verbatim}
\providecommand{\bibglsseesep}{, }
\end{verbatim}
You can define this before you load the \ext{bib} file:
\begin{verbatim}
\newcommand{\bibglsseesep}{; }
\GlsXtrLoadResources[src={entries}]
\end{verbatim}
Or you can redefine it afterwards:
\begin{verbatim}
\GlsXtrLoadResources[src={entries}]
\renewcommand{\bibglsseesep}{; }
\end{verbatim}

\subsection{\csfmt{bibglsseealsosep}}
\labelcs{bibglsseealsosep}

\begin{definition}
\cs{bibglsseealsosep}
\end{definition}

This is like \cs{bibglsseesep} but is used with cross-reference
lists provided with the \field{seealso} field, if supported.

\subsection{\csfmt{bibglspassim}}
\labelcs{bibglspassim}

\begin{definition}
\cs{bibglspassim}
\end{definition}

If \optref{max-loc-diff} is greater than 1, then any ranges that have
skipped over gaps will be followed by \cs{bibglspassim}, which is
defined as:
\begin{verbatim}
\providecommand{\bibglspassim}{ \bibglspassimname}
\end{verbatim}
You can define this before you load the \ext{bib} file:
\begin{verbatim}
\newcommand{\bibglspassim}{}
\GlsXtrLoadResources[src={entries}]
\end{verbatim}
Or you can redefine it afterwards:
\begin{verbatim}
\GlsXtrLoadResources[src={entries}]
\renewcommand{\bibglspassim}{}
\end{verbatim}

\subsection{\csfmt{bibglspassimname}}
\labelcs{bibglspassimname}

\begin{definition}
\cs{bibglspassimname}
\end{definition}

The default definition is obtained from the \langxml. For example, with \file{bib2gls-en.xml} the provided
definition is
\begin{verbatim}
\providecommand{\bibglspassimname}{passim}
\end{verbatim}

\subsection{\csfmt{bibglsrange}}
\labelcs{bibglsrange}

\begin{definition}
\cs{bibglsrange}\marg{\meta{start}\cs{delimR} \meta{end}}
\end{definition}

Explicit ranges formed using \glsopt[(]{format} and
\glsopt[)]{format} or \glsopt[(\meta{csname}]{format} and
\glsopt[)\meta{csname}]{format} (where \meta{csname} matches and is a
text-block command without the initial backslash) in the optional
argument of commands like \cs{gls} or \cs{glsadd} are encapsulated within
the argument of \cs{bibglsrange}. By default this simply does its
argument. This command is not used with ranges that are formed by collating
consecutive locations.

\subsection{\csfmt{bibglsinterloper}}
\labelcs{bibglsinterloper}

\begin{definition}
\cs{bibglsinterloper}\margm{location}
\end{definition}

If an explicit range conflicts with a record, a warning will be
issued and the conflicting record will be shifted to the front
of the range inside the argument of \cs{bibglsinterloper}.
The default definition just does \meta{location}\cs{delimN}
so that it fits neatly into the list.

For example, suppose on page~4 of my document I start a range with
\begin{verbatim}
\glsadd[format={(}]{sample}
\end{verbatim}
and end it on page~9 with
\begin{verbatim}
\glsadd[format={)}]{sample}
\end{verbatim}
This forms an explicit range, but let's suppose on page~6 I
have
\begin{verbatim}
\gls[format={hyperbf}]{sample}
\end{verbatim}
This record conflicts with the explicit range (which doesn't include
\texttt{hyperbf} in the format). This causes a warning and
the conflicting entry will be moved before the start of the
explicit range resulting in \textbf{6}, 4--9.

Note that implicit ranges can't be formed from interlopers (nor can
implicit ranges be merged with explicit ones),
so if \verb|\gls[format={hyperbf}]{sample}| also occurs
on pages~7 and~8 then the result will be \textbf{6}, \textbf{7},
\textbf{8}, 4--9. Either remove the explicit range or
remove the conflicting entries. (Alternatively, redefine
\cs{bibglsinterloper} to ignore its argument, which will
discard the conflicting entries.)

\subsection{\csfmt{bibglspostlocprefix}}
\labelcs{bibglspostlocprefix}

\begin{definition}
\cs{bibglspostlocprefix}
\end{definition}

If the \optref{loc-prefix} option is on, \csref{bibglslocprefix} will
be inserted at the start of location lists. The command \cs{bibglspostlocprefix}
is placed after the prefix text. This command is provided with:
\begin{verbatim}
\providecommand{\bibglspostlocprefix}{\ }
\end{verbatim}
which puts a space between the prefix text and the location list.
You can define this before you load the \ext{bib} file:
\begin{verbatim}
\newcommand{\bibglspostlocprefix}{: }
\GlsXtrLoadResources[src={entries},loc-prefix]
\end{verbatim}
Or you can redefine it afterwards:
\begin{verbatim}
\GlsXtrLoadResources[src={entries},loc-prefix]
\renewcommand{\bibglspostlocprefix}{: }
\end{verbatim}

\subsection{\csfmt{bibglslocprefix}}
\labelcs{bibglslocprefix}

\begin{definition}
\cs{bibglslocprefix}\margm{n}
\end{definition}

If the \optref{loc-prefix} option is on, this command will be
provided. If the glossary type has been provided by \optref{type}
(and \optref{dual-type} if there are any dual entries) then the
definition of \cs{bibglslocprefix} will be appended to the glossary
preamble for the given type (or types if there are dual entries).
For example, if the document has
\begin{verbatim}
\GlsXtrLoadResources[type=main,loc-prefix={p.,pp.},src={entries}]
\end{verbatim}
and there are no dual entries, then the following will be added to
the \ext{glstex} file:
\begin{verbatim}
\apptoglossarypreamble[main]{%
 \providecommand{\bibglslocprefix}[1]{%
  \ifcase##1
  \or p.\bibglspostlocprefix
  \else pp.\bibglspostlocprefix
  \fi
 }%
}
\end{verbatim}
However, if the \csopt{type} key is missing, then the following will
be added instead:
\begin{verbatim}
\appto\glossarypreamble{%
 \providecommand{\bibglslocprefix}[1]{%
  \ifcase#1
  \or p.\bibglspostlocprefix
  \else pp.\bibglspostlocprefix
  \fi
 }%
}
\end{verbatim}

\subsection{\csfmt{bibglspagename}}
\labelcs{bibglspagename}

\begin{definition}
\cs{bibglspagename}
\end{definition}

If \csopt[true]{loc-prefix} is used, then this command is provided
using the value of \texttt{tag.page} from the \langxml. For example with \file{bib2gls-en.xml} the definition is:
\begin{verbatim}
\providecommand{\bibglspagename}{Page}
\end{verbatim}

\subsection{\csfmt{bibglspagesname}}
\labelcs{bibglspagesname}

\begin{definition}
\cs{bibglspagesname}
\end{definition}

If \csopt[true]{loc-prefix} is used, then this command is provided
using the value of \texttt{tag.pages} from the \langxml. For example with \file{bib2gls-en.xml} the definition is:
\begin{verbatim}
\providecommand{\bibglspagesname}{Pages}
\end{verbatim}

\subsection{\csfmt{bibglslocsuffix}}
\labelcs{bibglslocsuffix}

\begin{definition}
\cs{bibglslocsuffix}\margm{n}
\end{definition}

If the \optref{loc-suffix} option is on, this command will be
provided. If the glossary type has been provided by \optref{type}
(and \optref{dual-type} if there are any dual entries) then the
definition of \cs{bibglslocsuffix} will be appended to the glossary
preamble for the given type (or types if there are dual entries).

This commands definition depends on the value provided by
\optref{loc-suffix}. For example, with \csopt[\cs{@}.]{loc-suffix}
the command is defined as:
\begin{verbatim}
\providecommand{\bibglslocsuffix}[1]{\@.}
\end{verbatim}
(which ignores the argument).

Whereas with \csopt[\meta{A}\dcomma\meta{B}\dcomma\meta{C}]{loc-suffix}
the command is defined as:
\begin{verbatim}
\providecommand{\bibglslocsuffix}[1]{\ifcase#1 A\or B\else C\fi}
\end{verbatim}

Note that this is slightly different from \cs{bibglslocprefix} as
it includes the 0 case, which in this instance means that there were
no locations but there was a cross-reference. This command isn't
added when the location list is empty.

\subsection{\csfmt{bibglslocationgroup}}
\labelcs{bibglslocationgroup}

\begin{definition}
\cs{bibglslocationgroup}\margm{n}\margm{counter}\margm{list}
\end{definition}

When the \optref{loc-counters} option is used, the locations
for each entry are grouped together according to the counter
(in the order specified in the value of \optref{loc-counters}).
Each group of locations is encapsulated within
\cs{bibglslocationgroup}, where \meta{n} is the number
of locations within the group, \meta{counter} is the
counter name and \meta{list} is the formatted location sub-list.
By default, this simply does \meta{list}, but may be
defined (before the resources are loaded) or redefined 
(after the resources are loaded) as required.

For example:
\begin{verbatim}
\newcommand*{\bibglslocationgroup}[3]{%
  \ifnum#1=1
   #2:
  \else
   #2s:
  \fi
  #3%
}

\GlsXtrLoadResources[
  loc-counters={equation,page},% group locations by counter
  src={entries}% data in entries.bib
]
\end{verbatim}
This will prefix each group with the counter name, if there's
only one location, or the counter name followed by \qt{s},
if there are multiple locations within the group.

There are various ways to adapt this to translate the counter
name to a different textual label, such as:
\begin{verbatim}
\providecommand{\pagename}{Page}
\providecommand{\pagesname}{Pages}
\providecommand{\equationname}{Equation}
\providecommand{\equationsname}{Equations}

\newcommand*{\bibglslocationgroup}[3]{%
  \ifnum#1=1
   \ifcsdef{#2name}{\csuse{#2name}}{#2}:
  \else
   \ifcsdef{#2sname}{\csuse{#2sname}}{#2s}:
  \fi
  #3%
}
\end{verbatim}

\subsection{\csfmt{bibglslocationgroupsep}}
\labelcs{bibglslocationgroupsep}

\begin{definition}
\cs{bibglslocationgroupsep}
\end{definition}

When the \optref{loc-counters} option is set, this command
is used to separate each location sub-group. It may be defined
before the resources are loaded:
\begin{verbatim}
\newcommand*{\bibglslocationgroupsep}{; }

\GlsXtrLoadResources[
  loc-counters={equation,page},% group locations by counter
  src={entries}% data in entries.bib
]
\end{verbatim}
or redefined after the resources are loaded:
\begin{verbatim}
\GlsXtrLoadResources[
  loc-counters={equation,page},% group locations by counter
  src={entries}% data in entries.bib
]

\renewcommand*{\bibglslocationgroupsep}{; }
\end{verbatim}

\subsection{\csfmt{bibglssupplemental}}
\labelcs{bibglssupplemental}

\begin{definition}
\cs{bibglssupplemental}\margm{n}\margm{list}
\end{definition}

When the \optref{supplemental-locations} option is used, the locations
from a supplementary document are encapsulated within the \meta{list}
part of \cs{bibglssupplemental}. The first argument \meta{n}
(ignored by default) is the number of supplementary locations.

\subsection{\csfmt{bibglssupplementalsep}}
\labelcs{bibglssupplementalsep}

\begin{definition}
\cs{bibglssupplementalsep}
\end{definition}

The separator between the main location list and the supplementary
location list. By default this is just \cs{delimN}. This may be
defined before the resources are loaded:
\begin{verbatim}
\newcommand{\bibglssupplementalsep}{; }

\GlsXtrLoadResources[
 supplemental-locations=supplDoc,
 src={entries}]
\end{verbatim}
or redefined after the resources are loaded:
\begin{verbatim}
\GlsXtrLoadResources[
 supplemental-locations=supplDoc,
 src={entries}]

\renewcommand{\bibglssupplementalsep}{; }
\end{verbatim}

\section{Letter Groups}
\label{sec:lettergroupdefs}

The commands listed in this section are provided for use with the
\argref{group} switch and glossary styles that display the letter
group title. If these need their definitions altered, they should
be defined before the resource file is loaded (rather than redefined
afterwards).

The base \sty{glossaries} package determines group titles through a fairly
simplistic rule. Both \app{makeindex} and \app{xindy} write the
line
\begin{alltt}
\cs{glsgroupheading}\margm{heading}
\end{alltt}
to the associated glossary file at the start of each new letter group.
For example, the \qt{A} letter group will be written as:
\begin{verbatim}
\glsgroupheading{A}
\end{verbatim}
This is quite straightforward and the heading title can just be
\qt{A}. The \qt{Symbols} group is written as
\begin{verbatim}
\glsgroupheading{glssymbols}
\end{verbatim}
To allow for easy translation, the base \sty{glossaries} package has
the simple rule: 
\begin{itemize}
\item if \csfmt{\meta{heading}groupname} exists use that;
\item otherwise just use \meta{heading}.
\end{itemize}
There's no \csfmt{Agroupname} provided, but \cs{glssymbolsgroupname}
is provided and is supported by the associated language modules,
such as \styfmt{glossaries-french}. (Similarly for the \qt{Numbers}
group.)

The glossary styles that provide hyperlinks to the groups (such as 
\glostyle{indexhypergroup}) use \meta{heading} to form the target
name. A problem arises when active characters occur in
\meta{heading}, which happens with extended characters and
\sty{inputenc}.

The \sty{glossaries-extra} package (as from version 1.14) provides
\begin{definition}
\cs{glsxtrsetgrouptitle}\margm{label}\margm{title}
\end{definition}
to set the title for a group with the given label. The internal
workings of \cs{glsgroupheading} are modified to use a slightly
altered rule:
\begin{itemize}
\item if a title has been set using
\cs{glsxtrsetgrouptitle}\margm{heading}\margm{title} for the given
\meta{heading}, use that;
\item if \csfmt{\meta{heading}groupname} exists, use that;
\item just use \meta{heading} for the title.
\end{itemize}
So if \cs{glsxtrsetgrouptitle} hasn't been used, it falls back on
the original rule.

The problem is now how to make the indexing application use the
desired label in the argument of \cs{glsgroupheading} instead of selecting
the heading based on the first character of each sort value for each
top-level entry in that group. This can't be done with
\app{makeindex}, and with \app{xindy} it requires a custom language
module, which isn't a trivial task.

With \bibgls, a different approach is used. The \ext{glstex} file
created isn't comparable to the \ext{gls} file created by
\app{makeindex} or \app{xindy}. There's nowhere for \bibgls\ to
write the \cs{glsgroupheading} line as it isn't creating the code
that typesets the glossary list. Instead it's creating the code that
defines the entries. The actual group heading is inserted by 
\cs{printunsrtglossary} and it's only able to do this by checking if
the entry has a \field{group} field and comparing it to the previous
entry's \field{group} field. 

The collators used by the locale and letter-based rules save the
following information for each entry based on the first significant letter of
the \field{sort} field (if the letter is recognised as alphabetical,
according to the rule):
\begin{itemize}
\item \meta{title} The group's title. This is typically title-cased.
For example, if the rule recognises the digraph \qt{dz}, then the
title is \qt{Dz}. Exceptions to this are included in the \langxml.
If the key \texttt{grouptitle.case.\meta{lc}} exists, where
\meta{lc} is the lower case version of \meta{title}, then the value
of that key is used instead. For example, the Dutch digraph \qt{ij}
should be converted to \qt{IJ}, so \file{bib2gls-en.xml} includes:
\begin{verbatim}
<entry key="grouptitle.case.ij">IJ</entry>
\end{verbatim}
(See the \argref{group} switch for more details.)
\item \meta{letter} This is the actual letter at the start of the
given entry's \field{sort} field, which may be lower case or may
contain diacritics that don't appear in \meta{title}.
\item \meta{id} A numeric identifier. This may be the collation key
or the code point for the given letter, depending on the sort
method.
\item \meta{type} The entry's glossary type. If not known, this will
be empty. (\bibgls\ won't know if you've modified the associated 
\csfmt{bibglsnew...} command to set the \field{type}. It can only
know the type if it's in the original \ext{bib} definition or is set
using resource options such as \optref{type}.)
\end{itemize}

The \field{group} field is then set using:
\begin{alltt}
group=\marg{\cs{bibglslettergroup}\margm{title}\margm{letter}\margm{id}\margm{type}}
\end{alltt}
This field needs to expand to a simple label, which \csref{bibglslettergroup}
is designed to do.  Note that non-letter groups are dealt with
separately (see below).

\subsection{\csfmt{bibglssetlettergrouptitle}}
\labelcs{bibglssetlettergrouptitle}

For each group that's detected, \bibgls\ will write the line:
\begin{definition}
\cs{bibglssetlettergrouptitle}\marg{\margm{title}\margm{letter}\margm{id}\margm{type}}
\end{definition}
in the \ext{glstex} file, which sets the group's title using
\begin{alltt}
\cs{glsxtrsetgrouptitle}\margm{group label}\margm{group title}
\end{alltt}
where the \meta{group label} part matches the corresponding \field{group}
value.

Note that \cs{bibglssetlettergrouptitle} only has a single
argument, but that argument contains the four arguments needed by
\csref{bibglslettergroup} and \csref{bibglslettergrouptitle}.
These arguments are as described above.

If \cs{glsxtrsetgrouptitle} has been defined (\sty{glossaries-extra}
version 1.14 onwards), then \cs{bibglssetlettergrouptitle} will be
defined as
\begin{verbatim}
\providecommand{\bibglssetlettergrouptitle}[1]{%
  \glsxtrsetgrouptitle{\bibglslettergroup#1}{\bibglslettergrouptitle#1}}
\end{verbatim}
If an earlier version of \sty{glossaries-extra} is used, then this
function can't be supported and the command will be defined to
simply ignore its argument. This will fall back on the original
method of just using \meta{title} as the label.

Since \cs{bibglssetlettergrouptitle} is used in the \ext{glstex} file to
set the group titles, the associated commands need to be defined
before the resource file is loaded if their definitions require
modification. After the resource file has been loaded, you can
adjust the title of a specific group, but you'll need to check the
\ext{glstex} file for the appropriate arguments. For example, if the
\ext{glstex} file contains:
\begin{alltt}
\cs{bibglssetlettergrouptitle}\marg{\marg{\AE}\marg{\ae}\marg{7274496}\marg{}}
\end{alltt}
but you actually want the group title to appear as \qt{\AE\ (AE)}
instead of just \qt{\AE}, then after the resource file has been
loaded you can do:
\begin{alltt}
\cs{glsxtrsetgrouptitle}
 \marg{\cs{bibglslettergroup}\marg{\AE}\marg{\ae}\marg{7274496}\marg{}}\% label
 \marg{\AE\ (AE)}\% title
\end{alltt}

\subsection{\csfmt{bibglslettergroup}}
\labelcs{bibglslettergroup}

\begin{definition}
\cs{bibglslettergroup}\margm{title}\margm{letter}\margm{id}\margm{type}
\end{definition}
This command is used to determine the letter group label. The
default definition is \meta{type}\meta{id}, which ensures that no
problematic characters occur in the label since \meta{type} can't
contains special characters and \meta{id} is numeric. The
\meta{type} is included in case there are multiple glossaries, since
the hyperlink name must be unique.

\subsection{\csfmt{bibglslettergrouptitle}}
\labelcs{bibglslettergrouptitle}

\begin{definition}
\cs{bibglslettergrouptitle}\margm{title}\margm{letter}\margm{id}\margm{type}
\end{definition}
This command is used to determine the letter group title.
The default definition is \cs{unexpanded}\margm{title}, which guards
against any expansion issues that may arise with characters outside
the basic Latin set.

For example:
\begin{verbatim}
@entry{angstrom,
  name={\AA ngstr\"om}
  description={a unit of length equal to one hundred-millionth 
of a centimetre}
}
\end{verbatim}
The \field{sort} value is \qtt{\AA ngstr\"om}. With \optref[en]{sort}
the \meta{title} part will be \texttt{A} but with \optref[sv]{sort}
the \meta{title} part will be \texttt{\AA}. In both cases the
\meta{letter} argument will be \texttt{\AA}.

Take care if you are using a script that needs encapsulating. For
example, with the \sty{CJKutf8} package the CJK characters need to
be placed within the \env{CJK} environment, so any letter group
titles that contain CJK characters will need special attention.

For example, suppose the \ext{bib} file contains entries in the
form:
\begin{alltt}
\atentryref{dualentry}\marg{\meta{label},
  name = \marg{\cs{cjkname}\margm{CJK characters}},
  description = \margm{English description}
}
\end{alltt}
and the document contains:
\begin{verbatim}
\usepackage{CJKutf8}
\usepackage[record,style=indexgroup,nomain]{glossaries-extra}

\newglossary*{japanese}{Japanese to English}
\newglossary*{english}{English to Japanese}

\newrobustcmd{\cjkname}[1]{\begin{CJK}{UTF8}{min}#1\end{CJK}}
\glsnoexpandfields

\GlsXtrLoadResources[
  src=testcjk,% bib file
  sort={ja-JP},% locale used to sort primary entries
  dual-sort={en-GB},% locale used to sort secondary entries
  type=japanese,% put the primary entries in the 'japanese' glossary
  dual-type=english,% put the primary entries in the 'english' glossary
  dual-prefix={en.}
]
\end{verbatim}
then CJK characters will appear in the \meta{title} argument of 
\cs{bibglslettergrouptitle} which causes a problem because they need
to be encapsulated within the \env{CJK} environment. This can be more
conveniently done with the user supplied \csfmt{cjkname}, but the CJK
characters need to be protected from expansion so \cs{unexpanded} is
also needed. The new definition of \cs{bibglslettergrouptitle} needs
to be defined before \cs{GlsXtrLoadResources}. For example:
\begin{verbatim}
\newcommand{\bibglslettergrouptitle}[4]{\unexpanded{\cjkname{#1}}}
\end{verbatim}
There's a slight problem here in that the English letter group titles 
also end up encapsulated. An alternative approach is to use the
\meta{type} part to provide different forms. For example:
\begin{verbatim}
\newcommand*{\englishlettergroup}[1]{#1}
\newcommand*{\japaneselettergroup}[1]{\cjkname{#1}}
\newcommand{\bibglslettergrouptitle}[4]{%
 \unexpanded{\csuse{#4lettergroup}{#1}}}
\end{verbatim}
(\csfmt{csuse} is provided by \sty{etoolbox}, which is automatically
loaded by the \styfmt{glossaries} package.)

\subsection{\csfmt{bibglssetothergrouptitle}}
\labelcs{bibglssetothergrouptitle}

The group label and title for non-alphabetic characters (symbols)
are dealt with in a similar way to the letter groups, but in this
case the title is set using
\begin{definition}
\cs{bibglssetothergrouptitle}\marg{\margm{character}\margm{id}\margm{type}}
\end{definition}
This is defined in an analogous manner:
\begin{verbatim}
\providecommand{\bibglssetothergrouptitle}[1]{%
 \glsxtrsetgrouptitle{\bibglsothergroup#1}{\bibglsothergrouptitle#1}}
\end{verbatim}
where the group label is obtained using \csref{bibglsothergroup} and
the group title is obtained from \csref{bibglsothergrouptitle}.
Note that since non-alphabetic characters don't have upper or lower
case versions, there are only three arguments. The other difference
between this and the letter group version is that the \meta{id} is
given in hexadecimal format (corresponding to the character code).

For example, suppose my \ext{bib} file contains:
\begin{verbatim}
@entry{sauthor,
  name={/Author},
  description = {author string}
}
\end{verbatim}
If a locale sort is used, the leading slash \texttt{/} will be
ignored and this entry will belong to the \qt{A} letter group using
the letter commands described above. If, instead, one of the
character code sort methods are used, such as
\optref[letter-case]{sort}, then this entry will be identified as
belonging to a symbol (or \qt{other}) group and the title will be
set using:
\begin{verbatim}
\bibglssetothergrouptitle{{/}{2F}{}}
\end{verbatim}

\subsection{\csfmt{bibglsothergroup}}
\labelcs{bibglsothergroup}

\begin{definition}
\cs{bibglsothergroup}\margm{character}\margm{id}\margm{type}
\end{definition}
This expands to the group label for symbol groups. This just
defaults to \texttt{glssymbols} (ignoring all arguments), which
replicates the label used when \app{makeindex} or \app{xindy}
generate the glossary files.

\subsection{\csfmt{bibglsothergrouptitle}}
\labelcs{bibglsothergrouptitle}

\begin{definition}
\cs{bibglsothergrouptitle}\margm{character}\margm{id}\margm{type}
\end{definition}
This expands to the group title for symbol groups. This just
expands to \cs{glssymbolsgroupname} by default.

\subsection{\csfmt{bibglssetnumbergrouptitle}}
\labelcs{bibglssetnumbergrouptitle}

The numeric sort methods all create number groups instead of letter
or symbol groups. These behave in an analogous way to the above.
\begin{definition}
\cs{bibglssetnumbergrouptitle}\marg{\margm{value}\margm{id}\margm{type}}
\end{definition}
In this case \meta{value} is the actual numeric sort value, and
\meta{id} is a decimal number obtained from converting \meta{value}
to an integer. This command is defined as
\begin{verbatim}
\providecommand{\bibglssetnumbergrouptitle}[1]{%
  \glsxtrsetgrouptitle{\bibglsnumbergroup#1}{\bibglsnumbergrouptitle#1}}
\end{verbatim}

\subsection{\csfmt{bibglsnumbergroup}}
\labelcs{bibglsnumbergroup}

The number group label is obtained from:
\begin{definition}
\cs{bibglsnumbergroup}\margm{value}\margm{id}\margm{type}
\end{definition}
This just defaults to \texttt{glsnumbers}.

\subsection{\csfmt{bibglsnumbergrouptitle}}
\labelcs{bibglsnumbergrouptitle}

The number group title is obtained from:
\begin{definition}
\cs{bibglsnumbergrouptitle}\margm{value}\margm{id}\margm{type}
\end{definition}
This just defaults to \cs{glsnumbersgroupname}.

\subsection{\csfmt{bibglshypergroup}}
\labelcs{bibglshypergroup}

\begin{definition}
\cs{bibglshypergroup}\margm{type}\margm{group id}
\end{definition}

If the \ext{log} file indicates that \sty{hyperref} has been loaded
and the \longarg{group} switch is used, then this command will be
used to create the navigation information for glossary styles such
as \glostyle{indexhypergroup}.

\section{Flattened Entries}
\label{sec:flattendefs}

These commands relate to the way the \field{name} field is altered
when flattening lonely child entries with the \optref{flatten-lonely}
option.

\subsection{\csfmt{bibglsflattenedhomograph}}
\labelcs{bibglsflattenedhomograph}

\begin{definition}
\cs{bibglsflattenedhomograph}\margm{name}\margm{parent label}
\end{definition}
The default definition simply does \meta{name}.

This command is used if the child and parent name's are identical.
For example, suppose the \ext{bib} file contains:
\begin{verbatim}
@index{super.glossary, name={glossary}}

@entry{glossarycol,
  parent={super.glossary},
  description={collection of glosses}
}

@entry{glossarylist,
  parent={super.glossary},
  description={list of technical words}
}
\end{verbatim}
The child entries don't have a \field{name} field, so the value is assumed
to be the same as the parent's \field{name} field. Here's an example 
document where both child entries are used:
\begin{verbatim}
\documentclass{article}

\usepackage[record,subentrycounter,style=treenoname]{glossaries-extra}

\GlsXtrLoadResources[src={entries}]

\begin{document}
\gls{glossarycol} (collection) vs \gls{glossarylist} (list).

\printunsrtglossary
\end{document}
\end{verbatim}
This uses one of the glossary styles designed for homographs and the
glossary has the structure:
\begin{flushleft}
\textbf{glossary}\par
\quad 1) collection of glosses 1\par
\quad 2) list of technical words 1
\end{flushleft}
If only one child entry is selected, then the result looks a little
odd. For example:
\begin{flushleft}
\textbf{glossary}\par
\quad 1) collection of glosses 1
\end{flushleft}
With the \optref{flatten-lonely} option, the parent is removed and
the child is moved up a hierarchical level. With 
\optref[postsort]{flatten-lonely} this would normally adjust the
name so that it appears as \meta{parent name}, \meta{child name}
but in this case it would look a little odd for the name to 
appear as \qt{glossary, glossary} so instead the name is
set to
\begin{verbatim}
\bibglsflattenedhomograph{glossary}{super.glossary}
\end{verbatim}
(where the first argument is the original name and the second argument is the
label of the parent entry).

This means that the name simply appears as \qt{glossary}, even if
the \optref[postsort]{flatten-lonely} option is used. Note that if
the parent entry is removed, the parent label won't be of much use.
You can test for existence using \cs{ifglsentryexists} (provided by
the \sty{glossaries} package) in case you want to vary the way the
name is displayed according to whether or not the parent is still
present.

\subsection{\csfmt{bibglsflattenedchildpresort}}
\labelcs{bibglsflattenedchildpresort}

\begin{definition}
\cs{bibglsflattenedchildpresort}\margm{child name}\margm{parent name}
\end{definition}

Used by the \optref[presort]{flatten-lonely} option. This defaults
to just \meta{child name}. If you want to change this, remember that
you can let the interpreter know by adding the definition to
\atentry{preamble}. For example:
\begin{verbatim}
@preamble{"\providecommand{\bibglsflattenedchildpresort}[2]{#1 (#2)}"}
\end{verbatim}

\subsection{\csfmt{bibglsflattenedchildpostsort}}
\labelcs{bibglsflattenedchildpostsort}

\begin{definition}
\cs{bibglsflattenedchildpostsort}\margm{parent name}\margm{child name}
\end{definition}

Used by the \optref[postsort]{flatten-lonely} option. This defaults
to \texttt{\meta{parent name}, \meta{child name}}.

Note that the arguments are in the reverse order to those of the
previous command. This is done to assist the automated first letter
upper-casing. If either command is redefined to alter the ordering,
then this can confuse the case-changing mechanism, in which case you
may want to consider switching on the expansion of the \field{name}
field using:
\begin{verbatim}
\glssetexpandfield{name}
\end{verbatim}
(before \cs{GlsXtrLoadResources}).

\chapter{Converting Existing \filefmt{.tex} to \filefmt{.bib}}
\label{sec:gls2bib}

If you have already been using the \sty{glossaries} or
\sty{glossaries-extra} package with a large file containing all your
definitions using commands like \cs{newglossaryentry}, then you can
use the supplementary tool \app{convertgls2bib} to convert the definitions
to the \ext{bib} format required by \bibgls. The syntax is:
\begin{alltt}
convertgls2bib \oargm{options} \meta{tex file} \meta{bib file}
\end{alltt}
where \meta{tex file} is the \ext{tex} file and \meta{bib file} is
the \ext{bib} file. This application is less secure than \bibgls\ as
it doesn't use \app{kpsewhich} to check \texttt{openin\_any} and 
\texttt{openout\_any}. Take care not to accidentally overwrite
existing \ext{bib} files as there's no check to determine if
\meta{bib file} already exists.

The \meta{options} are:
\begin{description}
\item[\longargfmt{texenc} \meta{encoding}] The character encoding of the
\ext{tex} file. If omitted, the operating system's default encoding
is assumed (or the Java Virtual Machine's).

\item[\longargfmt{bibenc} \meta{encoding}] The character encoding of the
\ext{bib} file. If omitted, the same encoding as the
\ext{tex} file is assumed.

\item[\longargfmt{space-sub} \meta{replacement}] The \ext{bib}
format doesn't allow spaces in labels. If your original
definitions in your \ext{tex} file have spaces, use this option to
replace spaces in labels. Each space will be substituted with
\meta{replacement}. The cross-referencing fields, \field{see},
\field{seealso} and \field{alias}, will also be adjusted, but any
references using \cs{gls} etc will have to be substituted manually 
(or use a global search and replace in your text editor).
If you want to strip the spaces, use an empty string for
\meta{replacement}. You'll need to delimit this according to your
operating system. For example:
\begin{verbatim}
gls2bib --space-sub '' entries.tex entries.bib
\end{verbatim}

\item[\longargfmt{help} or \shortargfmt{h}] Display help message and
quit.
\item[\longargfmt{version} or \shortargfmt{v}] Display version
information and quit.
\end{description}

This application recognises the commands listed below. Avoid any
overly complicated code within the \ext{tex} file. The \TeX\ parser
library isn't a \TeX\ engine!
In all cases below, if \meta{\keyvallist} contains
\begin{alltt}
see=[\cs{seealsoname}]\margm{label(s)}
\end{alltt}
this will be substituted with 
\begin{alltt}
seealso=\margm{label(s)}
\end{alltt}
For example:
\begin{verbatim}
\newterm[see={[\seealsoname]goose}]{duck}
\end{verbatim}
will be written as
\begin{verbatim}
@index{duck,
  seealso = {goose}
}
\end{verbatim}
(The \field{seealso} key is provided by \sty{glossaries-extra}
v1.16+.)

Additionally, if \meta{\keyvallist} contains
\begin{alltt}
type=\marg{\cs{glsdefaulttype}}
\end{alltt}
then this field will be ignored. (This \field{type} value is
recommended in \meta{\keyvallist} when loading files with
\cs{loadglsentries}\oargm{type}\margm{file} to allow the optional
argument to set the \field{type}. With \bibgls\ you can use the
\optref{type} option instead.)

\section{\cs{newglossaryentry}}
The base \sty{glossaries} package provides:
\begin{definition}
\cs{newglossaryentry}\margm{label}\margm{\keyvallist}
\end{definition}

This is converted to:
\begin{alltt}
\atentryref{entry}\marg{\meta{label},
  \meta{\keyvallist}
}
\end{alltt}

\cs{newentry} (provided by the \sty{glossaries-extra}
\styopt{shortcuts} option) is recognised as a synonym of \cs{newglossaryentry}.

\section{\cs{provideglossaryentry}}
The base \sty{glossaries} package provides:
\begin{definition}
\cs{provideglossaryentry}\margm{label}\margm{\keyvallist}
\end{definition}

This is converted to:
\begin{alltt}
\atentryref{entry}\marg{\meta{label},
  \meta{\keyvallist}
}
\end{alltt}
but only if \meta{label} hasn't already been defined.

\section{\cs{longnewglossaryentry}}
The base \sty{glossaries} package provides:
\begin{definition}
\cs{longnewglossaryentry}\margm{label}\margm{\keyvallist}\margm{description}
\end{definition}

This is converted to:
\begin{alltt}
\atentryref{entry}\marg{\meta{label},
 \meta{\keyvallist},
 description = \margm{description}
}
\end{alltt}

The starred version provided by the \sty{glossaries-extra} package
is also recognised. The unstarred version strips trailing spaces
from \meta{description}. (This doesn't add \cs{nopostdesc}, but
\sty{glossaries-extra} defaults to \styopt{nopostdot}.)

\section{\cs{longprovideglossaryentry}}

The base \sty{glossaries} package provides:
\begin{definition}
\cs{longprovideglossaryentry}\margm{label}\margm{\keyvallist}\margm{description}
\end{definition}

As above, but only if \meta{label} hasn't already been defined.

\section{\cs{newterm}}
The base \sty{glossaries} package provides:
\begin{definition}
\cs{newterm}\oargm{\keyvallist}\margm{label}
\end{definition}
(when the \styopt{index} option is used).

This is converted to:
\begin{alltt}
\atentryref{index}\marg{\meta{label},
 \meta{\keyvallist}
}
\end{alltt}
if the optional argument is present, otherwise it's just converted
to:
\begin{alltt}
\atentryref{index}\marg{\meta{label}}
\end{alltt}

If \longargfmt{space-sub} is used and \meta{label} contains one or
more spaces, then \field{name} will be set if not included in
\meta{\keyvallist}. For example, if \texttt{entries.bib}
contains
\begin{verbatim}
\newterm{sea lion}
\newterm[seealso={sea lion}]{seal}
\end{verbatim}
then
\begin{verbatim}
gls2bib --space-sub '-' entries.bib entries.tex
\end{verbatim}
will write the terms to \texttt{entries.tex} as
\begin{verbatim}
@index{sea-lion,
  name = {sea lion}
}

@index{seal,
  seealso = {sea-lion}
}
\end{verbatim}
whereas just
\begin{verbatim}
gls2bib entries.bib entries.tex
\end{verbatim}
will write the terms to \texttt{entries.tex} as
\begin{verbatim}
@index{sea lion}

@index{seal,
  seealso = {sea lion}
}
\end{verbatim}
which will cause a problem when the \ext{bib} file is parsed
by \bibgls\ (and will probably also cause a problem for 
bibliographic management systems).

\section{\cs{newabbreviation}}
The \sty{glossaries-extra} package provides:
\begin{definition}
\cs{newabbreviation}\oargm{\keyvallist}\margm{label}\margm{short}\margm{long}
\end{definition}

This is converted to:
\begin{alltt}
\atentryref{abbreviation}\marg{\meta{label},
 short = \margm{short},
 long = \margm{long},
 \meta{\keyvallist}
}
\end{alltt}
if the optional argument is present, otherwise it's converted to:
\begin{alltt}
\atentryref{abbreviation}\marg{\meta{label},
 short = \margm{short},
 long = \margm{long}
}
\end{alltt}

\section{\cs{newacronym}}
The base \sty{glossaries} package provides:
\begin{definition}
\cs{newacronym}\oargm{\keyvallist}\margm{label}\margm{short}\margm{long}
\end{definition}
(which is redefined by \sty{glossaries-extra} to use
\cs{newabbreviation}).

As above but uses \atentryref{acronym} instead.

\section{\cs{glsxtrnewsymbol}}
The \sty{glossaries-extra} package provides:
\begin{definition}
\cs{glsxtrnewsymbol}\oargm{\keyvallist}\margm{label}\margm{symbol}
\end{definition}
(when the \styopt{symbols} option is used).

This is converted to:
\begin{alltt}
\atentryref{symbol}\marg{\meta{label},
 name = \margm{symbol}
}
\end{alltt}
if the optional argument is missing, otherwise it's converted to:
\begin{alltt}
\atentryref{symbol}\marg{\meta{label},
 name = \margm{symbol},
 \meta{\keyvallist}
}
\end{alltt}
unless \meta{\keyvallist} contains the \field{name} field,
in which case it's converted to:
\begin{alltt}
\atentryref{symbol}\marg{\meta{label},
 \meta{\keyvallist}
}
\end{alltt}

\cs{newsym} (provided by the \styopt{shortcuts} option) is recognised 
as a synonym for \cs{glsxtrnewsymbol}.

\section{\cs{glsxtrnewnumber}}
The \sty{glossaries-extra} package provides:
\begin{definition}
\cs{glsxtrnewnumber}\oargm{\keyvallist}\margm{label}
\end{definition}
(when the \styopt{numbers} option is used).

This is converted to:
\begin{alltt}
\atentryref{number}\marg{\meta{label},
 name = \margm{label}
}
\end{alltt}
if the optional argument is missing, otherwise it's converted to:
\begin{alltt}
\atentryref{number}\marg{\meta{label},
 name = \margm{label},
 \meta{\keyvallist}
}
\end{alltt}
if \field{name} isn't listed in \meta{\keyvallist},
otherwise it's converted to:
\begin{alltt}
\atentryref{number}\marg{\meta{label},
 \meta{\keyvallist}
}
\end{alltt}

\cs{newnum} (provided by the \styopt{shortcuts} option) is
recognised as a synonym for \cs{glsxtrnewnumber}.

\section{\cs{newdualentry}}

\begin{definition}
\cs{newdualentry}\oargm{\keyvallist}\margm{label}\margm{short}\margm{long}\margm{description}
\end{definition}

This command isn't provided by either \sty{glossaries} or
\sty{glossaries-extra} but is used as an example in the
\sty{glossaries} user manual and in the sample file
\file{sample-dual.tex} that accompanies the \sty{glossaries}
package. Since this command seems to be used quite a bit (given the
number of times it crops up on sites like
\href{https://tex.stackexchange.com/}{\TeX\ on StackExchange}), 
\appfmt{convertgls2bib} also supports it unless this command is
defined using \csfmt{newcommand} or \csfmt{renewcommand} in the 
input file. In which case the default definition will be overridden.

If the command definition isn't overridden, then it's converted to
\begin{alltt}
\atentryref{dualentryabbreviation}\marg{\meta{label},
  short = \margm{short},
  long = \margm{long},
  description = \margm{description},
  \meta{\keyvallist}
}
\end{alltt}
if \meta{\keyvallist} is supplied, otherwise it's converted to:
\begin{alltt}
\atentryref{dualentryabbreviation}\marg{\meta{label},
  short = \margm{short},
  long = \margm{long},
  description = \margm{description}
}
\end{alltt}

For example, if the original \filefmt{.tex} file contains
\begin{verbatim}
\newcommand*{\newdualentry}[5][]{%
  \newglossaryentry{main-#2}{name={#4},%
  text={#3\glsadd{#2}},%
  description={#5},%
  #1
  }%
  \newacronym{#2}{#3\glsadd{main-#2}}{#4}
}

\newdualentry{svm}% label
  {SVM}% abbreviation
  {support vector machine}% long form
  {Statistical pattern recognition technique}% description
\end{verbatim}
then the \filefmt{.bib} file will contain
\begin{verbatim}
@entry{main-svm,
  name = {support vector machine},
  description = {Statistical pattern recognition technique},
  text = {SVM\glsadd{svm}}
}

@acronym{svm,
  short = {SVM\glsadd{main-svm}},
  long = {support vector machine}
}
\end{verbatim}
since \cs{newdualentry} was defined with \cs{newcommand}. However,
if the original file uses \cs{providecommand} or omits the
definition of \cs{newdualentry}, then the \filefmt{.bib} file will
contain:
\begin{verbatim}
@dualentryabbreviation{svm,
  short = {SVM},
  description = {Statistical pattern recognition technique},
  long = {support vector machine}
}
\end{verbatim}

\resetsecnumdepth
\printindex
\end{document}