summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/siunitx/siunitx.dtx
blob: 57eae2e27d3d0ba40ccbf192cc0d7a75ed5b68df (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
7518
7519
7520
7521
7522
7523
7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
7539
7540
7541
7542
7543
7544
7545
7546
7547
7548
7549
7550
7551
7552
7553
7554
7555
7556
7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
7615
7616
7617
7618
7619
7620
7621
7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
7650
7651
7652
7653
7654
7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
7696
7697
7698
7699
7700
7701
7702
7703
7704
7705
7706
7707
7708
7709
7710
7711
7712
7713
7714
7715
7716
7717
7718
7719
7720
7721
7722
7723
7724
7725
7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
7781
7782
7783
7784
7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
7809
7810
7811
7812
7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
7829
7830
7831
7832
7833
7834
7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
7871
7872
7873
7874
7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
7885
7886
7887
7888
7889
7890
7891
7892
7893
7894
7895
7896
7897
7898
7899
7900
7901
7902
7903
7904
7905
7906
7907
7908
7909
7910
7911
7912
7913
7914
7915
7916
7917
7918
7919
7920
7921
7922
7923
7924
7925
7926
7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
7943
7944
7945
7946
7947
7948
7949
7950
7951
7952
7953
7954
7955
7956
7957
7958
7959
7960
7961
7962
7963
7964
7965
7966
7967
7968
7969
7970
7971
7972
7973
7974
7975
7976
7977
7978
7979
7980
7981
7982
7983
7984
7985
7986
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999
8000
8001
8002
8003
8004
8005
8006
8007
8008
8009
8010
8011
8012
8013
8014
8015
8016
8017
8018
8019
8020
8021
8022
8023
8024
8025
8026
8027
8028
8029
8030
8031
8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
8050
8051
8052
8053
8054
8055
8056
8057
8058
8059
8060
8061
8062
8063
8064
8065
8066
8067
8068
8069
8070
8071
8072
8073
8074
8075
8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
8087
8088
8089
8090
8091
8092
8093
8094
8095
8096
8097
8098
8099
8100
8101
8102
8103
8104
8105
8106
8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
8147
8148
8149
8150
8151
8152
8153
8154
8155
8156
8157
8158
8159
8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
8194
8195
8196
8197
8198
8199
8200
8201
8202
8203
8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
8225
8226
8227
8228
8229
8230
8231
8232
8233
8234
8235
8236
8237
8238
8239
8240
8241
8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
8315
8316
8317
8318
8319
8320
8321
8322
8323
8324
8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
8361
8362
8363
8364
8365
8366
8367
8368
8369
8370
8371
8372
8373
8374
8375
8376
8377
8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
8399
8400
8401
8402
8403
8404
8405
8406
8407
8408
8409
8410
8411
8412
8413
8414
8415
8416
8417
8418
8419
8420
8421
8422
8423
8424
8425
8426
8427
8428
8429
8430
8431
8432
8433
8434
8435
8436
8437
8438
8439
8440
8441
8442
8443
8444
8445
8446
8447
8448
8449
8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
8481
8482
8483
8484
8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
8496
8497
8498
8499
8500
8501
8502
8503
8504
8505
8506
8507
8508
8509
8510
8511
8512
8513
8514
8515
8516
8517
8518
8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
8530
8531
8532
8533
8534
8535
8536
8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
8574
8575
8576
8577
8578
8579
8580
8581
8582
8583
8584
8585
8586
8587
8588
8589
8590
8591
8592
8593
8594
8595
8596
8597
8598
8599
8600
8601
8602
8603
8604
8605
8606
8607
8608
8609
8610
8611
8612
8613
8614
8615
8616
8617
8618
8619
8620
8621
8622
8623
8624
8625
8626
8627
8628
8629
8630
8631
8632
8633
8634
8635
8636
8637
8638
8639
8640
8641
8642
8643
8644
8645
8646
8647
8648
8649
8650
8651
8652
8653
8654
8655
8656
8657
8658
8659
8660
8661
8662
8663
8664
8665
8666
8667
8668
8669
8670
8671
8672
8673
8674
8675
8676
8677
8678
8679
8680
8681
8682
8683
8684
8685
8686
8687
8688
8689
8690
8691
8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
8765
8766
8767
8768
8769
8770
8771
8772
8773
8774
8775
8776
8777
8778
8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
8791
8792
8793
8794
8795
8796
8797
8798
8799
8800
8801
8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
8826
8827
8828
8829
8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
8851
8852
8853
8854
8855
8856
8857
8858
8859
8860
8861
8862
8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
8907
8908
8909
8910
8911
8912
8913
8914
8915
8916
8917
8918
8919
8920
8921
8922
8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
8982
8983
8984
8985
8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
9125
9126
9127
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
9256
9257
9258
9259
9260
9261
9262
9263
9264
9265
9266
9267
9268
9269
9270
9271
9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
9282
9283
9284
9285
9286
9287
9288
9289
9290
9291
9292
9293
9294
9295
9296
9297
9298
9299
9300
9301
9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
9313
9314
9315
9316
9317
9318
9319
9320
9321
9322
9323
9324
9325
9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
9339
9340
9341
9342
9343
9344
9345
9346
9347
9348
9349
9350
9351
9352
9353
9354
9355
9356
9357
9358
9359
9360
9361
9362
9363
9364
9365
9366
9367
9368
9369
9370
9371
9372
9373
9374
9375
9376
9377
9378
9379
9380
9381
9382
9383
9384
9385
9386
9387
9388
9389
9390
9391
9392
9393
9394
9395
9396
9397
9398
9399
9400
9401
9402
9403
9404
9405
9406
9407
9408
9409
9410
9411
9412
9413
9414
9415
9416
9417
9418
9419
9420
9421
9422
9423
9424
9425
9426
9427
9428
9429
9430
9431
9432
9433
9434
9435
9436
9437
9438
9439
9440
9441
9442
9443
9444
9445
9446
9447
9448
9449
9450
9451
9452
9453
9454
9455
9456
9457
9458
9459
9460
9461
9462
9463
9464
9465
9466
9467
9468
9469
9470
9471
9472
9473
9474
9475
9476
9477
9478
9479
9480
9481
9482
9483
9484
9485
9486
9487
9488
9489
9490
9491
9492
9493
9494
9495
9496
9497
9498
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508
9509
9510
9511
9512
9513
9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
9545
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
9576
9577
9578
9579
9580
9581
9582
9583
9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
9595
9596
9597
9598
9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
9624
9625
9626
9627
9628
9629
9630
9631
9632
9633
9634
9635
9636
9637
9638
9639
9640
9641
9642
9643
9644
9645
9646
9647
9648
9649
9650
9651
9652
9653
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663
9664
9665
9666
9667
9668
9669
9670
9671
9672
9673
9674
9675
9676
9677
9678
9679
9680
9681
9682
9683
9684
9685
9686
9687
9688
9689
9690
9691
9692
9693
9694
9695
9696
9697
9698
9699
9700
9701
9702
9703
9704
9705
9706
9707
9708
9709
9710
9711
9712
9713
9714
9715
9716
9717
9718
9719
9720
9721
9722
9723
9724
9725
9726
9727
9728
9729
9730
9731
9732
9733
9734
9735
9736
9737
9738
9739
9740
9741
9742
9743
9744
9745
9746
9747
9748
9749
9750
9751
9752
9753
9754
9755
9756
9757
9758
9759
9760
9761
9762
9763
9764
9765
9766
9767
9768
9769
9770
9771
9772
9773
9774
9775
9776
9777
9778
9779
9780
9781
9782
9783
9784
9785
9786
9787
9788
9789
9790
9791
9792
9793
9794
9795
9796
9797
9798
9799
9800
9801
9802
9803
9804
9805
9806
9807
9808
9809
9810
9811
9812
9813
9814
9815
9816
9817
9818
9819
9820
9821
9822
9823
9824
9825
9826
9827
9828
9829
9830
9831
9832
9833
9834
9835
9836
9837
9838
9839
9840
9841
9842
9843
9844
9845
9846
9847
9848
9849
9850
9851
9852
9853
9854
9855
9856
9857
9858
9859
9860
9861
9862
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872
9873
9874
9875
9876
9877
9878
9879
9880
9881
9882
9883
9884
9885
9886
9887
9888
9889
9890
9891
9892
9893
9894
9895
9896
9897
9898
9899
9900
9901
9902
9903
9904
9905
9906
9907
9908
9909
9910
9911
9912
9913
9914
9915
9916
9917
9918
9919
9920
9921
9922
9923
9924
9925
9926
9927
9928
9929
9930
9931
9932
9933
9934
9935
9936
9937
9938
9939
9940
9941
9942
9943
9944
9945
9946
9947
9948
9949
9950
9951
9952
9953
9954
9955
9956
9957
9958
9959
9960
9961
9962
9963
9964
9965
9966
9967
9968
9969
9970
9971
9972
9973
9974
9975
9976
9977
9978
9979
9980
9981
9982
9983
9984
9985
9986
9987
9988
9989
9990
9991
9992
9993
9994
9995
9996
9997
9998
9999
10000
10001
10002
10003
10004
10005
10006
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016
10017
10018
10019
10020
10021
10022
10023
10024
10025
10026
10027
10028
10029
10030
10031
10032
10033
10034
10035
10036
10037
10038
10039
10040
10041
10042
10043
10044
10045
10046
10047
10048
10049
10050
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070
10071
10072
10073
10074
10075
10076
10077
10078
10079
10080
10081
10082
10083
10084
10085
10086
10087
10088
10089
10090
10091
10092
10093
10094
10095
10096
10097
10098
10099
10100
10101
10102
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113
10114
10115
10116
10117
10118
10119
10120
10121
10122
10123
10124
10125
10126
10127
10128
10129
10130
10131
10132
10133
10134
10135
10136
10137
10138
10139
10140
10141
10142
10143
10144
10145
10146
10147
10148
10149
10150
10151
10152
10153
10154
10155
10156
10157
10158
10159
10160
10161
10162
10163
10164
10165
10166
10167
10168
10169
10170
10171
10172
10173
10174
10175
10176
10177
10178
10179
10180
10181
10182
10183
10184
10185
10186
10187
10188
10189
10190
10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
10201
10202
10203
10204
10205
10206
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226
10227
10228
10229
10230
10231
10232
10233
10234
10235
10236
10237
10238
10239
10240
10241
10242
10243
10244
10245
10246
10247
10248
10249
10250
10251
10252
10253
10254
10255
10256
10257
10258
10259
10260
10261
10262
10263
10264
10265
10266
10267
10268
10269
10270
10271
10272
10273
10274
10275
10276
10277
10278
10279
10280
10281
10282
10283
10284
10285
10286
10287
10288
10289
10290
10291
10292
10293
10294
10295
10296
10297
10298
10299
10300
10301
10302
10303
10304
10305
10306
10307
10308
10309
10310
10311
10312
10313
10314
10315
10316
10317
10318
10319
10320
10321
10322
10323
10324
10325
10326
10327
10328
10329
10330
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349
10350
10351
10352
10353
10354
10355
10356
10357
10358
10359
10360
10361
10362
10363
10364
10365
10366
10367
10368
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378
10379
10380
10381
10382
10383
10384
10385
10386
10387
10388
10389
10390
10391
10392
10393
10394
10395
10396
10397
10398
10399
10400
10401
10402
10403
10404
10405
10406
10407
10408
10409
10410
10411
10412
10413
10414
10415
10416
10417
10418
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436
10437
10438
10439
10440
10441
10442
10443
10444
10445
10446
10447
10448
10449
10450
10451
10452
10453
10454
10455
10456
10457
10458
10459
10460
10461
10462
10463
10464
10465
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483
10484
10485
10486
10487
10488
10489
10490
10491
10492
10493
10494
10495
10496
10497
10498
10499
10500
10501
10502
10503
10504
10505
10506
10507
10508
10509
10510
10511
10512
10513
10514
10515
10516
10517
10518
10519
10520
10521
10522
10523
10524
10525
10526
10527
10528
10529
10530
10531
10532
10533
10534
10535
10536
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554
10555
10556
10557
10558
10559
10560
10561
10562
10563
10564
10565
10566
10567
10568
10569
10570
10571
10572
10573
10574
10575
10576
10577
10578
10579
10580
10581
10582
10583
10584
10585
10586
10587
10588
10589
10590
10591
10592
10593
10594
10595
10596
10597
10598
10599
10600
10601
10602
10603
10604
10605
10606
10607
10608
10609
10610
10611
10612
10613
10614
10615
10616
10617
10618
10619
10620
10621
10622
10623
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641
10642
10643
10644
10645
10646
10647
10648
10649
10650
10651
10652
10653
10654
10655
10656
10657
10658
10659
10660
10661
10662
10663
10664
10665
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681
10682
10683
10684
10685
10686
10687
10688
10689
10690
10691
10692
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710
10711
10712
10713
10714
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729
10730
10731
10732
10733
10734
10735
10736
10737
10738
10739
10740
10741
10742
10743
10744
10745
10746
10747
10748
10749
10750
10751
10752
10753
10754
10755
10756
10757
10758
10759
10760
10761
10762
10763
10764
10765
10766
10767
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794
10795
10796
10797
10798
10799
10800
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819
10820
10821
10822
10823
10824
10825
10826
10827
10828
10829
10830
10831
10832
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842
10843
10844
10845
10846
10847
10848
10849
10850
10851
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869
10870
10871
10872
10873
10874
10875
10876
10877
10878
10879
10880
10881
10882
10883
10884
10885
10886
10887
10888
10889
10890
10891
10892
10893
10894
10895
10896
10897
10898
10899
10900
10901
10902
10903
10904
10905
10906
10907
10908
10909
10910
10911
10912
10913
10914
10915
10916
10917
10918
10919
10920
10921
10922
10923
10924
10925
10926
10927
10928
10929
10930
10931
10932
10933
10934
10935
10936
10937
10938
10939
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958
10959
10960
10961
10962
10963
10964
10965
10966
10967
10968
10969
10970
10971
10972
10973
10974
10975
10976
10977
10978
10979
10980
10981
10982
10983
10984
10985
10986
10987
10988
10989
10990
10991
10992
10993
10994
10995
10996
10997
10998
10999
11000
11001
11002
11003
11004
11005
11006
11007
11008
11009
11010
11011
11012
11013
11014
11015
11016
11017
11018
11019
11020
11021
11022
11023
11024
11025
11026
11027
11028
11029
11030
11031
11032
11033
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053
11054
11055
11056
11057
11058
11059
11060
11061
11062
11063
11064
11065
11066
11067
11068
11069
11070
11071
11072
11073
11074
11075
11076
11077
11078
11079
11080
11081
11082
11083
11084
11085
11086
11087
11088
11089
11090
11091
11092
11093
11094
11095
11096
11097
11098
11099
11100
11101
11102
11103
11104
11105
11106
11107
11108
11109
11110
11111
11112
11113
11114
11115
11116
11117
11118
11119
11120
11121
11122
11123
11124
11125
11126
11127
11128
11129
11130
11131
11132
11133
11134
11135
11136
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157
11158
11159
11160
11161
11162
11163
11164
11165
11166
11167
11168
11169
11170
11171
11172
11173
11174
11175
11176
11177
11178
11179
11180
11181
11182
11183
11184
11185
11186
11187
11188
11189
11190
11191
11192
11193
11194
11195
11196
11197
11198
11199
11200
11201
11202
11203
11204
11205
11206
11207
11208
11209
11210
11211
11212
11213
11214
11215
11216
11217
11218
11219
11220
11221
11222
11223
11224
11225
11226
11227
11228
11229
11230
11231
11232
11233
11234
11235
11236
11237
11238
11239
11240
11241
11242
11243
11244
11245
11246
11247
11248
11249
11250
11251
11252
11253
11254
11255
11256
11257
11258
11259
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277
11278
11279
11280
11281
11282
11283
11284
11285
11286
11287
11288
11289
11290
11291
11292
11293
11294
11295
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306
11307
11308
11309
11310
11311
11312
11313
11314
11315
11316
11317
11318
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334
11335
11336
11337
11338
11339
11340
11341
11342
11343
11344
11345
11346
11347
11348
11349
11350
11351
11352
11353
11354
11355
11356
11357
11358
11359
11360
11361
11362
11363
11364
11365
11366
11367
11368
11369
11370
11371
11372
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382
11383
11384
11385
11386
11387
11388
11389
11390
11391
11392
11393
11394
11395
11396
11397
11398
11399
11400
11401
11402
11403
11404
11405
11406
11407
11408
11409
11410
11411
11412
11413
11414
11415
11416
11417
11418
11419
11420
11421
11422
11423
11424
11425
11426
11427
11428
11429
11430
11431
11432
11433
11434
11435
11436
11437
11438
11439
11440
11441
11442
11443
11444
11445
11446
11447
11448
11449
11450
11451
11452
11453
11454
11455
11456
11457
11458
11459
11460
11461
11462
11463
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481
11482
11483
11484
11485
11486
11487
11488
11489
11490
11491
11492
11493
11494
11495
11496
11497
11498
11499
11500
11501
11502
11503
11504
11505
11506
11507
11508
11509
11510
11511
11512
11513
11514
11515
11516
11517
11518
11519
11520
11521
11522
11523
11524
11525
11526
11527
11528
11529
11530
11531
11532
11533
11534
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552
11553
11554
11555
11556
11557
11558
11559
11560
11561
11562
11563
11564
11565
11566
11567
11568
11569
11570
11571
11572
11573
11574
11575
11576
11577
11578
11579
11580
11581
11582
11583
11584
11585
11586
11587
11588
11589
11590
11591
11592
11593
11594
11595
11596
11597
11598
11599
11600
11601
11602
11603
11604
11605
11606
11607
11608
11609
11610
11611
11612
11613
11614
11615
11616
11617
11618
11619
11620
11621
11622
11623
11624
11625
11626
11627
11628
11629
11630
11631
11632
11633
11634
11635
11636
11637
11638
11639
11640
11641
11642
11643
11644
11645
11646
11647
11648
11649
11650
11651
11652
11653
11654
11655
11656
11657
11658
11659
11660
11661
11662
11663
11664
11665
11666
11667
11668
11669
11670
11671
11672
11673
11674
11675
11676
11677
11678
11679
11680
11681
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699
11700
11701
11702
11703
11704
11705
11706
11707
11708
11709
11710
11711
11712
11713
11714
11715
11716
11717
11718
11719
11720
11721
11722
11723
11724
11725
11726
11727
11728
11729
11730
11731
11732
11733
11734
11735
11736
11737
11738
11739
11740
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758
11759
11760
11761
11762
11763
11764
11765
11766
11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
11778
11779
11780
11781
11782
11783
11784
11785
11786
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851
11852
11853
11854
11855
11856
11857
11858
11859
11860
11861
11862
11863
11864
11865
11866
11867
11868
11869
11870
11871
11872
11873
11874
11875
11876
11877
11878
11879
11880
11881
11882
11883
11884
11885
11886
11887
11888
11889
11890
11891
11892
11893
11894
11895
11896
11897
11898
11899
11900
11901
11902
11903
11904
11905
11906
11907
11908
11909
11910
11911
11912
11913
11914
11915
11916
11917
11918
11919
11920
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938
11939
11940
11941
11942
11943
11944
11945
11946
11947
11948
11949
11950
11951
11952
11953
11954
11955
11956
11957
11958
11959
11960
11961
11962
11963
11964
11965
11966
11967
11968
11969
11970
11971
11972
11973
11974
11975
11976
11977
11978
11979
11980
11981
11982
11983
11984
11985
11986
11987
11988
11989
11990
11991
11992
11993
11994
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013
12014
12015
12016
12017
12018
12019
12020
12021
12022
12023
12024
12025
12026
12027
12028
12029
12030
12031
12032
12033
12034
12035
12036
12037
12038
12039
12040
12041
12042
12043
12044
12045
12046
12047
12048
12049
12050
12051
12052
12053
12054
12055
12056
12057
12058
12059
12060
12061
12062
12063
12064
12065
12066
12067
12068
12069
12070
12071
12072
12073
12074
12075
12076
12077
12078
12079
12080
12081
12082
12083
12084
12085
12086
12087
12088
12089
12090
12091
12092
12093
12094
12095
12096
12097
12098
12099
12100
12101
12102
12103
12104
12105
12106
12107
12108
12109
12110
12111
12112
12113
12114
12115
12116
12117
12118
12119
12120
12121
12122
12123
12124
12125
12126
12127
12128
12129
12130
12131
12132
12133
12134
12135
12136
12137
12138
12139
12140
12141
12142
12143
12144
12145
12146
12147
12148
12149
12150
12151
12152
12153
12154
12155
12156
12157
12158
12159
12160
12161
12162
12163
12164
12165
12166
12167
12168
12169
12170
12171
12172
12173
12174
12175
12176
12177
12178
12179
12180
12181
12182
12183
12184
12185
12186
12187
12188
12189
12190
12191
12192
12193
12194
12195
12196
12197
12198
12199
12200
12201
12202
12203
12204
12205
12206
12207
12208
12209
12210
12211
12212
12213
12214
12215
12216
12217
12218
12219
12220
12221
12222
12223
12224
12225
12226
12227
12228
12229
12230
12231
12232
12233
12234
12235
12236
12237
12238
12239
12240
12241
12242
12243
12244
12245
12246
12247
12248
12249
12250
12251
12252
12253
12254
12255
12256
12257
12258
12259
12260
12261
12262
12263
12264
12265
12266
12267
12268
12269
12270
12271
12272
12273
12274
12275
12276
12277
12278
12279
12280
12281
12282
12283
12284
12285
12286
12287
12288
12289
12290
12291
12292
12293
12294
12295
12296
12297
12298
12299
12300
12301
12302
12303
12304
12305
12306
12307
12308
12309
12310
12311
12312
12313
12314
12315
12316
12317
12318
12319
12320
12321
12322
12323
12324
12325
12326
12327
12328
12329
12330
12331
12332
12333
12334
12335
12336
12337
12338
12339
12340
12341
12342
12343
12344
12345
12346
12347
12348
12349
12350
12351
12352
12353
12354
12355
12356
12357
12358
12359
12360
12361
12362
12363
12364
12365
12366
12367
12368
12369
12370
12371
12372
12373
12374
12375
12376
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387
12388
12389
12390
12391
12392
12393
12394
12395
12396
12397
12398
12399
12400
12401
12402
12403
12404
12405
12406
12407
12408
12409
12410
12411
12412
12413
12414
12415
12416
12417
12418
12419
12420
12421
12422
12423
12424
12425
12426
12427
12428
12429
12430
12431
12432
12433
12434
12435
12436
12437
12438
12439
12440
12441
12442
12443
12444
12445
12446
12447
12448
12449
12450
12451
12452
12453
12454
12455
12456
12457
12458
12459
12460
12461
12462
12463
12464
12465
12466
12467
12468
12469
12470
12471
12472
12473
12474
12475
12476
12477
12478
12479
12480
12481
12482
12483
12484
12485
12486
12487
12488
12489
12490
12491
12492
12493
12494
12495
12496
12497
12498
12499
12500
12501
12502
12503
12504
12505
12506
12507
12508
12509
12510
12511
12512
12513
12514
12515
12516
12517
12518
12519
12520
12521
12522
12523
12524
12525
12526
12527
12528
12529
12530
12531
12532
12533
12534
12535
12536
12537
12538
12539
12540
12541
12542
12543
12544
12545
12546
12547
12548
12549
12550
12551
12552
12553
12554
12555
12556
12557
12558
12559
12560
12561
12562
12563
12564
12565
12566
12567
12568
12569
12570
12571
12572
12573
12574
12575
12576
12577
12578
12579
12580
12581
12582
12583
12584
12585
12586
12587
12588
12589
12590
12591
12592
12593
12594
12595
12596
12597
12598
12599
12600
12601
12602
12603
12604
12605
12606
12607
12608
12609
12610
12611
12612
12613
12614
12615
12616
12617
12618
12619
12620
12621
12622
12623
12624
12625
12626
12627
12628
12629
12630
12631
12632
12633
12634
12635
12636
12637
12638
12639
12640
12641
12642
12643
12644
12645
12646
12647
12648
12649
12650
12651
12652
12653
12654
12655
12656
12657
12658
12659
12660
12661
12662
12663
12664
12665
12666
12667
12668
12669
12670
12671
12672
12673
12674
12675
12676
12677
12678
12679
12680
12681
12682
12683
12684
12685
12686
12687
12688
12689
12690
12691
12692
12693
12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
12726
12727
12728
12729
12730
12731
12732
12733
12734
12735
12736
12737
12738
12739
12740
12741
12742
12743
12744
12745
12746
12747
12748
12749
12750
12751
12752
12753
12754
12755
12756
12757
12758
12759
12760
12761
12762
12763
12764
12765
12766
12767
12768
12769
12770
12771
12772
12773
12774
12775
12776
% \iffalse meta-comment
%
% Copyright (C) 2008 by
%    Joseph Wright <joseph.wright@morningstar2.co.uk>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The current maintainer of this work is Joseph Wright.
%
% This work consists of the source file siunitx.dtx
%                 and the derived files siunitx.ins,
%                                       siunitx.sty,
%                                       jawltxdoc.sty,
%                                       si-bug.ltx,
%                                       si-SIunits.cfg,
%                                       si-sistyle.cfg,
%                                       si-unitsdef.cfg,
%                                       si-units.cfg,
%                                       si-hepunits.cfg,
%                                       si-fancynum.cfg,
%                                       si-fancyunits.cfg,
%                                       si-prefix.cfg,
%                                       si-named.cfg,
%                                       si-prefixed.cfg,
%                                       si-addn.cfg,
%                                       si-accepted.cfg,
%                                       si-physical.cfg,
%                                       si-abbr.cfg,
%                                       si-synchem.cfg,
%                                       si-hep.cfg,
%                                       si-astro.cfg,
%                                       si-binary.cfg,
%                                       si-UK.cfg,
%                                       si-USA.cfg,
%                                       si-DE.cfg,
%                                       si-ZA.cfg,
%                                       siunitx.bib and
%                                       siunitx.pdf
%
% TDS-ready files:
%    The compressed file siunitx.tds.zip contains an unpacked version
%    of all of the files included here, and pre-compiled
%    documentation in PDF format.  Simply decompress siunitx.tds.dtx
%    in your local TeX directory, run your hash program (texhash,
%    initexmf --update-fndb, etc.) and everything will be ready to
%    go.  The user documentation for the package is called
%    siunitx-manual.pdf; the file siunitx.pdf includes the user
%    manual and the fully-indexed source code.
%
% Unpacking:
%    (a) If siunitx.ins is present:
%           tex siunitx.ins
%    (b) Without siunitx.ins:
%           tex siunitx.dtx
%    (c) If you use LaTeX to generate files:
%           latex \let\install=y\input{siunitx.dtx}
%
% Documentation:
%    (a) Without write18 enabled:
%          pdflatex siunitx.dtx
%          bibtex8 --wolfgang siunitx
%          makeindex -s gind.ist siunitx.idx
%          makeindex -s gglo.ist -o siunitx.gls siunitx.glo
%          pdflatex siunitx.dtx
%          pdflatex siunitx.dtx
%    (b) With write18 enabled:
%          pdflatex siunitx.dtx
%          pdflatex siunitx.dtx
%          pdflatex siunitx.dtx
%
% Installation:
%     Copy siunitx.sty and the various .cfg files to a location
%     searched by TeX, and if required by your TeX installation,
%     run the appropriate command to build a hash of files
%     (texhash, initexmf --update-fndb, etc.)
%
% Note:
%     The jawltxdoc.sty file is not needed for installation,
%     only for building the documentation; it may be deleted
%     after producing the documentation (if necessary).
%
%<*ignore>
% This is all taken verbatim from Heiko Oberdiek's packages
\begingroup
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
 ----------------------------------------------------------------
 The siunitx package --- A comprehensive (SI) units package
 Maintained by Joseph Wright
 E-mail: joseph.wright@morningstar2.co.uk
 Released under the LaTeX Project Public License v1.3c or later
 See http://www.latex-project.org/lppl.txt
 ----------------------------------------------------------------

\endpreamble
\Msg{Generating siunitx files:}
\generate{\file{jawltxdoc.sty}{\from{\jobname.dtx}{jawltxdoc}}
}
\usedir{tex/latex/siunitx}
\generate{\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\usedir{source/latex/siunitx}
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\usedir{doc/latex/siunitx}
\generate{\file{si-bug.ltx}{\from{\jobname.dtx}{bug}}
}
\usedir{tex/latex/siunitx/config}
\generate{\file{si-SIunits.cfg}{\from{\jobname.dtx}{SIunits}}
          \file{si-sistyle.cfg}{\from{\jobname.dtx}{sistyle}}
          \file{si-unitsdef.cfg}{\from{\jobname.dtx}{unitsdef}}
          \file{si-units.cfg}{\from{\jobname.dtx}{units}}
          \file{si-hepunits.cfg}{\from{\jobname.dtx}{hepunits}}
          \file{si-fancynum.cfg}{\from{\jobname.dtx}{fancynum}}
          \file{si-fancyunits.cfg}{\from{\jobname.dtx}{fancyunits}}
}
\generate{\file{si-prefix.cfg}{\from{\jobname.dtx}{prefix}}
          \file{si-named.cfg}{\from{\jobname.dtx}{named}}
          \file{si-prefixed.cfg}{\from{\jobname.dtx}{prefixed}}
          \file{si-addn.cfg}{\from{\jobname.dtx}{addn}}
          \file{si-accepted.cfg}{\from{\jobname.dtx}{accepted}}
          \file{si-physical.cfg}{\from{\jobname.dtx}{physical}}
          \file{si-abbr.cfg}{\from{\jobname.dtx}{abbr}}
}
\generate{\file{si-synchem.cfg}{\from{\jobname.dtx}{synchem}}
          \file{si-hep.cfg}{\from{\jobname.dtx}{hep}}
          \file{si-astro.cfg}{\from{\jobname.dtx}{astro}}
          \file{si-binary.cfg}{\from{\jobname.dtx}{binary}}
}
\generate{\file{si-UK.cfg}{\from{\jobname.dtx}{UK}}
          \file{si-USA.cfg}{\from{\jobname.dtx}{USA}}
          \file{si-DE.cfg}{\from{\jobname.dtx}{DE}}
          \file{si-ZA.cfg}{\from{\jobname.dtx}{ZA}}
}
\nopreamble\nopostamble
\usedir{doc/latex/siunitx}
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}
          \file{\jobname.bib}{\from{\jobname.dtx}{refs}}
}
\endbatchfile
%</install>
%<*readme>
----------------------------------------------------------------
The siunitx package --- A comprehensive (SI) units package
Maintained by Joseph Wright
E-mail: joseph.wright@morningstar2.co.uk
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
----------------------------------------------------------------

Typesetting values with units requires care to ensure that the
combined mathematical meaning of the value plus unit combination
is clear.  In particular, the SI units system lays down a
consistent set of units with rules on how these are to be used.
However, different countries and publishers have differing
conventions on the exact appearance of numbers (and units).

The siunitx provides a set of tools for authors to typeset
numbers and units in a consistent way.  The package has an
extended set of configuration options which make it possible to
follow varying typographic conventions with the same input
syntax.  The package includes automated processing of numbers
and units, and the ability to control tabular alignment of
numbers.

A number of LaTeX packages have been developed in the past for
formatting units: SIunits, sistyle, unitsdef, unitspkg,
fancyunits and fancynum.  Support for users of all of these
packages is available as emulation modules in siunitx.  In
addition, siunitx can carry out many of the functions of the
dcolumn, rccol and numprint packages.
%</readme>
%<*ignore>
\fi
% Will Robertson's trick
\immediate\write18{bibtex8 --wolfgang \jobname}
\immediate\write18{makeindex -s gind.ist -o \jobname.ind  \jobname.idx}
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls  \jobname.glo}
%</ignore>
%<*driver>
\PassOptionsToClass{a4paper}{article}
\documentclass[german,english,UKenglish]{ltxdoc}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%\OnlyDescription
% Various adjustments are needed to the packages loaded.  xfrac is
% only loaded if it is available.  MiKTeX users should note that they
% will need to download the expl3 and xbase bundles from CTAN to use
% xfrac; the MiKTeX versions are very old and will cause errors.
\usepackage[final]{graphicx}
\IfFileExists{xfrac.sty}
  {\usepackage{xfrac}}
  {}
\usepackage{jawltxdoc}
\usepackage{textcomp,tikz,pgfplots,tocloft}
\usepackage[latin1]{inputenc}
\sisetup{
  eVcorra=0.1ex,
  unitsep=cdot,
  alsoload={synchem,hep,binary,astro},
  loctolang={UK:UKenglish,DE:german}}
\setlength{\cftsubsecnumwidth}{2.5em}
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\CheckSum{9511}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
%\GetFileInfo{\jobname.sty}
%
%\DoNotIndex{\@car,\@eha,\@ehc,\@empty,\@firstofone,\@firstoftwo}
%\DoNotIndex{\@for,\@gobble,\@gobbletwo,\@ifl@aded,\@ifnextchar}
%\DoNotIndex{\@ifpackagelater,\@ifpackageloaded,\@ifstar}
%\DoNotIndex{\@ifundefined,\@makeother,\@namedef,\@nameuse,\@ne}
%\DoNotIndex{\@nil,\@secondoftwo,\@temptokena,\@undefined,\AA}
%\DoNotIndex{\active,\addto,\addtolength,\advance,\afterassignment}
%\DoNotIndex{\aftergroup,\AtBeginDocument,\AtEndOfPackage}
%\DoNotIndex{\begingroup,\bfseries,\bgroup,\boldmath,\box}
%\DoNotIndex{\capitalring,\catcode,\cdot,\chardef,\check@mathfonts}
%\DoNotIndex{\circ,\csname,\DeclareFontEncoding,\DeclareFontFamily}
%\DoNotIndex{\DeclareFontShape,\DeclareFontSubstitution}
%\DoNotIndex{\DeclareMathSymbol,\DeclareRobustCommand}
%\DoNotIndex{\DeclareSymbolFont,\DeclareTextSymbol}
%\DoNotIndex{\DeclareTextSymbolDefault,\def,\define@boolkey}
%\DoNotIndex{\define@choicekey,\define@cmdkey,\define@cmdkeys}
%\DoNotIndex{\define@key,\displaystyle,\displaywidth,\divide,\do}
%\DoNotIndex{\edef,\egroup,\else,\encodingdefault,\end,\endcsname}
%\DoNotIndex{\endgroup,\endinput,\endtabular,\ensuremath}
%\DoNotIndex{\expandafter,\f@family,\f@series,\fam,\fi,\font}
%\DoNotIndex{\fontsize,\frac,\gdef,\global,\hbox,\hfil,\hfill,\hskip}
%\DoNotIndex{\hspace,\hss,\ifcsname,\ifdim,\iffalse,\IfFileExists}
%\DoNotIndex{\ifmmode,\ifnum,\ifx,\ignorespaces,\inputencodingname}
%\DoNotIndex{\InputIfFileExists,\key@ifundefine,\let,\long,\m@ne}
%\DoNotIndex{\makeatletter,\math@version,\mathchoice,\mathnormal}
%\DoNotIndex{\mathord,\mathrm,\mathsf,\mathtt,\mdseries}
%\DoNotIndex{\MessageBreak,\mkern,\mp,\NC@find,\NeedsTeXFormat}
%\DoNotIndex{\newbox,\newcolumntype,\newcommand,\newcount,\newdimen}
%\DoNotIndex{\newif,\newlength,\newtoks,\nobreak,\noexpand,\p@}
%\DoNotIndex{\PackageError,\PackageInfo,\PackageWarning,\phantom}
%\DoNotIndex{\ProcessOptionsX,\protect,\protected@edef,\ProvidesFile}
%\DoNotIndex{\ProvidesPackage,\Q,\raisebox,\relax,\renewcommand}
%\DoNotIndex{\RequirePackage,\rlap,\sbox,\scantokens}
%\DoNotIndex{\scriptscriptstyle,\scriptstyle,\selectfont,\setbox}
%\DoNotIndex{\setkeys,\setlength,\settoheight,\sf@size,\sfdefault}
%\DoNotIndex{\sfrac,\skewchar,\sp,\space,\string,\strip@pt}
%\DoNotIndex{\tabularnewline,\text,\textdegree,\textmu,\textohm}
%\DoNotIndex{\textsc,\textstyle,\textsuperscript,\the,\thr@@,\times}
%\DoNotIndex{\ttdefault,\uccode,\unboldmath,\unhbox,\upmu,\Upomega}
%\DoNotIndex{\uppercase,\upshape,\wd,\xdef,\xspace,\z@}
%
%\DoNotIndex{\if,\lowercase,\+,\,,\-,\.,\:,\;,\@argdef,\@cdr}
%\DoNotIndex{\@ifdefinable,\@testopt,\@yargdef,\color,\endlinechar}
%\DoNotIndex{\key@ifundefined,\newrobustcmd,\protected,\scriptspace}
%\DoNotIndex{\usebox,\tw@,\ifinner,\usepackage,\texttt,\textsf}
%\DoNotIndex{\NC@do,\loop,\l@ngrel@x,\g@addto@macro,\documentclass}
%\DoNotIndex{\document\,\begin,\=,\@ehb,\\,\listfiles}
%
%\DoNotIndex{\pascalsecond,\amperemetresecond,\ohmmetre}
%\DoNotIndex{\newtonmetre,\newtonmetrenp}
%\DoNotIndex{\kilogramsquaremetre,\kilogramsquaremetrenp}
%
%\changes{v1.0}{2008/06/12}{First official release}
%
%\setkeys{lst}{language=[LaTeX]{TeX},moretexcs={sisetup,num,ang,SI,
%  si,newunit,newpower,newprefix,metre,candela,kelvin,ampere,eV,
%  second,mole,per,kilogram,Square,squared,cubed,cubic,kilo,centi,
%  gram,tothe,toprule,midrule,bottomrule,newton,micro,joule,mega,
%  raiseto,deci,mathnormal,numprint,electronvolt,selectlanguage,
%  kibi,byte,molar,Molar,mmHg,mebi,torr,parsec,lightyear,clight,
%  eVperc,addplot,color,milli,cm,Hz,kg,DeclareRobustCommand,
%  pascal,dalton}}
%
%\title{\currpkg\ --- A comprehensive (SI) units package^^A
%  \thanks{This file describes version \fileversion, last revised
%    \filedate.}}
%\author{Joseph Wright^^A
%  \thanks{E-mail: joseph.wright@morningstar2.co.uk}}
%\date{Released \filedate}
%
%\maketitle
%
%\newcommand*{\SIunits}{\pkg{SIunits}\xspace}
%\newcommand*{\SIstyle}{\pkg{SIstyle}\xspace}
%\newcommand*{\unitsdef}{\pkg{unitsdef}\xspace}
%\newcommand*{\units}{\pkg{units}\xspace}
%\newcommand*{\numprint}{\pkg{numprint}\xspace}
%\begin{abstract}
% Typesetting values with units requires care to ensure that the
% combined mathematical meaning of the value plus unit combination is
% clear.  In particular, the SI units system lays down a consistent
% set of units with rules on how these are to be used.  However,
% different countries and publishers have differing conventions on
% the exact appearance of numbers (and units).
%
% The \currpkg provides a set of tools for authors to typeset numbers
% and units in a consistent way.  The package has an extended set of
% configuration options which make it possible to follow varying
% typographic conventions with the same input syntax.  The package
% includes automated processing of numbers and units, and the ability
% to control tabular alignment of numbers.
%
% A number of \LaTeX\ packages have been developed in the past for
% formatting units: \SIunits, \SIstyle, \unitsdef, \units,
% \pkg{fancyunits} and \pkg{fancynum}. Support for users of all of
% these packages is available as emulation modules in \currpkg.
% In addition, \currpkg can carry out many of the functions of the
% \pkg{dcolumn}, \pkg{rccol} and \numprint packages.
%\end{abstract}
%
%\begin{multicols}{2}
%  \tableofcontents
%\end{multicols}
%
%\clearpage
%\part{Introduction}
% The correct application of units of measurement is very important
% in technical applications.  For this reason, carefully-crafted
% definitions of a coherent units system have been laid down by the
% \latin{Conf\'erence G\'en\'erale des Poids et
% Mesures}\footnote{General Conference on Weights and Measures.}
% (CGPM): this has resulted in the \latin{Syst\`eme International
% d'Unit\'es}\footnote{International System of Units.} (SI).  At the
% same time, typographic conventions for correctly displaying both
% numbers and units exist to ensure that no loss of meaning occurs in
% printed matter.
%
% \currpkg aims to provide a unified method for \LaTeX\ users to
% typeset units and values correctly and easily.  The design
% philosophy of \currpkg is to follow the agreed rules by default,
% but to allow variation through option settings.  In this way,
% users can use \currpkg to follow the requirements of publishers,
% co-authors, universities, \etc without needing to alter the input
% at all.
%
% \currpkg is intended as a complete replacement for \SIunits,
% \SIstyle, \unitsdef, \units, \pkg{fancyunits} and
% \pkg{fancynum}. As such, emulation modes are provided for all of
% these packages.  Where possible, conventions from the existing
% solutions have been used here.  For example, the macros \cs{num},
% \cs{ang} and \cs{SI} act in a very similar fashion to those in
% existing packages.
%
%\clearpage
%\part{Using the \currpkg package}
%
%\section{For the impatient}
% \currpkg provides the user macros:
%\begin{itemize}
%  \item \cs{SI}\oarg{options}\marg{value}\oarg{pre-unit}\marg{unit}
%  \item \cs{si}\oarg{options}\marg{unit}
%  \item \cs{num}\oarg{options}\marg{number}
%  \item \cs{ang}\oarg{options}\marg{angle}
%  \item \cs{sisetup}\marg{options}
%\end{itemize}
% plus the |S| and |S| column types for decimal alignments and units
% in tables.  These macros are designed for typesetting units and
% values with control of appearance and with intelligent processing.
%
% By default, all text is typeset in the current upright, serif maths
% font.  This can be changes by setting the appropriate package
% options: \opt{obeyall} will use the current font for typesetting.
%
% The package includes a ``unit processor'', which allows the use of
% named units or literal values.  Named units are processed to
% correctly include powers.
%\begin{LaTeXexample}
%  \SI{10}{\gram}\\
%  \SI{23.4}{g.cm^3}\\
%  \num{1e34}\\
%  \ang{1;2;3}\\
%  \emph{\SI{16,7}{\metre\per\second}}\\
%  \textbf{\SI{30e3}{\Hz}}\\
%  \SI{1.2 x 3.56 x 9.2}{\milli\metre}\\
%  \sisetup{obeyall}
%  \textbf{\SI{-4.5}{\cm}}\\
%  \si{\joule\per\mole\per\kelvin}\\
%  \si[per=frac]{\joule\per\mole\per\kelvin}\\
%  \num[dp=4]{1.23456}\\
%  \num[dp=4]{9.8}\\
%  \begin{tabular}{S[tabformat=3.2]}
%    \toprule
%    {Heading}\\
%    \midrule
%    1.3 \\
%    134.2 \\
%    3.56 \\
%    74,7 \\
%    \bottomrule
%  \end{tabular}
%\end{LaTeXexample}
%
%\section{Requirements}
% \currpkg requires a reasonably up to date \TeX\ system.  The
% package requires \eTeX-extensions, which should be available on
% most systems.\footnote{If you have an old \LaTeX\, try
% ``\texttt{elatex}'' rather than ``\texttt{latex}''.}  The following
% packages are also needed:
%\begin{itemize}
%  \item \pkg{array} and \pkg{xspace}: from the \pkg{tools} bundle,
%    which should be available to everyone;
%  \item \pkg{xkeyval}: this processes the option handling, and needs
%    to be at least v2.5;
%  \item \pkg{amstext}: from the \AMS\TeX\ support bundle (the
%    \AMS\ fonts are also needed to provide the default upright
%    \si{\micro}).
%\end{itemize}
% Hopefully most people using the package will have access to all of
% those items.
%
% To use the \opt{fraction=sfrac} option, the \pkg{xfrac} package is
% needed.  This needs various experimental \LaTeX3 packages.  As a
% result, \currpkg does not load \pkg{xfrac}.  If you want to use
% \opt{fraction=sfrac}, \emph{you} need to load \pkg{xfrac} in your
% preamble before \currpkg.\footnote{This document has been compiled
% in this way.  You have to load \pkg{xfrac} first as otherwise very
% nasty things happen with \pkg{xkeyval}.  MiK\TeX\ users should note
% that the packaged versions of \pkg{expl3}, \pkg{template} and
% \pkg{xparse} will not work with \pkg{xfrac}: download copies from
% \textsc{ctan}!} If the package is not loaded, \opt{fraction=sfrac}
% falls back on a \pkg{nicefrac}-like method.  The interested user
% should look at the \pkg{xfrac} documentation for reasons this might
% not be ideal.\footnote{On the other hand, some fractional units
% will look really bad with \cs{sfrac}.  Use this option with
% caution.}
%
%\section{Loading the package}
% \currpkg is loaded by the usual \LaTeX\ method.
%\begin{LaTeXexample}[noexample]
%  \usepackage[<options>]{siunitx}
%\end{LaTeXexample}
% As is shown in the example, the package can be loaded with one or
% more options, using the key--value system.  The full range of
% package options are described in Section~\ref{sec:options}; some
% options are described in the along with the appropriate user
% macros.  Most of the user macros accept the same key--value
% settings as an optional argument.
%
%\section{Numbers}
%\DescribeMacro{\num}
% Numbers are automatically formatted by the \cs{num} macro.  This
% takes one optional and one mandatory argument:
% \cs{num}\oarg{options}\marg{number}.  The contents of \meta{number}
% are automatically formatted, in a similar method to that used by
% \numprint.  The formatter removes ``hard'' spaces (\cs{,} and |~|),
% automatically identifies exponents (by default marked using |e| or
% |d|) and adds the appropriate spacing of large numbers.  A leading
% zero is added before a decimal marker, if needed: both ``|.|'' and
% ``|,|'' are recognised as decimal marker.
%\begin{LaTeXexample}
%  \num{1}    \num{123}     \num{1234}  \num{12345}\\
%  \num{0.1}  \num{0.123}   \num{0,1234} \num{.12345}\\
%  \num{1e10} \num{3.45d-4} \num{-e10}
%\end{LaTeXexample}
% Various error-checking systems are built into the package, so that
% if \meta{number} does not contain any numeric characters, a warning
% is issued.  Isolated signs are also detected.  The package
% recognises |(| and |)| as ``extra'' characters, which can be used
% to indicate the error in a number.\footnote{This is common in
% chemical crystallography, for example.}  The \opt{seperr} causes
% this data to be given as a separate error value.  If the number
% also contains an exponent, then brackets are re-added after the
% separation to ensure that meaning is not lost.
%\begin{LaTeXexample}
%  $\num{1.234(5)} = \num[seperr]{1.234(5)}$\\
%  $\num{1.234(5)e6} = \num[seperr]{1.234(5)e6}$
%\end{LaTeXexample}
% The same applies to the unit and value macro \cs{SI}, described
% later, for example the rest mass of an electron \cite{IUPAC}:
%\begin{LaTeXexample}
%   $ m_{\mathrm{e}}
%     = \SI{9.1093897(54)e-31}{\kg} $\\
%   $ m_{\mathrm{e}}
%     = \SI[seperr]{9.1093897(54)e-31}{\kg} $
%\end{LaTeXexample}
%
% A number of effects are available as options.  These are fully
% explained in Section~\ref{sec:options}.  Some of the more useful
% options are illustrated here.  By default, the output of the
% package is typeset in maths mode.  However, the use of the current
% text font can be forced.\footnote{This document is typeset using
% lowercase numbers in text mode, which emphasises the effect here.}
%\begin{LaTeXexample}
%  \num{1234567890} \num[mode=text]{1234567890}
%\end{LaTeXexample}
% \currpkg can automatically add zeros and signs to numbers.  This
% can be altered as desired.
%\begin{LaTeXexample}
%  \num{1.}  \num[padnumber=all]{1.}\\
%  \num{2}   \num[addsign=all]{2}\\
%  \num{3e4} \num[addsign=mant]{3e4} \num[addsign=all]{3e4}\\
%  \num{.5}  \num[padnumber=none]{.5}
%\end{LaTeXexample}
% The separation of digits can be turned on and off, and the output
% changed.
%\begin{LaTeXexample}
%  \num{1234}  \num[sepfour=true]{1234}\\
%  \num{12345} \num[digitsep=comma]{12345}\\
%  \num[digitsep=none]{12345}
%\end{LaTeXexample}
% The formatting of exponents is also customisable.
%\begin{LaTeXexample}
%  \num{1e10} \num[expproduct=cdot]{1e10}\\
%  \num{2e20} \num[expbase=5]{2e20}\\
%  \num{3e30} \num[expproduct=tighttimes]{3e30}
%\end{LaTeXexample}
%
% \currpkg can automatically add colour to negative numbers, which is
% often useful for highlighting purposes.  This is turned on with the
% \opt{colourneg} option; the colour used is set by \opt{negcolour}.
% Both of these are available with the US spellings: \opt{colorneg}
% and \opt{negcolor}.
%\begin{LaTeXexample}
%  \num{-1}\\
%  \sisetup{colourneg} \num{-2}\\
%  \num{3e-3}\\
%  \num[negcolour=blue]{-4}
%\end{LaTeXexample}
%
% \currpkg can automatically zero-fill and round to a fixed number of
% decimal places.  This is controlled by two options \opt{fixdp} and
% \opt{dp}.  The later is an integer which specifies how many places
% to fix to; setting this option automatically sets \opt{fixdp} to
% \opt{true}.  The place-fixing system will only alter pure numbers: for
% example, any error component will result in the input being left
% unchanged.
%\begin{LaTeXexample}
%  \num{1.23456}\\
%  \sisetup{dp=2}
%  \num{1.23456}\\
%  \num{9.8}\\
%  \num{-10.432}\\
%  \num{44.3221(2)}
%\end{LaTeXexample}
%
%\section{Tabular material}
%\subsection{Aligning numbers}
% Centring numbers in tabular content is handled by a new column
% type, the |S| column.  This is based closely on the \pkg{dcolumn}
% method for centring numbers in columns, but adds the functionality
% of the \cs{num} macro.\footnote{The approach used is actually a
% combination of \pkg{dcolumn} for centring the material and
% \numprint for processing it.  It will therefore give rather
% different results than the \texttt{n} and \texttt{N} column types
% in \numprint.}
%
% By default, the decimal marker of the number is placed at the
% centre of the column, which then resizes to accommodate the width
% of the contents (\ref{tab:default}).  This behaviour is set by the
% \opt{tabnumalign=centredecimal} option.  By setting the
% \opt{tabnumalign} option to \opt{centre}, the centre of the space
% reserved for the number is placed at the centre of the column.  The
% space reserved is stored in \opt{tabformat}, which is of the form
% \texttt{\meta{before}\meta{dec}\meta{after}}, where \meta{before}
% is the number of characters before the decimal marker and
% \meta{after} is the number after. Thus in the example,
% \opt{tabformat=2.4} provides space for two digits before the
% decimal marker and four after.  \opt{tabnumalign} can also be set
% to \opt{left} and \opt{right}, with the expected results.
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \caption{Behaviour of \texttt{S} column type
%      \label{tab:default}}
%    \centering
%    \begin{tabular}{%
%      S%
%      S[tabnumalign=centre,tabformat=2.4]%
%      S[tabnumalign=right,tabformat=2.4]%
%      S[tabnumalign=centre,tabformat=2.4,decimalsymbol=comma]}
%    \toprule
%    {Some Values} & {Some Values} & {Some Values} & {Some Values} \\
%    \midrule
%     2.3456  &  2.3456  &  2.3456 &  2.3456 \\
%    34.2345  & 34.2345  & 34.2345 & 34.2345 \\
%    56.7835  & 56.7835  & 56.7835 & 56.7835 \\
%    90.473   & 90.473   & 90.473  & 90.473  \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
% The \opt{tabformat} setting can also be used to reserve space for
% numbers containing exponents.  This is given in the same format as
% above, but with a mantissa and exponent part (\ref{tab:exptab}).
% Notice that this is designed to expect that numbers will contain a
% mantissa.  Exponents can either be aligned so that the ``$\times$''
% symbols match up vertically, or the exponent part can be allowed to
% move across as needed. Space for signs is added by using any sign
% in the \opt{tabformat}, so for example \opt{tabformat=+2.2} and
% \opt{tabformat=-2.2} have exactly the same effect. Setting
% \opt{tabformat} will automatically switch from \opt{tabnumalign}
% from \opt{centredecimal} to \opt{centre}, if the former is
% currently set. In other cases, the current alignment option is
% retained.
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \caption{Exponents in tables
%      \label{tab:exptab}}
%    \centering
%    \begin{tabular}{%
%      S[tabnumalign=right,tabformat=2.2e2]%
%      S[tabnumalign=centre,tabformat=2.2e1.1]%
%      S[tabnumalign=centre,tabformat=2.2e1.1,tabalignexp=false]%
%      S[tabnumalign=centre,tabformat=+2.2]}
%    \toprule
%        {Longer values}
%      & {Longer values}
%      & {Longer values}
%      & {Values} \\
%    \midrule
%    2.3e1    &  2.34e1  &  2.34e1  & +2.31 \\
%    34.23e45 & 34.23e45 & 34.23e45 & 34.23 \\
%    56.78    & 56.78    & 56.78    & -56.78 \\
%    1.0e34   & 1.0e34   & 1.0e34   & +-1.0 \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
%
% Data not to be processed as a number should be protected by
% wrapping it in braces: this is most likely to be true for column
% headers (again as illustrated).  By default, the contents of
% non-numeric cells are centred.  This can be altered by setting
% \opt{tabtextalign}, which can be set to \opt{left}, \opt{right} or
% \opt{centre}.  The use of digit separators in table columns is
% accounted for: extra space is reserved if digit separators will be
% added.
%
%\subsection{Columns of units}
% As a complement to the |S| column, \currpkg also provides a second
% column type, |s|.  This is intended for producing columns of units.
%  The letters chosen are intended to be similar to \cs{SI} and
% \cs{si}, respectively.  The alignment of material in |s| columns
% is governed by the \opt{tabunitalign} option.
%\begin{LaTeXexample}[float]
%  \begin{table}
%  \centering
%  \caption{Number and units in tables}
%  \label{tab:num-unit}
%    \begin{tabular}{%
%      S[tabformat=1.2e-1,tabnumalign=centre]%
%      s[tabunitalign=left]}
%    \toprule
%      {Value} &  \multicolumn{1}{c}{Unit} \\
%    \midrule
%      2.16e-5 & \metre\squared\per\second \\
%      2.83e-6 & \metre\squared\per\second \\
%      7.39e3  & \pascal\cubic\metre\per\mole \\
%      1.0e5   & \pascal \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
%
%\section{Angles}
%\DescribeMacro{\ang}
% Angles can be typeset using the \cs{ang} command.  This takes two
% arguments, \cs{ang}\oarg{options}\marg{angle}, where \meta{options}
% can be any of the package options to apply only to this value.
% \meta{angle} can be given either as a decimal number or as a
% semi-colon separated list of degrees, minutes and seconds, \ie\
% \cs{ang}\marg{decimal angle} or
% \cs{ang}|{|\meta{degrees}|;|\meta{minutes}|;|\meta{seconds}|}|. By
% default, no space is introduced between angles and the degrees,
% minutes and seconds markers.
%\begin{LaTeXexample}
%  \ang{10} \ang{12.3} \ang{4,5}\\
%  \ang{1;2;3} \ang{;;1}\\
%  \ang{+10;;} \ang{-0;1;}
%\end{LaTeXexample}
%
% By default, angles with no degrees (or minutes) are zero-filled;
% angles with degrees but no minutes or seconds are not filled.  This
% behaviour can be altered using the package options.
%\begin{LaTeXexample}
%  \ang{;;1} \ang[padangle=none]{;;1}\\
%  \ang{2;;} \ang[padangle=all]{2;;}\\
%  \sisetup{padangle=all} \ang{;3;} \ang{4;;} \ang{;;5}
%\end{LaTeXexample}
% The \cs{num} macro is used to typeset each number of the angle, so
% the options for \cs{num} also apply here.  The \opt{anglesep} value
% can be used to separate degrees, minutes and seconds.
%\begin{LaTeXexample}
%  \ang{1.05}    \ang[decimalsymbol=comma]{1.05}\\
%  \ang{3.67890} \ang[digitsep=comma]{3.67890}\\
%  \ang{9;8;7}   \ang[anglesep=thin]{9;8;7}
%\end{LaTeXexample}
% The degrees, minutes and seconds signs can be placed over the
% decimal sign using the \opt{astroang} option.  This is designed on
% the assumption that only the last number given has a decimal
% part.
%\begin{LaTeXexample}
%  \ang{1.2} \ang[astroang]{1.2}\\
%  \ang{1;2.3;} \ang[astroang]{1;2.3;}\\
%  \ang{1;2;3.4} \ang[astroang]{1;2;3.4}
%\end{LaTeXexample}
%
%\section{Units and values}
%\DescribeMacro{\SI}
% The core aim of \currpkg is correctly typesetting values which have
% units. The main output macro here is \cs{SI}, which has the same
% syntax as the macros with the same name in \SIstyle and \unitsdef
% packages. The \cs{SI} macro takes two mandatory arguments, in
% addition to the optional set up argument, and a second optional
% argument:
% \cs{SI}\oarg{options}\marg{number}\oarg{preunit}\marg{unit}.  The
% \meta{number} argument operates in exactly the same manner as the
% equivalent argument of the \cs{num} macro.  \meta{unit} will be
% typeset with a non-breakable space between it and the preceding
% number, with font control as outlined earlier.  Finally,
% \meta{preunit} is a unit to be typeset \emph{before} the numerical
% value (most likely to be a currency).  Some examples illustrate the
% general power of the macro.
%\begin{LaTeXexample}
%  \SI[mode=text]{1.23}{J.mol^{-1}.K^{-1}}\\
%  \SI{.23e7}{\candela}\\
%  \SI[per=slash]{1.99}[\pounds]{\per\kilogram}\\
%  \SI{70}{\metre\per\second}\\
%  \SI[per=frac,fraction=nice]{1,345}{\ampere\per\mole}
%\end{LaTeXexample}
% The use of unit macros outside of the \cs{SI} macro is described
% later.
%
%\subsection{Literal units}
% Units can be input in two ways, inspired by \SIstyle and \SIunits.
% The \SIstyle-like method uses literal input.  Four characters have
% a special meaning:
%\begin{itemize}
%  \item ``|^|'' The superscript character is used without the usual
%    need for surrounding maths characters (|$|);^^A$
%  \item ``|.|'' and ``|,|'': the full stop (point) symbol and comma
%    are made active, and produce the current contents of the
%    \opt{unitsep} option;
%  \item ``|~|'' The contents of the \opt{unitspace} option are typeset
%    by a tilde.
%\end{itemize}
% This allows ready input of units.
%\begin{LaTeXexample}
%  \SI{10}{kg.m.s^{-2}}\\
%  \SI{1.453}{g/cm^3}\\
%  \SI{33.562}{cd~s}\\
%  \SI[unitsep=medium]{100}{m.s^{-2}}
%\end{LaTeXexample}
% The literal unit system will correctly typeset input containing the
% symbols \si{\micro} (micro), \si{\degree} (degree) and
% \si{\angstrom} (ring-A).\footnote{Currently this works with \XeTeX\
% and \pkg{inputenc} using the \texttt{latin1}, \texttt{latin5} and
% \texttt{latin9} encodings.}
% \begingroup\makeatletter\si@unt@nonlatin
%\begin{LaTeXexample}
%  \SI{10}{µm}\\
%  \SI{20}{°C}\\
%  \SI{30}{Å}
%\end{LaTeXexample}
%\endgroup
%
%\subsection{The unit interpreter}
% The second operation mode for the \cs{SI} macro is based on the
% behaviour of \SIunits.  Here, each unit, SI multiple prefix and
% power is given a macro name.  These are entered in a method very
% similar to the reading of the unit name in English.
%\begin{LaTeXexample}
%  \SI{10}{\kilo\gram\metre\per\second\squared}\\
%  \SI{1.453}{\gram\per\cubic\centi\metre}\\
%  \SI{33.562}{\candela\second}\\
%  \SI[unitsep=thin]{100}{\metre\per\Square\second}\\
%  \SI[prefixsymbolic=false]{4.56}{\kilo\metre\per\second}
%\end{LaTeXexample}
% On its own, this is very similar to \SIunits, and is less
% convenient than the direct input method.\footnote{Users of \SIunits
% should note the lack of need for a \cs{usk}-type macro.}  However,
% the package allows you to define new unit macros; a large number of
% pre-defined abbreviations are also supplied.  More importantly, by
% defining macros for units, instead of literal values, new
% functionality is made available.  Units may be re-defined to give
% different output, and handling of reciprocal values can be altered.
%\begin{LaTeXexample}
%  \SI[per=frac,fraction=frac]{10}{\gram\metre\per\second\squared}\\
%  \SI[per=slash]{1.453}{\gram\per\cubic\centi\metre}\\
%  \SI{33.562}{\candela\second}\\
%  \SI[per=frac,fraction=nice]{100}{\metre\per\Square\second}
%\end{LaTeXexample}
% The unit processor will trap \emph{some} errors in the input and
% give the ``best guess'' result.  However, it is down to the user to
% check the output.
%
%\subsection{Powers of units}
%\DescribeMacro{\Square}
%\DescribeMacro{\ssquare}
%\DescribeMacro{\squared}
%\DescribeMacro{\cubic}
%\DescribeMacro{\cubed}
% Including powers in units is handled using a ``natural language''
% method.  Thus preceding a unit by \cs{Square} or \cs{cubic} which
% raise the unit to the appropriate power, while \cs{squared} or
% \cs{cubed} follow the unit they apply to. The \cs{Square} macro is
% capitalised to avoid a name clash with \pkg{pstricks}; the
% alternative \cs{ssquare} is also provided.
%\begin{LaTeXexample}
%  \SI{10}{\metre\squared}\\
%  \SI{20}{\Square\metre}\\
%  \SI{30}{\metre\cubed}\\
%  \SI{40}{\cubic\metre}
%\end{LaTeXexample}
%
%\DescribeMacro{\per}
% The \cs{per} macro intelligently creates reciprocal powers, and
% also adds the power $-1$ when appropriate.
%\begin{LaTeXexample}
%  \SI{10}{\per\second\squared}\\
%  \SI{20}{\per\Square\second}\\
%  \SI[per=frac,fraction=nice]{30}{\per\second\cubed}\\
%  \SI[per=slash]{40}{\per\cubic\second}\\
%  \SI{50}{\per\second}\\
%  \SI{60}{\per\metre\Square\candela}
%\end{LaTeXexample}
%
%\DescribeMacro{\tothe}
%\DescribeMacro{\raiseto}
% For powers not defined above or with \cs{newpower}, the \cs{tothe}
% macro can be used ``in line'' to produce a power.  As follows from
% standard English usage, this comes after the unit. \cs{raiseto}
% achieves the same, but is used \emph{before} a unit to add a power
% \emph{after}.\footnote{\cs{raiseto} acts in the same way as
% \cs{tothe} when used in a literal context: the power will be
% produced where the macro is, rather than moving after the next
% item.}
%\begin{LaTeXexample}
%  \SI{16.86}{\metre\tothe{4}}\\
%  \SI{7.895}{\raiseto{-6}\newton}\\
%  \SI{1.34}{\per\kelvin\tothe{7}}
%\end{LaTeXexample}
%
%\subsection{Units with no values}
%\DescribeMacro{\si}
% For typesetting the symbol for a unit on its own, with the full
% font control and without extra spaces, the \cs{si} macro is
% provided.\footnote{The same effect can be achieved using the
% \cs{SI} macro with an empty numerical argument.}  The macro name
% avoids a clash with the functionality of the earlier packages, but
% is similar to \cs{ilu} from the \unitsdef package.
%\begin{LaTeXexample}
%  \SI{}{kg.m/s^2}\\
%  \si{kg.m/s^2}\\
%  \si[mode=text,unitsep=thin]{\mole\per\cubic\deci\metre}
%\end{LaTeXexample}
%
%\subsection{Free-standing units}
% Users of the \unitsdef package will be a accustomed to using unit
% macros on their own (following a value) or with an optional
% argument containing a number.  In both cases, only a single unit
% macro could be used. \currpkg supports both operation modes, with
% the limitation that units trailing values loose font control of the
% value.  When used in this way, the units \emph{do not} take an
% optional \pkg{keyval} argument.
%\begin{LaTeXexample}
%  \sisetup{prespace,allowoptarg}
%  123\metre\\
%  \kelvin[123]\\
%  \sisetup{mode=text} \ampere[234]\\
%  6\second
%\end{LaTeXexample}
%
%\subsection{Pre-defined units, prefixes and powers}
%\newcommand*{\csindex}[1]{^^A
%  \cs{#1}^^A
%  \expandafter\SpecialUsageIndex\csname#1\endcsname}
%\newcommand*{\unitinfo}[1]{^^A
%  #1 & \csindex{#1} &
%  \expandafter\si\expandafter{\csname#1\endcsname}}
%\begin{table}
%  \caption{The seven base SI units}
%  \label{tab:baseunits}
%  \centering
%  \begin{tabular}{lll}
%    \toprule
%      \multicolumn{1}{c}{Unit} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Symbol} \\
%    \midrule
%    \unitinfo{kilogram}\\
%    \unitinfo{metre}\\
%    \unitinfo{second}\\
%    \unitinfo{mole}\\
%    \unitinfo{kelvin}\\
%    \unitinfo{ampere}\\
%    \unitinfo{candela}\\
%    \bottomrule
%  \end{tabular}
%\end{table}
%\DescribeMacro{\metre}
%\DescribeMacro{\meter}
% The package always defines the seven base SI units, irrespective of
% any package options given (\ref{tab:baseunits}). The kilogram is
% notable as by default it is a \emph{base} unit with a prefix. Thus,
% when the package is loaded with the option \opt{load=\{\}},
% \cs{kilo} and \cs{gram} \emph{are not defined}.  As metre is often
% spelled as ``meter'' in the US, the macro \cs{meter} is provided in
% addition to the \cs{metre} macro.\footnote{The official SI spelling
% for the unit is ``metre''.}
%
% By default, a number of additional definitions are created by the
% package.  These are controlled by the \opt{load} and \opt{noload}
% options. Unless specifically requested with the option
% \opt{noload=prefix}, \currpkg defines the standard prefixes for
% powers of ten (\ref{tab:prefix}).  This leads to the redefinition
% of \cs{kilogram} as \cs{kilo}\cs{gram}.  The macro \cs{deka} is
% provided, as this is used as an alias for \cs{deca} in some places.
% The package also defines a number of derived SI units which have
% assigned names and symbols (\ref{tab:derived}). Note that \cs{Gray}
% is capitalised to avoid a name clash with the \pkg{pstricks}
% package.\footnote{The macros \cs{ohm} and \cs{celsius} are not
% defined by \currpkg if the \pkg{gensymb} package is loaded.}
%\newcommand*{\prefixunitsym}[1]{\si[prefixsymbolic=false]{#1}}
%\newcommand*{\prefixinfo}[1]{^^A
%  #1 & \csindex{#1} &
%    \expandafter\prefixunitsym\expandafter{\csname#1\endcsname} &
%    \expandafter\si\expandafter{\csname#1\endcsname}}
%\begin{table}
%  \caption{The SI prefixes (\opt{load=prefix})}
%  \label{tab:prefix}
%  \centering
%  \begin{tabular}{lllclllc}
%    \toprule
%      \multicolumn{1}{c}{Prefix} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Power} &
%      Symbol &
%      \multicolumn{1}{c}{Prefix} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Power} &
%      Symbol \\
%    \midrule
%    \prefixinfo{yocto} &
%    \prefixinfo{deca} \\
%    \prefixinfo{zepto} &
%    \prefixinfo{hecto} \\
%    \prefixinfo{atto} &
%    \prefixinfo{kilo} \\
%    \prefixinfo{femto} &
%    \prefixinfo{mega} \\
%    \prefixinfo{pico} &
%    \prefixinfo{giga} \\
%    \prefixinfo{nano} &
%    \prefixinfo{tera} \\
%    \prefixinfo{micro} &
%    \prefixinfo{peta} \\
%    \prefixinfo{milli} &
%    \prefixinfo{exa} \\
%    \prefixinfo{centi} &
%    \prefixinfo{zetta} \\
%    \prefixinfo{deci} &
%    \prefixinfo{yotta} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%\begin{table}
%  \caption{The derived SI units with defined names
%    (\opt{load=derived})}
%  \label{tab:derived}
%  \centering
%  \begin{tabular}{llllll}
%    \toprule
%      \multicolumn{1}{c}{Unit} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Symbol} &
%      \multicolumn{1}{c}{Unit} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Symbol} \\
%    \midrule
%    \unitinfo{becquerel} &
%    \unitinfo{newton} \\
%    \unitinfo{celsius} &
%    \unitinfo{ohm} \\
%    \unitinfo{coulomb} &
%    \unitinfo{pascal} \\
%    \unitinfo{farad} &
%    \unitinfo{radian} \\
%    \unitinfo{Gray} &
%    \unitinfo{siemens} \\
%      & \csindex{ggray} & \ggray &
%    \unitinfo{sievert} \\
%    \unitinfo{hertz} &
%    \unitinfo{steradian} \\
%    \unitinfo{henry} &
%    \unitinfo{tesla} \\
%    \unitinfo{joule} &
%    \unitinfo{volt} \\
%    \unitinfo{katal} &
%    \unitinfo{watt} \\
%    \unitinfo{lumen} &
%    \unitinfo{weber} \\
%    \unitinfo{lux} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
% In addition to these units, there are three other groups of units
% for use with the SI system which do not fit into the above.  These
% are those derived from physical measurements
% (\ref{tab:experimental}), those considered ``accepted''
% (\ref{tab:accepted}), and those accepted temporarily
% (\ref{tab:addn}).\footnote{These are supposed to be replaced over
% time by SI units.}
%\DescribeMacro{\litre}
%\DescribeMacro{\liter}
% The unit ``litre'' is often spelled ``liter'' in the US; both
% spellings are provided by \currpkg, with \cs{liter} giving
% \si{\liter} and \cs{litre} producing \si{\litre}.
%\begin{table}
%  \caption{Units derived from experiments
%    (\opt{load=physical})}
%  \label{tab:experimental}
%  \centering
%  \begin{tabular}{lll}
%    \toprule
%      \multicolumn{1}{c}{Unit} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Symbol} \\
%    \midrule
%    electron volt & \csindex{electronvolt} & \electronvolt \\
%    unified atomic mass unit
%      & \csindex{atomicmassunit} & \atomicmassunit \\
%      & \csindex{atomicmass} & \atomicmass \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%\begin{table}
%  \caption{Units accepted for use with SI
%    (\opt{load=accepted})}
%  \label{tab:accepted}
%  \centering
%  \begin{tabular}{lll}
%    \toprule
%      \multicolumn{1}{c}{Unit} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Symbol} \\
%    \midrule
%    \unitinfo{bel} \\
%    day & \csindex{Day} & \Day \\
%     & \csindex{dday} & \dday \\
%    \unitinfo{degree} \\
%    \unitinfo{hour} \\
%    \unitinfo{litre} \\
%     & \csindex{liter} & \liter \\
%    \unitinfo{minute} \\
%    minute (arc) & \csindex{arcmin} & \arcmin \\
%    \unitinfo{neper} \\
%    \unitinfo{percent} \\
%    second (arc) & \csindex{arcsec} & \arcsec \\
%    \unitinfo{tonne} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%\begin{table}
%  \centering
%  \caption{Additional (temporary) SI units
%    (\opt{load=addn})}
%  \label{tab:addn}
%  \begin{tabular}{lll}
%    \toprule
%      \multicolumn{1}{c}{Unit} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Symbol} \\
%    \midrule
%    {\aa}ngstr{\"o}m & \csindex{angstrom} & \angstrom \\
%    \unitinfo{are} \\
%    \unitinfo{curie} \\
%    bar & \csindex{BAR} & \BAR \\
%     & \csindex{bbar} & \bbar \\
%    \unitinfo{barn} \\
%    \unitinfo{gal} \\
%    \unitinfo{hectare} \\
%    \unitinfo{millibar} \\
%    \unitinfo{rad} \\
%    \unitinfo{rem} \\
%    \unitinfo{roentgen} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\subsection{Prefixed and abbreviated units}
% Many basic units have prefixes which are commonly used with the
% unit, such as centimetre or megahertz.  The package therefore
% defines a number of common prefixed units (\opt{load=prefixed}).
% Several of these also have obvious abbreviations (such as \cs{MHz}
% for \cs{megahertz}), which are made available by \opt{load=abbr}.
% In common with the units discussed above, the prefixed and
% abbreviated unit definitions are loaded by default.
%\newcommand*{\tablesubhead}[1]{^^A
%  \addlinespace \emph{#1} \\*}
%\begin{longtable}{llll}
%    \caption{Prefixed (\opt{load=prefixed}) and abbreviated
%      (\opt{load=abbr}) units\label{tab:abbr}}\\
%    \toprule
%    Unit & Macro & Symbol & Abbreviation \\
%    \midrule
%  \endfirsthead
%    \toprule
%    Unit & Macro & Symbol & Abbreviation \\
%    \midrule
%  \endhead
%    \bottomrule
%    \multicolumn{4}{r}{\emph{Continued on next page}}
%  \endfoot
%    \bottomrule
%  \endlastfoot
%
%  \tablesubhead{Masses}
%  \unitinfo{kilogram} & \csindex{kg} \\
%  \unitinfo{femtogram} & \csindex{fg} \\
%  \unitinfo{picogram} & \csindex{pg} \\
%  \unitinfo{nanogram} & \csindex{nanog} \\
%  \unitinfo{microgram} & \csindex{micg} \\
%  \unitinfo{milligram} & \csindex{mg} \\
%  atomic mass & \csindex{atomicmass} & \amu & \csindex{amu} \\
%
%  \tablesubhead{Lengths}
%  \unitinfo{picometre} & \csindex{picom} \\
%  \unitinfo{nanometre} & \csindex{nm} \\
%  \unitinfo{micrometre} & \csindex{micm} \\
%  \unitinfo{millimetre} & \csindex{mm} \\
%  \unitinfo{centimetre} & \csindex{cm} \\
%  \unitinfo{decimetre} & \csindex{dm} \\
%  \unitinfo{kilometre} & \csindex{km} \\
%
%  \tablesubhead{Times}
%  \unitinfo{second} & \csindex{Sec} \\
%  \unitinfo{attosecond} & \csindex{as} \\
%  \unitinfo{femtosecond} & \csindex{fs} \\
%  \unitinfo{picosecond} & \csindex{ps} \\
%  \unitinfo{nanosecond} & \csindex{ns} \\
%  \unitinfo{microsecond} & \csindex{mics} \\
%  \unitinfo{millisecond} & \csindex{ms} \\
%
%  \tablesubhead{Moles}
%  \unitinfo{femtomole} & \csindex{fmol} \\
%  \unitinfo{picomole} & \csindex{pmol} \\
%  \unitinfo{nanomole} & \csindex{nmol} \\
%  \unitinfo{micromole} & \csindex{micmol} \\
%  \unitinfo{millimole} & \csindex{mmol} \\
%
%  \tablesubhead{Currents}
%  \unitinfo{picoampere} & \csindex{pA} \\
%  \unitinfo{nanoampere} & \csindex{nA} \\
%  \unitinfo{microampere} & \csindex{micA} \\
%  \unitinfo{milliampere} & \csindex{mA} \\
%  \unitinfo{kiloampere} & \csindex{kA} \\
%
%  \tablesubhead{Areas}
%  square centimetre & \csindex{squarecentimetre} &
%    \squarecentimetre & \csindex{cms} \\*
%    & \csindex{centimetresquared} & \centimetresquared \\
%  square metre & \csindex{squaremetre} & \squaremetre \\
%  square kilometre & \csindex{squarekilometre} & \squarekilometre \\
%
%  \tablesubhead{Volumes}
%  \unitinfo{microlitre} & \csindex{micl} \\
%  \unitinfo{millilitre} & \csindex{ml} \\
%  cubic centimetre & \csindex{cubiccentimetre} &
%    \cubiccentimetre & \csindex{cmc} \\*
%    & \csindex{centimetrecubed} & \centimetrecubed \\
%  cubic decimetre & \csindex{cubicdecimetre} &
%    \cubicdecimetre & \csindex{dmc} \\
%
%  \tablesubhead{Frequencies}
%  \unitinfo{hertz} & \csindex{Hz} \\
%  \unitinfo{millihertz} & \csindex{mHz} \\
%  \unitinfo{kilohertz} & \csindex{kHz} \\
%  \unitinfo{megahertz} & \csindex{MHz} \\
%  \unitinfo{gigahertz} & \csindex{GHz} \\
%  \unitinfo{terahertz} & \csindex{THz} \\
%
%  \tablesubhead{Potentials}
%  \unitinfo{millivolt} & \csindex{mV} \\
%  \unitinfo{kilovolt} & \csindex{kV} \\
%
%  \tablesubhead{Energies}
%  \unitinfo{kilojoule}  & \csindex{kJ}\\
%  \unitinfo{electronvolt} & \csindex{eV} \\
%  \unitinfo{millielectronvolt} & \csindex{meV} \\
%  \unitinfo{kiloelectronvolt} & \csindex{keV} \\
%  \unitinfo{megaelectronvolt} & \csindex{MeV} \\
%  \unitinfo{gigaelectronvolt} & \csindex{GeV} \\
%  \unitinfo{teraelectronvolt} & \csindex{TeV} \\
%  \unitinfo{kilowatthour} & \cs{kWh} \\
%
%  \tablesubhead{Powers}
%  \unitinfo{milliwatt} \\
%  \unitinfo{kilowatt} \\
%  \unitinfo{megawatt} \\
%
%  \tablesubhead{Capacitances}
%  \unitinfo{femtofarad} \\
%  \unitinfo{picofarad} \\
%  \unitinfo{nanofarad} \\
%  \unitinfo{microfarad} \\
%  \unitinfo{millifarad} \\
%
%  \tablesubhead{Resistances}
%  \unitinfo{kiloohm} \\
%  \unitinfo{megaohm} \\
%  \unitinfo{gigaohm} \\
%  \unitinfo{millisiemens} \\
%
%  \tablesubhead{Forces}
%  \unitinfo{millinewton} \\
%  \unitinfo{kilonewton} \\
%
%  \tablesubhead{Other units}
%  \unitinfo{hectopascal} \\
%  \unitinfo{megabecquerel} \\
%  \unitinfo{millisievert} \\
%\end{longtable}
%
%\subsection{Defining new units}
%\DescribeMacro{\newunit}
%\DescribeMacro{\renewunit}
%\DescribeMacro{\provideunit}
% New units are produced using the \cs{newunit} macro.  This works as
% might be expected:
% \cs{newunit}\oarg{options}\marg{unit}\marg{symbol}, where
% \meta{symbol} can contain literal values, other units, multiple
% prefixes, powers and \cs{per}.  The \meta{options} argument can be
% any suitable options, and applies the specific unit macro only. The
% most obvious example for using this macro is the \cs{degree}
% unit.\footnote{Although the \cs{ang} macro is preferred for this
% job.}  The (first) optional argument to \cs{SI} and \cs{si} can be
% used to override the settings for the unit.  The \cs{renewunit} and
% \cs{provideunit} macros take the same arguments.
%\begin{LaTeXexample}
%  \SI{3.1415}{\degree}\\
%  \newunit[valuesep=none]{\oddunit}{XXX}
%  \SI{12345}{\oddunit}
%  \SI[valuesep=thick]{67890}{\oddunit}
%\end{LaTeXexample}
%
% As with the \LaTeX\ commands \cs{newcommand}, \etc, the choice of
% \cs{newunit}, \cs{renewunit} or \cs{provideunit} depends on the
% presence of an existing definition.  While \cs{newunit} should be
% used when a unit has not been previously defined, \cs{renewunit}
% will issue a warning if the named unit does not already exist.
% \cs{provideunit} defines the unit if it does not exist, and
% otherwise does nothing at all.  The same behaviour is seen with
% \cs{providepower} and \cs{provideprefix} (\latin{vide infra}).
%
% Output that is only valid in maths mode requires \cs{ensuremath},
% text-only input requires \cs{text}.  In the example below,
% \cs{mathnormal} is used to force the font choice only for the
% single character.\footnote{The \cs{mathrm} font used for this
% document has an ``\ss'' at the $\pi$ position.}
%\begin{LaTeXexample}
%  \newunit{\SIpi}{\ensuremath{\mathnormal{\pi}}}
%  \SI{10}{\metre\per\SIpi\squared}
%\end{LaTeXexample}
%
%\DescribeMacro{\newpower}
%\DescribeMacro{\renewpower}
%\DescribeMacro{\providepower}
% Powers are defined:
% \cs{newpower}\ofixarg{post}\marg{power}\marg{num}. Here,
% \meta{power} is the name of the power macro and \meta{num} is the
% (positive) number it represents.  The later argument is always
% processed internally by \cs{num}, but \emph{must} be a number.
% Giving the optional argument \opt{post} indicates to the package
% that the power will come after the unit it applies to; by default
% it is assumed that it will come before.
%\begin{LaTeXexample}
%  \newpower{\quartic}{4}
%  \newpower[post]{\totheforth}{4}\\
%  \si{\kilogram\totheforth}\\
%  \si{\quartic\metre}
%\end{LaTeXexample}
%
%\DescribeMacro{\newprefix}
%\DescribeMacro{\renewprefix}
%\DescribeMacro{\provideprefix}
% The standard SI powers of ten are defined by the package, and are
% described above.  However, the user can define new prefixes with
% \cs{newprefix}.  This has syntax
% \cs{newunit}\ofixarg{binary}\marg{prefix}\marg{symbol}\marg{powers-ten},
% where \meta{powers-ten} is the number of powers of ten the prefix
% represents.  When the \opt{binary} option is given, the prefix is a
% power of two.  For example, \cs{kilo} and \cs{kibi} are defined:
%\begin{LaTeXexample}[noexample]
%  \newprefix{\kilo}{k}{3}
%  \newprefix[binary]{\kibi}{Ki}{10}
%\end{LaTeXexample}
%
%\section{Specialist units}
% In some subject area, there are units which are in common use even
% though they are outside of the SI system.  Unlike the units
% discussed earlier, these specialist units are not loaded by
% default.  In each case, they should be requested with the option
% \opt{alsoload=\meta{name}}.
%
%\subsection{Binary units (\opt{binary})\label{sec:binary}}
%\DescribeMacro{\bit}
%\DescribeMacro{\byte}
% The binary prefixes, \cs{bit}, \cs{byte} (\ref{tab:binary}) are not
% formally part of the SI system. They are available by giving the
% \opt{alsoload=binary} option.
%\begin{LaTeXexample}
%  \SI{100}{\mebi\byte}
%\end{LaTeXexample}
%\begin{table}
%  \caption{Binary prefixes
%    (\opt{alsoload=binary})}
%  \label{tab:binary}
%  \centering
%  \begin{tabular}{lllc}
%    \toprule
%      \multicolumn{1}{c}{Prefix} &
%      \multicolumn{1}{c}{Macro} &
%      \multicolumn{1}{c}{Power} &
%      Symbol \\
%    \midrule
%      \prefixinfo{kibi} \\
%      \prefixinfo{mebi} \\
%      \prefixinfo{gibi} \\
%      \prefixinfo{tebi} \\
%      \prefixinfo{pebi} \\
%      \prefixinfo{exbi} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\subsection{Synthetic chemistry (\opt{synchem})}
%\DescribeMacro{\mmHg}
%\DescribeMacro{\molar}
%\DescribeMacro{\Molar}
%\DescribeMacro{\torr}
%\DescribeMacro{\dalton}
% The \opt{synchem} file adds the common chemistry units \cs{mmHg},
% \cs{molar}, \cs{Molar}, \cs{torr} and \cs{dalton} to \currpkg.  The
% \cs{Molar} macro is somewhat awkward, as it can be given as either
% ``\textsc{m}'' or ``M''.  The later is obviously easily confused
% with the sign for the prefix mega.  By default, \currpkg uses the
% UK default of a small-caps symbol.  The \cs{dalton} unit is defined
% here as this name is not recognised by the various international
% bodies: the symbol \si{\amu} is preferred.
%\begin{LaTeXexample}
%  \SI{1}{\Molar} HCl\\
%  \SI{760}{\torr}\\
%  \SI{0.01}{\mmHg}\\
%  \SI{3.0}{\molar}\\
%  \SI{106.42}{\dalton}
%\end{LaTeXexample}
%
%\subsection{High-energy physics (\opt{hep})}
% In contrast to \pkg{hepunits}, \currpkg does not define a long list
% of compound units for high-energy physics.\footnote{Using the
% \opt{emulate=hepunits} option will load a file defining those.}
% Instead, a small selection of new units are defined
% (\ref{tab:hep}).  The mechanisms provided by \currpkg should avoid
% the need for large numbers of abbreviations.  For example, the
% \pkg{hepunits} \cs{MinveV} can be given as |\per\MeV| in \currpkg,
% which requires only one more character.
%\begin{table}
%  \caption{High-energy physics units (\opt{alsoload=hep})}
%  \label{tab:hep}
%  \centering
%  \begin{tabular}{lllc}
%    \toprule
%    Unit & Macro & Symbol & Abbreviation \\
%    \midrule
%    \addlinespace \emph{Areas} \\
%    \unitinfo{yoctobarn} & \csindex{yb} \\
%    \unitinfo{zeptobarn} & \csindex{zb} \\
%    \unitinfo{attobarn} & \csindex{ab} \\
%    \unitinfo{femtobarn} & \csindex{fb} \\
%    \unitinfo{picobarn} & \csindex{pb} \\
%    \unitinfo{nanobarn} & \csindex{nb} \\
%    \addlinespace \emph{Other units} \\
%    \unitinfo{micron} \\
%    millirad & \csindex{mrad} & \mrad \\
%    \unitinfo{gauss} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeMacro{\clight}
%\DescribeMacro{\eVperc}
% The \opt{hep} option defines two units which are slightly unusual.
% \cs{clight} gives \clight, which is recognised as a unit when used
% in the appropriate circumstances. The second unit provided is
% \cs{eVperc}, which is commonly-used and clear enough for a compound
% definition. Notice that the value of \opt{eVcorrb} will need to be
% adjusted when using this unit.
%\begin{LaTeXexample}
%  \SI[per=slash,eVcorrb=0.4ex]{4.657}{\mega\eVperc\squared}
%\end{LaTeXexample}
%
%\subsection{Astronomy (\opt{astro})}
%\DescribeMacro{\parsec}
%\DescribeMacro{\lightyear}
% For astronomers, the \cs{parsec} and \cs{lightyear} units are
% available, and give the obvious results.
%\begin{LaTeXexample}
%  \SI{12}{\parsec}\\
%  \SI{1}{\lightyear}
%\end{LaTeXexample}
%
%\section{Font control}
% Following the lead of \SIstyle, \currpkg provides control over the
% font used to typeset output.  By default, all text is typeset using
% the current upright serif maths font, whether the macros are given
% in text or maths mode.  Some examples will show the effect.
%\begin{LaTeXexample}
%  \num{10} $\num{10}$\\
%  \sffamily \ang{20} $\ang{20}$\\
%  \textbf{\SI{30}{\kilo\gram}}\\
%  \boldmath $\SI{40}{\kilo\gram}$
%  \[ \num{50} \]
%\end{LaTeXexample}
%
% In contrast, by setting \opt{obeyall}, the current font is used:
% this may be maths or text, depending on the context.
%\begin{LaTeXexample}
%  \sisetup{obeyall}\\
%  \ang{1;1;1} $\ang{1;1;1}$\\
%  \sffamily \ang{2;2;2} $\ang{2;2;2}$\\
%  \textbf{\ang{3;3;3}} \boldmath $\ang{3;3;3}$\\
%  \emph{\ang{4;4;4}} \emph{$\ang{4;4;4}$}
%  \[ \ang{5;5;5} \]
%\end{LaTeXexample}
%
% Fine control of which elements of the local font are used is
% available with the \opt{obeyfamily}, \opt{obeybold},
% \opt{obeyitalic} and \opt{obeymode} options.
%\begin{LaTeXexample}
%  \sisetup{obeyfamily}\\
%  \ang{1;1;1} $\ang{1;1;1}$\\
%  \sffamily \ang{2;2;2} $\ang{2;2;2}$\\
%  \sisetup{obeybold}
%  \textbf{\ang{3;3;3}} \boldmath $\ang{3;3;3}$\\
%  \emph{\ang{4;4;4}} \emph{$\ang{4;4;4}$}
%  \[ \ang{5;5;5} \]
%\end{LaTeXexample}
%
%\section{Package options\label{sec:options}}
%\DescribeMacro{\sisetup}
% The ``native'' options for the package are all given using the
% key--value method. Most of the package options can be given both
% when loading the package and at any point in the document.  This is
% achieved using the \cs{sisetup} macro.
%
% The package options take a number of different forms.
%\begin{itemize}
%  \item \opt{option=\meta{bool}} Simple true/false values.  These
%    macros all default to \opt{option=true}, meaning that giving the
%    option name along will set the appropriate flag.
%  \item \opt{option=\meta{choice}} Take a single item from a
%    pre-determined list. Depending on the value, one or more
%    internal states will be altered.  Values not on the list are
%    ignored (with a warning).
%  \item \opt{option=\meta{choice,literal}} If the given value is a
%    \meta{choice}, then the internal settings for that choice are
%    used.  Any other value is used directly.
%  \item \opt{option=\meta{literal}} The given value is used as a
%    literal by the package.
%  \item \opt{option=\meta{csname}} These options expect a command
%    sequence as a value.
%  \item \opt{option=\meta{length}} Requires a \TeX\ length, for
%    example \opt{0.5ex}.
%  \item \opt{option=\meta{list}} Takes a list of one or more items,
%    which are not determined in advance.
%  \item \opt{option=\meta{number}} Takes a number (possibly
%    including an exponent part).
%\end{itemize}
%
% The package has a large range of options, to allow full control of
% the various features of the package.  These control differing
% aspects of the package, and are given below in groups based on
% function.  Where the key has a default value, it is given in bold.
%
%\subsection{Font family and style}
% The font used when typesetting material can be tightly controlled
% using \currpkg.  A number of options affect how the package matches
% the surrounding font, and the font families used to achieve this.
% The default is to use the current upright maths serif font with no
% variation.
%
%\DescribeOption{mode}
%\DescribeOption{textmode}
%\DescribeOption{valuemode}
%\DescribeOption{unitmode}
%\DescribeOption{obeymode}
% The output of \currpkg can occur using either text or maths mode.
% The package option \opt{mode} determines which is used: valid
% options are \defaultopt{maths} and \opt{text}.\footnote{Here and in
% all other cases, either UK or US spelling may be used.  Thus
% \opt{mode=maths} or \opt{mode=math} have exactly the same effect.}
% The shortcut \opt{textmode} is provided for setting \opt{mode=text}
% quickly. Further refinement is possible using the \opt{valuemode}
% and \opt{unitmode} options.  These apply to numbers (the output of
% \cs{num} and the first mandatory argument of \cs{SI}) and units
% (all other output), respectively. By setting the \opt{obeymode}
% flag, the package will use the local typesetting mode (maths or
% text).
%
%\DescribeOption{obeyall}
%\DescribeOption{obeyfamily}
%\DescribeOption{obeybold}
%\DescribeOption{obeyitalic}
% The detection and matching of surrounding text can be controlled
% using a number of Boolean package options. \opt{obeyall} turns on
% all of the detection.  Thus output with \opt{obeyall} in force will
% always match the local text appearance.  \opt{obeyfamily} instructs
% the package on detecting the surrounding font family (Roman, sans
% serif, fixed width), but does not detect bold or italic.
% \opt{obeybold} detects the local bold setting, whilst
% \opt{obeyitalic} picks up italic fonts.
%
% Bold detection is influenced by the value of \opt{inlinebold},
% which takes values \defaultopt{text} and \opt{maths}.  The package
% can detect the local value of bold for either the surrounding text,
% or the surrounding inline (|$|\ldots|$|) maths.  The
% \opt{obeyitalic} option does \emph{not} have the same facility
% (maths is italic anyway).
%
%\DescribeOption{mathsrm}
%\DescribeOption{mathssf}
%\DescribeOption{mathstt}
%\SpecialOptionIndex{mathrm}
%\SpecialOptionIndex{mathsf}
%\SpecialOptionIndex{mathtt}
%\DescribeOption{textrm}
%\DescribeOption{textsf}
%\DescribeOption{texttt}
% The font commands used by the package to achieve the above are all
% available for user modification.  The options \opt{mathsrm},
% \opt{mathssf} and \opt{mathstt} hold the command sequences used in
% maths mode,\footnote{These can also be set using \opt{mathrm},
% \opt{mathsf} and \opt{mathtt}} while \opt{textrm}, \opt{textsf} and
% \opt{texttt} do the same for text mode.  By default, these contain
% the obvious command names, for example \opt{mathsrm=mathrm} and
% \opt{texttt=ttfamily}.  However, they can be set at will: the macro
% names indicate the nature of the surrounding text detected.  For
% example, the value of \opt{mathssf} is used in maths mode when the
% surrounding text is sans serif.
%
%\SpecialOptionIndex{valuemathsrm}
%\SpecialOptionIndex{valuemathssf}
%\SpecialOptionIndex{valuemathstt}
%\SpecialOptionIndex{valuemathrm}
%\SpecialOptionIndex{valuemathsf}
%\SpecialOptionIndex{valuemathtt}
%\SpecialOptionIndex{unitmathsrm}
%\SpecialOptionIndex{unitmathssf}
%\SpecialOptionIndex{unitmathstt}
%\SpecialOptionIndex{valuetextrm}
%\SpecialOptionIndex{valuetextsf}
%\SpecialOptionIndex{valuetexttt}
%\SpecialOptionIndex{valuetextrm}
%\SpecialOptionIndex{valuetextsf}
%\SpecialOptionIndex{valuetexttt}
%\SpecialOptionIndex{unittextrm}
%\SpecialOptionIndex{unittextsf}
%\SpecialOptionIndex{unittexttt}
% Each of the font options can be given separately for the contents
% of numbers and units.  The option names include \opt{value} or
% \opt{unit} before the mode name.  For example, the \opt{mathsrm}
% option may be split into \opt{valuemathsrm} and \opt{unitmathsrm}.
%
%\DescribeOption{detectdisplay}
% The font detection system can treat displayed mathematical content
% in two ways.  This is controlled by the \opt{detectdisplay} option.
% When set to \defaultopt{true}, display mathematics is treated
% independently from the body of the document.  Thus the local
% \emph{maths} font is checked for matching.  In contrast, when set
% to \opt{false}, display material is treated with the current
% running text font.
%\begin{LaTeXexample}
%  \sffamily
%  Some text
%  \sisetup{obeyall}
%  \[ x = \SI{1.2e3}{\kg\kelvin\candela} \]
%  More text
%  \sisetup{detectdisplay=false}
%  \[ y = \SI{3}{\metre\second\mole} \]
%\end{LaTeXexample}
%
%\subsection{Spacing and separators}
%\DescribeOption{unitsep}
%\DescribeOption{valuesep}
%\DescribeOption{digitsep}
%\DescribeOption{anglesep}
% The separators between items can all be set using options taking a
% list of pre-defined items or a literal value.  The ``\opt{sep}''
% options (\opt{unitsep}, \opt{valuesep}, \opt{digitsep} and
% \opt{anglesep}) all recognise \opt{thin}, \opt{medium}, \opt{med},
% \opt{thick}, \opt{space}, \opt{cdot}, \opt{times}, \opt{tightcdot},
% \opt{tighttimes}, \opt{fullstop}, \opt{stop}, \opt{period} and
% \opt{none}.  The named spaces are the normal maths separations,
% with \opt{space} representing a full (non-breakable text) space,
% and with the obvious meanings for \opt{cdot} and \opt{times}.  The
% \opt{tight} variants reduce the spacing available. Three possible
% values are provided for ``|.|'', and \opt{none} yields no space at
% all. In all cases, other values are treated literally and are
% typeset in maths mode.  The default value is \defaultopt{thin} for
% all separations except \opt{anglesep}, which is set to
% \defaultopt{none}.
%
%\DescribeOption{unitspace}
%\DescribeOption{errspace}
% The \opt{unitspace} and \opt{errspace} options again take a list
% or literal value, but only the ``real'' spaces \opt{thin},
% \opt{medium}, \opt{med}, \opt{thick}, \opt{space} and \opt{none}
% are recognised in the list. The \opt{unitspace} option controls the
% output generated by an explicit space (|~|) inside a unit macro,
% while \opt{errspace} is used to separate a bracketed error from the
% main number.
%
%\subsection{Number formatting}
%\DescribeOption{numdigits}
%\DescribeOption{numdecimal}
%\DescribeOption{numexp}
%\DescribeOption{numsign}
%\DescribeOption{numaddn}
%\DescribeOption{numgobble}
% There are two groups of options for formatting numbers.  The first
% group all begin with ``\opt{num}'', and take literal values used by
% the package to parse numbers.  \opt{numdigits} contains the valid
% number symbols (\defaultopt{0123456789}), with \opt{numdecimal}
% containing the decimal markers (\defaultopt{.,}).  As in the
% \numprint package, \opt{numexp} (the list of exponent markers)
% recognises \defaultopt{deDE} as valid by default.  \opt{numsign}
% contains the sign markers for numbers
% (\defaultopt{+-\cs{pm}\cs{mp}}).  \opt{numaddn} and
% \opt{numgobble} both control which other characters do not give an
% error when present in a number.  \opt{numaddn} contains valid
% characters which should be included in the final output ``as is'',
% whereas \opt{numgobble} lists the characters that are completely
% ignored.  In all cases, the content of the options is a simple
% string, for example \opt{numdigits=1234567890}.
%
%\DescribeOption{decimalsymbol}
%\DescribeOption{digitsep}
%\DescribeOption{sepfour}
% The second group of number options control the output of numbers
% after parsing. The symbol used by \currpkg as a decimal marker is
% set by the \opt{decimalsymbol} option, which can take a list of
% choices or a literal.  The valid choices here are
% \defaultopt{fullstop}, \opt{comma}, \opt{cdot} and
% \opt{tightcdot}.\footnote{\opt{fullstop} also has aliases
% \opt{stop} and \opt{period}.}  Notice that this does not have to
% agree with the input marker.  The other separator for numerical
% output is the division of digits into groups of three.  The result
% is dependant on two options.  The previously-described
% \opt{digitsep} option controls the spacing added between groups of
% three numbers.  For numbers consisting of exactly four digits, the
% \opt{sepfour} Boolean option controls whether separation occurs in
% these cases.  The default is \defaultopt{false}.
%\begin{LaTeXexample}
%  \num{1234}\\
%  \num[sepfour]{1234}
%\end{LaTeXexample}
%
%\DescribeOption{seperr}
%\DescribeOption{numopenerr}
%\DescribeOption{numcloseerr}
% For numbers given with an error [\eg \num{1.23(4)}], the package
% can separate out the error part, to give for example
% \num[seperr]{1.23(4)}.  This behaviour is activated by the
% \opt{seperr} option, and requires that \opt{numopenerr} and
% \opt{numcloseerr} contain the left- and right-hand delimiters for
% the error [defaults \opt{numopenerr=(} and \opt{numcloseerr=)}].
%\begin{LaTeXexample}
%  \sisetup{seperr}\\
%  \num{1.234(5)}\\
%  \num{1.234(5)e6}
%\end{LaTeXexample}
%\DescribeOption{trapambigerr}
%\DescribeOption{openerr}
%\DescribeOption{closeerr}
%\DescribeOption{tightpm}
% If the number has an exponent, or if units are not repeated, then
% the result can be considered ambiguous.  By default, the package
% adds the markers stored in \opt{openerr} and \opt{closeerr} to
% remove the ambiguity; the options have the same default values as
% the input error markers.  Detection of a potentially-ambiguous
% error is controlled by the \opt{trapambigerr} option, although for
% numbers with units the \opt{repeatunits} option is also important.
% The spacing around the $\pm$ sign is normally set by \TeX. However,
% using the \opt{tightpm} option will cause this to be reduced to a
% minimum.
%\begin{LaTeXexample}
%  \sisetup{seperr}\\
%  \num[trapambigerr=false]{1.234(5)e6}\\
%  \SI{1.234(5)}{\metre}\\
%  \sisetup{repeatunits=false}
%  \SI{1.234(5)}{\metre}\\
%  \SI[trapambigerr=false]{1.234(5)}{\metre}\\
%  \num[tightpm]{1.234(5)}
%\end{LaTeXexample}
%
%\DescribeOption{numprod}
%\DescribeOption{repeatunits}
% The number processor can recognise products in the numerical input;
% the symbols used for products are stored in \opt{numprod}, with the
% default value of ``\opt{x}''.  By default, the \cs{SI} macro will
% repeat the units for a number given in this way.  This behaviour is
% altered  by the \opt{repeatunits} option, which takes the values
% \defaultopt{true}, \opt{false} and \opt{power}.  The later applies
% only when providing multiplied numbers with units, and converts the
% unit to the appropriate power rather than repeating the
% units.\footnote{This is a very simply option: do not expect it to
% work with anything except areas and volumes.} Notice that when
% applied to errors, \opt{repeatunits} takes priority over
% \opt{trapambigerr}.
%\begin{LaTeXexample}
%  \num{1 x 2 x 3}\\
%  \SI{4 x 5 x 6}{\metre}\\
%  \sisetup{repeatunits=false}
%  \SI{1.2 x 3.4 x 5.6}{\milli\metre\cubed}\\
%  \SI[seperr]{1.234(5)}{\metre}\\
%  \SI[seperr,
%    trapambigerr=false]
%    {9.1093897(54)e-31}{\kilo\gram}\\
%  \SI[seperr,repeatunits,
%    trapambigerr=false]
%    {9.1093897(54)e-31}{\kilo\gram}\\
%  \SI[repeatunits=power]{1 x 2 x 3}{\metre}
%\end{LaTeXexample}
%
%\DescribeOption{expproduct}
%\DescribeOption{expbase}
%\DescribeOption{allowzeroexp}
% The formatting of exponents is controlled by \opt{expproduct} and
% \opt{expbase}.  \opt{expproduct} sets the symbol used to indicate a
% product for exponents (\eg the $\times$ in \num{2e2}), while the
% value of \opt{expbase} sets the power used (the \num{10} in the
% example).  Both options accept a very short list of options:
% \defaultopt{times}, \opt{tighttimes}, \opt{cdot} and
% \opt{tightcdot} for the product, and \defaultopt{ten} and \opt{two}
% for the power.\footnote{The \opt{tighttimes} and \opt{tightcdot}
% options give the rather questionable results:
% \num[expproduct=tighttimes]{1e2} and
% \num[expproduct=tightcdot]{1e2}, as opposed to \num{1e2} and
% \num[expproduct=cdot]{1e2}.} Other choices are used literally. Also
% relevant to exponent processing is the \opt{allowzeroexp} option.
% By default, the package will suppress a zero exponent, but setting
% the flag will allow the output of \num[allowzeroexp]{e0}.
%
%\DescribeOption{addsign}
%\DescribeOption{sign}
%\DescribeOption{retainplus}
% Additions to the input can take the form of implicit signs and
% padded zeros.  The \opt{addsign} option takes a list of potential
% sites to add a sign: \defaultopt{none}, \opt{mantissa},
% \opt{exponent} and \opt{both}.\footnote{Aliases are provided:
% \opt{mant} = \opt{mantissa}, \opt{exp} = \opt{exponent}, \opt{all}
% = \opt{true} = \opt{both}, \opt{false} = \opt{none}.}  If no sign
% is given in the input, the setting here determines if one is added.
% The sign to add is stored in \opt{sign}, which takes the list of
% choices \defaultopt{plus}, \opt{minus}, \opt{pm} and \opt{mp}, or
% uses the input literally (in maths mode).  For positive numbers,
% the \opt{retainplus} option causes a $+$ sign explicitly in the
% input to be retained.  By default, the package will remove such
% signs.
%
%\DescribeOption{padnumber}
% The \opt{padnumber} option controls the addition of zeros to the
% input, to ``pad'' the result.  The option takes a list of choices:
% \defaultopt{leading}, \opt{trailing}, \opt{both} and
% \opt{none}.\footnote{Aliases: \opt{all} = \opt{true} = \opt{both},
% \opt{false} = \opt{none}.}  No additional precision is added by
% this option; integer input will not add a decimal point.
%\begin{LaTeXexample}
%  \num[padnumber=leading]{.1}\\
%  \num[padnumber=leading]{2.}\\
%  \num[padnumber=trailing]{3.}\\
%  \num[padnumber=both]{4.}\\
%  \num[padnumber=both]{.5}\\
%  \num[padnumber=both]{6}\\
%  \num[padnumber=none]{7.}\\
%  \num[padnumber=none]{.8}
%\end{LaTeXexample}
%
%\DescribeOption{fixdp}
%\DescribeOption{dp}
% In contrast to the \opt{padnumber} option, the package can alter
% the precision of the input number if the \opt{fixdp} option is set.
% The will fix the decimal places of the output to the number stored
% in the \opt{dp} option.  The later should be a positive integer.
%\begin{LaTeXexample}
%  \sisetup{fixdp,dp=3}
%  \num{1}\\
%  \num{53.9}\\
%  \num{4.56783}\\
%  \num{-1.2942}\\
%  \num{-1.2949}\\
%  \num{9.9999}
%\end{LaTeXexample}
%
%\subsection{Angle formatting}
%\DescribeOption{padangle}
%\DescribeOption{strictarc}
% The angle formatter uses \cs{num} to format numbers: any options
% for numbers are therefore applicable here.  The \opt{padangle}
% option takes choices \defaultopt{small}, \opt{large}, \opt{all} and
% \opt{none}, and controls how angles are padded when given in
% degrees, minutes and seconds.\footnote{Aliases: \opt{all} =
% \opt{true} = \opt{both}, \opt{false} = \opt{none}.}  When giving
% angles as arcs (in degrees, minutes and seconds), the package can
% detect if the correct number of semi-colons have been given. This
% is controlled by the \opt{strictarc} option, which is a Boolean
% switch with a \defaultopt{true} default.  With \opt{strictarc} set
% to \opt{false}, an incomplete arc is interpreted as degrees and
% minute, while an over-complete one will drop excess input.
%\begin{LaTeXexample}
%  \ang[padangle=none]{1;;}\\
%  \ang[padangle=large]{2;;}\\
%  \ang[padangle=small]{3;;}\\
%  \ang[padangle=both]{;4;}\\
%  \ang[padangle=none]{;5;5}\\
%  \ang[strictarc=false]{1;2}\\
%  \ang[strictarc=false]{1;2;3;4;}
%\end{LaTeXexample}
%
%\DescribeOption{angformat}
% The angle formatting system can convert between decimal angles and
% those given as degrees, minutes and seconds.  This is controlled by
% the \opt{angformat} option, which takes choices
% \defaultopt{unchanged}, \opt{decimal} and
% \opt{arc}.\footnote{Aliases: \opt{decimal} = \opt{dec}, \opt{arc} =
% \opt{dms}, \opt{unchanged} = \opt{none}.}  When set to
% \opt{unchanged}, nothing is done to the input.  The conversion is
% based on \TeX\ dimensions, and is therefore limited in accuracy.
% For this reason, the output is automatically rounded: output as a
% decimal angle is limited to three places, and that as an arc is
% given to a single decimal place for the seconds component.
%\begin{LaTeXexample}
%  $\ang{1;2;3} = \ang[angformat=dec]{1;2;3}$\\
%  $\ang{4.56} = \ang[angformat=arc]{4.56}$
%\end{LaTeXexample}
%
%\DescribeOption{astroang}
% For astronomers, the \opt{astroang} option is provided.  This
% moves the degrees, minutes or seconds symbol (as appropriate)
% over the decimal marker rather than after the number.
%\begin{LaTeXexample}
%  \ang{1;2;3.4}\\
%  \ang[astroang]{5;6;7.8}
%\end{LaTeXexample}
%
%\subsection{Tabular material}
%\DescribeOption{tabnumalign}
% Material typeset in |S| columns is processed internally by the
% \cs{num} macro.  Thus, as with angles, the number options also
% apply here.  The positioning of tabular material is controlled by
% the two options \opt{tabnumalign} and \opt{tabformat}.
% \opt{tabnumalign} takes values \defaultopt{centredecimal},
% \opt{centre}, \opt{left} and \opt{right}.\footnote{Aliases
% \opt{centerdecimal} = \opt{centredecimal}; \opt{center} =
% \opt{centre}.}  When using \opt{centredecimal}, the package places
% the decimal marker of the mantissa at the centre of the column,
% which then grows to accommodate the widest number given.  For equal
% numbers of digits before and after the decimal sign, this is the
% easiest option.  The other choices use a fixed-width box to store
% the number; the box is then aligned with the edges of the column.
%
%\DescribeOption{tabformat}
% The \opt{tabformat} option sets the amount of space reserved by
% \currpkg for the alignment box when not using the
% \opt{centredecimal} setting of \opt{tabnumalign}.  The numerical
% parts of \opt{tabformat} are interpreted as
% \texttt{\meta{pre}\meta{dec}\meta{post}}; \meta{pre} and
% \meta{post} are the number of digits before and after the decimal
% sign, respectively.  Both signs and exponents can be included in
% \opt{tabformat}, resulting in appropriate space being reserved. The
% entire \opt{tabformat} input is processed using the \cs{num} macro
% internally.  Thus the decimal and exponent signs used in
% \opt{tabformat} are checked against \opt{numdecimal} and
% \opt{numexp}, respectively.
%
%\DescribeOption{tabalignexp}
% When \opt{tabformat} contains exponents, two possibilities are
% available for alignment.  The first method is to place the exponent
% parts so that the ``$\times 10$'' parts form a column, with
% whitespace after shorter mantissa components.  In the second
% method, no additional space is added after the mantissa, and the
% exponents do no line up (\ref{tab:alignexp}).  This is controlled
% by the \opt{tabexpalign} option, which can be set to
% \defaultopt{true} or \opt{false}.
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \centering
%    \caption{The \opt{tabalignexp} option}
%    \label{tab:alignexp}
%    \sisetup{tabformat=1.3e2,tabnumalign=centre}
%    \begin{tabular}{SS[tabalignexp=false]}
%      \toprule
%      {Header} & {Header} \\
%      \midrule
%      1.2e3    & 1.2e3    \\
%      1.234e56 & 1.234e56 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
%
%\DescribeOption{tabtextalign}
%\DescribeOption{tabunitalign}
%\DescribeOption{tabalign}
% Cells containing no numbers are handled by \currpkg in a manner
% similar to \cs{multicolumn}.  The setting of \opt{tabtextalign} is
% taken from the list \defaultopt{centre}, \opt{right} and
% \opt{left}.\footnote{Alias \opt{centre} = \opt{center}.}  As would
% be expected, these settings centre, right- or left-align the cell
% contents. In |s| columns, all content is treated as input to the
% \cs{si} macro.  The alignment of the contents relative to the cell
% is controlled by the \opt{tabunitalign} option, which takes options
% \defaultopt{left}, \opt{right} and \opt{centre}.  The settings for
% \opt{tabnumalign}, \opt{tabtextalign} and \opt{tabunitalign} can be
% set to the same value in one go with the \opt{tabalign} option.
%
%\DescribeOption{tabautofit}
% The contents of table cells can automatically be rounded or
% zero-filled to the number of decimal places given in
% \opt{tabformat}.  The is activated by the \opt{tabautofit} Boolean
% option. As \opt{tabformat} does not apply to columns with alignment
% \opt{centredecimal}, \opt{tabautofit} is also inactive for these
% columns (\ref{tab:autofit}).
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \centering
%    \caption{The \opt{tabautofit} option}
%    \label{tab:autofit}
%    \sisetup{tabformat=1.3,tabnumalign=centre}
%    % Notice the overfull hbox which results with
%    % the first column
%    \begin{tabular}{%
%      S%
%      S[tabautofit]%
%      S[tabautofit,tabnumalign=centredecimal]}
%      \toprule
%      {Header} & {Header} & {Header} \\
%      \midrule
%      1.2    & 1.2    & 1.2    \\
%      1.2345 & 1.2345 & 1.2345 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
%
%\subsection{Units}
%\DescribeOption{per}
% Most of the unit options are concerned with the processing of named
% units.  The processor for units given as macro names can be
% influenced to give a variety of output formats.  The \opt{per}
% option defines how the keyword macro \cs{per} is handled.  This
% option takes a choice from the list \defaultopt{reciprocal},
% \opt{slash} and \opt{fraction}.\footnote{Aliases \opt{reciprocal} =
% \opt{rp} = \opt{power}, \opt{fraction} = \opt{frac}.}  The default
% option uses \cs{per} to indicate reciprocal powers, whereas
% \opt{slash} causes the package to use ``$/$'' to show division.
%
%\DescribeOption{fraction}
%\DescribeOption{slash}
% The \opt{fraction} option defines how \opt{per=fraction} is
% interpreted.  The list of applicable values here is
% \defaultopt{frac}, \opt{nice}, \opt{ugly} and \opt{sfrac}.  In each
% case, the unit is typeset as a fraction, but the macro use to
% achieve this varies. \opt{frac} uses the \TeX\ \cs{frac}, macro,
% while \opt{nice} makes use of a \cs{nicefrac}-like method.  The
% \opt{ugly} option uses a slash in text mode and \cs{frac} in maths
% mode.\footnote{Similar to the \pkg{ugly} option of the
% \pkg{nicefrac} package.}  Finally, the setting \opt{fraction=sfrac}
% uses the \cs{sfrac} macro from the \pkg{xfrac} package, when
% available.\footnote{\pkg{xfrac} is part of the experimental system
% for \LaTeX3.  As it requires a number of additional packages to
% work, \currpkg does not load \pkg{xfrac}. If it is unavailable, the
% \opt{sfrac} setting will fall back to using \cs{nicefrac}.  See the
% \pkg{xfrac} documentation for reasons to prefer \cs{sfrac} to
% \cs{nicefrac}.}  The \opt{slash} option sets the symbol used when
% \opt{per=slash} is in force.  This recognises the single keyword
% \opt{slash}; anything else is used literally.
%\begin{LaTeXexample}
%  \sisetup{per=fraction}
%  \si[fraction=frac]{\metre\per\second}\\
%  \si[fraction=nice]{\metre\per\second}\\
%  \si[fraction=sfrac]{\metre\per\second}\\
%  \si[per=slash]{\metre\per\second}
%\end{LaTeXexample}
%
%\DescribeOption{stickyper}
% By default, \cs{per} applies only to the next unit
% given.\footnote{This is the standard method of reading units in
% English: for example, \si{\joule\per\mole\per\kelvin} is pronounced
% ``joules per mole per kelvin''.}  By setting the \opt{stickyper}
% flag, this behaviour is changed so that \cs{per} applies to all
% subsequent units.\footnote{This is the behaviour in \SIunits.}
%\begin{LaTeXexample}
%  \si{\kilogram\per\metre\ampere}\\
%  \si[stickyper]{\kilogram\per\metre\ampere}
%\end{LaTeXexample}
%
%\DescribeOption{trapambigfrac}
%\DescribeOption{openfrac}
%\DescribeOption{closefrac}
% When using \opt{per=slash}, multiple units in the denominator will
% yield a potentially ambiguous result.  The \opt{trapambigfrac}
% determines whether the package checks for this: this takes
% \defaultopt{true} and \opt{false}.  When set, the contents of
% \opt{openfrac} are inserted before the denominator, and
% \opt{closefrac} is inserted after.
%\begin{LaTeXexample}
%  \sisetup{trapambigfrac,openfrac=(,closefrac=),per=slash}\\
%  \si{\metre\per\second\per\kilogram}\\
%  \si[trapambigfrac=false]{\metre\per\second\per\kilogram}
%\end{LaTeXexample}
%
%\DescribeOption{prefixsymbolic}
%\DescribeOption{prefixbase}
%\DescribeOption{prefixproduct}
% The unit prefixes (\cs{kilo}, \etc) are normally given as letters.
% However, the package can convert these into numerical
% powers.\footnote{Provided things are not too complex!}  This is
% controlled by the \opt{prefixsymbolic} Boolean option, which by
% default is \defaultopt{true}.  If \opt{prefixsymboli} is set to
% \opt{false}, the format of the prefix is controlled by
% \opt{prefixbase} and \opt{prefixproduct}, which work in the same
% way as \opt{expbase} and \opt{expproduct}.
%
%\DescribeOption{prespace}
%\DescribeOption{xspace}
%\DescribeOption{allowoptarg}
% By default, the single unit macros (\eg \cs{metre}) add no space
% either before or after the unit.  Setting the \opt{xspace} flag to
% true means that the single macros are followed by the \cs{xspace}
% command (when used outside of \cs{SI}/\cs{si}).  For users of
% \unitsdef, the \opt{prespace} macro changes the behaviour of the
% unit macros, so that they can immediately follow a number.  As a
% result, the unit macros will \emph{always} be preceded by a fixed
% space when the \opt{prespace} flag is true: this will be in
% addition to any other space. Also relevant to users moving from
% \unitsdef is the \opt{allowoptarg} option.  This allows single unit
% macros to take an optional numerical argument, in the same way that
% occurs in that package.
%\begin{LaTeXexample}
%  \metre is the symbol for metres\\
%  \sisetup{xspace}
%  No, \metre is the correct symbol\\
%  \sisetup{prespace}
%  30\metre\\
%  Do not use \metre in running text\\
%  \sisetup{allowoptarg}
%  \metre[40]
%\end{LaTeXexample}
%
%\subsection{Symbols}
% User access to control the symbols used for \si{\ohm}, \si{\micro},
% \si{\degree}, \si{\arcmin}, \si{\arcsec}, \si{\angstrom} and
% \si{\celsius} is provided here. These are all literal options,
% which are available in text and maths mode variants.  For example,
% \opt{textmicro} is the code used for the \si{\micro} symbol in text
% mode.  The text mode macros should be safe when forced into text,
% and the maths ones when forced into maths.  The symbols defined in
% this way are:
%\newcommand*{\listsymbopt}[1]{\item \opt{#1}\SpecialOptionIndex{#1}}
%\begin{itemize}
%  \listsymbopt{textOmega};
%  \listsymbopt{mathsOmega};
%  \listsymbopt{textmu};
%  \listsymbopt{mathsmu};
%  \listsymbopt{textdegree};
%  \listsymbopt{mathsdegree};
%  \listsymbopt{textminute};
%  \listsymbopt{mathsminute};
%  \listsymbopt{textsecond};
%  \listsymbopt{mathssecond};
%  \listsymbopt{textringA};
%  \listsymbopt{mathsringA};
%  \listsymbopt{textcelsius};
%  \listsymbopt{mathscelsius}.
%\end{itemize}
%
%\DescribeOption{redefsymbols}
% When \currpkg is loaded, it can check for the presence of the
% \pkg{textcomp} and \pkg{upgreek} packages, to provide better
% symbols for certain items. To prevent this, set the
% \opt{redefsymbols} option \opt{false} (the default is
% \defaultopt{true}).
%
%\DescribeOption{eVcorra}
%\DescribeOption{eVcorrb}
% The \si{\electronvolt} symbol requires some fine-tuning, and so has
% two options of its own, both \TeX\ lengths.  \opt{eVcorra} is the
% correction applied to the gap between ``e'' and ``V'' of the unit:
% the default is \defaultopt{0.3ex}. \opt{eVcorrb} is the correction
% applied to the gap between ``V'' of the unit and whatever follows;
% the default is \defaultopt{0ex}.  The optimal value for these
% options will depend on the current font settings.\footnote{This
% document uses \opt{eVcorra=0.1ex}.}
%\begin{LaTeXexample}
%  \si[per=slash]{\electronvolt\per\metre}\\
%  \si[per=slash,eVcorrb=0.7ex]{\electronvolt\per\metre}
%\end{LaTeXexample}
%
%\subsection{Colour}
%\DescribeOption{colourall}
%\DescribeOption{colourunits}
%\DescribeOption{colourvalues}
%\SpecialOptionIndex{colorall}
%\SpecialOptionIndex{colorunit}
%\SpecialOptionIndex{colorvalue}
% The package provides internal hooks for applying colour to part or
% all of the output.  This requires the user to load the \pkg{color}
% or \pkg{xcolor} package to support colour in the output; \currpkg
% will ignore a colour request if support is unavailable. The Boolean
% options \opt{colourall}, \opt{colourunits} and \opt{colourvalues}
% are used to turn application of a given colour on or off for all
% output, only units and only values, respectively.  All three
% switches are available with US spelling, \eg \opt{colorall} and
% \opt{colourall} behave in the same way.  With colour turned off, no
% \cs{color} command is issued internally, and output follows the
% surrounding text.
%
%\DescribeOption{colour}
%\DescribeOption{unitcolour}
%\DescribeOption{valuecolour}
%\SpecialOptionIndex{color}
%\SpecialOptionIndex{unitcolor}
%\SpecialOptionIndex{valuecolor}
% The colour names to use for colouring output are set by the
% \opt{colour}, \opt{unitcolour} and \opt{valuecolour} options (all
% also available with US spelling).  The \opt{colour} option
% internally sets both \opt{unitcolour} and \opt{valuecolour}.
%\begin{LaTeXexample}
%  {\color{brown} Text \num{50}}\\
%  \sisetup{colourall,colour=green}
%  \SI{10}{\metre}\\
%  {\color{purple} Text \num{70}}\\
%  \sisetup{colourunits=true,colourvalues=false}
%  \SI{40}{\second}
%\end{LaTeXexample}
%
%\DescribeOption{colourneg}
%\DescribeOption{negcolour}
%\SpecialOptionIndex{colorneg}
%\SpecialOptionIndex{negcolor}
% \currpkg can automatically add a colour to negative numbers.  This
% is turned on using the \opt{colourneg} switch.  The colour used is
% set by the \opt{negcolour} option; both options are available using
% US spellings.
%
%\subsection{International support}
%\DescribeOption{locale}
% \currpkg allows the user to switch between the typographic
% conventions of different (geographical) areas by using
% \latin{locales}.  Currently, the package is supplied with
% configurations for locales \opt{UK}, \opt{USA}, \opt{DE} (Germany)
% and \opt{ZA} (South Africa). The \opt{locale} option is used to
% switch to a particular locale.
%\begin{LaTeXexample}
%  \SI{1.234}{\metre}\\
%  \SI[locale=DE]{6.789}{\metre}
%\end{LaTeXexample}
%
%\DescribeOption{loctolang}
% Locales are distinct from \pkg{babel} languages, as typographic
% conventions are not tightly integrated with language.  However, it
% is useful to be able to associate a particular locale with a
% \pkg{babel} language.  The option \opt{loctolang} handles this, and
% expects pairs of values:
% \opt{loctolang=\meta{locale}:\meta{language}}.
%\begin{LaTeXexample}
%  \sisetup{loctolang={UK:UKenglish,DE:german}}\\
%  \SI{6.022e23}{\per\mole}\\
%  \selectlanguage{german}\\
%  \SI{6.022e23}{\per\mole}
%\end{LaTeXexample}
%
%\subsection{Package control}
%\DescribeOption{load}
%\DescribeOption{noload}
%\DescribeOption{alsoload}
% The package keeps most of the unit and abbreviations definitions in
% files separate from \file{siunitx.sty}.  To control what is loaded,
% three complementary options are provided, all of which take a list
% of one or more choices.  \opt{load} and \opt{alsoload} define which
% support configuration files are loaded.  The list in \opt{load}
% recognises the value \opt{default}, which is expanded to the normal
% list before loading. The difference between \opt{load} and
% \opt{alsoload} is that \opt{load} specifies the \emph{complete}
% list of files to load, whereas \opt{alsoload} adds to the existing
% list. To use the \opt{load} option successfully requires knowing
% everything that is needed. The \opt{noload} option can be used to
% delete one or more items from the \opt{load} list, without needing
% to know what is on it.\footnote{\opt{noload} does not prevent the
% loading of a file needed by one which is loaded.  Thus the package
% may internally override a \opt{noload} value if needed.}
%
%\DescribeOption{log}
%\DescribeOption{debug}
% To control data written to the \ext{log} file, the \opt{log} option
% is provided.  This takes a value from the list \defaultopt{normal},
% \opt{none}, \opt{minimal}, \opt{errors} and \opt{debug}.  As would
% be expected, these indicate the amount of detail written to the log
% file. As a shortcut to \opt{log=debug}, the package also recognises
% the \opt{debug} option directly.
%
%\DescribeOption{strict}
% Some users will want to stick closely to the official rules for
% typesetting units.  This could be made complicated if the options
% for non-standards behaviour could not be turned off.  The load-time
% option \opt{strict} resets package behaviour to follow the rules
% closely, and disables options which deviate from this.  If the
% package is loaded with the \opt{strict} option, all output is made
% in maths mode using the upright serif font.
%
%\subsection{Back-compatibility options}
%\DescribeOption{emulate}
% The package can emulate \SIunits, \SIstyle, \unitsdef, \units,
% \pkg{hepunits}, \pkg{fancyunits} and \pkg{fancynum}.  Giving the
% \opt{emulate=\meta{package}} option will give the desired
% emulation, and combinations which would be possible with the real
% packages will also work here. The package will recognise the
% options of the emulated packages.  This will automatically cause
% emulation to be switched on.
%
%\subsection{Summary of all options}
% \ref{tab:allopt} lists a summary of the package options (excluding
% those for backward-compatibility).  A reminder or the input format
% is also provided.
%\begin{longtable}{>{\ttfamily}lll}
%    \caption{All package options\label{tab:allopt}}\\
%    \toprule
%    Option & Type & Description \\
%    \midrule
%  \endfirsthead
%    \toprule
%    Option & Type & Description \\
%    \midrule
%  \endhead
%    \bottomrule
%    \multicolumn{3}{r}{\emph{Continued on next page}}
%  \endfoot
%    \bottomrule
%  \endlastfoot
%  addsign & List & Add sign to number \\
%  allowzeroexp & Boolean & Allow \num[allowzeroexp]{e0} \\
%  angformat & List & Conversion of angle format \\
%  anglesep & List or literal & Space between angle components \\
%  astroang & Boolean & Astronomy-style angles \\
%  closeerr & Literal & Closes potential-ambiguous error \\
%  closefrac & Literal & Closes potential-ambiguous fraction \\
%  color & Literal & Colour used for units and values \\
%  colour & Literal & Colour used for units and values \\
%  colorall & Boolean & Switch for colouring all output \\
%  colourall & Boolean & Switch for colouring all output \\
%  colorneg & Boolean & Colour negative numbers \\
%  colourneg & Boolean & Colour negative numbers \\
%  colorunits & Boolean & Switch for colouring units \\
%  colourunits & Boolean & Switch for colouring units \\
%  colorvalues & Boolean & Switch for colouring values \\
%  colourvalues & Boolean & Switch for colouring values \\
%  decimalsymbol & List or literal & Decimal symbol \\
%  debug & Boolean & Write debugging data to log \\
%  detectdisplay & Boolean & Treat display maths separately \\
%  digitsep & List & Separation of digits in large numbers \\
%  dp & Integer & Number of decimal places to \\
%   & & output numbers to \\
%  emulate & Modules & Emulation modules to load \\
%  errspace & List & Spacing of bracketed error \\
%  eVcorra & Length & Spacing correction in \eV \\
%  eVcorrb & Length & Spacing correction after \eV \\
%  expbase & List or Literal & Base used for exponents \\
%  expproduct & List or literal & Product sign for exponents \\
%  fixdp & Boolean & Switch for fixing decimal \\
%   & & places of numbers \\
%  fraction & List & Method used when setting \opt{per=frac} \\
%  inlinebold & List & Select how inline bold is tested \\
%  load & Modules & Modules to load \\
%  locale & Modules & Locale to follow \\
%  loctolang & Special & Associate locale with \pkg{babel}
%    language \\
%  log & List & Amount of data added to log \\
%  mathOmega & Literal & ``$\makeatletter\si@mathsOmega\makeatother$''
%    symbol in maths mode \\
%  mathcelsius & Literal & ``$\makeatletter\si@mathscelsius\makeatother$''
%    symbol in maths mode \\
%  mathdegree & Literal & ``$\makeatletter\si@mathsdegree\makeatother$''
%    symbol in maths mode \\
%  mathminute & Literal & ``$\makeatletter\si@mathsminute\makeatother$''
%    symbol in maths mode \\
%  mathmu & Literal & ``$\makeatletter\si@mathsmu\makeatother$''
%    symbol in maths mode \\
%  mathringA & Literal & ``$\makeatletter\si@mathsringA\makeatother$''
%    symbol in maths mode \\
%  mathrm & Csname & Roman maths font \\
%  mathsOmega & Literal & ``$\makeatletter\si@mathsOmega\makeatother$''
%    symbol in maths mode \\
%  mathscelsius & Literal & ``$\makeatletter\si@mathscelsius\makeatother$''
%    symbol in maths mode \\
%  mathsdegree & Literal & ``$\makeatletter\si@mathsdegree\makeatother$''
%    symbol in maths mode \\
%  mathsecond & Literal & ``$\makeatletter\si@mathssecond\makeatother$''
%    symbol in maths mode \\
%  mathsf & Csname & Sans serif maths font \\
%  mathsminute & Literal & ``$\makeatletter\si@mathsminute\makeatother$''
%    symbol in maths mode \\
%  mathsmu & Literal & ``$\makeatletter\si@mathsmu\makeatother$''
%    symbol in maths mode \\
%  mathsringA & Literal & ``$\makeatletter\si@mathsringA\makeatother$''
%    symbol in maths mode \\
%  mathsrm & Csname & Roman maths font \\
%  mathssecond & Literal & ``$\makeatletter\si@mathssecond\makeatother$''
%    symbol in maths mode \\
%  mathssf & Csname & Sans serif maths font \\
%  mathstt & Csname & Fixed-width maths font \\
%  mathtt & Csname & Fixed-width maths font \\
%  mode & List & Use text or maths mode for \\
%   & & typesetting \\
%  negcolor & Literal & Colour used for negative numbers \\
%  negcolour & Literal & Colour used for negative numbers \\
%  noload & Modules & Modules not to load \\
%  numaddn & Literal & Additional input allowed in numbers \\
%  numcloseerr & Literal & Character indicating end of \\
%   & & numerical error\\
%  numdecimal & Literal & Decimal symbols in numbers\\
%  numdigits & Literal & Digit characters in numbers \\
%  numexp & Literal & Exponent characters in numbers \\
%  numgobble & Literal & Characters to ignore in numbers \\
%  numopenerr & Literal & Character indicating start of \\
%   & & numerical error\\
%  numprod & Literal & Characters used for a product \\
%  numsign & Literal & Sign characters in numbers \\
%  obeyall & Boolean & Combination of \opt{obeybold}, \\
%   & & \opt{obeyitalic} and \opt{obeymode} \\
%  obeybold & Boolean & Check local bold setting \\
%  obeyitalic & Boolean & Check local italic setting \\
%  obeymode & Boolean & Check local mode (text/maths) \\
%  openerr & Literal & Opens potentially-ambiguous error \\
%  openfrac & Literal & Opens potentially-ambiguous fraction \\
%  padangle & List & Add zeros to blank parts of angles \\
%  padnumber & List & Add zeros to blank parts of numbers \\
%  per & List & Behaviour of \cs{per} \\
%  prefixbase & List or literal & Base used when making prefixes \\
%   & & numerical \\
%  prefixproduct & List or literal & Product sign for prefixes \\
%  prefixsymbolic & Boolean & Behaviour of unit prefixes\\
%  prespace & Boolean & Add space before units \\
%  redefsymbols & Boolean & Use better symbols if available \\
%  repeatunits & List & Repeat units with separated errors \\
%   & &  and products \\
%  retainplus & Boolean & Retain explicit plus sign\\
%  seperr & Boolean & Separate number and error \\
%  sepfour & Boolean & Separate four-digit numbers \\
%  sign & List or literal & Sign to add to numbers \\
%  slash & List or literal & Symbol used for ``/'' \\
%  stickyper & Boolean & Require \cs{per} only once \\
%  strict & Boolean & Obey the rules strictly \\
%  strictarc & Boolean & Require exactly zero or \\
%   & & two semi-colons \\
%  tabalign & List & Positioning of all column data \\
%  tabalignexp & Boolean & Alignment of exponents in tables \\
%  tabautofit & Boolean & Switch for rounding numbers to \\
%   & & length given by \opt{tabformat} \\
%  tabformat & Number & Space reserved in table for numbers \\
%  tabnumalign & List & Alignment of |S| column numbers \\
%  tabtextalign & List & Positioning of text in |S| columns \\
%  tabunitalign & List & Positioning of units in |s| columns \\
%  textcelsius & Literal & ``$^{\circ}$C'' symbol in text mode \\
%  textdegree & Literal & ``${\circ}$'' symbol in text mode \\
%  textminute & Literal & ``$'$'' symbol in text mode \\
%  textmu & Literal & ``$\upmu$'' symbol in text mode \\
%  textomega & Literal & ``$\Omega$'' symbol in text mode \\
%  textringa & Literal & ``\AA'' symbol in maths mode \\
%  textrm & Csname & Roman text font \\
%  textsecond & Literal & ``$''$'' symbol in text mode \\
%  textsf & Csname & Sans serif text font \\
%  texttt & Csname & Fixed-width text font \\
%  tightpm & Boolean & Reduce space around $\pm$ \\
%  trapambigerr & Boolean & Check for ambiguous errors \\
%  trapambigfrac & Boolean & Check for ambiguous fractions \\
%  unitcolor & Literal & Switch for colouring units \\
%  unitcolour & Literal & Switch for colouring units \\
%  unitmathrm & Csname & Roman maths font for units \\
%  unitmathsf & Csname & Sans serif maths font for units \\
%  unitmathsrm & Csname & Roman maths font for units \\
%  unitmathssf & Csname & Sans serif maths font for units \\
%  unitmathstt & Csname & Fixed-width maths font for units \\
%  unitmathtt & Csname & Fixed-width maths font for units \\
%  unitmode & List &  As \opt{mode}, for units only \\
%  unitsep & List or literal & Separator for units \\
%  unitspace & List or literal & Space used for ``|~|'' in units \\
%  valuecolor & Literal & Switch for colouring value \\
%  valuecolour & Literal & Switch for colouring value \\
%  valuemathrm & Csname & Roman maths font for values \\
%  valuemathsf & Csname & Sans serif maths font for values \\
%  valuemathsrm & Csname & Roman maths font for values \\
%  valuemathssf & Csname & Sans serif maths font for values \\
%  valuemathstt & Csname & Fixed-width maths font for values \\
%  valuemathtt & Csname & Fixed-width maths font for values \\
%  valuemode & List &  As \opt{mode}, for values only \\
%  valuesep & List or literal & Separator between value and unit \\
%  xspace & Boolean & Use \pkg{xspace} after units \\
%\end{longtable}
%
%\section{Emulation of other packages}
% \currpkg has been designed as a replacement for \SIunits, \SIstyle,
% \unitsdef, \units, \pkg{hepunits}, \pkg{fancyunits} and
% \pkg{fancynum}. It therefore provides options reproduce the
% functions of all of these packages.  In this way, \currpkg should
% be usable as a straight replacement for the older
% packages.\footnote{User macros means that they are described in the
% package documentation; simply not containing an \texttt{@} does not
% mean they will have been emulated.}  This means for example that
% the \cs{num} macro takes an optional star when emulating \SIstyle.
% However, there are some points that should be remembered.  In
% particular, \currpkg validates numerical input, meaning that places
% where a number is expected in the older packages \emph{require} a
% number when emulated by \currpkg.
%
% The \numprint package has provided many useful ideas for the code
% used here for number formatting. The basic use of the \cs{numprint}
% (or \cs{np}) macro can be reproduced using \currpkg.  However,
% \numprint is large and complex, with its own backward-compatibility
% options.  As a result, emulation of \numprint is not provided here.
% To use an \numprint document with \currpkg, the \cs{numprint} macro
% could be provided using the following code.
%^^A Need to deal with \cs{numprint} being defined.
%\let\numprint\relax
%\begin{LaTeXexample}
%  \newcommand*{\numprint}[2][]{\SI[obeymode]{#2}{#1}}\\
%  \numprint{-123456} \\
%  \numprint[N/mm^2]{-123456}
%\end{LaTeXexample}
%^^A Back to the normal - with \cs{newcommand}
%\newcommand*{\numprint}{\pkg{numprint}\xspace}
%
% \currpkg can be used more-or-less directly to replace both
% \pkg{dcolumn} and \pkg{rccol}.  As is explained in the code
% section, much of the column-alignment system here is taken from
% \pkg{dcolumn}, while \pkg{rccol} provided a model for a
% customisable system.  However, neither package has been directly
% emulated here.  The |S| column type can be used to replace both |D|
% and |R| columns by setting the appropriate package options.
%
%\section{Configuration files}
% \currpkg is a modular package.  The unit definitions, abbreviations
% and locales are all stored in configuration files.  These all take
% names of the form \file{si-\meta{name}.cfg}, where \meta{name} is
% the part of the filename used as an option in \cs{sisetup} or when
% loading \currpkg.  Producing new configuration files therefore
% consists of making a suitably-named file and adding it to the path
% searched by \TeX.  The files should normally consist of settings
% (in \cs{sisetup}) and unit definitions, \etc.
%
%\DescribeMacro{\addtolocale}
% To allow arbitrary macros to be stored in locales, the
% \cs{addtolocale} macro is provided.  This ensures that arbitrary
% text is only executed when using a locale, not when loading it.
%
%\DescribeMacro{\requiresiconfigs}
% To load one or more configuration files from inside another
% configuration file, the \cs{requiresiconfigs} macro is provided.
% This accepts a comma-separated list of configuration names, in the
% same way as \opt{load} or \opt{noload}.
%
% In addition to the various configuration files provided with the
% package, a local file \file{siunitx.cfg} may be provided.  This is
% read at the end of loading \currpkg, and allows the user to include
% any local definitions or settings easily.
%
%\section{Common questions}
%\subsection{Why do I need \cs{per} more than once?}
% The unit engine of \currpkg is based around the English method for
% reading units out loud. Thus \si{\joule\per\mole\per\kelvin} is
% pronounced ``joules per mole per kelvin''.  Hence by default you
% need to put \cs{per} before each item in the denominator of a unit.
% The behaviour can be altered by setting the \opt{stickyper} option.
%
%\subsection{Why is the order of my units changed?}
% Then using \opt{per=reciprocal}, the units are typeset as given.
% However, when using \opt{per=slash} or \opt{per=fraction}, the
% package needs to find which ones are in the denominator.  It then
% prints the numerator and denominator separately.  So if you give a
% unit in the denominator \emph{before} one in the numerator, they
% have to be re-ordered.\footnote{``Double division''
% (\SI{1}{s/m/kg}) is mathematically incorrect.}
%\begin{LaTeXexample}
%  \SI{88}{\per\kilogram\metre} \\
%  \SI[per=slash]{66}{\per\kilogram\metre}
%\end{LaTeXexample}
%
%\subsection{Why are compound units not recommended outside of
%  \cs{SI}/\cs{si}?}
% To fully process units made up of several parts, the processor has
% to know where the end of the unit is.  When the unit macros are
% used outside of \cs{SI}/\cs{si}, this is not the case.  The package
% therefore does its best, but results may be sub-optimal.  To get
% consistent results, either define a new \emph{single} unit, or keep
% compound units inside \cs{SI} and \cs{si}.
%\begin{LaTeXexample}
%  \metre\per\micro\second \\
%  \si{\metre\per\micro\second} \\
%  \newunit{\myunit}{\metre\per\micro\second}
%  \myunit
%  \newunit{\myunittwo}{\kilogram\myunit} \\
%  \myunittwo \\
%  \kilogram\myunit
%\end{LaTeXexample}
% Notice the difference in behaviour of \cs{per} in the first two
% lines, and the spacing error on the last line in the example.
%
%\subsection{How do I set superscripts to use lining numbers?}
% Lowercase (``old style'') numbers are favoured by many people for
% use in running text.  However, this does not necessarily look good
% in superscripts. The mode used to typeset data can be varied, so
% that maths mode numbers are used for the unit part of the output.
%\begin{LaTeXexample}
%  \SI[mode=text]{1234}{\metre\per\second}\\
%  \SI[valuemode=text,unitmode=maths]{1234}{\metre\per\second}
%\end{LaTeXexample}
%
%\subsection{Why do most of the examples use
%  \texorpdfstring{\si{\joule\per\mole\per\kelvin}}{J mol-1 K-1}?}
% The package author is a chemist, and this is the unit of entropy
% (disorder).  It nicely demonstrates the use of the \cs{per} macro,
% and so it crops up a lot.  It is also in the subsection heading
% here to act as a test with \pkg{hyperref} and moving arguments!
%
%\subsection{What can \numprint do that \currpkg cannot?}
% \currpkg uses a lot of ideas from \numprint: a reasonable amount of
% the number-processing code here is based on that in \numprint.
% However, the two packages have somewhat different aims, and as a
% result there are things that \numprint can do that \currpkg does
% not implement.  The main features of \numprint not available here
% are:
%\begin{itemize}
%  \item General support for numbers with base other than $10$ (see
%    \pkg{nbaseprt});
%  \item Alignment of the decimal marker of powers in tables;
%  \item Alignment of numbers in running text;
%  \item Specific formatting commands for \TeX\ counters and lengths.
%\end{itemize}
%
%\section{Tricks and known issues}
%
%\subsection{Ensuring maths mode}
% Due to the possibility of output in either maths or text mode, any
% input which requires a particular mode needs to be protected.  You
% cannot use |$|\ldots|$|, as this can get ``caught out'', but also
% as it may give hard-to-follow errors.  Always use \cs{ensuremath}
% to force maths processing, and \cs{text} (from the \AMS\TeX\
% bundle) to ensure text mode.
%
%\subsection{Using \texttt{.} and fixed spaces in units}
% To use a literal |.| in a unit, it has to be within an extra set of
% braces.  This does not need any extra protection, unlike the
% situation with \SIstyle (for example, no \cs{text} macro is
% needed).  The fixed space (|~|) is more problematic: set
% \opt{unitspace=space} to get a full space here.
%\begin{LaTeXexample}
%  \newunit[unitspace=space]{\myunit}{V~vs{.}~NHE}%
%  \SI{10}{\myunit}
%\end{LaTeXexample}
%
%\subsection{Limitations of \cs{mathrm}}
% The package uses the \cs{mathrm} font family by default to typeset
% output in maths mode.  This however has a few side-effects.  For
% example, the Greek alphabet can give odd results.\footnote{This
% depends on your font setup; this document uses T1 encoding, which
% shows the issue, whereas using OT1 does not.}  The use of the
% \cs{mathnormal} font \emph{may} get around this issue.
%\begin{LaTeXexample}
%  \num[numaddn=\pi]{4\pi e-7}\\
%  \num[numaddn=\pi,mathsrm=mathnormal]{4\pi e-7}
%\end{LaTeXexample}
% On the other hand, you may want to use text mode, in which case
% \cs{ensuremath} is needed.  Depending on the exact circumstances,
% the \LaTeX\ protection mechanism (\cs{DeclareRobustCommand}) may be
% sufficient; in some cases, this will fail and the \eTeX\
% \cs{protected} system may be required. There are several potential
% pitfalls in this area; experimentation may well be needed.
%\begin{LaTeXexample}
%  \DeclareRobustCommand*{\numpi}{\ensuremath{\pi}}
%  \num[numaddn=\numpi,mode=text]{4\numpi e-7}
%\end{LaTeXexample}
%
%\subsection{Entire document in sans serif font}
% If your entire document is not in a Roman font, using
% the font detection system is not the most efficient method
% for setting the \currpkg output.  Instead, the \opt{mathrm}
% and \opt{textrm} package options can be redefined.
%\begin{LaTeXexample}
%  \sffamily
%  Some text \\
%  \sisetup{obeyfamily=false,mathrm=mathsf,textrm=sffamily}
%  \num{1e2} \\
%  \SI{3}{\newton}
%  \[ \num{4e5} \si{\pascal} \]
%\end{LaTeXexample}
%
%\subsection{Effects of emulation}
% The package has been designed so that almost everything can be set
% using the options.  In the emulation code, some internal macros are
% redefined.  This is because the legacy packages do odd things,
% which are deliberately not implemented by \currpkg.  Using an
% emulation file will prevent subsequent loading of the real package.
% This is to prevent errors or, worse, difficult to diagnose changes
% to output.
%
%\subsection{Centring columns on non-decimal input}
% The \pkg{dcolumn} manual suggests using that package to align a
% column on a $\pm$ sign. The same type of output is possible using
% \currpkg, but some care is needed (\ref{tab:dcolumn}).  Odd things
% may happen: use with care!
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \caption{Non-standard \texttt{S} column}
%    \label{tab:dcolumn}
%    \centering
%    \begin{tabular}{%
%      S[digitsep=none,decimalsymbol={\,\pm\,},
%        numdigits={0123456789.},numdecimal=+]}
%    \toprule
%    {Some Values} \\
%    \midrule
%    2.3456  + 0.02  \\
%    34.2345 + 0.001 \\
%    56.7835 + 0.067 \\
%    90.473  + 0.021 \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
%
%\subsection{Adding items after the last column of a tabular}
% If you use an |S| or |s| column as the last one in a tabular, and
% you use the \pkg{array} ``|<|'' construction to add items after it,
% the spacing may be wrong.  This will occur if the column contents
% are of differing widths.  Changing the \LaTeX\ |\\| line ending for
% the plain \TeX\ \cs{cr} will give the correct spacing, but does not
% allow adjustment of inter-row distance (\ref{tab:cr}).\footnote{For
% the \TeX\ experts, the issue here is that the system to gather up
% cell contents is added in using the \texttt{<} construction.
% Normally, this comes after the cell contents and any other
% \texttt{<} arguments, so collects the user additions.  However, in
% the last cell the contents include \texttt{\bslash\bslash}, which
% is converted to \cs{cr} before gathering can occur.  By using
% \cs{cr} directly, the gathering process receives all of the cell
% contents as normal.}  In most cases, this should not be a serious
% issue.
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \caption{Correcting spacing in last \texttt{S} column}
%    \label{tab:cr}
%    \hfil
%    \begin{tabular}{S<{\,\si{\kg}}S<{\,\si{\kg}}}
%      \toprule
%      \multicolumn{1}{c}{Long header} &
%        \multicolumn{1}{c}{Long header} \\
%      \midrule
%      1.23 & 1.23 \\
%      4.56 & 4.56 \\
%      7.8  & 7.8  \\
%      \bottomrule
%    \end{tabular}
%    \hfil
%    \begin{tabular}{S<{\,\si{\kg}}S<{\,\si{\kg}}}
%      \toprule
%      \multicolumn{1}{c}{Long header} &
%        \multicolumn{1}{c}{Long header} \\
%      \midrule
%      1.23 & 1.23 \cr
%      4.56 & 4.56 \cr
%      7.8  & 7.8  \cr
%      \bottomrule
%    \end{tabular}
%    \hfil
%  \end{table}
%\end{LaTeXexample}
%
%\iffalse
%<*bug>
%\fi
%\section{Reporting a problem}
% \currpkg is quite long and complicated, and works hard to cover all
% possible eventualities.  However, there will be bugs in the code
% and unexpected interactions with other packages.  If you think you
% have found a bug, please report it.  A short test-case
% demonstrating the problem would be very welcome.  The following is
% a suitable template, and is available as \file{si-bug.ltx} in the
% \texttt{doc/latex/siunitx} directory or by running the \ext{dtx} or
% \ext{ins} file through \TeX.
%    \begin{macrocode}
\listfiles
\documentclass{article}
%    \end{macrocode}
% Load other packages needed here.
%    \begin{macrocode}
\usepackage{siunitx}
%    \end{macrocode}
% Normally, debugging the load procedure will not be needed; the
% debug option here means that all run-time information is logged.
%    \begin{macrocode}
\sisetup{debug}
\begin{document}
This is the bug test-case document for the \textsf{siunitx}
package.\\
Please put your demonstration here, and e-mail to the package
author.
\begin{center}
  \texttt{joseph.wright@morningtar2.co.uk}
\end{center}
\end{document}
%    \end{macrocode}
%\iffalse
%</bug>
%\fi
%
%\section{Feature requests}
% Feature requests for \currpkg are welcome.  The package maintainer
% will consider any ideas within the remit of the package (units and
% values).  If suggesting a new feature, an example of how it should
% work would be appreciated.  If new controls are needed, some
% suggestions for option names would be welcome.
%
%\section{Acknowledgements}
% Many thanks indeed to Stefan Pinnow, who has made a very large
% number of suggestions and found numerous bugs in the package.  His
% contribution to the package has been vital. The package author has
% learned \LaTeX\ tricks from far too many people to thank all of
% them.  However, for this package specific thanks must go to the
% authors of the existing ``unit'' packages: Danie Els (\SIstyle),
% Marcel Heldoorn (\SIunits), Patrick Happel (\unitsdef), Axel
% Reichert (\units) and Harald Harders (\numprint).  Will Robertson
% and Heiko Oberdiek deserve much credit for demonstrating \LaTeX\
% coding best practice. Victor Eijkhout's excellent (and free)
% \emph{\TeX\ by Topic} has provided some useful coding hints
% \cite{Eijkhout}.  The idea for combining and extending unit
% provision in \LaTeX\ was heavily inspired by Philip Lehmann's
% \pkg{biblatex}. Thanks to the various contributors of ideas for the
% package: Donald Arseneau, Michele Dondi, Paul Gans, Ben Morrow, Lan
% Thuy Pham, Alan Ristow, Patrick Heinze, Andrea Blomenhofer, Morten
% H{\o}gholm, Burkhard Moddemann  and Patrick Steegstra.
%
%\clearpage
%\part{Correct application of (SI) units}
%\section{Background}
% Consistent and logical units are a necessity for scientific work,
% and have applicability everywhere.  Historically, a number of
% systems have been used for physical units.  SI units were
% introduced by the \latin{Conf\'erence G\'en\'erale des Poids et
% Mesures} (CGPM) in 1960.  SI units are a coherent system based on
% seven base units, from which all other units may be derived.
%
% At the same time, physical quantities with units are mathematical
% entities, and as such way that they are typeset is important.  In
% mathematics, changes of type (such as using bold, italic, sans
% serif typeface and so on) convey information.  This means that
% rules exist not only for the type of units to be used under the SI
% system, but also the way they should appear in print.  Advice on
% best practice has been made available by the \emph{National
% Institute of Standards and Technology} (NIST) \cite{NIST}.
%
% As befits an agreed international standard, the full rules are
% detailed. It is not appropriate to reproduce these in totality
% here; instead, a useful summary of the key points is provided. The
% full details are available from the \latin{Bureau International des
% Poids et Mesures} (BIPM) in French \cite{BIPM:FR} and English
% \cite{BIPM:EN}.  They also publish a very useful and detailed guide
% to using units, values and so on, available online in a number of
% different formats \cite{BIPM:PDF}.
%
% \currpkg takes account of the information given here, so far as is
% possible.  Thus the package defaults follow the recommendations
% made for typesetting units and values.  Spacing and so forth is
% handled in such a way as to make implementing the rules
% (relatively) easy.
%
%\section{Units}
%\subsection{SI base units}
% There are seven base SI units, listed in \ref{tab:baseunits}. Apart
% from the kilogram, these are defined in terms of a measurable
% physical quantity needing the definition alone.\footnote{Some base
% units need others defined first; there is therefore a required
% order of definition.}  The base units have been chosen such that
% all physical quantities can be expressed using an appropriative
% combination of these units, needing no others and with no
% redundancy.  The kilogram is slightly different from the other base
% units as it is still defined in terms of a ``prototype'' held in
% Paris.\footnote{At the time of writing, this is under review and
% will be altered.}
%
%\subsection{SI derived units}
% All other units within the SI system are regarded as ``derived''
% from the seven base units.  At the most basic, all other SI units
% can be expressed as combinations of the base units.  However, many
% units (listed in \ref{tab:derived}, \ref{tab:experimental} and
% \ref{tab:accepted}) have a special name and symbol.\footnote{The
% nautical mile has a given name but no agreed symbol, and although
% accepted by the SI is not provided by \currpkg as a unit macro.}
% Most of these units are simple combinations of one or more base
% units (raised to powers as appropriate).  A small number of units
% derived from experimental data are allowed as SI units
% (\ref{tab:experimental}).
%
% Some of these units (in \ref{tab:accepted}) are regarded as only
% ``temporarily'' accepted, as the use of only the base and
% fully-consistent derived units in \ref{tab:derived} is encouraged.
% They are accepted as they are in common use in one or more
% disciplines; some are still very widespread in the appropriate
% areas.  These units are mainly multiples of base units (for
% example, a tonne is \SI{1000}{\kilo\gram}).
%
% One point to note is that ``unitless ratios'' are regarded as
% having base units which cancel out.  For example, the radian is
% regarded as having base unit \si{\metre\per\metre}.  The result of
% this division (``$1$'') is therefore regarded as a derived SI unit
% in this context.
%
%\subsection{SI prefixes}
% A series of SI prefixes for decimal multiples and submultiples are
% provided, and can be used as modifiers for any SI unit (either base
% or derived units) with the exception of the kilogram.  The prefixes
% are listed in \ref{tab:prefix}.  No space should be used between a
% prefix and the unit, and only a single prefix should be used.  Even
% the degree Celsius can be given a prefix, for example
% \SI{1}{\milli\celsius}.  The only exception to this rule is for
% degrees, minutes and seconds of an arc: \ang{1;2;3}.
%
% It is important to note that the kilogram is the only SI unit with
% a prefix as part of its name and symbol.  Only  single prefix may
% be used, and so in the case of the kilogram prefix names are used
% with the unit name ``gram'' and the prefix symbols are used with
% the unit symbol \si{\gram}.  For example $\SI{1e-6}{\kilogram} =
% \SI{1}{\milli\gram}$.
%
%\subsection{Other units}
% The application of SI units is meant to provide a single set of
% units which ensure consistency and clarity across all areas.
% However, other units are common is many areas, and are not without
% merit. The units provided by \currpkg by default do not included
% any of these; only units which are part of the SI set or are
% accepted for use with SI units are defined.  However, several other
% sets of units can be loaded as optional modules. The binary
% prefixes and units (Section~\ref{sec:binary} and \ref{tab:binary})
% are the most obvious example.  These are \emph{not} part of the SI
% specifications, but the prefix names are derived from those in
% \ref{tab:prefix}.
%
% Other units (such as those provided by the modules \opt{synchem},
% \opt{hep} and \opt{astro}) are normally to be avoided where
% possible.  SI units should, in the main, be preferred due to the
% advantages of clear definition and self-consistency this brings.
% However, there will probably always be a place for specialist or
% non-standard units.  This is particulary true of units derived from
% basic physical constants; for example reason, the \opt{hep} module
% defines the speed of light, \si{\clight}, as a unit.  For work in
% basic science, a small number of physical constants are recognised
% as units provided the results for comparison with experiment are
% given in SI units.
%
% There are also many areas where non-standard units are used so
% commonly that to do otherwise is difficult or impossible.  For
% example, most synthetic chemists measure the pressure inside vacuum
% apparatus in \si{\mmHg}, partly because the most common gauge for
% the task still uses a column of mercury metal.  For these reasons,
% \currpkg does define non-SI units.
%
%\section{Units and values in print}
%\subsection{Mathematical meaning}
% As explained earlier, a unit--value combination is a single
% mathematical entity.  This has implications for how both the number
% and the unit should be printed.  Firstly, the two parts should not
% be separated.  With the exception of the symbols for plane angles
% (\si{\degree}, \si{\arcmin} and \si{\arcsec}), it is usual to have
% a space between the unit and the value.  This should therefore be a
% non-breaking space between the two.  Different geographical areas
% have different conventions on the size of this space; a ``small''
% space (|\,|) is the \currpkg default.
%\begin{LaTeXexample}
%  A space for \SI{10}{\percent}\\
%  and also for \SI{100}{\celsius}\\
%  but not for \ang{1.23}.
%\end{LaTeXexample}
%
% The mathematical meaning of units also means that the shape, weight
% and family are important.  Units are supposed to be typeset in an
% upright, medium weight serif font.  Italic, bold and sans serif are
% all used mathematically to convey other meanings.  \currpkg package
% defaults again follow this convention: any local settings are
% ignored, and uses the current upright serif maths font.  However,
% there are occasions where this may not be the most desirable
% behaviour.  A classic example would be in an all-bold section
% heading.  As the surrounding text is bold, some people feel that
% any units should follow this.
%\begin{LaTeXexample}
%  Units should \textbf{not be bold: \SI{54}{\farad}}\\
%  \textbf{But perhaps in a running block,\\
%  it might look better: \SI[obeybold]{54}{\farad}}
%\end{LaTeXexample}
%
%\subsection{Unit multiplication and division}
% Symbols for units formed from other units by multiplication are
% indicated by means of either a half-height (that is, centred) dot
% or a (thin) space.  This document uses a half-height dot as
% (\emph{i}) this is the recommendation of \textsc{nist}, amongst
% others and (\emph{ii}) it avoids potential confusion between unit
% prefixes and multiplied units.
%\begin{LaTeXexample}
%  $\si{\metre\second} = \mbox{metre second}$ \\
%  $\si{\milli\second} = \mbox{millisecond}$ \\
%  \sisetup{unitsep=thin}
%  $\si{\metre\second} = \mbox{metre second}$ \\
%  $\si{\milli\second} = \mbox{millisecond}$
%\end{LaTeXexample}
% There are some circumstances under which it is permissable to omit
% any spaces.  The classic example is \si{\kWh}, where
% ``\si[unitsep=thin]{\kWh}'' does not add any useful information.
% If using such a unit repeatedly, users of \currpkg are advised to
% create a custom unit to ensure consistency.\footnote{\cs{kWh} and
% \cs{kilowatthour} are defined by \currpkg in this way.}
%
% Symbols for units formed from other units by division are indicated
% by means of a virgule (oblique stroke, slash, |/|), a horizontal
% line, or negative exponents.\footnote{Notice that a virgule and a
% solidus are not the same symbol.}  However, to avoid ambiguity, the
% virgule must not be repeated on the same line unless parentheses
% are used. This is ensured when using named unit macros in \currpkg,
% which will ``trap'' repeated division and format it correctly.  In
% complicated cases, negative exponents are to be preferred over
% other formats.
%\begin{LaTeXexample}
%  \si{\joule\per\mole\per\kelvin}\\
%  \si[per=fraction]{\joule\per\mole\per\kelvin}\\
%  \si[per=slash]{\joule\per\mole\per\kelvin}
%\end{LaTeXexample}
%
%\subsection{Repeating units}
% Products and errors should show what unit applies to each value
% given.  Thus \SI{2x3}{\metre} is an ordered set of lengths of a
% geometric area, whereas \SI[repeatunits=false]{2x3}{\metre} is a
% length (and equal to \SI{6}{\metre}). Thus, $\times$ is not a
% product but is a mathematical operator; in the same way, a $2
% \times 3$ matrix is not a $6$ matrix!  In some areas, areas and
% volumes are given with separated units but a unit raised to the
% appropriate power: \SI[repeatunits=power]{2 x 3}{\metre}. Although
% this does display the correct overall units, it is
% potentially-confusing and is not encouraged.
%
%\subsection{Clarity in writing values of quantities}
% Care must be taken when writing ranges of numbers.  For purely
% numerical values, it is common to use a en-dash between values, for
% example ``see pages 1--5''.  On the other hand, values with units
% could be misinterpret as negative values if written in this way. As
% the unit--value combination is a single mathematic entity, writing
% the values with an en-dash followed by a single unit is also
% incorrect.  As a result, using the word ``to'' is strongly
% recommended.
%\begin{LaTeXexample}
%  \SI{1}{\metre} to \SI{5}{\metre} long.
%\end{LaTeXexample}
%
%\subsection{Graphs and tables}
% In tables and graphs, repetition of the units following each entry
% or axis mark is confusing and repetitive.  It is therefore best to
% place the unit in the label part of the information.  Placing the
% unit in square brackets is common but mathematically
% poor.\footnote{For example, for an acceleration $a$, the expression
% $[a]$ is the dimensions of $a$, \ie length per time squared in this
% case.}  Much better is to show division of all values by the unit,
% which leaves the entries as unitless ratios.  This is illustrated
% in \ref{tab:label} and \ref{fig:label}.
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \centering
%    \caption{An example of table labelling}
%    \label{tab:label}
%    \begin{tabular}{cS[tabformat=1.4,tabnumalign=centre]}
%      \toprule
%      {Entry} & {Length/\si{\metre}} \\
%      \midrule
%      1 & 1.1234 \\
%      2 & 1.1425 \\
%      3 & 1.7578 \\
%      4 & 1.9560 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
%\begin{LaTeXexample}[float]
%  \begin{figure}
%    \centering
%    \begin{tikzpicture}
%      \begin{axis}[xlabel=$t/\si{\second}$,ylabel=$d/\si{\metre}$]
%        \addplot[smooth,mark=x]
%          plot coordinates {
%            (0,0)
%            (1,5)
%            (2,8)
%            (3,9)
%            (4,8)
%            (5,5)
%            (6,0)
%           };
%      \end{axis}
%    \end{tikzpicture}
%    \caption{An example of graph labelling}
%    \label{fig:label}
%  \end{figure}
%\end{LaTeXexample}
%
% In most cases, adding exponent values in the body of a table is
% less desirable than adding a fixed exponent to column headers.  An
% example is shown in \ref{tab:exp}.  The use of \cs{multicolumn} is
% needed here due to the ``|<|''; without \cs{multicolumn}, the
% titles are followed by ``\si{\kilo\gram}''!
%\begin{LaTeXexample}[float]
%  \begin{table}
%    \centering
%    \caption{Good and bad columns}
%    \label{tab:exp}
%    \sisetup{tabnumalign=centre}
%    \begin{tabular}{%
%      c%
%      S[tabformat=1.3e1]<{\,\si{\kilogram}}%
%      S[tabformat=2.2]}
%      \toprule
%      Entry & \multicolumn{1}{c}{Mass} &
%        {Mass/\SI{e3}{\kilogram}} \\
%      \midrule
%      1 & 4.56e3  & 4.56 \\
%      2 & 2.40e3  & 2.40 \\
%      3 & 1.345e4 & 13.45 \\
%      4 & 4.5e2   & 0.45 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXexample}
%
%\bibliographystyle{unsrt}
%\StopEventually{%
%  \clearpage
%  \part{Notes}
%  \PrintChanges
%  \PrintIndex
%  \bibliography{siunitx}}
%
% \iffalse
%<*package>
% \fi
%
%\clearpage
%\part{Implementation}
%\section{Main package}
% Much of the code here is taken, with little or no modification,
% from the existing packages.  These are all released under the LPPL,
% and so this use is entirely allowed.  Rather than confuse the
% source here with repeated references, note that code here could be
% copied from \SIstyle, \SIunits, \numprint, \unitsdef or \units.
% Some ideas have also been borrowed from \pkg{biblatex}; again these
% will not be specifically noted. Code from other packages will be
% marked when used.
%
% User-space commands (those not containing |@|) defined here should
% give the same result as macros with the same name in the older
% packages.\footnote{Although extra optional arguments may be added.}
% However, internal package macros will behave differently; if the
% user has redefined internal macros, then compatibility will be
% impaired.
%
% The code used here uses \LaTeX\ rather than \TeX\ commands where
% possible.\footnote{This applies to \LaTeX\ kernel commands only;
% for example, \pkg{ifthenelse} is not used.}  For example,
% \cs{newcommand*} is used in place of \cs{def}, unless custom
% parameters are needed.  Hopefully, this will aid future
% maintenance.  Grouping is used where possible to limit the scope of
% temporary assignments.
%
%\subsection{Setup code}
%\begin{macro}{\si@svn@version}
%\begin{macro}{\si@svn@id}
%\begin{macro}{\si@svn@ver}
% As always, the package starts with identification.  This defines a
% couple of macros for use with \emph{Subversion}, so that everything
% is nice and clear.  This should also make it a bit easier to avoid
% messing up the revision data!  For anyone reading the source, the
% revision number is also available as well as the release version
% number, of course.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\newcommand*{\si@svn@ver}{v1.0e}
\def\si@svn@id$#1: #2.#3 #4 #5-#6-#7 #8 #9${%
  \newcommand*{\si@svn@version}{%
    #5/#6/#7\space\si@svn@ver\space}}
\si@svn@id $Id: siunitx.dtx 101 2008-07-03 09:02:22Z joseph $
\ProvidesPackage{siunitx}
  [\si@svn@version A comprehensive (SI) units package]
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
% The package requires \eTeX, so the usual test is made.
%    \begin{macrocode}
\begingroup
  \@ifundefined{eTeXversion}
    {\PackageError{siunitx}
       {Not running under e-TeX}
       {This package requires e-TeX. Try compiling the document
        with\MessageBreak `elatex' instead of `latex'. When
        using pdfTeX, try `pdfelatex'\MessageBreak instead of
        `pdflatex'}%
     \endgroup\endinput}
    {\endgroup}
%    \end{macrocode}
%\begin{macro}{\si@catcodes}
% There are circumstances under which some odd category codes might
% be in place.  The category codes for |{|, |}|, |[|, |]| and |#| are
% assumed to be okay; if issues arise, this can be altered.  \LaTeX\
% will have set |@| as a letter on loading \currpkg.
%    \begin{macrocode}
\edef\si@catcodes{%
  \catcode\string`\string ` \the\catcode\string`\`\relax
  \catcode\string`\string = \the\catcode\string`\=\relax
  \catcode\string`\string ^ \the\catcode\string`\^\relax
  \catcode\string`\string ~ \the\catcode\string`\~\relax
  \catcode\string`\string : \the\catcode\string`\:\relax
  \catcode\string`\string - \the\catcode\string`\-\relax
  \catcode\string`\string + \the\catcode\string`\+\relax
  \catcode\string`\string ; \the\catcode\string`\;\relax
  \catcode\string`\string , \the\catcode\string`\,\relax
  \catcode\string`\string . \the\catcode\string`\.\relax}
\catcode\string`\` 12\relax
\catcode`\= 12\relax
\catcode`\^ 7\relax
\catcode`\~ \active\relax
\@makeother{\:}
\@makeother{\-}
\@makeother{\+}
\@makeother{\;}
\@makeother{\,}
\@makeother{\.}
%    \end{macrocode}
%\end{macro}
% Packages needed for functionality are loaded.  \pkg{xkeyval}
% handles the package options, while \pkg{amstext} from the \AMS\
% bundle is needed for \cs{text}.  \pkg{array} is needed for the new
% column type for tabular material.  \pkg{xspace} provides ``magic''
% spacing after macros, if requested.
%    \begin{macrocode}
\RequirePackage{xkeyval}[2005/05/07]
\RequirePackage{amstext,array,xspace}
%    \end{macrocode}
%\begin{macro}{\si@tempa}
%\begin{macro}{\si@tempb}
%\begin{macro}{\si@tempc}
% Some scratch commands are defined; apart from where a known value
% is carried through, these could contain anything.
%    \begin{macrocode}
\newcommand*{\si@tempa}{}
\newcommand*{\si@tempb}{}
\newcommand*{\si@tempc}{}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@switch}
% Various items will need a switch.  To avoid name pollution, a
% single switch is defined here; grouping will keep the definition
% local.
%    \begin{macrocode}
\newif\ifsi@switch
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tempboxa}
%\begin{macro}{\si@tempboxb}
%\begin{macro}{\si@tempboxc}
%\begin{macro}{\si@tempboxd}
% Some boxes are also needed.
%    \begin{macrocode}
\newbox\si@tempboxa
\newbox\si@tempboxb
\newbox\si@tempboxc
\newbox\si@tempboxd
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@packagecheck}
%\begin{macro}{\si@blockpkgs}
%\begin{macro}{\si@checkpkgs}
% As \currpkg is intended to replace the other unit-management
% packages, these are tested for before any further processing.  If
% any are loaded, the package halts compilation; name clashes or
% unexpected results could occur if this is not tested.  Notice that
% \SIunits and \SIstyle could be loaded with variable capitalisation
% (at least on Windows); both possibilities are tested.
%    \begin{macrocode}
\newcommand*{\si@blockpkgs}{SIunits,sistyle,siunits,SIstyle,%
  unitsdef,fancyunits}
\newcommand*{\si@checkpkgs}{units,hepunits,fancynum}
\newcommand*{\si@packagecheck}{%
  \begingroup
  \@for\si@tempa:=\si@blockpkgs\do{
    \@ifpackageloaded{\si@tempa}
      {\PackageError{siunitx}
         {Package `\si@tempa' incompatible}
         {The \si@tempa\space package and siunitx are
          incompatible.\MessageBreak Use the
          `emulate=\si@tempa' package option when loading
          siunitx}}
      {}}
%    \end{macrocode}
% Some packages should not cause a clash, but are emulated and would
% be better handled that way.
%    \begin{macrocode}
  \@for\si@tempa:=\si@checkpkgs\do{%
    \@ifpackageloaded{\si@tempa}
      {\PackageWarning{siunitx}
         {Consider loading the siunitx package
          with\MessageBreak option `emulate=\si@tempa', rather
          than\MessageBreak loading both \si@tempa\space and
          siunitx}}
      {}}
  \endgroup}
%    \end{macrocode}
% The check is carried out on loading and at the beginning of the
% document, so that packages loaded both before and after \currpkg
% are caught.
%    \begin{macrocode}
\si@packagecheck
\AtBeginDocument{\si@packagecheck}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ifdefinable}
% Using \cs{@ifdefinable} to check macro definitions gives a generic
% error.  To give something more helpful, \cs{@ifundefined} is used,
% but this needs some \cs{expandafter} work.  This way it can also be
% used as a form of \cs{@ifundefined} for macro names.\\
%\cs{si@ifdefinable}\marg{macro}
%    \begin{macrocode}
\newcommand*{\si@ifdefinable}[1]{%
  \expandafter\expandafter\expandafter\@ifundefined%
    \expandafter\expandafter\expandafter%
      {\expandafter\@gobble\string#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@addtolist}
% It is quite useful to be able to add to a comma-separated list
% of expandable items.\\
%\cs{si@addtolist}\marg{macro}\marg{items}
%    \begin{macrocode}
\newcommand*{\si@addtolist}[2]{%
  \ifx\@empty#1\@empty
    \edef#1{#2}%
  \else
    \edef#1{#1,#2}%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@addtocsname}
%\begin{macro}{\si@temptoks}
% A second item to add to a command sequence.\\
%\cs{si@addtocsname}\marg{csname}\marg{tokens}
%    \begin{macrocode}
\newtoks{\si@temptoks}
\newcommand*{\si@addtocsname}[2]{%
  \@ifundefined{#1}
    {\expandafter\gdef\csname #1\endcsname{#2}}
    {\si@temptoks\expandafter\expandafter\expandafter{%
       \csname #1\endcsname#2}%
     \expandafter\xdef\csname #1\endcsname{\the\si@temptoks}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ifmtarg}
%\begin{macro}{\si@xifmtarg}
%\begin{macro}{\si@ifnotmtarg}
% To keep down dependance on other packages, the very short code
% block from \pkg{ifmtarg} is copied here with an internal name.
%    \begin{macrocode}
\begingroup
  \catcode`\Q=3
  \long\gdef\si@ifmtarg#1{%
    \si@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil}
  \long\gdef\si@xifmtarg#1#2Q#3#4#5\@nil{#4}
  \long\gdef\si@ifnotmtarg#1{%
    \si@xifmtarg#1QQ\@firstofone\@gobble\@nil}
\endgroup
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@newrobustcmd}
%\begin{macro}{\si@newcommand}
%\begin{macro}{\si@newcmd}
%\begin{macro}{\si@xargdef}
% Some more copying, this time from \pkg{etoolbox}.  Various macros
% need to be \emph{really} robust.  This is achieved using the \eTeX\
% \cs{protected} primitive in various places.  However, it would be
% nice to have a \cs{protected} version of \cs{newcommand}.
% \pkg{etoolbox} has code for that, but to avoid needing to load it,
% the necessary stuff is copied here.  The only changes form the
% original are names, and the use of \cs{newcommand*} for the
% \cs{si@newcommand} macro.\\
%\cs{si@newcommand}\marg{macro}\\
%\cs{si@newcmd}\marg{macro}\oarg{num-args}\\
%\cs{si@xargdef}\marg{macro}\oarg{num-args}\oarg{default}\marg{def}
%    \begin{macrocode}
\@ifpackageloaded{etoolbox}
  {\let\si@newrobustcmd\newrobustcmd}
  {\protected\def\si@newrobustcmd{%
     \@ifstar
       {\let\l@ngrel@x\protected\si@newcommand}
       {\def\l@ngrel@x{\protected\long}\si@newcommand}}
   \newcommand*{\si@newcommand}[1]{\@testopt{\si@newcmd#1}0}
   \def\si@newcmd#1[#2]{%
     \@ifnextchar[%]
       {\si@xargdef#1[#2]}
       {\@argdef#1[#2]}}
   \long\def\si@xargdef#1[#2][#3]#4{%
     \@ifdefinable#1{%
       \expandafter\protected
       \expandafter\def
       \expandafter#1%
       \expandafter{%
         \expandafter\@testopt
         \csname\string#1\endcsname{#3}}%
       \expandafter\@yargdef
       \csname\string#1\endcsname\tw@{#2}{#4}}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Logging}
%\begin{macro}{\ifsi@debug}
%\begin{macro}{\ifsi@logmin}
%\begin{macro}{\ifsi@lognone}
% To control logging, some new switches are declared.
%    \begin{macrocode}
\newif\ifsi@debug
\newif\ifsi@logmin
\newif\ifsi@lognone
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@log@err}
%\begin{macro}{\si@log@warn}
%\begin{macro}{\si@log@inf}
% Some handy re-usable macros are defined here.  These all take names
% beginning  These pop up in various places.  First errors, warnings
% and information are handled.  Package options are used to control
% how much output is given.\\
%\cs{si@log@err}\marg{error}\marg{explanation}\\
%\cs{si@log@warn}\marg{warning}\\
%\cs{si@log@inf}\marg{information}
%    \begin{macrocode}
\newcommand*{\si@log@err}[2]{%
  \ifsi@lognone\else
    \ifsi@logmin
      \PackageWarning{siunitx}{#1}%
    \else
      \PackageError{siunitx}{#1}{#2}%
    \fi
  \fi}
\newcommand*{\si@log@warn}[1]{%
  \ifsi@lognone\else
    \ifsi@logmin\else
      \PackageWarning{siunitx}{#1}%
    \fi
  \fi}
\newcommand*{\si@log@inf}[1]{%
  \ifsi@lognone\else
    \ifsi@logmin\else
      \PackageInfo{siunitx}{#1}%
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@log@debug}
% The debug macro only gives output if the appropriate package option
% is set.\\
%\cs{si@log@debug}\marg{debug-information}
%    \begin{macrocode}
\newcommand*{\si@log@debug}[1]{%
  \ifsi@lognone\else
    \ifsi@debug
      \PackageInfo{siunitx}{#1}%
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{String comparison}
%\begin{macro}{\si@str@ifchrstr}
%\begin{macro}{\si@str@chrstr}
% At various points, the package needs to compare two strings, to
% find if one occurs in the other.  The first test is if a single
% character is part of a second string; this is used, for example, to
% check that a character is valid as input.  The first argument is
% not expanded further, but the second is two allow division into
% individual units.\\
%\cs{si@str@ifchrstr}\marg{char}\marg{chars}\\
%\cs{si@str@chrstr}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@str@ifchrstr}[2]{%
  \begingroup
    \si@switchfalse
    \renewcommand*{\si@tempa}{#1}%
    \protected@edef\si@tempb{#2}%
    \expandafter\si@str@chrstr\si@tempb\@empty\@empty\@empty
    \ifsi@switch
      \aftergroup\@firstoftwo
    \else
      \aftergroup\@secondoftwo
    \fi
  \endgroup}
\def\si@str@chrstr#1#2\@empty{%
  \renewcommand*{\si@tempc}{#1}%
  \ifx\si@tempa\si@tempc
    \expandafter\si@switchtrue
  \else
    \ifx\@empty#2\@empty\else
      \si@str@chrstr#2\@empty\@empty
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@str@ifonlychrs}
%\begin{macro}{\si@str@onlychrs}
% The second test builds on the first.  Here, a check is made to see
% if the first string is made up only of characters from the second
% string.  In this case, the first string is expanded before
% testing.  The second string will be expanded by the internal
% character by character test.\\
%\cs{si@str@ifonlychars}\marg{string}\marg{valid-chars}\\
%\cs{si@str@onlychars}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@str@ifonlychrs}[2]{%
  \begingroup
    \si@switchtrue
    \protected@edef\si@tempa{#1}%
    \renewcommand*{\si@tempb}{#2}%
    \expandafter\si@str@onlychrs\si@tempa\@empty\@empty\@empty
    \ifsi@switch
      \aftergroup\@firstoftwo
    \else
      \aftergroup\@secondoftwo
    \fi
  \endgroup}
\def\si@str@onlychrs#1#2\@empty{%
  \si@str@ifchrstr{#1}{\si@tempb}
    {}{\si@switchfalse}%
  \ifx\@empty#2\@empty\else
    \si@str@onlychrs#2\@empty\@empty
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Option handling}
%\begin{macro}{\sisetup}
% To allow modification of options at run time, a setup macro is
% provided.
%    \begin{macrocode}
\newcommand*{\sisetup}{\setkeys[si]{key}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@opt@key}
% To aid maintenance, some shortcuts are defined for generating keys.
% These also allow the debugging messages to be added automatically
% to every key.  First of all the basic key definition.\\
%\cs{si@opt@key}\marg{keyname}\marg{code}
%    \begin{macrocode}
\newcommand*{\si@opt@key}[2]{%
  \define@key[si]{key}{#1}
  {#2\si@log@debug{Option #1 set to ##1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@opt@cmdkey}
%\begin{macro}{\si@opt@cmdkeys}
% The command versions of the above.\\
%\cs{si@opt@cmdkey}\oarg{default}\marg{keyname}\marg{function}\\
%\cs{si@opt@cmdkeys}\oarg{default}\marg{keynames}
%    \begin{macrocode}
\newcommand*{\si@opt@cmdkey}[3][]{%
  \define@cmdkey[si]{key}[si@]{#2}[#1]{#3}}
\newcommand*{\si@opt@cmdkeys}[2][]{%
  \define@cmdkeys[si]{key}[si@]{#2}[#1]}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@opt@boolkey}
% Keys which only take switch values; anything other than \opt{true}
% or \opt{false} will generate a warning from \pkg{xkeyval}.\\
%\cs{si@opt@boolkey}\oarg{optional-processing}\marg{keyname}
%    \begin{macrocode}
\newcommand*{\si@opt@boolkey}[2][]{%
  \define@boolkey[si]{key}[si@]{#2}[true]
  {#1\si@log@debug{Option #2 set to ##1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@opt@choicekey}
% A ``fill in the blanks'' choice key.  In all cases, \cs{si@tempa}
% is used to hold the value given to the key, so that \cs{ifx}
% testing can occur.\\
%\cs{si@opt@choicekey}\oarg{default}\marg{keyname}\marg{choices}^^A
%\marg{in-list}
%    \begin{macrocode}
\newcommand*{\si@opt@choicekey}[4][]{%
  \define@choicekey*+[si]{key}{#2}[\si@tempa]{#3}[#1]
    {#4\si@log@debug{Option #2 set to ##1}}
    {\si@log@warn{Unknown value `##1' for option #2}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@opt@xchoicekey}
% Several of the package options can take either a choice from a list
% of known options, or a value to be interpreted literally.  To aid
% maintenance, the necessary code can be set up here.  These keys all
% define a new macro, which must exist.  The \cs{si@opt@xchoicekey}
% macro therefore ensures that this is defined, as well as setting up
% the \pkg{xkeyval} key.\\
%\cs{si@opt@xchoicekey}\marg{keyname}\marg{choices}\marg{initial}
%    \begin{macrocode}
\newcommand*{\si@opt@xchoicekey}[3]{%
  \define@choicekey*+[si]{key}{#1}[\si@tempa]{#2}[#1]
%    \end{macrocode}
% This code will execute if the option is on the list.  There will be
% a ``fixed'' macro with a matching name, which is used for this.
%    \begin{macrocode}
    {\si@log@debug{Option #1 set to ##1}%
     \expandafter\renewcommand\expandafter*\expandafter{%
      \csname si@#1\endcsname}{\@nameuse{si@fix@##1}}}
%    \end{macrocode}
% The user has given something that is not on the list as an
% argument.  It is used literally.
%    \begin{macrocode}
    {\si@log@debug{Option #1 set to ##1}%
     \expandafter\renewcommand\expandafter*\expandafter{%
      \csname si@#1\endcsname}{##1}}
%    \end{macrocode}
% Finally, the initial value of the macro is set up.
%    \begin{macrocode}
  \expandafter\newcommand\expandafter*\expandafter{%
    \csname si@#1\endcsname}%
    {\@nameuse{si@fix@#3}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@opt@compatkey}
% An all-in-one definition for a back-compatibility key.  These
% should only be used at load time, so are automatically disabled
% once the package is loaded.  Emulation is also automatically turned
% on.\\
%\cs{si@opt@compatkey}\marg{package}\marg{keyname}.
%    \begin{macrocode}
\newcommand*{\si@opt@compatkey}[2]{%
  \define@boolkey[si]{key}[si@old@]{#2}[true]
  {\si@log@debug{Emulating #1 package option\MessageBreak #2}%
   \sisetup{emulate=#1}%
   \si@log@debug{Option #2 set to ##1}}
   \AtEndOfPackage{\si@opt@disablekey{#2}
     {Compatibility option #2 only\MessageBreak
        available when loading siunitx package}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@opt@disablekey}
% The ability to disable a key with a meaningful message is a must;
% the warning will come from \currpkg, and not from \pkg{xkeyval}\\
%\cs{si@opt@disablekey}\marg{keyname}\marg{warning}
%    \begin{macrocode}
\newcommand*{\si@opt@disablekey}[2]{%
  \key@ifundefined[si]{key}{#1}
    {}
    {\si@log@debug{Disabling key #1}%
     \si@opt@key{#1}{\si@log@warn{#2}}}}
%    \end{macrocode}
%\end{macro}
%
% The \pkg{xkeyval} package option for logging is declared. This is
% then processed to set the switches correctly.
%    \begin{macrocode}
\si@opt@choicekey[normal]{log}{debug,verbose,normal,errors,none}
%    \end{macrocode}
% A series of comparisons are made to assign the logging mode.  The
% \opt{normal} option is not tested, as executing the option sets the
% switches appropriately.
%    \begin{macrocode}
  {\si@debugfalse
   \si@logminfalse
   \si@lognonefalse
   \renewcommand*{\si@tempb}{none}%
   \ifx\si@tempa\si@tempb
     \si@lognonetrue
   \fi
   \renewcommand*{\si@tempb}{minimal}%
   \ifx\si@tempa\si@tempb
     \si@logmintrue
   \fi
   \renewcommand*{\si@tempb}{debug}%
   \ifx\si@tempa\si@tempb
     \si@debugtrue
   \fi
   \renewcommand*{\si@tempb}{verbose}%
   \ifx\si@tempa\si@tempb
     \si@debugtrue
   \fi}
%    \end{macrocode}
% A quick method to set \opt{log=debug}.
%    \begin{macrocode}
\si@opt@boolkey{debug}
%    \end{macrocode}
%\begin{macro}{\ifsi@strict}
% It would be useful to be able to disable some keys, when strict
% interpretation of the rules is desired.  This is a load-time
% option, and has to disable various options.
%    \begin{macrocode}
\si@opt@boolkey[%
  \ifsi@strict
    \sisetup{
      obeymode=false,
      obeybold=false,
      obeyitalic=false,
      mode=maths,
      repeatunits=true,
      trapambigerr=true,
      trapambigfrac=true}
    \@for\si@tempa:=obeyall,obeymode,obeyitalic,mode,unitmode,%
      valuemode,textmode,obeybold,repeatunits,trapambigerr,%
      trapambigfrac\do{%
      \begingroup
        \edef\si@tempb{\endgroup
          \noexpand\si@opt@disablekey{\si@tempa}
          {Option `\si@tempa' forbidden in strict mode}}%
      \si@tempb}
  \fi]{strict}
\AtEndOfPackage{
  \si@opt@disablekey{strict}
    {Option `strict' only available when\MessageBreak
     loading package}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@emulate}
% The \opt{emulate} option is used for back-compatibility mode; the
% option is only valid when loading \currpkg.
%    \begin{macrocode}
\newcommand*{\si@emulate}{}
\si@opt@key{emulate}{\si@addtolist{\si@emulate}{#1}}
\AtEndOfPackage{
  \si@opt@disablekey{emulate}
    {Option `emulate' only available when\MessageBreak
     loading package}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unitsep}
%\begin{macro}{\si@unitspace}
%\begin{macro}{\si@errspace}
%\begin{macro}{\si@valuesep}
% The two \opt{\dots sep} options control the size of spaces between
% the number and the unit (\cs{si@valuesep}), and that used to
% represent a product (\cs{si@unitsep}).  Known values here are
% \opt{thin}, \opt{med}, \opt{medium}, \opt{thick}, \opt{cdot},
% \opt{tightcdot}\footnote{Both \cs{cdot}-based options only valid
% for \opt{unitsep}.} and \opt{none};\footnote{Only valid for
% \opt{valuesep}.} other entries will be treated as custom spaces.
%    \begin{macrocode}
\si@opt@xchoicekey{unitsep}
  {thin,med,medium,thick,none,comma,stop,fullstop,period,
    times,tighttimes,cdot,tightcdot}{thin}
\si@opt@xchoicekey{unitspace}{space,thin,med,medium,thick,
  none}{thin}
\si@opt@xchoicekey{errspace}{space,thin,med,medium,thick,
  none}{none}
\si@opt@xchoicekey{valuesep}
  {thin,med,medium,thick,none,comma,stop,fullstop,period,
    times,tighttimes,cdot,tightcdot}{thin}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@digitsep}
% Separation of digits in large numbers is controlled by the
% \opt{digitsep} option.  As with the other \opt{sep} values, this
% one has a choice of possible values.  The list is quite long, so
% that a range of options are handled automatically.  Notice that
% \opt{digitsep=none} will be used for no separation at all.
%    \begin{macrocode}
\si@opt@xchoicekey{digitsep}
  {thin,med,medium,thick,none,comma,stop,fullstop,period,
    times,tighttimes,cdot,tightcdot}{thin}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@decimalsymbol}
% The symbol used for the decimal position is varied here.  There are
% only two real options, but options are given for the name of a full
% stop.
%    \begin{macrocode}
\si@opt@xchoicekey{decimalsymbol}{comma,stop,fullstop,period,
  cdot,tightcdot}{fullstop}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@anglesep}
% The separator between degrees and minutes, and between minutes and
% seconds, when using \cs{ang}.
%    \begin{macrocode}
\si@opt@xchoicekey{anglesep}
    {thin,med,medium,thick,none,comma,stop,fullstop,period,
      times,tighttimes,cdot,tightcdot}{none}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@obeymode}
% The first test for the font control is whether to respect the
% surrounding maths or text mode.
%    \begin{macrocode}
\si@opt@boolkey{obeymode}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@numtextmode}
%\begin{macro}{\ifsi@unittextmode}
% The output of the package can be typeset using either text or maths
% mode fonts. Two switches are needed, for numbers and units.
%    \begin{macrocode}
\newif\ifsi@numtextmode
\newif\ifsi@unittextmode
%    \end{macrocode}
%\end{macro}
%\end{macro}
% The \opt{textmode} option has to set both flags.
%    \begin{macrocode}
\si@opt@choicekey[true]{textmode}{true,false}
  {\si@numtextmodefalse
   \si@unittextmodefalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@numtextmodetrue
     \si@unittextmodetrue
   \fi}
%    \end{macrocode}
% The \opt{mode} option applies to numbers and units.
%    \begin{macrocode}
\si@opt@choicekey{mode}{math,maths,text}
  {\si@numtextmodefalse
   \si@unittextmodefalse
   \renewcommand*{\si@tempb}{text}%
   \ifx\si@tempa\si@tempb
     \si@numtextmodetrue
     \si@unittextmodetrue
   \fi}
%    \end{macrocode}
% Now the two options for numbers or units alone.
%    \begin{macrocode}
\si@opt@choicekey{valuemode}{math,maths,text}
  {\si@numtextmodefalse
   \renewcommand*{\si@tempb}{text}%
   \ifx\si@tempa\si@tempb
     \si@numtextmodetrue
   \fi}
\si@opt@choicekey{unitmode}{math,maths,text}
  {\si@unittextmodefalse
   \renewcommand*{\si@tempb}{text}%
   \ifx\si@tempa\si@tempb
     \si@unittextmodetrue
   \fi}
%    \end{macrocode}
%\begin{macro}{\ifsi@obeyfamily}
% The package can work to match the font family (serif, sans serif,
% typewriter) of the surrounding text.  This is controlled by a
% Boolean option.
%    \begin{macrocode}
\si@opt@boolkey{obeyfamily}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@obeybold}
% The package can attempt to respect bold, or may ignore it.
%    \begin{macrocode}
\si@opt@boolkey{obeybold}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@inlinebtext}
% For inline maths, two options for checking what is bold are
% available, the maths environment (\ie \cs{boldmath}) and the
% surrounding text (\cs{textbf} or \cs{bffamily}).
%    \begin{macrocode}
\newif\ifsi@inlinebtext
\si@opt@choicekey{inlinebold}{text,maths,math}
  {\si@inlinebtextfalse
   \renewcommand*{\si@tempb}{text}%
   \ifx\si@tempa\si@tempb
     \si@inlinebtexttrue
   \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@obeyitalic}
% Italic is slightly different to bold, as there is no convenient
% switch for maths.  Thus a choice key is used, with the appropriate
% check.
%    \begin{macrocode}
\si@opt@boolkey{obeyitalic}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@detectdisplay}
% For handling display mathematics, a setting is needed for whether to
% treat it differently from other maths.
%    \begin{macrocode}
\si@opt@boolkey{detectdisplay}
%    \end{macrocode}
%\end{macro}
% The option to obey all font switching commands is Boolean-like but
% needs alternative setup.
%    \begin{macrocode}
\si@opt@choicekey[true]{obeyall}{true,false}
  {\si@obeyboldfalse
   \si@obeyitalicfalse
   \si@obeymodefalse
   \si@obeyfamilyfalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@obeyboldtrue
     \si@obeyitalictrue
     \si@obeymodetrue
     \si@obeyfamilytrue
   \fi}
%    \end{macrocode}
%\begin{macro}{\si@valuemathsrm}
%\begin{macro}{\si@valuemathssf}
%\begin{macro}{\si@valuemathstt}
%\begin{macro}{\si@unitmathsrm}
%\begin{macro}{\si@unitmathssf}
%\begin{macro}{\si@unitmathstt}
% The fonts used by the package default to the obvious \LaTeX\ ones;
% however, this needs to be exposed to user modification.  First the
% maths mode fonts are sorted out.
%    \begin{macrocode}
\si@opt@cmdkeys{valuemathsrm,valuemathssf,valuemathstt}
\si@opt@cmdkeys{unitmathsrm,unitmathssf,unitmathstt}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% To make life easier for the user, US spellings are provided for the
% maths keys.
%    \begin{macrocode}
\si@opt@key{valuemathrm}{\sisetup{valuemathsrm=#1}}
\si@opt@key{valuemathsf}{\sisetup{valuemathssf=#1}}
\si@opt@key{valuemathtt}{\sisetup{valuemathstt=#1}}
\si@opt@key{unitmathrm}{\sisetup{unitmathsrm=#1}}
\si@opt@key{unitmathsf}{\sisetup{unitmathssf=#1}}
\si@opt@key{unitmathtt}{\sisetup{unitmathstt=#1}}
%    \end{macrocode}
% The combined options are given, for setting numbers and units
% at the same time.
%    \begin{macrocode}
\si@opt@key{mathsrm}{\sisetup{valuemathsrm=#1,unitmathsrm=#1}}
\si@opt@key{mathssf}{\sisetup{valuemathssf=#1,unitmathssf=#1}}
\si@opt@key{mathstt}{\sisetup{valuemathstt=#1,unitmathstt=#1}}
\si@opt@key{mathrm}{\sisetup{valuemathsrm=#1,unitmathsrm=#1}}
\si@opt@key{mathsf}{\sisetup{valuemathssf=#1,unitmathssf=#1}}
\si@opt@key{mathtt}{\sisetup{valuemathstt=#1,unitmathstt=#1}}
%    \end{macrocode}
%\begin{macro}{\si@valuetextrm}
%\begin{macro}{\si@valuetextsf}
%\begin{macro}{\si@valuetexttt}
%\begin{macro}{\si@unittextrm}
%\begin{macro}{\si@unittextsf}
%\begin{macro}{\si@unittexttt}
% The same thing for text mode fonts.  Once again the default values
% are pretty obvious.
%    \begin{macrocode}
\si@opt@cmdkeys{valuetextrm,valuetextsf,valuetexttt}
\si@opt@cmdkeys{unittextrm,unittextsf,unittexttt}
\si@opt@key{textrm}{\sisetup{unittextrm=#1,valuetextrm=#1}}
\si@opt@key{textsf}{\sisetup{unittextsf=#1,valuetextsf=#1}}
\si@opt@key{texttt}{\sisetup{unittexttt=#1,valuetexttt=#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@numdigits}
%\begin{macro}{\si@numdecimal}
%\begin{macro}{\si@numexp}
%\begin{macro}{\si@numprod}
%\begin{macro}{\si@numgobble}
%\begin{macro}{\si@numsign}
%\begin{macro}{\si@numcloseerr}
%\begin{macro}{\si@numopenerr}
%\begin{macro}{\si@numaddn}
% The list of possible valid characters for parsing numbers is set
% up.  This is similar to \numprint, but with the \opt{extra} class,
% and with characters ignored with no output renamed as \opt{gobble}.
%    \begin{macrocode}
\si@opt@cmdkeys{numdigits,numdecimal,numexp,numgobble,numsign,%
  numcloseerr,numopenerr,numaddn,numprod}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@numvalid}
%\begin{macro}{\si@numextra}
% The various valid characters are collected together in a single
% macro for later.  In common with the above macros, this one starts
% \cs{si@num\ldots}.  The order here is the order the values are
% tested later on.
%    \begin{macrocode}
\newcommand*{\si@numextra}{%
  \si@numopenerr\si@numcloseerr\si@numaddn}
\newcommand*{\si@numvalid}{\si@numgobble\si@numexp\si@numsign
  \si@numdecimal\si@numdigits\si@numextra\si@numprod}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@seperr}
%\begin{macro}{\ifsi@trapambigerr}
%\begin{macro}{\si@openerr}
%\begin{macro}{\si@closeerr}
% An option to control whether numerical error values are printed with
% or separate from the number.
%    \begin{macrocode}
\si@opt@boolkey{seperr}
\si@opt@boolkey{trapambigerr}
\si@opt@cmdkeys{openerr,closeerr}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@sepfour}
% With four digits in a number, separating may or may not be desired.
% Note that this option is the same as one for \numprint.
%    \begin{macrocode}
\si@opt@boolkey{sepfour}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@retainplus}
% An option to keep an explicit positive sign.
%    \begin{macrocode}
\si@opt@boolkey{retainplus}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@expbase}
%\begin{macro}{\si@expproduct}
% The options for exponents are set up.
%    \begin{macrocode}
\si@opt@xchoicekey{expproduct}{times,tighttimes,
  cdot,tightcdot}{times}
\si@opt@xchoicekey{expbase}{ten}{ten}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@allowzeroexp}
% The package normally prevents \num[allowzeroexp]{e0}.
%    \begin{macrocode}
\si@opt@boolkey{allowzeroexp}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@prefixproduct}
% The marker for multiplication in prefixes.
%    \begin{macrocode}
\si@opt@xchoicekey{prefixproduct}{times,tighttimes,cdot,
  tightcdot,none}{times}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@prefixbase}
% In the same area, the power for prefixes is variable.  Here, two
% choices ar needed.
%    \begin{macrocode}
\si@opt@xchoicekey{prefixbase}{ten,two}{ten}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@prefixsymbolic}
% Unit prefixes can be given as either symbols or numerically.
%    \begin{macrocode}
\si@opt@boolkey{prefixsymbolic}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@num@padlead}
%\begin{macro}{\ifsi@num@padtrail}
% A setting is needed to indicate when to add zeros to decimal
% numbers, either before the decimal marker (|.1| giving
% ``\num[padnumber=all]{.1}'') or after (|1.| giving
% ``\num[padnumber=all]{1.}'').
%    \begin{macrocode}
\newif\ifsi@num@padlead
\newif\ifsi@num@padtrail
\si@opt@choicekey[all]{padnumber}
  {leading,lead,trailing,trail,all,both,true,none,false}
  {\si@num@padleadfalse
   \si@num@padtrailfalse
   \renewcommand*{\si@tempb}{leading}%
   \ifx\si@tempa\si@tempb
     \si@num@padleadtrue
   \fi
   \renewcommand*{\si@tempb}{lead}%
   \ifx\si@tempa\si@tempb
     \si@num@padleadtrue
   \fi
   \renewcommand*{\si@tempb}{trailing}%
   \ifx\si@tempa\si@tempb
     \si@num@padtrailtrue
   \fi
   \renewcommand*{\si@tempb}{trail}%
   \ifx\si@tempa\si@tempb
     \si@num@padtrailtrue
   \fi
   \renewcommand*{\si@tempb}{all}%
   \ifx\si@tempa\si@tempb
     \si@num@padleadtrue
     \si@num@padtrailtrue
   \fi
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@num@padleadtrue
     \si@num@padtrailtrue
   \fi
   \renewcommand*{\si@tempb}{both}%
   \ifx\si@tempa\si@tempb
     \si@num@padleadtrue
     \si@num@padtrailtrue
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@sign}
%\begin{macro}{\ifsi@num@signmant}
%\begin{macro}{\ifsi@num@signexp}
% Some new switches for adding signs to numbers
%    \begin{macrocode}
\newif\ifsi@num@signmant
\newif\ifsi@num@signexp
%    \end{macrocode}
%\end{macro}
%\end{macro}
% Signs can be added to numbers by default. Two options are needed
% here; whether to add a sign by default, and what the sign is.
%    \begin{macrocode}
\si@opt@xchoicekey{sign}{plus,minus,pm,mp}{plus}
\si@opt@choicekey[all]{addsign}
  {mantissa,exponent,mant,exp,all,both,true,none,false}
%    \end{macrocode}
%\end{macro}
% The option is now processed.
%    \begin{macrocode}
  {\si@num@signmantfalse
   \si@num@signexpfalse
   \renewcommand*{\si@tempb}{mantissa}%
   \ifx\si@tempa\si@tempb
     \si@num@signmanttrue
   \fi
   \renewcommand*{\si@tempb}{mant}%
   \ifx\si@tempa\si@tempb
     \si@num@signmanttrue
   \fi
   \renewcommand*{\si@tempb}{exponent}%
   \ifx\si@tempa\si@tempb
     \si@num@signexptrue
   \fi
   \renewcommand*{\si@tempb}{exp}%
   \ifx\si@tempa\si@tempb
     \si@num@signexptrue
   \fi
   \renewcommand*{\si@tempb}{all}%
   \ifx\si@tempa\si@tempb
     \si@num@signmanttrue
     \si@num@signexptrue
   \fi
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@num@signmanttrue
     \si@num@signexptrue
   \fi
   \renewcommand*{\si@tempb}{both}%
   \ifx\si@tempa\si@tempb
     \si@num@signmanttrue
     \si@num@signexptrue
   \fi}
%    \end{macrocode}
%\begin{macro}{\ifsi@tightpm}
%\begin{macro}{\si@pm}
% To reduce spacing, it might be necessary to use a ``tight'' $\pm$
% sign.
%    \begin{macrocode}
\si@opt@boolkey{tightpm}
\newcommand*{\si@pm}{%
  \ifsi@tightpm
    \si@fix@tightpm
  \else
    \si@fix@pm
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@ang@padsmall}
%\begin{macro}{\ifsi@ang@padlarge}
% A switch for determining whether to typeset |\ang{;;1}| as
% \ang[padangle=both]{;;1} or \ang[padangle=none]{;;1}.  First, two
% new Boolean switches are needed to indicate padding.
%    \begin{macrocode}
\newif\ifsi@ang@padsmall
\newif\ifsi@ang@padlarge
\si@opt@choicekey[all]{padangle}
  {small,large,all,both,true,none,false}
  {\si@ang@padsmallfalse
   \si@ang@padlargefalse
   \renewcommand*{\si@tempb}{small}%
   \ifx\si@tempa\si@tempb
     \si@ang@padsmalltrue
   \fi
   \renewcommand*{\si@tempb}{large}%
   \ifx\si@tempa\si@tempb
     \si@ang@padlargetrue
   \fi
   \renewcommand*{\si@tempb}{all}%
   \ifx\si@tempa\si@tempb
     \si@ang@padsmalltrue
     \si@ang@padlargetrue
   \fi
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@ang@padsmalltrue
     \si@ang@padlargetrue
   \fi
   \renewcommand*{\si@tempb}{both}%
   \ifx\si@tempa\si@tempb
     \si@ang@padsmalltrue
     \si@ang@padlargetrue
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@ang@toarc}
%\begin{macro}{\ifsi@ang@todec}
% To control whether angles are formatted as decimals or
% degrees--minutes--seconds, a package option plus two switches are
% needed.  The later format is referred to as ``\opt{arc}'' most
% readily.  An option to leave the input unchanged is also provided.
%    \begin{macrocode}
\newif\ifsi@ang@toarc
\newif\ifsi@ang@todec
\si@opt@choicekey[all]{angformat}
  {dec,decimal,arc,dms,unchanged,none}
  {\si@ang@toarcfalse
   \si@ang@todecfalse
   \renewcommand*{\si@tempb}{dec}%
   \ifx\si@tempa\si@tempb
     \si@ang@todectrue
   \fi
   \renewcommand*{\si@tempb}{decimal}%
   \ifx\si@tempa\si@tempb
     \si@ang@todectrue
   \fi
   \renewcommand*{\si@tempb}{arc}%
   \ifx\si@tempa\si@tempb
     \si@ang@toarctrue
   \fi
   \renewcommand*{\si@tempb}{dms}%
   \ifx\si@tempa\si@tempb
     \si@ang@toarctrue
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@astroang}
% A slightly odd option to allow the method used by astronomers for
% angles.
%    \begin{macrocode}
\si@opt@boolkey{astroang}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@strictarc}
% For the \cs{ang} macro, the default is to require two semi-colons
% in the input for arc angles.  This is controlled here.
%    \begin{macrocode}
\si@opt@boolkey{strictarc}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@tab@fixed}
%\begin{macro}{\si@tabnumalign}
%\begin{macro}{\si@tab@rfill@S}
%\begin{macro}{\si@tab@lfill@S}
% To determine the control of table alignment, two options are
% provided.  The \opt{tabnumalign} option controls which centring method
% is used, and the fills used for achieving this.
%    \begin{macrocode}
\newif\ifsi@tab@fixed
\si@opt@choicekey{tabnumalign}
  {centredecimal,centerdecimal,right,left,centre,center}
  {\si@tab@fixedtrue
   \let\si@tab@rfill@S\hfil
   \let\si@tab@lfill@S\hfil
   \renewcommand*{\si@tempb}{right}%
   \ifx\si@tempa\si@tempb
     \let\si@tab@lfill@S\hfill
   \fi
   \renewcommand*{\si@tempb}{left}%
   \ifx\si@tempa\si@tempb
     \let\si@tab@rfill@S\hfill
   \fi
   \renewcommand*{\si@tempb}{centredecimal}%
   \ifx\si@tempa\si@tempb
     \expandafter\si@tab@fixedfalse
   \fi
   \renewcommand*{\si@tempb}{centerdecimal}%
   \ifx\si@tempa\si@tempb
     \expandafter\si@tab@fixedfalse
   \fi}
\si@opt@key{tabalign}{\sisetup{tabnumalign=#1,tabtextalign=#1,
  tabunitalign=#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@tabalignexp}
% A switch for aligning exponents.
%    \begin{macrocode}
\si@opt@boolkey{tabalignexp}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tab@mantprecnt}
%\begin{macro}{\si@tab@mantpostcnt}
%\begin{macro}{\si@tab@expprecnt}
%\begin{macro}{\si@tab@exppostcnt}
%\begin{macro}{\ifsi@tab@mantsign}
%\begin{macro}{\ifsi@tab@expsign}
% To process the format information, various internal
% number-processing macros are used.  First, some
% storage areas are created.
%    \begin{macrocode}
\newcount\si@tab@mantprecnt
\newcount\si@tab@mantpostcnt
\newcount\si@tab@expprecnt
\newcount\si@tab@exppostcnt
\newif\ifsi@tab@mantsign
\newif\ifsi@tab@expsign
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% The input is split into a mantissa and exponent, then passed to a
% re-useable macro for further processing.
%    \begin{macrocode}
\si@opt@cmdkey{tabformat}
  {\si@num@fixpm
   \renewcommand*{\si@num@arg}{tabformat data}%
   \renewcommand*{\si@num@exp}{}%
   \renewcommand*{\si@num@mant}{}%
   \si@tab@mantsignfalse
   \si@tab@expsignfalse
   \si@switchfalse
   \si@num@sepmantexp{#1}%
%    \end{macrocode}
% When checking for a sign, the internal flag for finding but
% deleting a plus sign is used.
%    \begin{macrocode}
   \si@num@sepsign{mant}%
   \ifx\@empty\si@num@mantsign\@empty
     \ifsi@num@delplus
       \expandafter\expandafter\expandafter\si@tab@mantsigntrue
     \fi
   \else
     \expandafter\si@tab@mantsigntrue
   \fi
   \si@num@sepsign{exp}%
   \ifx\@empty\si@num@expsign\@empty
     \ifsi@num@delplus
       \expandafter\expandafter\expandafter\si@tab@expsigntrue
     \fi
   \else
     \expandafter\si@tab@expsigntrue
   \fi
   \si@opt@proctform{mant}%
   \si@opt@proctform{exp}%
%    \end{macrocode}
% The \opt{tabformat} input should really have both an integer and
% decimal part for the mantissa.  If neither are present, an error is
% raised. If just the one part is missing, an warning seems more
% suitable.
%    \begin{macrocode}
   \ifnum\si@tab@mantpostcnt=\z@\relax
     \ifnum\si@tab@mantprecnt=\z@\relax
       \si@log@err{Empty mantissa argument for tabformat}
         {The argument `#1' contains no valid entry for
          a mantissa\MessageBreak It should be of the
          form `m.n', where  m and n are integers}%
     \else
       \si@log@warn{Argument of tabformat contains\MessageBreak
         no decimal part}%
     \fi
   \else
     \ifnum\si@tab@mantprecnt=\z@\relax
       \si@log@warn{Argument of tabformat contains\MessageBreak
         no integer part}%
     \fi
   \fi
%    \end{macrocode}
% If \opt{tabformat} has been given with
% \opt{tabnumalign=centredecimal} active, then the alignment is
% changed to centred.
%    \begin{macrocode}
   \ifsi@tab@fixed\else
     \sisetup{tabnumalign=centre}%
   \fi
   \let\pm\si@num@pm
   \let\mp\si@num@mp}
%    \end{macrocode}
%\begin{macro}{\si@opt@proctform}
% Processing the number further uses the \cs{si@num@digits} macro.
% The results are stored in the appropriate counter.\\
%\cs{si@opt@proctform}\marg{mant/exp}
%    \begin{macrocode}
\newcommand*{\si@opt@proctform}[1]{%
  \renewcommand*{\si@num@predec}{}%
  \renewcommand*{\si@num@postdec}{}%
  \si@switchfalse
  \expandafter\si@ifnotmtarg\expandafter{%
    \csname si@num@#1\endcsname}
     {\expandafter\expandafter\expandafter\si@num@digits
        \csname si@num@#1\endcsname\@empty\@empty}%
   \csname si@tab@#1precnt\endcsname\z@\relax
   \csname si@tab@#1postcnt\endcsname\z@\relax
   \ifx\@empty\si@num@predec\@empty\else
     \csname si@tab@#1precnt\endcsname\si@num@predec\relax
   \fi
   \ifx\@empty\si@num@postdec\@empty\else
     \csname si@tab@#1postcnt\endcsname\si@num@postdec\relax
   \fi}
%    \end{macrocode}
%\end{macro}
% The alignment of tabular material when not processed by \cs{num}
% needs to be available.
%    \begin{macrocode}
\si@opt@choicekey{tabtextalign}{left,right,centre,center}
%    \end{macrocode}
%\begin{macro}{\si@tab@rfill@t}
%\begin{macro}{\si@tab@lfill@t}
% By default, centring happens on both sides of the content of
% tabular material.
%    \begin{macrocode}
  {\let\si@tab@rfill@t\hfill
   \let\si@tab@lfill@t\hfill
   \renewcommand*{\si@tempb}{right}%
   \ifx\si@tempa\si@tempb
     \let\si@tab@rfill@t\relax
   \fi
   \renewcommand*{\si@tempb}{left}%
   \ifx\si@tempa\si@tempb
     \let\si@tab@lfill@t\relax
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
% The alignment of unit columns for tabular material has a similar
% control option.
%    \begin{macrocode}
\si@opt@choicekey{tabunitalign}{left,right,centre,center}
%    \end{macrocode}
%\begin{macro}{\si@tab@rfill@s}
%\begin{macro}{\si@tab@lfill@s}
% By default, centring happens on both sides of the content of
% tabular material.
%    \begin{macrocode}
  {\let\si@tab@rfill@s\hfill
   \let\si@tab@lfill@s\hfill
   \renewcommand*{\si@tempb}{right}%
   \ifx\si@tempa\si@tempb
     \let\si@tab@rfill@s\relax
   \fi
   \renewcommand*{\si@tempb}{left}%
   \ifx\si@tempa\si@tempb
     \let\si@tab@lfill@s\relax
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@fixdp}
%\begin{macro}{\si@num@dp}
% To allow control of rounding, two options are needed.  One sets how
% many fixed digits to use, the second turns this function on and
% off.
%    \begin{macrocode}
\si@opt@boolkey{fixdp}
\newcount\si@num@dp
\si@opt@key{dp}{%
  \si@str@ifonlychrs{#1}{0123456789}
    {}
    {\si@log@err{Invalid input for dp option}
      {The dp option must be given a positive integer}}%
  \si@num@dp#1\relax
  \si@fixdptrue}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@tabautofit}
% To apply rounding automatically in a table, a separate option is
% used.
%    \begin{macrocode}
\si@opt@boolkey{tabautofit}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@xspace}
% Unit macros on their own may need \pkg{xpsace}.
%    \begin{macrocode}
\si@opt@boolkey{xspace}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@prespace}
%    \begin{macrocode}
\si@opt@boolkey
  [\si@unt@numfalse
   \ifsi@prespace
     \si@unt@numtrue
  \fi]
  {prespace}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@allowoptarg}
% For \unitsdef users, a method to absorb optional arguments is
% needed.
%    \begin{macrocode}
\si@opt@boolkey{allowoptarg}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@frac}
%\begin{macro}{\ifsi@slash}
%\begin{macro}{\ifsi@stickyper}
% The option processing for formatting units with \cs{per} in them
% needs two switches.
%    \begin{macrocode}
\newif\ifsi@slash
\newif\ifsi@frac
\si@opt@boolkey{stickyper}
\si@opt@choicekey[reciprocal]{per}
  {reciprocal,rp,power,slash,frac,fraction}
  {\si@slashfalse
   \si@fracfalse
   \renewcommand*{\si@tempb}{slash}%
   \ifx\si@tempa\si@tempb
     \si@fractrue
     \si@slashtrue
     \let\si@frac\si@frc@slash
   \fi
   \renewcommand*{\si@tempb}{frac}%
   \ifx\si@tempa\si@tempb
     \si@fractrue
   \fi
   \renewcommand*{\si@tempb}{fraction}%
   \ifx\si@tempa\si@tempb
     \si@fractrue
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@slash}
% For the \opt{slash} option, the separator can be customised.
%    \begin{macrocode}
\si@opt@xchoicekey{slash}{slash}{slash}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@repeatunits}
%\begin{macro}{\ifsi@addunitpower}
% An option is needed for cases where units should be repeated.
%    \begin{macrocode}
\newif\ifsi@repeatunits
\newif\ifsi@addunitpower
\si@opt@choicekey[true]{repeatunits}{true,false,power}
  {\si@repeatunitsfalse
   \si@addunitpowerfalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@repeatunitstrue
   \fi
   \renewcommand*{\si@tempb}{power}%
   \ifx\si@tempa\si@tempb
     \si@addunitpowertrue
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@trapambigfrac}
%\begin{macro}{\si@closefrac}
%\begin{macro}{\si@openfrac}
% Macros for the right and left brackets added to potentially
% ambiguous denominators.
%    \begin{macrocode}
\si@opt@boolkey{trapambigfrac}
\si@opt@cmdkeys{closefrac,openfrac}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
% In the case of fractional handling of the \cs{per} operator,
% further refinement is available.
%    \begin{macrocode}
\si@opt@choicekey[frac]{fraction}
  {frac,nicefrac,nice,sfrac,xfrac,uglyfrac,ugly}
  {\let\si@frac\si@frc@frac
   \renewcommand*{\si@tempb}{nicefrac}%
   \ifx\si@tempa\si@tempb
     \let\si@frac\si@frc@nice
   \fi
   \renewcommand*{\si@tempb}{uglyfrac}%
   \ifx\si@tempa\si@tempb
     \let\si@frac\si@frc@ugly
   \fi
   \renewcommand*{\si@tempb}{nice}%
   \ifx\si@tempa\si@tempb
     \let\si@frac\si@frc@nice
   \fi
   \renewcommand*{\si@tempb}{sfrac}%
   \ifx\si@tempa\si@tempb
     \let\si@frac\si@frc@sfrac
   \fi
   \renewcommand*{\si@tempb}{xfrac}%
   \ifx\si@tempa\si@tempb
     \let\si@frac\si@frc@sfrac
   \fi
   \renewcommand*{\si@tempb}{ugly}%
   \ifx\si@tempa\si@tempb
     \let\si@frac\si@frc@ugly
   \fi}
%    \end{macrocode}
%\begin{macro}{\si@load}
%\begin{macro}{\si@noload}
% Loading of support files is controlled by two keys.  The first
% defines a list of files that may be loaded, the second a list that
% will not.  This makes it easy to exclude a single file from a long
% list.
%    \begin{macrocode}
\si@opt@cmdkeys{load,noload}
\si@opt@key{alsoload}{\si@addtolist{\si@load}{#1}}
\AtEndOfPackage{
  \si@opt@disablekey{load}
    {Configuration files can only be used\MessageBreak
     when loading package}
  \si@opt@disablekey{noload}
    {Configuration files can only be used\MessageBreak
     when loading package}}
\AtEndOfPackage{
  \si@opt@key{alsoload}{%
    \@for\si@tempa:=#1\do{\si@loadfile{\si@tempa}}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@colourunits}
%\begin{macro}{\ifsi@colourvalues}
%\begin{macro}{\si@unitcolour}
%\begin{macro}{\si@valuecolour}
% Colour is turned on and off using two switches and the appropriate
% options.  US spellings are also provided.
%    \begin{macrocode}
\si@opt@boolkey{colourunits}
\si@opt@boolkey{colourvalues}
\si@opt@choicekey[true]{colorunits}
  {true,false}
  {\si@colourunitsfalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@colourunitstrue
   \fi}
\si@opt@choicekey[true]{colorvalues}
  {true,false}
  {\si@colourvaluesfalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@colourvaluestrue
   \fi}
\si@opt@choicekey[true]{colorall}
  {true,false}
  {\si@colourvaluesfalse
   \si@colourunitsfalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@colourunitstrue
     \si@colourvaluestrue
   \fi}
\si@opt@choicekey[true]{colourall}
  {true,false}
  {\si@colourvaluesfalse
   \si@colourunitsfalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@colourunitstrue
     \si@colourvaluestrue
   \fi}
\si@opt@cmdkeys{unitcolour,valuecolour}
\si@opt@key{unitcolor}{\sisetup{unitcolour=#1}}
\si@opt@key{valuecolor}{\sisetup{valuecolour=#1}}
\si@opt@key{colour}{\sisetup{unitcolour=#1,valuecolour=#1}}
\si@opt@key{color}{\sisetup{unitcolour=#1,valuecolour=#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@colourneg}
%\begin{macro}{\si@negcolour}
% The set up for colouring negative numbers is similar.
%    \begin{macrocode}
\si@opt@boolkey{colourneg}
\si@opt@choicekey[true]{colorneg}
  {true,false}
  {\si@colournegfalse
   \renewcommand*{\si@tempb}{true}%
   \ifx\si@tempa\si@tempb
     \si@colournegtrue
   \fi}
\si@opt@cmdkeys{negcolour}
\si@opt@key{negcolor}{\sisetup{negcolour=#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@textOmega}
%\begin{macro}{\si@mathsOmega}
% The various non-Latin symbols need to be handled, and given user interfaces.
% Some definitions are more complex than others; for \si{\ohm}
% things are easy.
%    \begin{macrocode}
\si@opt@cmdkeys{textOmega,mathsOmega}
\si@opt@key{mathOmega}{\sisetup{mathsOmega=#1}}
\newcommand*{\si@mathsOmega}{\text{\ensuremath{\Omega}}}
\newcommand*{\si@textOmega}{\ensuremath{\Omega}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\changes{v1.0c}{2008/06/25}{Fixed excess loading of maths fonts}
%\begin{macro}{\si@textmu}
%\begin{macro}{\si@mathsmu}
% For the \si{\micro} symbol, some direct loading of symbols is
% needed as the maths mu sign ($\mu$) is wrong.
%    \begin{macrocode}
\si@opt@cmdkeys{textmu,mathsmu}
\si@opt@key{mathmu}{\sisetup{mathsmu=#1}}
\DeclareFontEncoding{TS1}{}{}
\DeclareFontSubstitution{TS1}{cmr}{m}{n}
\DeclareTextSymbol{\si@textmu}{TS1}{181}
\DeclareTextSymbolDefault{\si@textmu}{TS1}
\@ifpackageloaded{upgreek}
  {}
  {\DeclareFontFamily{OML}{eur}{\skewchar\font'177}
   \DeclareFontShape{OML}{eur}{m}{n}{%
    <-6> eurm5 <6-8> eurm7 <8-> eurm10}{}}
\AtBeginDocument{
  \@ifpackageloaded{upgreek}
    {\let\si@mathsmu\upmu}
    {\DeclareSymbolFont{si@greek}{OML}{eur}{m}{n}
     \DeclareMathSymbol{\si@mathsmu}{\mathord}{si@greek}{"16}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@textdegree}
%\begin{macro}{\si@mathsdegree}
%\begin{macro}{\si@textminute}
%\begin{macro}{\si@mathsminute}
%\begin{macro}{\si@textsecond}
%\begin{macro}{\si@mathssecond}
% The angle signs.
%    \begin{macrocode}
\si@opt@cmdkeys{textdegree,mathsdegree,textminute,mathsminute,
  textsecond,mathssecond}
\si@opt@key{mathdegree}{\sisetup{mathsdegree=#1}}
\si@opt@key{mathminute}{\sisetup{mathsminute=#1}}
\si@opt@key{mathsecond}{\sisetup{mathssecond=#1}}
\newcommand*{\si@textdegree}{\ensuremath{{}^{\circ}}}
\newcommand*{\si@mathsdegree}{{}^{\circ}}
\newcommand*{\si@textminute}{\ensuremath{{}^{\prime}}}
\newcommand*{\si@mathsminute}{{}^{\prime}}
\newcommand*{\si@textsecond}{\ensuremath{{}^{\prime\prime}}}
\newcommand*{\si@mathssecond}{{}^{\prime\prime}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@textcelsius}
%\begin{macro}{\si@mathscelsius}
% Finally, degrees Celsius, which may need the degree symbol.
%    \begin{macrocode}
\si@opt@cmdkeys{textcelsius,mathscelsius}
\si@opt@key{mathcelsius}{\sisetup{mathscelsius=#1}}
\newcommand*{\si@textcelsius}{%
  \si@textdegree\kern-\scriptspace C}
\newcommand*{\si@mathscelsius}{%
  \si@mathsdegree\kern-\scriptspace\mathrm{C}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@textringA}
%\begin{macro}{\si@mathsringA}
% The \si{\angstrom} sign.
%    \begin{macrocode}
\si@opt@cmdkeys{textringA,mathsringA}
\si@opt@key{mathringA}{\sisetup{mathsringA=#1}}
\newcommand*{\si@textringA}{\AA}
\newcommand*{\si@mathsringA}{\text{\AA}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@redefsymbols}
% A flag for using \pkg{textcomp} and \pkg{upgreek} to provide better
% symbols.
%    \begin{macrocode}
\si@opt@boolkey{redefsymbols}
\AtBeginDocument{
  \si@opt@disablekey{redefsymbols}
    {Symbols can only be redefined\MessageBreak
     when loading siunitx}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@eVcorra}
%\begin{macro}{\si@eVcorrb}
%    \begin{macrocode}
\newlength\si@eVcorra
\newlength\si@eVcorrb
\si@opt@key{eVcorra}{\setlength\si@eVcorra{#1}}
\si@opt@key{eVcorrb}{\setlength\si@eVcorrb{#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@locale}
%\begin{macro}{\si@loctolang}
% Handling typographic conventions needs three keys.  \opt{locale} is
% used to set the locale, \opt{loctolang} to bind to \pkg{babel}.
%    \begin{macrocode}
\si@opt@key{locale}{%
  \si@loc@load{#1}%
  \si@loc@set{#1}}%
\si@opt@key{loctolang}{\si@loc@ltol{#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Compatibility options}
%\begin{macro}{\ifsi@old@ugly}
%\begin{macro}{\ifsi@old@nice}
%\begin{macro}{\ifsi@old@loose}
%\begin{macro}{\ifsi@old@tight}
% With the options for the package set up, the next stage is to
% provide support for users of the older packages.  These all set up
% switches, but do not do anything.  That is left to the emulation
% files, loaded at the end of the package. First of all, the
% \units options are dealt with; there are not many.
%    \begin{macrocode}
\si@opt@compatkey{units}{ugly}
\si@opt@compatkey{units}{nice}
\si@opt@compatkey{units}{loose}
\si@opt@compatkey{units}{tight}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@OHM}
%\begin{macro}{\ifsi@old@ohm}
%\begin{macro}{\ifsi@old@redef-gensymb}
%\begin{macro}{\ifsi@gensymb}
% The \unitsdef package is unfortunately much more profligate with
% options. The first set are to do with support for \pkg{gensymb}.
%    \begin{macrocode}
\si@opt@compatkey{unitsdef}{OHM}
\si@opt@compatkey{unitsdef}{ohm}
\si@opt@compatkey{unitsdef}{redef-gensymb}
\newif\ifsi@gensymb
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@LITER}
%\begin{macro}{\ifsi@old@liter}
%\begin{macro}{\ifsi@old@noxspace}
%\begin{macro}{\ifsi@old@noconfig}
% The second set are more general functionality.
%    \begin{macrocode}
\si@opt@compatkey{unitsdef}{LITER}
\si@opt@compatkey{unitsdef}{liter}
\si@opt@compatkey{unitsdef}{noxspace}
\si@opt@compatkey{unitsdef}{noconfig}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@noabbr}
%\begin{macro}{\ifsi@old@noamperageabbr}
%\begin{macro}{\ifsi@old@nofrequncyabbr}
%\begin{macro}{\ifsi@old@nomolabbr}
%\begin{macro}{\ifsi@old@novoltageabbr}
%\begin{macro}{\ifsi@old@novolumeabbr}
%\begin{macro}{\ifsi@old@noweightabbr}
%\begin{macro}{\ifsi@old@noenergyabbr}
%\begin{macro}{\ifsi@old@nolengthabbr}
%\begin{macro}{\ifsi@old@notimeabbr}
% The final set are for control of abbreviations, and are a good
% demonstration of why to use \pkg{xkeyval}!
%    \begin{macrocode}
\si@opt@compatkey{unitsdef}{noabbr}
\si@opt@compatkey{unitsdef}{noampereageabbr}
\si@opt@compatkey{unitsdef}{nofrequncyabbr}
\si@opt@compatkey{unitsdef}{nomolabbr}
\si@opt@compatkey{unitsdef}{novoltageabbr}
\si@opt@compatkey{unitsdef}{novolumeabbr}
\si@opt@compatkey{unitsdef}{noweightabbr}
\si@opt@compatkey{unitsdef}{noenergyabbr}
\si@opt@compatkey{unitsdef}{nolengthabbr}
\si@opt@compatkey{unitsdef}{notimeabbr}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@cdot}
%\begin{macro}{\ifsi@old@thickspace}
%\begin{macro}{\ifsi@old@mediumspace}
%\begin{macro}{\ifsi@old@thinspace}
%\begin{macro}{\ifsi@old@thickqspace}
%\begin{macro}{\ifsi@old@mediumqspace}
%\begin{macro}{\ifsi@old@thinqspace}
% The \SIunits package has lots of options.  These ones are all
% related to spacing.
%    \begin{macrocode}
\si@opt@compatkey{SIunits}{cdot}
\si@opt@compatkey{SIunits}{thickspace}
\si@opt@compatkey{SIunits}{mediumspace}
\si@opt@compatkey{SIunits}{thinspace}
\si@opt@compatkey{SIunits}{thickqspace}
\si@opt@compatkey{SIunits}{mediumqspace}
\si@opt@compatkey{SIunits}{thinqspace}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@amssymb}
%\begin{macro}{\ifsi@old@squaren}
%\begin{macro}{\ifsi@old@pstricks}
%\begin{macro}{\ifsi@old@Gray}
%\begin{macro}{\ifsi@old@italian}
% These options are used by \SIunits to control clashes with other
% packages.
%    \begin{macrocode}
\si@opt@compatkey{SIunits}{amssymb}
\si@opt@compatkey{SIunits}{squaren}
\si@opt@compatkey{SIunits}{pstricks}
\si@opt@compatkey{SIunits}{Gray}
\si@opt@compatkey{SIunits}{italian}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@textstyle}
%\begin{macro}{\ifsi@old@binary}
%\begin{macro}{\ifsi@old@noams}
%\begin{macro}{\ifsi@old@derivedinbase}
%\begin{macro}{\ifsi@old@derived}
% The miscellaneous options.
%    \begin{macrocode}
\si@opt@compatkey{SIunits}{textstyle}
\si@opt@compatkey{SIunits}{binary}
\si@opt@compatkey{SIunits}{noams}
\si@opt@compatkey{SIunits}{derivedinbase}
\si@opt@compatkey{SIunits}{derived}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@noprefixcmds}
% The \pkg{hepunits} package only has one option.
%    \begin{macrocode}
\si@opt@compatkey{hepunits}{noprefixcmds}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@old@english}
%\begin{macro}{\ifsi@old@french}
% \pkg{fancynum} provides a few options.  First the rather oddly
% named \opt{english} and \opt{french} ones.
%    \begin{macrocode}
\si@opt@compatkey{fancynum}{english}
\si@opt@compatkey{fancynum}{french}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@tight}
%\begin{macro}{\ifsi@old@loose}
% A couple for spacing multiplication.
%    \begin{macrocode}
\si@opt@compatkey{fancynum}{tight}
\si@opt@compatkey{fancynum}{loose}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@thinspaces}
%\begin{macro}{\ifsi@old@commas}
%\begin{macro}{\ifsi@old@plain}
% Three for digit separation.
%    \begin{macrocode}
\si@opt@compatkey{fancynum}{thinspaces}
\si@opt@compatkey{fancynum}{commas}
\si@opt@compatkey{fancynum}{plain}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@old@spaceqspace}
% The \pkg{fancyunits} package provides one option not available with
% \SIunits.
%    \begin{macrocode}
\si@opt@compatkey{fancyunits}{spaceqspace}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Constants}
% A number of macros are needed by the package that provide a
% non-changing output.  These are defined here; the intention is that
% these should not be macros that the user is likely to need to
% alter.  All of these macros have preface \cs{si@fix@}, to flag that
% that are intended as constants.  The package may rely on the
% contents of these macros for functionality.
%
%\begin{macro}{\si@fix@thin}
%\begin{macro}{\si@fix@med}
%\begin{macro}{\si@fix@medium}
%\begin{macro}{\si@fix@thick}
%\begin{macro}{\si@fix@space}
%\changes{v1.0a}{2008/06/20}{Fixed problem with \opt{space} option}
% First, there are the various space macros.  To allow both \opt{med}
% and \opt{medium} to be used as a space description, two macros are
% needed for the same output.
%    \begin{macrocode}
\newcommand*{\si@fix@thin}{\,}
\newcommand*{\si@fix@med}{\:}
\newcommand*{\si@fix@medium}{\:}
\newcommand*{\si@fix@thick}{\;}
\newcommand*{\si@fix@space}{\text{ }}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fix@cdot}
%\begin{macro}{\si@fix@comma}
%\begin{macro}{\si@fix@stop}
%\begin{macro}{\si@fix@fullstop}
%\begin{macro}{\si@fix@period}
%\begin{macro}{\si@fix@times}
%\begin{macro}{\si@fix@tighttimes}
%\begin{macro}{\si@fix@tightcdot}
% Next there are macros for material that is not simply whitespace.
% To allow several options, the full-stop gets lots of names.
%    \begin{macrocode}
\newcommand*{\si@fix@cdot}{{}\cdot{}}
\newcommand*{\si@fix@comma}{{,}}
\newcommand*{\si@fix@stop}{{.}}
\newcommand*{\si@fix@fullstop}{{.}}
\newcommand*{\si@fix@period}{{.}}
\newcommand*{\si@fix@times}{\times}
\newcommand*{\si@fix@tighttimes}{\bgroup\times\egroup}
\newcommand*{\si@fix@tightcdot}{\bgroup\cdot\egroup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fix@plus}
%\begin{macro}{\si@fix@minus}
%\begin{macro}{\si@fix@pm}
%\begin{macro}{\si@fix@tightpm}
%\begin{macro}{\si@fix@mp}
% Signs for numbers are needed.
%    \begin{macrocode}
\newcommand*{\si@fix@plus}{+}
\newcommand*{\si@fix@minus}{-}
\newcommand*{\si@fix@pm}{\pm}
\newcommand*{\si@fix@tightpm}{\bgroup\pm\egroup}
\newcommand*{\si@fix@mp}{\mp}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fix@two}
%\begin{macro}{\si@fix@ten}
% The literals ``2'' and ``10'' are needed for exponents.
%    \begin{macrocode}
\newcommand*{\si@fix@two}{2}
\newcommand*{\si@fix@ten}{10}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fix@slash}
% Another optional component that will probably not be used by many
% people.
%    \begin{macrocode}
\newcommand*{\si@fix@slash}{/}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@fix@none}
% Finally for spacing, there is the possibility of nothing at all
%    \begin{macrocode}
\newcommand*{\si@fix@none}{}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Symbols}
%\begin{macro}{\si@symbol}
% Each of the symbol macros needs to be set up; the options give a
% maths and text mode sign, but internally a single macro is needed
% for each.
%    \begin{macrocode}
\newcommand*{\si@symbol}[1]{%
  \expandafter\protected\expandafter\def
    \csname si@sym@#1\endcsname{%
    \ifmmode
      \expandafter\csname si@maths#1\expandafter\endcsname
    \else
      \expandafter\csname si@text#1\expandafter\endcsname
    \fi}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@sym@Omega}
%\begin{macro}{\si@sym@ringA}
%\begin{macro}{\si@sym@mu}
%\begin{macro}{\si@sym@degree}
%\begin{macro}{\si@sym@minute}
%\begin{macro}{\si@sym@second}
%\begin{macro}{\si@sym@celsius}
% The various symbols are now declared.
%    \begin{macrocode}
\si@symbol{Omega}
\si@symbol{ringA}
\si@symbol{mu}
\si@symbol{degree}
\si@symbol{minute}
\si@symbol{second}
\si@symbol{celsius}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% The issue of redefinition of symbols now arises.  \currpkg can
% check for the loading of a number of support package, and can then
% redefine the appropriate symbols.
%    \begin{macrocode}
\AtBeginDocument{%
  \ifsi@redefsymbols
    \@ifpackageloaded{textcomp}
      {\si@log@debug{Redefining symbols using textcomp}%
       \renewcommand*{\si@textdegree}{\textdegree}%
       \renewcommand*{\si@mathsdegree}{\text{\textdegree}}%
%    \end{macrocode}
% \pkg{mathptmx} will give issues with \pkg{textcomp} and the
% \si{\ohm} sign.
%    \begin{macrocode}
       \@ifpackageloaded{mathptmx}{}
         {\renewcommand*{\si@textmu}{\textmu}%
          \renewcommand*{\si@textOmega}{\textohm}}%
%    \end{macrocode}
% The \si{\angstrom} symbol is only redefined if the encoding is
% OT1; other encodings should have a proper glyph used for \cs{AA}.
% The \cs{encodingdefault} macro is \cs{long} for some reason.
%    \begin{macrocode}
       \renewcommand*{\si@tempa}{OT1}%
       \ifx\si@tempa\encodingdefault
         \renewcommand*{\si@mathsringA}{%
           \text{\capitalring{A}}}%
         \renewcommand*{\si@textringA}{\capitalring{A}}
       \fi}{}
    \@ifpackageloaded{upgreek}
      {\si@log@debug{Redefining symbols using upgreek}%
       \renewcommand*{\si@mathsOmega}{\Upomega}}{}
  \fi}
%    \end{macrocode}
%
%\subsection{Handling fractions}
%\begin{macro}{\si@frac}
%\begin{macro}{\si@frc@hook}
%\begin{macro}{\si@frc@frac}
%\begin{macro}{\si@frc@slash}
%\begin{macro}{\si@frc@nice}
%\begin{macro}{\si@frc@sfrac}
% Various methods of handling fractions are provided.
%    \begin{macrocode}
\newcommand*{\si@frc@frac}[2]{%
  \ensuremath{\si@frc@hook\frac{%
    \expandafter\si@unt@out\expandafter{#1}}%
    {\expandafter\si@unt@out\expandafter{#2}}}}
\let\si@frac\si@frc@frac
\newcommand*{\si@frc@hook}{}
\newcommand*{\si@frc@slash}[2]{%
    \expandafter\si@unt@out\expandafter{#1}%
    \si@out{\ensuremath{\si@slash}}%
    \expandafter\si@unt@out\expandafter{#2}}
\newcommand*{\si@frc@nice}[2]{%
  \ensuremath{\si@frc@nicefrac{\expandafter\si@unt@out%
    \expandafter{#1}}{\expandafter\si@unt@out\expandafter
      {#2}}}}
\newcommand*{\si@frc@sfrac}[2]{%
    \sfrac{\expandafter\si@unt@out\expandafter{#1}}%
      {\expandafter\si@unt@out\expandafter{#2}}}
\AtBeginDocument{
  \@ifpackageloaded{xfrac}
    {}
    {\si@log@inf{xfrac package unavailable\MessageBreak
       using `fraction=sfrac' will fall back on\MessageBreak
       nicefrac-like method}%
     \renewcommand*{\si@frc@sfrac}[2]{%
      \si@log@warn{xfrac package unavailable}%
      \si@frc@nice{#1}{#2}}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@frc@nicefrac}
%\begin{macro}{\si@frc@displen}
%\begin{macro}{\si@frc@textlen}
%\begin{macro}{\si@frc@suplen}
%\begin{macro}{\si@frc@ssuplen}
% To avoid needing \units installed, the \cs{nicefrac} macro needs
% to be emulated here. The code is taken (with permission) from
% \kg{nicefrac}.\footnote{The original is licensed under the GPL;
% thanks to the author Axel Reichert for permission to copy the code
% here.}
%    \begin{macrocode}
\newlength\si@frc@displen
\newlength\si@frc@textlen
\newlength\si@frc@suplen
\newlength\si@frc@ssuplen
\newcommand*{\si@frc@nicefrac}{%
  \ifmmode
    \expandafter\si@frc@mathsnf
  \else
    \expandafter\si@frc@textnf
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@frc@mathsnf}
% The maths mode system.\\
%\cs{si@frc@mathsnf}\marg{numerator}\marg{denominator}
%    \begin{macrocode}
\newcommand*{\si@frc@mathsnf}[2]{%
  \begingroup
    \settoheight{\si@frc@displen}{\ensuremath{%
      \displaystyle{M}}}%
    \settoheight{\si@frc@textlen}{\ensuremath{%
      \textstyle{M}}}%
    \settoheight{\si@frc@suplen}{\ensuremath{%
      \scriptstyle{M}}}%
    \settoheight{\si@frc@ssuplen}{%
      \ensuremath{\scriptscriptstyle{M}}}%
    \addtolength{\si@frc@displen}{-\si@frc@ssuplen}%
    \addtolength{\si@frc@textlen}{-\si@frc@ssuplen}%
    \addtolength{\si@frc@suplen}{-\si@frc@ssuplen}%
    \mathchoice
      {\raisebox{\si@frc@displen}{\ensuremath{%
        \scriptstyle{#1}}}}%
      {\raisebox{\si@frc@textlen}{\ensuremath{%
         \scriptstyle{#1}}}}%
      {\raisebox{\si@frc@suplen}%
        {\ensuremath{\scriptscriptstyle{#1}}}}%
      {\raisebox{\si@frc@ssuplen}%
        {\ensuremath{\scriptscriptstyle{#1}}}}%
    \mkern-2mu\relax/\mkern-1mu\relax
    \bgroup
      \mathchoice
        {\scriptstyle}%
        {\scriptstyle}%
        {\scriptscriptstyle}%
        {\scriptscriptstyle}%
      {#2}%
    \egroup
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@frc@textnf}
% A stripped down version of the \pkg{nicefrac} system for text mode.\\
%\cs{si@frc@textnf}\marg{numerator}\marg{denominator}
%    \begin{macrocode}
\newcommand*{\si@frc@textnf}[2]{%
  \begingroup
    \settoheight{\si@frc@textlen}{M}%
    \settoheight{\si@frc@ssuplen}{\fontsize\sf@size\z@\relax
      \selectfont{M}}%
    \addtolength{\si@frc@textlen}{-\si@frc@ssuplen}%
    \raisebox{\si@frc@textlen}{\fontsize\sf@size\z@\relax
      \selectfont{#1}}%
    \hspace{-0.25ex}/\hspace{-0.25ex}%
    \hbox{\fontsize\sf@size\z@\selectfont{#2}}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@frc@ugly}
% The \cs{si@frc@ugly} macro is needed to emulate the \opt{ugly}
% option in \units, where output depends on the current mode.\\
%\cs{si@frc@ugly}\marg{numerator}
%    \begin{macrocode}
\newcommand*{\si@frc@ugly}[1]{%
  \renewcommand*{\si@tempa}{#1}%
  \ifmmode
    \expandafter\si@frc@frac
  \else
    \renewcommand*{\si@tempb}{1}%
    \ifx\si@tempa\si@tempb
%    \end{macrocode}
% The slash switch cannot be used, so the possibility of the
% numerator being one is handled here.
%    \begin{macrocode}
      \setbox\si@tempboxa=\hbox{\ensuremath{\si@valuesep}}%
      \hskip-\wd\si@tempboxa\relax
      \renewcommand*{\si@tempa}{}%
    \fi
    \expandafter\si@frc@slash
  \fi
  {\si@tempa}}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Font control}
% A number of controls and tests are needed to control the font used
% for output.  Underlying all of this is the \AMS\ package
% \pkg{amstext} package, providing the \cs{text} command.  Much of
% the font control system here is taken more or less verbatim from
% \SIstyle; modifications have been made to fit the \currpkg
% interface.
%
%\begin{macro}{\si@fam@sf}
%\begin{macro}{\si@fam@tt}
% The package needs to know the maths font families in use.  This is
% set right at the start of the document, after any changes can have
% been made by, for example, \pkg{fontspec}.
%    \begin{macrocode}
\g@addto@macro{\document}{%
  \ifdefined\mathsf
    \setbox\si@tempboxa=\hbox{%
      $\mathsf{\global\chardef\si@fam@sf=\fam}$}%
  \else
    \si@log@inf{\string\mathsf not found}%
    \global\chardef\si@fam@sf=99\relax
  \fi
  \ifdefined\mathtt
    \setbox\si@tempboxa=\hbox{%
      $\mathtt{\global\chardef\si@fam@tt=\fam}$}%
  \else
    \si@log@inf{\string\mathtt not found}%
    \global\chardef\si@fam@tt=99\relax
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fam@ifbtext}
%\begin{macro}{\si@fam@ifbmaths}
% These tests check for bold in text and maths mode, respectively.\\
%\cs{si@fam@ifbtext}\marg{code}\\
%\cs{si@fam@ifbmaths}\marg{code}
%    \begin{macrocode}
\newcommand*{\si@fam@ifbtext}[1]{%
  \if b\expandafter\@car\f@series\@nil
    #1\fi}
\newcommand*{\si@fam@ifbmaths}[1]{%
  \renewcommand*{\si@tempa}{bold}%
  \ifx\math@version\si@tempa
    #1\fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fam@ifbinline}
% For compatibility with \units, a method to change the behaviour
% when in inline maths is needed for the bold detector.
%    \begin{macrocode}
\newcommand*{\si@fam@ifbinline}{%
  \ifsi@inlinebtext
    \expandafter\si@fam@ifbtext
  \else
    \expandafter\si@fam@ifbmaths
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@fam@ifitext}
% This test check for italic or slanted text in text mode, by
% negation (upright text is |n|).\\
%\cs{si@fam@ifitext}\marg{code}
%    \begin{macrocode}
\newcommand*{\si@fam@ifitext}[1]{%
  \if n\expandafter\@car\f@series\@nil\else
    #1\fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@fam@mode}
% Detection of the current mode needs to happen``early'' (before any
% change of \cs{ensuremath}).  So a short macro is provided to do the
% job.
%    \begin{macrocode}
\newcommand*{\si@fam@mode}{%
  \ifsi@obeymode
    \ifmmode
      \sisetup{mode=maths}%
    \else
      \sisetup{mode=text}%
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@fam@colourcmd}
% The colour command is set up.
%    \begin{macrocode}
\AtBeginDocument{
  \@ifpackageloaded{color}
    {\let\si@fam@colourcmd\color}
    {\let\si@fam@colourcmd\@gobble}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifsi@fam@set}
%\begin{macro}{\ifsi@textmode}
% A marker is set up to check if font-matching has been taken place.
% A second flag is used to track the use of text mode.
%    \begin{macrocode}
\newif\ifsi@fam@set
\newif\ifsi@textmode
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fam@set}
% Using the code from \SIstyle as a base, a set of tests are used to
% set the current font families and weights.  To begin with, the
% mode to use is set up.
%    \begin{macrocode}
\newcommand*{\si@fam@set}{%
  \ifsi@out@num
    \ifsi@numtextmode
      \expandafter\expandafter\expandafter\si@textmodetrue
    \else
      \expandafter\expandafter\expandafter\si@textmodefalse
    \fi
  \else
    \ifsi@unittextmode
      \expandafter\expandafter\expandafter\si@textmodetrue
    \else
      \expandafter\expandafter\expandafter\si@textmodefalse
    \fi
  \fi
%    \end{macrocode}
%\begin{macro}{\si@mathsrm}
%\begin{macro}{\si@mathssf}
%\begin{macro}{\si@mathstt}
%\begin{macro}{\si@textrm}
%\begin{macro}{\si@textsf}
%\begin{macro}{\si@texttt}
%\begin{macro}{\si@colourcmd}
%\begin{macro}{\si@colour}
% The appropriate font macros are now established, if necessary.
%    \begin{macrocode}
  \ifsi@fam@set\else
    \let\si@colourcmd\@gobble
    \ifsi@out@num
      \let\si@mathsrm\si@valuemathsrm
      \let\si@mathssf\si@valuemathssf
      \let\si@mathstt\si@valuemathstt
      \let\si@textrm\si@valuetextrm
      \let\si@textsf\si@valuetextsf
      \let\si@texttt\si@valuetexttt
      \ifsi@colourvalues
        \let\si@colourcmd\si@fam@colourcmd
      \fi
      \let\si@colour\si@valuecolour
    \else
      \let\si@mathsrm\si@unitmathsrm
      \let\si@mathssf\si@unitmathssf
      \let\si@mathstt\si@unitmathstt
      \let\si@textrm\si@unittextrm
      \let\si@textsf\si@unittextsf
      \let\si@texttt\si@unittexttt
      \ifsi@colourunits
        \let\si@colourcmd\si@fam@colourcmd
      \fi
      \let\si@colour\si@unitcolour
    \fi
  \fi
  \si@fam@settrue
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% The temporary macros are needed for the \cs{ifx} tests, which need to
% be expanded once.
%    \begin{macrocode}
  \edef\si@tempa{\sfdefault}%
  \edef\si@tempb{\ttdefault}%
%    \end{macrocode}
%\begin{macro}{\si@fam@maths}
%\begin{macro}{\si@fam@text}
% The surrounding font family is only tested if matching is
% requested.  First, the defaults are set up assuming no detection
% takes place.
%    \begin{macrocode}
  \expandafter\let\expandafter\si@fam@maths
    \csname\si@mathsrm\endcsname
  \expandafter\let\expandafter\si@fam@text
    \csname\si@textrm\endcsname
  \ifsi@obeyfamily
    \si@log@debug{Font detection: checking font}%
%    \end{macrocode}
%\end{macro}
%\end{macro}
% The detection code has to check the mode currently in operation.
% Display mathematics can be handled in two ways, so this means some
% code is repeated: it is spun out to separate routines.
%    \begin{macrocode}
    \ifmmode
      \ifinner
        \si@log@debug{Font detection: inline maths}%
        \si@fam@dettext
      \else
        \si@log@debug{Font detection: display maths}%
        \ifsi@detectdisplay
          \si@fam@detmaths
        \else
          \si@fam@dettext
        \fi
      \fi
    \else
      \si@log@debug{Font detection: text}%
      \si@fam@dettext
    \fi
  \else
    \si@log@debug{Font detection: inactive}%
  \fi
%    \end{macrocode}
%\begin{macro}{\si@fam@bold}
% With the font family set, the next check is for bold text.  This
% again needs to examine the current mode. Things are a bit more
% complex than in \SIstyle as it is possible to be typesetting in
% either text or maths mode.  The bold command is set up with
% \cs{def}, as nested calls can occur.
%    \begin{macrocode}
  \def\si@fam@bold{\unboldmath\mdseries}%
  \ifsi@obeybold
    \si@log@debug{Weight detection: checking weight}%
    \ifmmode
      \ifdim\displaywidth>0pt\relax
        \ifsi@detectdisplay
          \expandafter\si@fam@ifbmaths
        \else
          \expandafter\si@fam@ifbtext
        \fi
        \si@fam@setbold
      \else
        \si@fam@ifbinline\si@fam@setbold
      \fi
    \else
      \si@fam@ifbtext\si@fam@setbold
    \fi
  \fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@fam@italic}
% The value of \opt{obeyitalic} is now tested; as this does nothing
% in maths mode, a reminder is added to the log.
%    \begin{macrocode}
  \let\si@fam@italic\upshape
  \ifsi@obeyitalic
    \si@log@debug{Italic detection: checking italic}%
    \si@fam@ifitext
      {\let\si@fam@italic\relax
       \si@log@debug{Italic detection: italic}}%
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fam@detmaths}
%\begin{macro}{\si@fam@dettext}
% Two detection macros are needed for maths and text mode. This
% allows handling of the various combinations without needing too
% many code lines.
%    \begin{macrocode}
\newcommand*{\si@fam@detmaths}{%
  \ifnum\the\fam=\si@fam@sf
    \si@log@debug{Font detection: sf}%
    \expandafter\let\expandafter\si@fam@maths
      \csname\si@mathssf\endcsname
    \expandafter\let\expandafter\si@fam@text
      \csname\si@textsf\endcsname
  \else
    \ifnum\the\fam=\si@fam@tt
      \si@log@debug{Font detection: tt}%
      \expandafter\let\expandafter\si@fam@maths
        \csname\si@mathstt\endcsname
      \expandafter\let\expandafter\si@fam@text
        \csname\si@texttt\endcsname
    \else
      \si@log@debug{Font detection: rm}%
      \expandafter\let\expandafter\si@fam@maths
        \csname\si@mathsrm\endcsname
      \expandafter\let\expandafter\si@fam@text
        \csname\si@textrm\endcsname
    \fi
  \fi}
\newcommand*{\si@fam@dettext}{%
  \ifx\f@family\si@tempa
    \si@log@debug{Font detection: sf}%
    \expandafter\let\expandafter\si@fam@maths
      \csname\si@mathssf\endcsname
    \expandafter\let\expandafter\si@fam@text
      \csname\si@textsf\endcsname
  \else
    \ifx\f@family\si@tempb
      \si@log@debug{Font detection: tt}%
      \expandafter\let\expandafter\si@fam@maths
        \csname\si@mathstt\endcsname
      \expandafter\let\expandafter\si@fam@text
        \csname\si@texttt\endcsname
    \else
      \si@log@debug{Font detection: rm}%
      \expandafter\let\expandafter\si@fam@maths
        \csname\si@mathsrm\endcsname
      \expandafter\let\expandafter\si@fam@text
        \csname\si@textrm\endcsname
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@fam@setbold}
%\begin{macro}{\si@fam@boldify}
% For setting bold, a couple of control macros are needed.
%    \begin{macrocode}
\newcommand*{\si@fam@setbold}{%
  \si@log@debug{Weight detection: bold weight}%
  \let\si@fam@bold\si@fam@boldify}
\newcommand*{\si@fam@boldify}{\boldmath\bfseries}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Formatting numbers}
%\begin{macro}{\num}
% The system used here is modelled on that in \numprint; the
% input is broken down into single tokens, each one is examined and
% the result is re-assembled into an output number.  However, various
% changes have been made to the system used, and so the macros here
% are not simply renamed copies of those in \numprint.  The user
% macro \cs{num} sets any local keys, then calls the number
% formatting macro on the processed number.\\
%\cs{num}\oarg{options}\marg{num}
%    \begin{macrocode}
\si@newrobustcmd*{\num}[2][]{%
  \begingroup
    \sisetup{#1}%
    \si@fam@mode
    \si@num@intabfalse
    \si@log@debug{Processing \string\num\space input `#2'}%
    \expandafter\si@out@num\expandafter{\si@num{#2}}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@num@intab}
% A flag for processing inside a table is needed.
%    \begin{macrocode}
\newif\ifsi@num@intab
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num}
% This is the main processing macro.  Unlike the related macro in
% \numprint, the output of this macro is not subjected to any font
% changes.  That is left to one of the \cs{si@out@\ldots} macros.  No
% grouping is applied here; any call to \cs{si@num} (or any of the
% sub-macros) must be within a group as the definitions used rely on
% this.  Grouping is not applied here so that other macros can get
% the various separated parts of the input.\\
%\cs{si@num}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@num}[1]{%
%    \end{macrocode}
% The argument of the macro is fully expanded before any processing.
% By using \cs{scantokens}, any odd problems from packages with
% active characters can be avoided.
%    \begin{macrocode}
  \si@num@fixpm
  \begingroup
    \makeatletter
    \@makeother{\,}%
    \@makeother{\.}%
    \@makeother{\+}%
    \@makeother{\-}%
    \def~{}%
    \def\,{}%
    \catcode`\~=\active\relax
    \catcode`\^=\active\relax
    \everyeof{\noexpand}%
    \endlinechar\m@ne
    \protected@xdef\si@tempa{\scantokens{#1}}%
  \endgroup
%    \end{macrocode}
% Processing only takes place if there is actually something in the
% argument.  This is tested once ``hard'' spaces have been stripped
% out; if there is input other than spaces, the processor first
% checks the validity of the input, then moves on to format it.
%    \begin{macrocode}
  \si@ifnotmtarg{\si@tempa}
    {\si@num@ifvalid{\si@tempa}
      {\si@num@format{\si@tempa}}
%    \end{macrocode}
% The parser has to bailed-out, and so no further processing of
% the input is done.  Instead, whatever was passed to the macro is
% returned as supplied.
%    \begin{macrocode}
      {\si@log@err{Invalid character `#1' in numerical input}%
         {Only characters from the list
          `\si@numvalid'\MessageBreak should be present in the
          argument of the \string\num\space  macro\MessageBreak
         (or derivative such as an `s' column)}%
       {#1}}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@fixpm}
%\begin{macro}{\si@num@pm}
%\begin{macro}{\si@num@mp}
%\begin{macro}{\pm}
%\begin{macro}{\mp}
% With certain packages loaded, there can be issues with \cs{pm} and
% \cs{mp}.  To avoid this, the \eTeX\ \cs{protected} system is
% employed; this is only used within local groups.
%    \begin{macrocode}
\newcommand*{\si@num@fixpm}{%
  \let\si@num@pm\pm
  \let\si@num@mp\mp
  \protected\def\pm{\si@num@pm}%
  \protected\def\mp{\si@num@mp}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@ifvalid}
%\begin{macro}{\si@num@valid}
% Assuming that there is a non-space argument to \cs{si@num}, every
% character is checked to ensure it is valid in the context, so that
% further processing can occur without sanity checks.  If the
% character is valid, recursion occurs.\\
%\cs{si@num@ifvalid}\marg{chars}\\
%\cs{si@num@valid}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@ifvalid}[1]{%
  \begingroup
    \si@switchtrue
    \expandafter\si@num@valid#1\@empty\@empty
    \ifsi@switch
      \aftergroup\@firstoftwo
    \else
      \aftergroup\@secondoftwo
    \fi
  \endgroup}
\def\si@num@valid#1#2\@empty{%
  \si@str@ifchrstr{#1}{\si@numvalid}
    {\ifx\@empty#2\@empty\else
       \si@num@valid#2\@empty\@empty\@empty
     \fi}
    {\si@switchfalse}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@in}
%\begin{macro}{\si@num@out}
%\begin{macro}{\si@num@exp}
%\begin{macro}{\si@num@expsign}
%\begin{macro}{\si@num@mant}
%\begin{macro}{\si@num@mantsign}
%\begin{macro}{\si@num@err}
%\begin{macro}{\si@num@xpart}
%\begin{macro}{\si@num@ambig}
%\begin{macro}{\si@tab@out}
%\begin{macro}{\si@tab@expout}
% Various storage macros are needed.
%    \begin{macrocode}
\newcommand*{\si@num@in}{}
\newcommand*{\si@num@out}{}
\newcommand*{\si@num@exp}{}
\newcommand*{\si@num@expsign}{}
\newcommand*{\si@num@mant}{}
\newcommand*{\si@num@mantsign}{}
\newcommand*{\si@num@err}{}
\newcommand*{\si@num@xpart}{}
\newcommand*{\si@num@ambig}{}
\newcommand*{\si@tab@out}{}
\newcommand*{\si@tab@expout}{}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@num@erropen}
% A flag is set up for tracking unclosed errors.
%    \begin{macrocode}
\newif\ifsi@num@erropen
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@format}
%\begin{macro}{\si@num@arg}
% The number processor starts by saving |#1| (odd things happen
% otherwise).  A hook is also provided to allow modifications by
% other macros.\\
%\cs{si@num@format}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@num@arg}{}
\newcommand*{\si@num@format}[1]{%
  \protected@edef\si@num@arg{#1}%
  \si@log@debug{Formatting number `\si@num@arg'}%
%    \end{macrocode}
%\end{macro}
% The storage areas are emptied.
%    \begin{macrocode}
  \renewcommand*{\si@num@in}{}%
  \renewcommand*{\si@num@exp}{}%
  \renewcommand*{\si@num@expsign}{}%
  \renewcommand*{\si@num@mant}{}%
  \renewcommand*{\si@num@mantsign}{}%
  \renewcommand*{\si@num@err}{}%
  \renewcommand*{\si@num@xpart}{}%
%    \end{macrocode}
% Any ``x-part'' is now found, leaving the first number in
% \cs{si@num@in} and anything else in \cs{si@num@xpart}.
%    \begin{macrocode}
  \si@switchfalse
  \expandafter\si@num@findxpart\si@num@arg\@empty\@empty
%    \end{macrocode}
% The input is split into an mantissa and an exponent; the flag is
% used here to indicate if an exponent is found.  The mantissa will
% end up in \cs{si@num@mant}, and the exponent in \cs{si@num@exp}.
%    \begin{macrocode}
  \si@switchfalse
  \si@num@sepmantexp{\si@num@in}%
%    \end{macrocode}
% The sign and value of the mantissa and exponent are separated; the
% mantissa is done after the exponent as this makes life easier when
% using the table-formatting fork. Checks are then needed, as a sign
% with no value is potentially-valid for the mantissa (for example
% \num{-e10}).
%    \begin{macrocode}
  \si@num@sepsign{exp}%
  \si@num@sepsign{mant}%
  \ifx\@empty\si@num@exp\@empty
    \ifx\@empty\si@num@expsign\@empty\else
      \si@log@warn{Sign but no number for `\si@num@arg'}%
    \fi
    \let\si@num@expsign\@empty
  \fi
  \ifx\@empty\si@num@mant\@empty
    \ifx\@empty\si@num@mantsign\@empty\else
      \ifx\@empty\si@num@exp\@empty
        \si@log@warn{Sign but no number for `\si@num@arg'}%
        \let\si@num@mantsign\@empty
      \fi
    \fi
  \fi
%    \end{macrocode}
% A check for negative mantissa values is made, to allow some
% colour-based trickery.
%    \begin{macrocode}
  \renewcommand*{\si@tempa}{{-}}%
  \ifx\si@num@mantsign\si@tempa
    \ifsi@colourneg
      \expandafter\expandafter\expandafter\si@fam@colourcmd
    \else
      \expandafter\expandafter\expandafter\@gobble
    \fi
  \else
    \expandafter\@gobble
  \fi
  {\si@negcolour}%
%    \end{macrocode}
% The next stage is to process the remaining data, to find the
% decimal marker and reformat correctly.  These two macros control
% this entire process.  The exponent is processed first as this makes
% life easier when the system is used to typeset tabular
% material.\footnote{The contents of \cs{si@num@predec} and
% \cs{si@num@postdec} are needed for the mantissa.}
%    \begin{macrocode}
  \si@num@procnum{exp}%
  \si@num@procnum{mant}%
%    \end{macrocode}
% If the exponent is zero, then if might need to be deleted.
%    \begin{macrocode}
  \si@str@ifonlychrs{\si@num@exp}{0\si@numdecimal}
    {\ifsi@allowzeroexp\else
       \renewcommand*{\si@num@exp}{}%
       \ifx\@empty\si@num@mant\@empty
         \renewcommand*{\si@num@mant}{1}%
       \fi
     \fi}{}%
%    \end{macrocode}
% To build up the number for typesetting, a rather complex series
% of tests is needed.  First, the ``ambiguous error'' flag is
% set if there is an exponent and the package has been asked to check
% this.  The same flag will already be true if a unit is present and
% checking is active.
%    \begin{macrocode}
  \ifx\@empty\si@num@exp\@empty\else
    \ifsi@trapambigerr
      \expandafter\expandafter\expandafter\si@num@ambigerrtrue
    \fi
  \fi
%    \end{macrocode}
%\begin{macro}{\si@num@out}
%\begin{macro}{\si@tab@out}
%\begin{macro}{\si@tab@expout}
% Processing now divides, as when used with the |S| column some extra
% steps are needed.  Inside a table, the macro \cs{si@tab@out} holds
% the part of the mantissa before the decimal sign.  The post-decimal
% part then ends up in \cs{i@num@out}.  On the other hand, under
% normal circumstances the entire mantissa should be copied to
% \cs{si@num@out}.
%    \begin{macrocode}
  \protected@edef\si@num@out{%
    \ensuremath{{\si@num@mantsign}}\si@num@mant}%
  \renewcommand*{\si@tempa}{num}%
  \ifsi@num@intab
    \protected@edef\si@tab@out{%
      \ensuremath{{\si@num@mantsign}}\si@num@predec}%
    \protected@edef\si@num@out{\si@num@postdec}%
    \renewcommand*{\si@tempa}{tab}%
  \fi
%    \end{macrocode}
% Now there is the error part to handle.  For tables, a check has to
% be made so the error ends up in the correct part of the number. The
% value of \cs{si@tempa} is used to track this., and so is set up
% here.
%    \begin{macrocode}
  \ifx\@empty\si@num@postdec\@empty\else
    \renewcommand*{\si@tempa}{num}%
  \fi
  \ifx\@empty\si@num@err\@empty\else
%    \end{macrocode}
% If there is an error, and it is begin separated, the problem arises
% of the potential for ambiguous values.  This can only apply outside
% of a table, as \opt{seperr} is disabled in tabular material.
%    \begin{macrocode}
    \ifsi@seperr
      \ifsi@num@ambigerr
        \protected@edef\si@num@out{%
          \ensuremath{\si@openerr}\si@num@out}%
        \si@repeatunitsfalse
        \expandafter\si@num@erropentrue
      \else
%    \end{macrocode}
% If there is an exponential part and an error, errors are being
% separated and ambiguous errors are not trapped, then there is work
% to do.  The exponent part is added to the \emph{error}, and deleted
% from the mantissa if necessary.
%    \begin{macrocode}
        \ifsi@trapambigerr\else
          \ifx\@empty\si@num@exp\@empty\else
            \protected@edef\si@num@err{%
              \si@num@err\expandafter\@car\si@numexp\@nil
              \si@num@expsign\si@num@exp}%
            \ifsi@repeatunits\else
              \renewcommand*{\si@num@exp}{}%
              \renewcommand*{\si@num@expsign}{}%
            \fi
          \fi
        \fi
      \fi
%    \end{macrocode}
% If \opt{seperr} is not in force, the error and mantissa have to be
% recombined.  This is handled so that the same macro deals with
% tables and normal processing.
%    \begin{macrocode}
    \else
      \expandafter\protected@edef\csname
        si@\si@tempa @out\endcsname{%
          \si@num@out\ensuremath{\si@errspace}\ensuremath
          {\si@openerr}\si@num@err\ensuremath{\si@closeerr}}%
      \renewcommand*{\si@num@err}{}%
    \fi
  \fi
%    \end{macrocode}
% The main reconstruction can now occur.  This performs various
% checks on the validity of the input, and adds the necessary
% ``filler'' between the supplied data.
%    \begin{macrocode}
  \renewcommand*{\si@tempa}{num@out}%
  \ifsi@num@erropen
    \renewcommand*{\si@tempa}{num@ambig}%
  \fi
  \ifsi@num@intab
    \renewcommand*{\si@tempa}{tab@expout}%
  \fi
  \ifx\@empty\si@num@exp\@empty
    \ifx\@empty\si@num@mant\@empty
      \si@log@err{Invalid number format `\si@num@arg'}
        {Something is wrong with the number format; does it
         contain \MessageBreak any numbers (from the list
         `\si@numdigits')?}%
      \renewcommand*\si@num@out{}%
    \fi
  \else
    \ifx\@empty\si@num@mant\@empty\else
      \expandafter\protected@edef\csname
        si@\si@tempa\endcsname{%
          \csname si@\si@tempa\endcsname\ensuremath{{}%
          \si@expproduct{}}}%
    \fi
    \expandafter\protected@edef\csname
      si@\si@tempa\endcsname{%
        \csname si@\si@tempa\endcsname\si@expbase
        \textsuperscript{\ensuremath{\si@num@expsign}%
        \si@num@exp}}%
  \fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
% With everything done, the result is output.
%    \begin{macrocode}
  \ifsi@num@intab\else
    \expandafter\si@num@out
  \fi
%    \end{macrocode}
% If there is anything inside the ``x-part'', then there is now
% more work to do.
%    \begin{macrocode}
  \ifx\@empty\si@num@err\@empty\else
    \expandafter\si@num@procerr
  \fi
  \ifsi@num@erropen
    \expandafter\si@out@num\expandafter{%
      \ensuremath{\si@closeerr}}%
      \ifx\@empty\si@num@ambig\@empty\else
        \expandafter\si@out@num\expandafter{\si@num@ambig}%
        \renewcommand*{\si@num@ambig}{}%
    \fi
  \fi
  \si@num@erropenfalse
  \ifx\@empty\si@num@xpart\@empty\else
    \expandafter\si@num@sepxpart
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@findxpart}
% Before processing the number, any multiplied parts have to be found
% and removed.  As there can be more than one product sign, the
% building process here has no error checking.
%    \begin{macrocode}
\def\si@num@findxpart#1#2\@empty{%
  \si@str@ifchrstr{#1}{\si@numprod}
    {\si@switchtrue\si@seperrfalse}{}%
  \ifsi@switch
    \protected@edef\si@num@xpart{\si@num@xpart#1}%
  \else
    \protected@edef\si@num@in{\si@num@in#1}%
  \fi
  \ifx\@empty#2\@empty\else
    \si@num@findxpart#2\@empty
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@sepmantexp}
%\begin{macro}{\si@num@mantexp}
% Splitting the mantissa and exponent first checks for characters to
% gobble, which are simply thrown away.  For any other input, there
% are two possibilities.  If the character is an exponent marker,
% then the package switches from collecting the mantissa to
% collecting the exponent (after a sanity check).  All other
% characters are added to either the mantissa or the exponent, as
% appropriate.\\
%\cs{si@num@sepmantexp}\marg{num}\\
%\cs{si@num@mantexp}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@sepmantexp}[1]{%
  \expandafter\si@num@mantexp#1\@empty\@empty}
\def\si@num@mantexp#1#2\@empty{%
  \si@str@ifchrstr{#1}{\si@numgobble}
    {\si@log@debug{Gobbling `#1' in \si@num@arg}}
    {\si@str@ifchrstr{#1}{\si@numexp}
       {\ifsi@switch
          \si@log@err{Duplicate exponent marker found}
            {Only a single exponent character \MessageBreak
            (from the list `\si@numexp')\MessageBreak may
            occur in a numerical argument}%
        \else
          \si@log@debug{Exponent marker `#1' found in
            `\si@num@arg'}%
        \fi
        \si@switchtrue}%
       {\ifsi@switch
          \expandafter\si@num@addexp
        \else
          \expandafter\si@num@addmnt
        \fi
        {#1}}}%
%    \end{macrocode}
% If the recursion has not bottomed out, another loop occurs.
%    \begin{macrocode}
  \ifx\@empty#2\@empty
    \expandafter\@gobble
  \else
    \expandafter\si@num@sepmantexp
  \fi
  {#2}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@addmnt}
%\begin{macro}{\si@num@addexp}
%\begin{macro}{\si@num@addmntexp}
% To allow \cs{expandafter} use in the above, the actual addition to the
% appropriate macro is handled here.\\
%\cs{si@num@addmnt}\marg{char}\\
%\cs{si@num@addexp}\marg{char}\\
%\cs{si@num@addmntexp}\marg{char}\marg{mant/exp}\marg{text}
%    \begin{macrocode}
\newcommand*{\si@num@addmnt}[1]{%
  \si@num@addmntexp{#1}{mant}{mantissa}}
\newcommand*{\si@num@addexp}[1]{%
  \si@num@addmntexp{#1}{exp}{exponent}}
\newcommand*{\si@num@addmntexp}[3]{%
  \si@log@debug{Adding `#1' to #3 for `\si@num@arg'}%
  \expandafter\protected@edef\csname si@num@#2\endcsname{%
    \csname si@num@#2\endcsname#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@sepsign}
% The input is now tested for a sign.  If one exists, it is
% transferred into the \cs{si@num@}|#1sign| storage macro, with the
% remained of the number in \cs{si@num@}|#1|.  The only check made
% directly here is that there is something to process.\\
%\cs{si@num@sepsign}\marg{mant/exp}
%    \begin{macrocode}
\newcommand*{\si@num@sepsign}[1]{%
  \expandafter\ifx\expandafter\@empty
    \csname si@num@#1\endcsname\@empty
    \expandafter\@gobble
  \else
    \expandafter\si@num@gensign
  \fi
  {#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@gensign}
% The sign generator starts by calling the procedure to check if the
% input contains a valid one- or two-digit sign.  The results are
% returned as \cs{si@num@sign} and \cs{si@num@value}.\\
%\cs{si@num@gensign}\marg{mant/exp}
%    \begin{macrocode}
\newcommand*{\si@num@gensign}[1]{%
  \expandafter\expandafter\expandafter\si@num@findsign
    \csname si@num@#1\endcsname\@empty\@empty
%    \end{macrocode}
% If no sign has been found, then there may be a need to add one
% anyway.
%    \begin{macrocode}
  \ifx\@empty\si@num@sign\@empty
    \ifx\@empty\si@num@value\@empty
      \expandafter\expandafter\expandafter\@gobble
    \else
      \expandafter\expandafter\expandafter\si@num@addsign
    \fi
  \else
    \expandafter\@gobble
  \fi
  {#1}%
%    \end{macrocode}
% The appropriate storage areas are now assigned.
%    \begin{macrocode}
  \expandafter\let\csname si@num@#1sign\endcsname\si@num@sign
  \expandafter\let\csname si@num@#1\endcsname\si@num@value}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@findsign}
%\begin{macro}{\si@num@sign}
%\begin{macro}{\si@num@value}
% The first one or two characters of the mantissa or exponent may
% contain a sign.  To test for this, the first two characters of the
% number are split off, and examined.  Two characters are used so
% that \cs{pm} and \cs{mp} can be represented by |+-| and |-+|,
% respectively. To allow the user to alter the valid signs, but
% retain this conversion, the generic character test is used before
% checking specific matches.\\
%\cs{si@num@findsign}\meta{char}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@sign}{}
\def\si@num@findsign#1#2#3\@empty{%
  \si@num@delplusfalse
  \si@str@ifchrstr{#1}{\si@numsign}{%
    \si@str@ifchrstr{#2}{\si@numsign}{%
      \if +#1%
        \if -#2%
          \si@log@debug{Found sign combination +- for
            `\si@num@arg'}%
          \renewcommand*{\si@num@sign}{{\si@pm}}%
        \else
          \si@log@inf{Unknown sign combination `#1#2'}%
          \renewcommand*{\si@num@sign}{{#1#2}}%
        \fi
      \else
        \if -#1%
          \if +#2%
            \si@log@debug{Found sign combination -+ for
              `\si@num@arg'}%
            \renewcommand*{\si@num@sign}{{\mp}}%
          \else
            \si@log@inf{Unknown sign combination `#1#2'}%
            \renewcommand*{\si@num@sign}{{#1#2}}%
          \fi
        \else
          \si@log@inf{Unknown sign combination `#1#2'}%
          \renewcommand*{\si@num@sign}{{#1#2}}%
        \fi
      \fi
      \protected@edef\si@num@value{#3}}%
%    \end{macrocode}
% Only one valid sign character.
%    \begin{macrocode}
      {\si@log@debug{Found single sign character `#1' for
         `\si@num@arg'}%
       \renewcommand*{\si@num@sign}{{#1}}%
       \if +#1%
         \ifsi@retainplus\else
           \expandafter\expandafter\expandafter\si@num@killsign
         \fi
       \fi
       \protected@edef\si@num@value{#2#3}}}%
%    \end{macrocode}
% No valid sign, so \cs{@empty} is returned for the sign .
%    \begin{macrocode}
    {\si@log@debug{No sign found for `\si@num@arg'}%
     \renewcommand*{\si@num@sign}{}%
     \protected@edef\si@num@value{#1#2#3}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@num@delplus}
%\begin{macro}{\si@num@killsign}
% A simple spin-out to remove a plus sign.  A flag is set as it might
% be useful to know this.
%    \begin{macrocode}
\newif\ifsi@num@delplus
\newcommand*{\si@num@killsign}{%
  \si@num@delplustrue
  \renewcommand*{\si@num@sign}{}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@addsign}
%\begin{macro}{\si@num@asign}
% The macro to add a sign to an unsigned number has to check whether
% this is a mantissa or an exponent.  The result is still placed in
% \cs{si@num@sign} for ease of processing later.\\
%\cs{si@num@addsign}\marg{mant/exp}\\
%\cs{si@num@asign}\marg{mantissa/exponent}
%    \begin{macrocode}
\newcommand*{\si@num@addsign}[1]{%
  \begingroup
    \renewcommand*{\si@tempa}{#1}%
    \renewcommand*{\si@tempb}{mant}%
    \ifx\si@tempa\si@tempb
      \aftergroup\@firstoftwo
    \else
      \aftergroup\@secondoftwo
    \fi
  \endgroup
  {\ifsi@num@signmant
     \expandafter\si@num@asign
   \else
     \expandafter\@gobble
   \fi
   {mantissa}}
  {\ifsi@num@signexp
     \expandafter\si@num@asign
   \else
     \expandafter\@gobble
   \fi
   {exponent}}}
\newcommand*{\si@num@asign}[1]{%
  \let\si@num@sign\si@sign
  \si@log@debug{Adding sign \si@sign\space to #1 for
    `\si@num@arg'}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@procnum}
% The control macro for processing the number (plus any extra
% characters).
%\cs{si@num@finddigits}\marg{mant/exp}
%    \begin{macrocode}
\newcommand*{\si@num@procnum}[1]{%
  \expandafter\ifx\expandafter\@empty
    \csname si@num@#1\endcsname\@empty
    \expandafter\@gobble
  \else
    \expandafter\si@num@finddigits
  \fi
  {#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@predec}
%\begin{macro}{\si@num@postdec}
% Two new storage areas are defined.
%    \begin{macrocode}
\newcommand*{\si@num@predec}{}
\newcommand*{\si@num@postdec}{}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@finddigits}
% The core digit processor divides the number into the parts before
% and after the decimal point marker.  The temporary switch is used
% to indicate finding a decimal marker.\\
%\cs{si@num@finddigits}\marg{mant/exp}
%    \begin{macrocode}
\newcommand*{\si@num@finddigits}[1]{%
  \renewcommand*{\si@num@predec}{}%
  \renewcommand*{\si@num@postdec}{}%
  \si@switchfalse
  \expandafter\expandafter\expandafter\si@num@digits
    \csname si@num@#1\endcsname\@empty\@empty
%    \end{macrocode}
% Tests are now made to see if padding zeros are needed.  The
% trailing test needs to verify if a decimal marker was found, as
% well as if a zero is needed.
%    \begin{macrocode}
  \ifx\@empty\si@num@predec\@empty
    \ifsi@num@padlead
      \expandafter\expandafter\expandafter\si@num@addprezero
    \fi
  \fi
  \ifx\@empty\si@num@postdec\@empty
    \ifsi@num@padtrail
      \ifsi@switch
        \expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter
          \si@num@addpostzero
      \fi
    \fi
  \fi
%    \end{macrocode}
% The next checks to make concern input validity in a more
% mathematical sense.  First, if the number is zero, then no sign
% should be given under any circumstances.  Then leading zeros need
% to be removed from the input.  This is slightly complicated by the
% potential presence of ``extra'' characters.
%    \begin{macrocode}
  \si@num@unsign{#1}%
  \ifx\@empty\si@num@predec\@empty
  \else
    \expandafter\si@num@nozero
  \fi
%    \end{macrocode}
% A sanity check is made to ensure that the supplied number consisted
% of more than a decimal marker.
%    \begin{macrocode}
  \ifx\@empty\si@num@predec\@empty
    \ifx\@empty\si@num@postdec\@empty
      \expandafter\expandafter\expandafter\@gobble
    \else
      \expandafter\expandafter\expandafter\si@num@sepdigits
    \fi
  \else
    \expandafter\si@num@sepdigits
  \fi
  {#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@digits}
%\begin{macro}{\si@num@pre}
%\begin{macro}{\si@num@post}
%\begin{macro}{\si@num@prepost}
% The \cs{si@num@digits} macro compares each character in the input
% against the list of characters valid at this stage: numbers,
% decimal markers and ``extra'' characters.
%\cs{si@num@digits}\meta{char}\meta{chars}\cs{@empty}\\
%\cs{si@num@pre}\marg{num}\\
%\cs{si@num@pre}\marg{num}\\
%\cs{si@num@prepost}\marg{num}\marg{pre/post}\marg{text}
%    \begin{macrocode}
\def\si@num@digits#1#2\@empty{%
  \si@str@ifchrstr{#1}{\si@numdecimal}
    {\ifsi@switch
       \si@log@err{Duplicate decimal marker in `\si@num@arg'}
         {Only a single decimal marker (from the list
            `\si@numdecimal')\MessageBreak may occur in a
            numerical argument}%
     \else
       \si@log@debug{Found decimal marker `#1' in
         `\si@num@arg'}%
       \expandafter\si@switchtrue
     \fi}
%    \end{macrocode}
% The earlier code only checks for a sign at the start of the text. A
% check is therefore needed for a sign after the first two
% characters; if one is found, it is ignored.
%    \begin{macrocode}
    {\si@str@ifchrstr{#1}{\si@numsign}
       {\si@log@err{Misplaced sign character
          `#1' in `\si@num@arg'}
          {Sign characters `\si@numsign' can only
            occur\MessageBreak at the start of a number}}
%    \end{macrocode}
% The current character is added to the appropriate stack; this is
% ``spun out'' to avoid problems with expansion of the switch code.
%    \begin{macrocode}
       {\ifsi@switch
          \expandafter\si@num@post
        \else
          \expandafter\si@num@pre
        \fi
        {#1}}}%
  \ifx\@empty#2\@empty\else
    \si@num@digits#2\@empty\@empty
  \fi}
\newcommand*{\si@num@pre}[1]{%
  \si@num@prepost{#1}{pre}{integer}}
\newcommand*{\si@num@post}[1]{%
  \si@num@prepost{#1}{post}{decimal}}
\newcommand*{\si@num@prepost}[3]{%
  \expandafter\protected@edef\csname si@num@#2dec\endcsname{%
    \csname si@num@#2dec\endcsname#1}%
  \si@log@debug{Adding `#1' to #3 part for `\si@num@arg'}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@addprezero}
%\begin{macro}{\si@num@addpostzero}
%\begin{macro}{\si@num@addpzero}
% A similar set of macros are used for the padding zeros.\\
%\cs{si@num@addpzero}\marg{pre/post}\marg{text}
%    \begin{macrocode}
\newcommand*{\si@num@addprezero}{%
  \si@num@addpzero{pre}{leading}}
\newcommand*{\si@num@addpostzero}{%
  \si@num@addpzero{post}{trailing}}
\newcommand*{\si@num@addpzero}[2]{%
  \si@log@debug{Adding #2 zero for `\si@num@arg'}%
  \@namedef{si@num@#1dec}{0}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@unsign}
%\begin{macro}{\si@num@nosign}
% The trap for a sign with zero numerical input is made.  First, a
% check is made to see if there is a sign to worry about.  The pre-
% and post-decimal parts are then examined, to see if they contain
% something other than ``0'' or an extra character.\\
%\cs{si@num@unsign}\marg{mant/exp}\\
%\cs{si@num@nosign}\marg{mant/exp}
%    \begin{macrocode}
\newcommand*{\si@num@unsign}[1]{%
  \expandafter\ifx\expandafter\@empty
    \csname si@num@#1sign\endcsname\@empty
    \expandafter\@gobble
  \else
    \expandafter\si@num@nosign
  \fi
  {#1}}
\newcommand*{\si@num@nosign}[1]{%
  \begingroup
    \si@switchtrue
    \si@str@ifonlychrs{\si@num@predec\si@num@postdec}{0}
      {\si@switchfalse}{}%
    \ifsi@switch
      \aftergroup\@gobble
    \else
      \aftergroup\@firstofone
    \fi
  \endgroup
  {\si@log@debug{Zero value: removing any sign}%
   \ifsi@ang@sign\else
     \@namedef{si@num@#1sign}{}%
   \fi}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@nozero}
%  A very short test for a totally zero pre-decimal component.
%    \begin{macrocode}
\newcommand*{\si@num@nozero}{%
  \si@str@ifonlychrs{\si@num@predec}{0}
    {\renewcommand*{\si@num@predec}{0}}{}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@decimalhook}
% A hook is needed to attach things inside the group to happen
% afterwards, if the number is a decimal.
%    \begin{macrocode}
\newcommand*{\si@num@decimalhook}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@sepdigits}
% The \cs{si@num@sepdigits} macro is only called if at least one of
% the mantissa and exponent contain something to output.\\
%\cs{si@num@sepdigits}\marg{mant/exp}
%    \begin{macrocode}
\newcommand*{\si@num@sepdigits}[1]{%
%    \end{macrocode}
% First an overall check is needed for additional characters.  By
% altering the contents of \cs{si@numextra}, the same code can be
% shared by two different checks.
%    \begin{macrocode}
  \begingroup
    \let\si@numextra\si@numaddn
    \protected@edef\si@tempa{\si@num@predec\si@num@postdec}%
    \si@num@ifextra{\si@tempa}
      {\aftergroup\@gobble}
      {\aftergroup\@firstofone}%
  \endgroup
%    \end{macrocode}
% Separation of the error in a number from the number itself is only
% attempted for the mantissa.
%    \begin{macrocode}
  {\renewcommand*{\si@tempb}{mant}%
   \renewcommand*{\si@tempc}{#1}%
   \ifx\si@tempb\si@tempc
     \expandafter\si@num@checkerr
   \fi}%
%    \end{macrocode}
% If both parts of the number contain only digits, then any rounding
% can be attempted if there is no error part.  Otherwise, the input
% must be left alone.
%    \begin{macrocode}
  \protected@edef\si@tempa{\si@num@predec\si@num@postdec}%
  \expandafter\si@str@ifonlychrs\expandafter{\si@tempa}
    {0123456789}
    {\ifx\@empty\si@num@err\@empty
       \ifsi@fixdp
         \expandafter\expandafter\expandafter\si@num@fixdp
       \fi
     \fi}{}%
%    \end{macrocode}
% If the pre-decimal part contains nothing except numbers, then
% digit separation is carried out.
%    \begin{macrocode}
  \si@num@ifextra{\si@num@predec}{}
    {\expandafter\si@num@int\expandafter{\si@num@predec}}%
%    \end{macrocode}
% A decision is made about the decimal sign, then digit separation
% occurs on the post-decimal part of the number.
%    \begin{macrocode}
  \renewcommand*{\si@tempc}{}%
  \ifx\@empty\si@num@postdec\@empty\else
    \si@num@decimalhook
    \renewcommand*{\si@tempc}{%
      \ensuremath{{\si@decimalsymbol}}}%
    \si@num@ifextra{\si@num@postdec}{}
      {\expandafter\si@num@dec\expandafter{\si@num@postdec}}%
  \fi
%    \end{macrocode}
% The construction is finalised by re-combining the number.
%    \begin{macrocode}
  \expandafter\protected@edef\csname si@num@#1\endcsname
    {\si@num@predec\si@tempc\si@num@postdec}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@ifextra}
%\begin{macro}{\si@num@extra}
% A relatively simple test for ``extra'' characters.  Once again, a
% bit of group trickery is used.\\
%\cs{si@num@ifextra}\marg{integer}\\
%\cs{si@num@extra}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@ifextra}[1]{%
  \begingroup
    \si@switchfalse
    \expandafter\si@num@extra#1\@empty\@empty
    \ifsi@switch
      \si@log@debug{Found `extra' characters in `#1'}%
      \aftergroup\@firstoftwo
    \else
      \aftergroup\@secondoftwo
    \fi
  \endgroup}
\def\si@num@extra#1#2\@empty{%
  \ifx\@empty#1\@empty\else
    \si@str@ifchrstr{#1}{\si@numextra}{\si@switchtrue}{}%
    \ifx\@empty#2\@empty\else
      \si@num@extra#2\@empty\@empty
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@num@ambigerr}
%\begin{macro}{\si@num@checkerr}
% When separating out an error from a number, the first step is to
% see if there is a decimal part to the number.  If so, any error
% must be in that part of the decimal part; it is not possible to
% have an error starting in the integer part and continuing into the
% decimal part.
%    \begin{macrocode}
\newif\ifsi@num@ambigerr
\newcommand*{\si@num@checkerr}{%
  \ifx\@empty\si@num@postdec\@empty
    \expandafter\si@num@preerr
  \else
    \expandafter\si@num@posterr
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@preerr}
% Errors in integers are easy to handle.  After finding the error,
% the result is simply stored in the error macro \cs{si@num@err}.
%    \begin{macrocode}
\newcommand*{\si@num@preerr}{%
  \si@num@seperr{pre}%
  \ifx\@empty\si@tempb\@empty\else
    \expandafter\renewcommand\expandafter*\expandafter
      \si@num@err\expandafter{\si@tempb}%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@posterr}
%\begin{macro}{\si@num@psterr}
% Life is more complex for an error in the decimal part.  This is
% found, then it may need zero-filling or the insertion of a decimal
% point.  This depends on whether the number of error digits is
% larger than the number of post-decimal digits.
%    \begin{macrocode}
\newcommand*{\si@num@posterr}{%
  \si@num@seperr{post}%
  \ifx\@empty\si@tempb\@empty\else
    \ifsi@seperr
      \expandafter\expandafter\expandafter\si@num@psterr
    \else
      \let\si@num@err\si@tempb
    \fi
  \fi}
\newcommand*{\si@num@psterr}{%
    \si@num@cntdigits{\si@tempb}%
    \si@tempcntb\si@tempcnta\relax
    \si@num@cntdigits{\si@num@postdec}%
    \ifnum\si@tempcnta<\si@tempcntb\relax
      \expandafter\si@num@largeerr
    \else
      \expandafter\si@num@smallerr
    \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@seperr}
%\begin{macro}{\si@num@finderr}
% The usual hand-off is made for searching for an error.\\
%\cs{si@num@seperr}\marg{pre/post}\\
%\cs{si@num@finderr}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@seperr}[1]{%
  \si@switchfalse
  \renewcommand*{\si@tempa}{}%
  \renewcommand*{\si@tempb}{}%
  \expandafter\expandafter\expandafter\si@num@finderr
    \csname si@num@#1dec\endcsname\@empty\@empty
  \ifx\@empty\si@tempb\@empty\else
    \expandafter\let\csname si@num@#1dec\endcsname\si@tempa
  \fi}
\def\si@num@finderr#1#2\@empty{%
%    \end{macrocode}
% First a check for the opening character of an error.
%    \begin{macrocode}
  \si@str@ifchrstr{#1}{\si@numopenerr}
%    \end{macrocode}
% If the switch is set when an error is found, then something is
% wrong.
%    \begin{macrocode}
    {\ifsi@switch
       \si@log@err{Invalid error in number}
         {The numerical argument \si@num@arg\space has two (or
           more)\MessageBreak error-opening characters}%
     \else
       \expandafter\si@switchtrue
     \fi}
%    \end{macrocode}
% The end-of-error character has to be the last item of the input,
% and an error needs to start before it ends.
%    \begin{macrocode}
    {\si@str@ifchrstr{#1}{\si@numcloseerr}
       {\ifsi@switch
          \ifx\@empty#2\@empty\else
            \si@log@err{Invalid error in number}
              {The numerical argument \si@num@arg\space has an
              error-closing before the last character}%
          \fi
        \else
          \si@log@err{Invalid error in number}
           {The numerical argument \si@num@arg\space has an
              error-closing character\MessageBreak but no
              error-opening one}%
        \fi}
%    \end{macrocode}
% The input must be a digit.  It is stored in the appropriate area.
%    \begin{macrocode}
       {\ifsi@switch
          \expandafter\si@num@addtmpb
        \else
          \expandafter\si@num@addtmpa
        \fi
        {#1}}}%
  \ifx\@empty#2\@empty\else
    \si@num@finderr#2\@empty
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@addtmpa}
%\begin{macro}{\si@num@addtmpb}
%\begin{macro}{\si@num@addtmp}
% Some quick methods for adding to the temporary macros with \cs{if}
% expansion.\\
%\cs{si@num@addtmpa}\marg{num}\\
%\cs{si@num@addtmpb}\marg{num}\\
%\cs{si@num@addtmp}\marg{a/b}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@num@addtmpa}[1]{\si@num@addtmp{a}{#1}}
\newcommand*{\si@num@addtmpb}[1]{\si@num@addtmp{b}{#1}}
\newcommand*{\si@num@addtmp}[2]{%
  \expandafter\protected@edef\csname si@temp#1\endcsname{%
    \csname si@temp#1\endcsname#2}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@cntdigits}
%\begin{macro}{\si@num@cntdgt}
% A recursive system for counting the number of characters in a given
% input; only used here to count digits in a number.\\
%\cs{si@num@cntdigits}\marg{num}\\
%\cs{si@num@cntdgt}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@cntdigits}[1]{%
  \si@tempcnta\z@\relax
  \expandafter\si@num@cntdgt#1\@empty\@empty}
\def\si@num@cntdgt#1#2\@empty{%
  \ifx\@empty#1\@empty\else
    \advance\si@tempcnta\@ne\relax
  \fi
  \ifx\@empty#2\@empty\else
    \expandafter\si@num@cntdgt#2\@empty
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@smallerr}
%\begin{macro}{\si@num@serr}
% For handling an error with no more digits than the post-decimal
% part of a number, zero-padding is undertaken before adding a
% decimal sign and (possibly) leading zero.
%    \begin{macrocode}
\newcommand*{\si@num@smallerr}{%
  \si@tempcntb\si@tempcnta\relax
  \si@num@serr
  \protected@edef\si@num@err{%
    \ifsi@num@padlead0\fi\expandafter\@car\si@numdecimal\@nil
    \si@tempb}}
\newcommand*{\si@num@serr}{%
  \si@num@cntdigits{\si@tempb}%
  \ifnum\si@tempcnta=\si@tempcntb\relax\else
    \protected@edef\si@tempb{0\si@tempb}%
    \expandafter\si@num@serr
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@largeerr}
%\begin{macro}{\si@num@lerr}
%\begin{macro}{\si@num@movedigit}
% When the error has more digits than the decimal part, some
% shuffling is needed.\\
%\cs{si@num@movedigit}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@largeerr}{%
  \renewcommand*{\si@tempa}{}%
  \si@tempcntb\si@tempcnta\relax
  \si@num@lerr
  \protected@edef\si@num@err{%
    \si@tempa\ensuremath{\si@decimalsymbol}\si@tempb}}
\newcommand*{\si@num@lerr}{%
  \si@num@cntdigits{\si@tempb}%
  \ifnum\si@tempcnta=\si@tempcntb\relax\else
    \expandafter\si@num@movedigit\si@tempb\@empty\@empty
    \si@num@lerr
  \fi}
\def\si@num@movedigit#1#2\@empty{%
  \protected@edef\si@tempa{\si@tempa#1}%
  \protected@edef\si@tempb{#2}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@fixdp}
% The test for fixing decimal places starts by counting up the number
% of decimal digits.  The number is then padded, rounded or left
% alone.
%    \begin{macrocode}
\newcommand*{\si@num@fixdp}{%
  \si@num@cntdigits{\si@num@postdec}%
  \ifx\@empty\si@num@postdec\@empty
    \si@tempcnta\z@\relax
  \fi
  \ifnum\si@tempcnta>\si@num@dp\relax
    \expandafter\si@num@round
  \else
    \ifnum\si@tempcnta<\si@num@dp\relax
      \expandafter\expandafter\expandafter\si@num@pad
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@pad}
%\begin{macro}{\si@num@pd}
% Padding a number is a relatively easy matter.  The number of digits
% is increased by adding ``$0$'' recursively.
%    \begin{macrocode}
\newcommand*{\si@num@pad}{%
  \si@log@debug{Padding to \the\si@num@dp\space digits}%
  \loop\ifnum\si@tempcnta<\si@num@dp\si@num@pd\repeat}
\newcommand*{\si@num@pd}{%
  \advance\si@tempcnta\@ne\relax
  \protected@edef\si@num@postdec{\si@num@postdec0}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@round}
%\begin{macro}{\si@num@prernd}
%\begin{macro}{\si@num@postrnd}
%\begin{macro}{\si@num@reverse}
%\begin{macro}{\si@num@rev}
% Rounding a number is more complicated.  The main macro here relies
% on several others.  The initial stage is to reverse the entire
% number, to make life easier.  This is then undone by the other
% macros as the output is constructed.\\
%\cs{si@num@reverse}\marg{macro}\\
%\cs{si@num@rev}\meta{char}\meta{chars}\cs{@empty}
%    \begin{macrocode}
\newcommand*{\si@num@prernd}{}
\newcommand*{\si@num@postrnd}{}
\newcommand*{\si@num@round}{%
  \si@log@debug{Rounding to \the\si@num@dp\space digits}%
  \si@num@reverse{\si@num@postdec}%
  \si@num@reverse{\si@num@predec}%
  \let\si@num@prernd\si@num@predec
  \let\si@num@postrnd\si@num@postdec
  \renewcommand*{\si@num@predec}{}%
  \renewcommand*{\si@num@postdec}{}%
  \si@switchfalse
  \si@num@rnd}
\newcommand*{\si@num@reverse}[1]{%
  \renewcommand*{\si@tempa}{}%
  \expandafter\si@num@rev#1\@empty\@empty
  \let#1\si@tempa}
\def\si@num@rev#1#2\@empty{%
  \edef\si@tempa{#1\si@tempa}%
  \ifx\@empty#2\@empty\else
    \si@num@rev#2\@empty\@empty
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@rnd}
%\begin{macro}{\si@num@rndpre}
%\begin{macro}{\si@num@rndpost}
%\changes{v1.0b}{2008/06/23}{Corrected bug in rounding code}
% The core looping macro of the system simply divides the flow
% between rounding before and after the decimal.  The two routines
% are quite similar, but have subtly different requirements.  Both
% take one character at a time from the input, increment if there is
% a carry digit, check its value, and add to the output string.
%    \begin{macrocode}
\newcommand*{\si@num@rnd}{%
  \ifnum\si@tempcnta>\z@\relax
    \expandafter\si@num@rndpost
  \else
    \expandafter\si@num@rndpre
  \fi}
\newcommand*{\si@num@rndpre}{%
  \expandafter\edef\expandafter\si@tempa\expandafter{%
    \expandafter\@car\si@num@prernd\@nil}%
  \expandafter\edef\expandafter\si@num@prernd\expandafter{%
    \expandafter\@cdr\si@num@prernd\@nil}%
  \si@tempcntb\si@tempa\relax
  \ifsi@switch
    \advance\si@tempcntb\@ne\relax
  \fi
  \si@switchfalse
  \ifnum\si@tempcntb=10\relax
    \si@tempcntb\z@\relax
    \expandafter\expandafter\expandafter\si@switchtrue
  \fi
  \edef\si@num@predec{\the\si@tempcntb\si@num@predec}%
  \ifx\@empty\si@num@prernd\@empty
    \ifsi@switch
      \edef\si@num@predec{1\si@num@predec}%
    \fi
  \else
    \expandafter\si@num@rnd
  \fi}
\newcommand*{\si@num@rndpost}{%
  \expandafter\edef\expandafter\si@tempa\expandafter{%
    \expandafter\@car\si@num@postrnd\@nil}%
  \expandafter\edef\expandafter\si@num@postrnd\expandafter{%
    \expandafter\@cdr\si@num@postrnd\@nil}%
  \si@tempcntb\si@tempa\relax
  \ifsi@switch
    \advance\si@tempcntb\@ne\relax
  \fi
  \si@switchfalse
  \advance\si@num@dp\@ne\relax
  \ifnum\si@tempcnta>\si@num@dp\relax
    \advance\si@num@dp\m@ne\relax
  \else
    \advance\si@num@dp\m@ne\relax
    \ifnum\si@tempcnta>\si@num@dp\relax
      \ifnum\si@tempcntb>4\relax
        \expandafter\expandafter\expandafter\si@switchtrue
      \fi
    \else
      \ifnum\si@tempcntb=10\relax
        \si@tempcntb\z@\relax
        \expandafter\expandafter\expandafter\si@switchtrue
      \fi
      \edef\si@num@postdec{\the\si@tempcntb\si@num@postdec}%
    \fi
  \fi
  \advance\si@tempcnta\m@ne\relax
  \si@num@rnd}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@int}
% The formatting code for separating thousands is taken more-or-less
% directly from \SIstyle.  A few changes are made to fit the various
% conventions here.  Following on from the code above, \cs{si@tempa}
% is used to store the integer part of the number, and \cs{si@tempb}
% is used for the decimal part.\\
%\cs{si@num@int}\marg{integer-part}
%    \begin{macrocode}
\newcommand*{\si@num@int}[1]{%
  \renewcommand*{\si@num@predec}{}%
  \ifsi@sepfour
    \si@num@intfmt{}#1\@empty\@empty\@empty
  \else
    \si@num@iffive{#1}
      {\si@num@intfmt{}#1\@empty\@empty\@empty}
      {\renewcommand*{\si@num@predec}{#1}}%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@iffive}
%\begin{macro}{\si@num@five}
% A test is needed for the presence of more than four characters.\\
%\cs{si@num@iffive}\marg{num}\\
%\cs{si@num@five}\meta{char}\meta{char}\meta{char}\meta{char}^^A
%\meta{chars}\cs{end}
%    \begin{macrocode}
\newcommand*{\si@num@iffive}[1]{%
  \si@num@five#1\@empty\@empty\@empty\@empty\@empty\end}
\def\si@num@five#1#2#3#4#5\end{%
   \ifx\@empty#5\@empty
      \expandafter\@secondoftwo
   \else
      \expandafter\@firstoftwo
   \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@intfmt}
%\begin{macro}{\si@num@fiint}
% The business end of the integer formatter.\\
%\cs{si@num@intfmt}\marg{char}\marg{char}\marg{char}\marg{char}\\
%\cs{si@num@fiint}\meta{chars}\cs{fi}\cs{fi}\cs{fi}
%    \begin{macrocode}
\newcommand*{\si@num@intfmt}[4]{%
  \ifx\@empty#2\@empty
    \si@num@intsep#1\relax
  \else
    \ifx\@empty#3\@empty
      \si@num@intsep\@empty\@empty#1#2\relax
    \else
      \ifx\@empty#4\@empty
        \si@num@intsep\@empty#1#2#3\relax
      \else
        \si@num@fiint{#1#2#3#4}%
      \fi
    \fi
  \fi}
\def\si@num@fiint#1\fi\fi\fi{\fi\fi\fi\si@num@intfmt{#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@intsep}
% For adding separation to integers, an extra function is needed.\\
%\cs{si@num@intsep}\marg{char}\marg{char}\marg{char}\marg{char}
%    \begin{macrocode}
\newcommand*{\si@num@intsep}[4]{%
  \protected@edef\si@num@predec{\si@num@predec#1#2#3}%
  \if\relax#4\relax\else
    \protected@edef\si@num@predec{%
      \si@num@predec\ensuremath{\noexpand\si@digitsep}}%
    \expandafter\si@num@intsep\expandafter#4%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@dec}
%\begin{macro}{\si@num@decfmt}
% Formatting a decimal uses a similar mechanism, but with a few
% alterations needed.\\
%\cs{si@num@dec}\marg{decimal-part}\\
%\cs{si@num@decfmt}\marg{char}\marg{char}\marg{char}\marg{char}
%    \begin{macrocode}
\newcommand*{\si@num@dec}[1]{%
  \renewcommand*{\si@num@postdec}{}%
  \ifsi@sepfour
    \si@num@decfmt#1\@empty\@empty\@empty\@empty
  \else
    \si@num@iffive{#1}
      {\si@num@decfmt#1\@empty\@empty\@empty\@empty}
      {\protected@edef\si@num@postdec{\si@num@postdec#1}}%
  \fi}
\newcommand*{\si@num@decfmt}[4]{%
  \protected@edef\si@num@postdec{\si@num@postdec#1#2#3}%
  \ifx\@empty#4\@empty%
  \else
    \protected@edef\si@num@postdec{%
      \si@num@postdec\ensuremath{\noexpand\si@digitsep}}%
    \expandafter\si@num@decfmt\expandafter#4%
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@num@procerr}
% Any error is recycled to to formatted correctly.  The $\pm$ sign,
% and any unit, are also added.
%    \begin{macrocode}
\newcommand*{\si@num@procerr}{%
  \si@num@addunit
  \ensuremath{\si@pm}%
  \expandafter\si@num\expandafter{\si@num@err}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@sepxpart}
% A similar approach for numbers containing products, except the
% first token of the input has to be deleted.
%    \begin{macrocode}
\newcommand*{\si@num@sepxpart}{%
  \si@num@addunit
  \ensuremath{\times}%
  \expandafter\expandafter\expandafter\si@num\expandafter
    \expandafter\expandafter{%
      \expandafter\@cdr\si@num@xpart\@nil}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@num@addunit}
% A short macro to add units if needed.
%    \begin{macrocode}
\newcommand*{\si@num@addunit}{%
  \si@unt@numtrue
  \ifx\@empty\si@unt@unitarg\@empty\else
    \ifsi@repeatunits
      \si@unt@printunit{\si@unt@unitarg}%
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Formatting angles}
%\begin{macro}{\ang}
% The approach used here is similar to that in \SIstyle, but has been
% modified in a few ways.\\
%\cs{ang}\oarg{options}\marg{decimal-angle}\\
%\cs{ang}\oarg{options}|{|\meta{deg};\meta{min};\meta{sec}|}|
%    \begin{macrocode}
\si@newrobustcmd*{\ang}[2][]{%
  \begingroup
    \sisetup{#1}%
    \si@fam@mode
    \si@log@debug{Processing \string\ang\space input `#2'}%
    \@makeother{\;}%
    \makeatletter
    \scantokens{\si@ang@parse#2;;;\@nil}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@ang@parse}
% With the correct catcodes in place, processing can take place strip
% out the semi-colons.  Here, the input must either contain no
% semi-colons or two semi-colons.\\
%\cs{si@ang@parse}\meta{num}|;|\meta{num}|;|\meta{num}|;|^^A
%\meta{chars}\cs{@nil}
%    \begin{macrocode}
\def\si@ang@parse#1;#2;#3;#4\@nil{%
  \let\ifsi@ang@fixdp\ifsi@fixdp
  \si@fixdpfalse
  \si@ifmtarg{#4}
    {\si@log@debug{Angle argument contains no
       semi-colons:\MessageBreak decimal angle}%
     \si@ang@dec{#1}{}{}}
    {\si@log@debug{Angle argument contains
       semi-colons:\MessageBreak degree-minute-second angle}%
     \renewcommand*{\si@tempa}{#4}%
     \renewcommand*{\si@tempb}{;;}%
     \ifx\si@tempa\si@tempb\else
       \ifsi@strictarc
         \renewcommand*{\si@tempb}{;}%
         \ifx\si@tempa\si@tempb
           \si@log@err{Insufficient semi-colons in argument
             of \string\ang}{The argument of
             \string\ang\space  must contain either no
             semi-colons or exactly two}%
         \else
           \si@log@err{Excess semi-colons in argument of
             \string\ang}{The argument of \string\ang\space
             must contain either no semi-colons or exactly
             two}%
         \fi
       \fi
     \fi
     \si@ang@arc{#1}{#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@ang@dec}
%\begin{macro}{\si@ang@arc}
% Two tests are needed, in case the input format requires conversion.
%    \begin{macrocode}
\newcommand*{\si@ang@dec}{%
  \let\si@ang@fix\@gobble
  \ifsi@ang@toarc
    \expandafter\si@ang@dectoarc
  \else
    \sisetup{padangle=none}\expandafter\si@ang@typeset
  \fi}
\newcommand*{\si@ang@arc}{%
  \let\si@ang@fix\si@ang@arcfix
  \ifsi@ang@todec
    \expandafter\si@ang@arctodec
  \else
    \expandafter\si@ang@typeset
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@ang@fixdp}
%\begin{macro}{\si@ang@fix}
%\begin{macro}{\si@ang@arcfix}
% A check is needed so that rounding and zero filling are only
% applied to the seconds of an arc angle.
%\cs{si@ang@fix}\marg{degree/minute/second}\\
%\cs{si@ang@arcfix}\marg{degree/minute/second}
%    \begin{macrocode}
\newif\ifsi@ang@fixdp
\newcommand*{\si@ang@fix}[1]{}
\newcommand*{\si@ang@arcfix}[1]{%
  \renewcommand*{\si@tempa}{second}%
  \renewcommand*{\si@tempb}{#1}%
  \ifx\si@tempa\si@tempb
    \ifsi@ang@fixdp
      \expandafter\expandafter\expandafter\si@fixdptrue
    \else
      \expandafter\expandafter\expandafter\si@fixdpfalse
    \fi
  \else
    \expandafter\si@fixdpfalse
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ang@ifnum}
% A test is required to check that the provided data consists of
% numbers which can actually be processed by \TeX.  This is achieved
% by using \cs{si@num@ifvalid} with a fixed list of valid
% characters.\\
%\cs{si@ang@ifnum}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@ang@ifnum}[1]{%
  \begingroup
    \renewcommand*{\si@numvalid}{0123456789,.+-}%
    \ifx\@empty#1\@empty
      \aftergroup\@firstoftwo
    \else
      \si@num@ifvalid{#1}
        {\aftergroup\@firstoftwo}
        {\aftergroup\@secondoftwo}%
    \fi
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@ang@arctodec}
% The business end of converting arcs to decimal angles is relatively
% straight-forward, as it only needs one calculation.  This has to be
% divided up, so that disaster does not strike if there are empty
% arguments; a check is also needed for the sign of the angle,
% so that the maths makes sense.\\
%\cs{si@ang@arctodec}\marg{dec}\marg{min}\marg{sec}
%    \begin{macrocode}
\newcommand*{\si@ang@arctodec}[3]{%
  \let\si@ang@fix\@gobble
  \ifnum\si@num@dp>\thr@@\relax
    \si@num@dp\thr@@\relax
  \fi
  \si@fixdptrue
  \si@ang@ifnum{#1}
    {\si@ang@ifnum{#2}
      {\si@ang@ifnum{#3}
        {\si@tempdima\z@\relax
         \renewcommand*{\si@tempa}{+}%
         \ifx\@empty#1\@empty\else
           \si@tempdima #1pt\relax
         \fi
         \ifdim\si@tempdima<\z@\relax
           \renewcommand*{\si@tempa}{-}%
         \fi
         \ifx\@empty#2\@empty\else
           \si@tempdima\dimexpr\si@tempdima\si@tempa
             #2pt/60\relax
         \fi
         \ifdim\si@tempdima<\z@\relax
           \renewcommand*{\si@tempa}{-}%
         \else
         \fi
         \ifx\@empty#3\@empty\else
           \si@tempdima\dimexpr\si@tempdima\si@tempa
             #3pt/3600\relax
         \fi
         \sisetup{numdecimal=.}%
         \expandafter\si@ang@typeset\expandafter{%
           \strip@pt\si@tempdima}{}{}}
        {\si@ang@notnum{#1}{#2}{#3}}}
      {\si@ang@notnum{#1}{#2}{#3}}}
    {\si@ang@notnum{#1}{#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@ang@dectoarc}
%\begin{macro}{\si@ang@arcdeg}
%\begin{macro}{\si@ang@arcmin}
%\begin{macro}{\si@ang@arcsec}
% The conversion macros for decimal to arc angles.  Life is more
% complex here than above, even without the need for checks on the
% input.  A number of separation steps are needed, each of which
% needs a separate macro.\\
%\cs{si@ang@dectoarc}\marg{angle}
%    \begin{macrocode}
\newcommand*{\si@ang@dectoarc}[1]{%
  \let\si@ang@fix\si@ang@arcfix
  \si@ang@fixdptrue
  \ifnum\si@num@dp>\@ne\relax
    \si@num@dp\@ne\relax
  \fi
  \si@ang@ifnum{#1}
    {\si@tempdima\z@\relax
     \ifx\@empty#1\@empty\else
       \si@tempdima #1pt\relax
     \fi
     \si@ang@sepint{deg}%
     \si@tempdima\dimexpr\si@tempdima *60\relax
     \si@ang@sepint{min}%
     \edef\si@tempa{\the\dimexpr\si@tempdima *60\relax}%
     \expandafter\newcommand\expandafter*\expandafter{%
       \expandafter\si@ang@arcsec\expandafter}\expandafter{%
       \expandafter\si@ang@strippt\si@tempa}%
%    \end{macrocode}
% A check is made for ``0.0'' seconds, which should be converted to
% simply ``0''.
%    \begin{macrocode}
     \si@tempdima\z@\relax
     \edef\si@tempa{\the\si@tempdima}%
     \expandafter\renewcommand\expandafter*\expandafter{%
       \expandafter\si@tempa\expandafter}\expandafter{%
       \expandafter\si@ang@strippt\si@tempa}%
     \ifx\si@tempa\si@ang@arcsec
       \renewcommand*{\si@ang@arcsec}{0}%
     \fi
%    \end{macrocode}
% To avoid adding zeros where they are not required, each part of the
% angle is now checked.
%    \begin{macrocode}
     \renewcommand*{\si@tempa}{0}%
     \ifx\si@ang@arcdeg\si@tempa
       \si@temptoks{{}}%
     \else
       \si@temptoks{{\si@ang@arcdeg}}%
     \fi
     \ifx\si@ang@arcmin\si@tempa
       \si@temptoks\expandafter{\the\si@temptoks{}}%
     \else
       \si@temptoks\expandafter{\the\si@temptoks{%
         \si@ang@arcmin}}%
     \fi
     \ifx\si@ang@arcsec\si@tempa
       \si@temptoks\expandafter{\the\si@temptoks{}}%
     \else
       \si@temptoks\expandafter{\the\si@temptoks{%
         \si@ang@arcsec}}%
     \fi
     \expandafter\si@ang@typeset\the\si@temptoks}
    {\si@ang@notnum{#1}{}{}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ang@sepint}
%\begin{macro}{\si@ang@sint}
%\begin{macro}{\si@ang@strippt}
% Support macros for the conversion from decimal to arc angles.\\
%\cs{si@ang@sepint}\marg{deg/min}\\
%\cs{si@ang@sint}\meta{chars}.\meta{chars}\cs{@empty}\\
%\cs{si@ang@strippt}\meta{chars}\texttt{pt}
%    \begin{macrocode}
\newcommand*{\si@ang@sepint}[1]{%
  \expandafter\si@ang@sint\the\si@tempdima\@empty
  \expandafter\let\csname si@ang@arc#1\endcsname\si@tempa}
\def\si@ang@sint#1.#2\@empty{%
  \renewcommand*{\si@tempa}{#1}%
  \si@tempdima 0.#2\relax}
\begingroup
  \catcode`P=12
  \catcode`T=12
  \lowercase{
    \renewcommand*{\si@tempa}{%
      \def\si@ang@strippt##1PT{##1}}}
  \expandafter\endgroup
\si@tempa
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ang@notnum}
% Not a \TeX\ number: complain.\\
%\cs{si@ang@notnum}\marg{dec}\marg{min}\marg{sec}
%    \begin{macrocode}
\newcommand*{\si@ang@notnum}[3]{%
  \si@log@warn{Angle `#1;#2;#3' is not a pure
    number:\MessageBreak output will be as given}%
  \si@ang@typeset{#1}{#2}{#3}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@ang@sign}
% A flag is needed to leave signs along for angles, where
% a zero value may still need a sign.
%    \begin{macrocode}
\newif\ifsi@ang@sign
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@ang@typeset}
% The \cs{si@ang@set} macro does the work of assigning the degrees,
% minutes and seconds, and actually typesetting the result.\\
%\cs{si@ang@typeset}\marg{num}\marg{num}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@ang@typeset}[3]{%
%    \end{macrocode}
%\begin{macro}{\si@ang@degs}
%\begin{macro}{\si@ang@mins}
%\begin{macro}{\si@ang@secs}
% First, the three macros that will contain the measures must exist.
%    \begin{macrocode}
  \ifsi@ang@padlarge
    \newcommand*{\si@ang@degs}{0\si@sym@degree}%
    \newcommand*{\si@ang@mins}{0\si@sym@minute}%
    \newcommand*{\si@ang@secs}{0\si@sym@second}%
  \else
    \newcommand*{\si@ang@degs}{}%
    \newcommand*{\si@ang@mins}{}%
    \newcommand*{\si@ang@secs}{}%
  \fi
  \protected@edef\si@ang@decimalsymbol{\si@decimalsymbol}%
%    \end{macrocode}
%\begin{macro}{\si@ang@movesign}
% Either the signs need to be moved, or this needs to be killed off.
%    \begin{macrocode}
  \ifsi@astroang
    \let\si@ang@movesign\si@ang@astrosign
  \else
    \let\si@ang@movesign\@gobble
  \fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@ang@secnum}
%\begin{macro}{\si@ang@minnum}
% The arguments are now examined in reverse order.  If they are
% empty, then nothing is done.  Otherwise, the larger measures are
% zero-filled, if this has been requested. Some steps are needed
% to allow for addition of signs to numbers.
%    \begin{macrocode}
  \newcommand*{\si@ang@secnum}{\si@ang@num{second}}%
  \newcommand*{\si@ang@minnum}{\si@ang@num{minute}}%
   \si@ifnotmtarg{#3}
     {\si@log@debug{Found seconds `#3'}%
      \si@ang@ifnum{#3}
        {\ifdim #3 pt=\z@\relax\else
           \si@ang@signtrue
         \fi}{}%
      \renewcommand*{\si@ang@secs}
       {\si@ang@secnum{#3}\si@sym@second}%
      \renewcommand*{\si@ang@mins}
        {\si@ang@pad{0\si@sym@minute}}%
      \renewcommand*{\si@ang@degs}
        {\si@ang@pad{0\si@sym@degree}}}%
   \si@ifnotmtarg{#2}
     {\si@log@debug{Found minutes `#2'}%
      \si@ang@ifnum{#2}
        {\ifdim #2 pt=\z@\relax\else
           \si@ang@signtrue
         \fi}{}%
      \renewcommand*{\si@ang@secnum}{%
        \si@ang@signlessnum{second}}%
      \renewcommand*{\si@ang@mins}
       {\si@ang@minnum{#2}\si@sym@minute}%
      \renewcommand*{\si@ang@degs}
        {\si@ang@pad{0\si@sym@degree}}}%
   \si@ifnotmtarg{#1}
     {\si@log@debug{Found degrees `#1'}%
      \renewcommand*{\si@ang@secnum}{%
        \si@ang@signlessnum{second}}%
      \renewcommand*{\si@ang@minnum}{%
        \si@ang@signlessnum{minute}}%
      \renewcommand*{\si@ang@degs}
%    \end{macrocode}
% The group here is needed to get the mechanism to move the symbol to
% work properly.
%    \begin{macrocode}
       {\si@ang@num{degree}{#1}%
        \si@sym@degree}}%
   \si@out@num
     {\si@ang@degs\si@anglesep\si@ang@mins\si@anglesep
        \si@ang@secs}%
%    \end{macrocode}
%\end{macro}
%\end{macro}
% The group opened by \cs{ang} is closed.
%    \begin{macrocode}
   \endgroup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ang@pad}
% Padding is only added if requested; the zero is a literal.\\
%\cs{si@ang@pad}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@ang@pad}[1]{\ifsi@ang@padsmall #1\fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@ang@num}
%\begin{macro}{\si@ang@signlessnum}
% Modified versions of \cs{num}, one to typeset angles without a
% leading sign and the other with.\\
%\cs{si@ang@num}\marg{degree/minute/second}\marg{num}\\
%\cs{si@ang@signlessnum}\marg{degree/minute/second}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@ang@num}[2]{%
  \begingroup
    \si@ang@fix{#1}%
    \si@ang@movesign{#1}%
    \si@num{#2}%
  \endgroup}
\newcommand*{\si@ang@signlessnum}[2]{%
  \begingroup
    \si@ang@fix{#1}%
    \si@ang@movesign{#1}%
    \sisetup{addsign=none}%
    \si@num{#2}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ang@killdegree}
%\begin{macro}{\si@ang@killminute}
%\begin{macro}{\si@ang@killsecond}
%\begin{macro}{\si@ang@astrosign}
%\begin{macro}{\si@ang@decimalsymbol}
% A mechanism is needed to handle moving the angle unit signs for the
% \opt{astroang} option.  This requires two steps, producing the sign
% over the decimal sign and preventing duplicate symbols appearing.
% This is based on a suggestion from Morten H{\o}gholm, but using
% \TeX\ internals as \cs{makebox} does not work here.  Note the need
% to correct for \cs{scriptspace} (thanks to Donald Arseneau for
% that).\\
%\cs{si@ang@astrosign}\marg{degree/minute/second}
%    \begin{macrocode}
\newcommand*{\si@ang@killdegree}{\let\si@sym@degree\relax}
\newcommand*{\si@ang@killminute}{\let\si@sym@minute\relax}
\newcommand*{\si@ang@killsecond}{\let\si@sym@second\relax}
\newcommand*{\si@ang@astrosign}[1]{%
  \renewcommand*{\si@decimalsymbol}{%
    \setbox\si@tempboxa=\hbox{%
      \ensuremath{{\si@ang@decimalsymbol}}}%
    \si@tempdima\wd\si@tempboxa\relax
    \setbox\si@tempboxb=\hbox to\z@{%
      \hss\unhbox\si@tempboxa\hss}%
    \setbox\si@tempboxa=\hbox{%
      \csname si@sym@#1\endcsname\hskip-\scriptspace}%
    \si@tempdimb\wd\si@tempboxa\relax
    \setbox\si@tempboxc=\hbox to\z@{%
      \hss\unhbox\si@tempboxa\hss}%
    \setbox\si@tempboxd=\hbox{%
      \usebox\si@tempboxb\usebox\si@tempboxc}%
    \ifdim\si@tempdima>\si@tempdimb\relax
      \setbox\si@tempboxa=\hbox to\si@tempdima{%
        \hss\unhbox\si@tempboxd\hss}%
    \else
      \setbox\si@tempboxa=\hbox to\si@tempdimb{%
        \hss\unhbox\si@tempboxd\hss}%
    \fi
    \usebox\si@tempboxa%
    \ifdim\si@tempdima>\si@tempdimb\relax\else
      \hskip\scriptspace
    \fi}%
  \renewcommand*{\si@num@decimalhook}{\expandafter\aftergroup
    \csname si@ang@kill#1\endcsname}}%
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Tabular material}
% The automatic formatting and alignment of numerical data in columns
% is handled here.  The various other packages that work in this area
% are basically ripped-off here.  The letters |D|, |N| and |R| are
% already taken by the other packages for numerical alignment, and so
% |S| ($=$ \currpkg) is chosen for the alignment of numerical
% material.  The package also provides a second column type, |s|, for
% units (the letter is taken from \cs{si}).
%
%\begin{macro}{\NC@list}
% The first part of the job is to create the basic apparatus for the
% columns using the \pkg{array} package.  To prevent any issues with
% the content of optional arguments to the new columns, so
% rearrangement is needed.  The \currpkg columns have to come
% \emph{before} any other column definitions.  This is achieved by
% saving \cs{NC@list}, creating the columns then restoring the list
% with the appropriate extra parts.
%    \begin{macrocode}
\edef\si@tempa{%
  \noexpand\NC@do S\noexpand\NC@do s\the\NC@list}
\newcolumntype{S}{}
\newcolumntype{s}{}
\NC@list\expandafter{\si@tempa}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\NC@rewrite@S}
%\begin{macro}{\NC@rewrite@s}
% Following the \numprint approach, the \cs{NC@rewrite@\ldots} macros
% are rewritten to collect the cell contents.  This means messing
% with the internal macros of another package, but there is no other
% way to do this.  As \pkg{array} is a standard package from the
% \pkg{tools} bundle, this should be reasonably safe. Here the begin
% and end code needed is added to the existing list if
% \cs{@temptokena}, with the start and end macros unexpanded.
% Argument |#1| contains any user setup options for this column.
% Passing an argument at this stage will cause issues, so each column
% type needs its own \texttt{begin} and \texttt{end} macros.\\
%\cs{NC@rewrite@S}\oarg{options}
%\cs{NC@rewrite@s}\oarg{options}
%    \begin{macrocode}
\renewcommand*{\NC@rewrite@S}[1][]{%
  \edef\si@tempa{\the\@temptokena
    >{\noexpand\si@tab@begin@S[#1]}c%
    <{\noexpand\si@tab@end@S}}%
  \@temptokena\expandafter{\si@tempa}%
  \NC@find}
\renewcommand*{\NC@rewrite@s}[1][]{%
  \edef\si@tempa{\the\@temptokena
    >{\noexpand\si@tab@begin@s[#1]}c%
    <{\noexpand\si@tab@end@s}}%
  \@temptokena\expandafter{\si@tempa}%
  \NC@find}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@begin@S}
%\begin{macro}{\si@tab@begin@s}
%\begin{macro}{\si@tab@gettok}
% At this stage, the appropriate token gathering macro is activated,
% and the common starting macro is called.  For the |S| column, the
% \opt{seperr} is turned off, and an error is set to be raised by any
% ``x-part'' input.\\
%\cs{si@tab@begin@S}\oarg{options}\\
%\cs{si@tab@begin@s}\oarg{options}
%    \begin{macrocode}
\newcommand*{\si@tab@begin@S}[1][]{%
  \si@log@debug{Processing S column cell contents}%
  \let\si@tab@gettok\si@tab@gettok@S
  \si@seperrfalse
  \renewcommand*{\si@num@sepxpart}{%
    \si@log@err{Multiple numbers not allowed in
       tables\MessageBreak Only the first number used}
       \@ehb}%
  \si@tab@begin[#1]}
\newcommand*{\si@tab@begin@s}[1][]{%
  \si@log@debug{Processing s column cell contents}%
  \let\si@tab@gettok\si@tab@gettok@s
  \si@tab@begin[#1]}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@toks}
%\begin{macro}{\si@tab@pretoks}
%\begin{macro}{\si@tab@posttoks}
% Some storage is needed for the data to build up.  In common with
% \pkg{rccol} and \numprint, token registers are used for this (thus
% leaving problematic input to be handled later).
%    \begin{macrocode}
\newtoks\si@tab@toks
\newtoks\si@tab@pretoks
\newtoks\si@tab@posttoks
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@begin}
% The macro for gathering up input is common to both column types. It
% uses the method for \pkg{rccol}; the cell contents are collected by
% a second macro, which then stores all of the data in an appropriate
% token store.\\
%\cs{si@tab@begin}\oarg{options}
%    \begin{macrocode}
\newcommand*{\si@tab@begin}[1][]{%
  \begingroup
    \sisetup{#1}%
    \si@tab@toks{}%
    \si@tab@pretoks{}%
    \si@tab@posttoks{}%
    \si@switchfalse
    \si@tab@gettok}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tab@gettok@S}
%\begin{macro}{\si@tab@othertok}
%\begin{macro}{\si@tab@gettok@s}
%\changes{v1.0a}{2008/06/20}{Fixed issues with alignment of
%  \texttt{s} column contents}
%\begin{macro}{\si@tab@next}
% The two collection macros are very similar.  Both compare the
% current input with a list of possible fixed values; this is pretty
% much a direct copy of \numprint.  If the input is not on the list
% of choices, it is processed as data for \currpkg to handle.  The
% |S| column does an additional check, to allow division of a number
% from any text.  For the |s| column, everything gets added to
% \cs{si@tab@toks} for later processing.  Two separate macros are
% needed here as the fixed values are dependant on the column type,
% and awkward errors pop up if a combined approach is tried.\\
%\cs{si@tab@gettok@S}\marg{cell-contents}\\
%\cs{si@tab@othertok}\marg{chars}\\
%\cs{si@tab@gettok@s}\marg{cell-contents}
%    \begin{macrocode}
\newcommand*{\si@tab@gettok@S}[1]{%
  \ifx\tabularnewline#1\relax
    \let\si@tab@next\si@tab@newline@S
  \else
    \ifx\end#1\relax
      \let\si@tab@next\end
    \else
      \ifx\si@tab@end@S#1\relax
        \let\si@tab@next\si@tab@end@S
      \else
        \ifx\endtabular#1\relax
          \let\si@tab@next\endtabular
        \else
          \ifx\csname#1\relax
            \let\si@tab@next\csname
          \else
            \ifx\relax#1\relax
              \let\si@tab@next\relax
            \else
              \let\si@tab@next\si@tab@gettok@S
              \si@str@ifchrstr{#1}{\si@numvalid}
                {\si@switchtrue
                 \si@log@debug{Found numerical cell
                   contents `#1'}%
                 \si@tab@toks=\expandafter{%
                   \the\si@tab@toks#1}}
                {\si@log@debug{Found other cell contents
                   \string#1}%
                 \si@tab@othertok{#1}}%
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
  \si@tab@next}
\newcommand*{\si@tab@othertok}[1]{%
  \ifsi@switch
    \si@tab@posttoks=\expandafter{\the\si@tab@posttoks#1}%
  \else
    \si@tab@pretoks=\expandafter{\the\si@tab@pretoks#1}%
  \fi}
\newcommand*{\si@tab@gettok@s}[1]{%
  \ifx\tabularnewline#1\relax
    \let\si@tab@next\si@tab@newline@s
  \else
    \ifx\end#1\relax
      \let\si@tab@next\end
    \else
      \ifx\si@tab@end@s#1\relax
        \let\si@tab@next\si@tab@end@s
      \else
        \ifx\endtabular#1\relax
          \let\si@tab@next\endtabular
        \else
          \ifx\csname#1\relax
            \let\si@tab@next\csname
          \else
            \ifx\relax#1\relax
              \let\si@tab@next\relax
            \else
              \let\si@tab@next\si@tab@gettok@s
              \ifx\ignorespaces#1\relax\else
                \ifx\unskip#1\relax\else
                  \si@tab@toks=\expandafter{%
                    \the\si@tab@toks#1}%
                  \si@log@debug{Found cell contents `#1'}%
                \fi
              \fi
            \fi
          \fi
        \fi
      \fi
    \fi
  \fi
  \si@tab@next}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@end@S}
%\changes{v1.0a}{2008/06/20}{Fixed mixed number/text column
%  alignment}
%\begin{macro}{\si@tab@rfill}
%\begin{macro}{\si@tab@lfill}
%\begin{macro}{\si@tab@end@s}
% The end macros are similar, but with some minor differences. In
% both cases, the appropriate filling is carried out.  For the |S|
% column, this depends on the cell contents, whereas for the |s|
% column the fill is always the same.  Output of a number in an |S|
% column is only attempted if one was found, otherwise the cell
% contents will all be in \cs{si@tab@pretoks}.
%    \begin{macrocode}
\newcommand*{\si@tab@end@S}{%
    \ifsi@switch
      \let\si@tab@lfill\si@tab@lfill@S
      \let\si@tab@rfill\si@tab@rfill@S
    \else
      \let\si@tab@rfill\si@tab@rfill@t
      \let\si@tab@lfill\si@tab@lfill@t
    \fi
    \si@tab@lfill\relax
    \ifsi@switch
      \llap{\the\si@tab@pretoks}%
      \expandafter\si@tab@numout
      \rlap{\the\si@tab@posttoks}%
    \else
      \the\si@tab@pretoks
    \fi
    \si@tab@rfill\relax
  \endgroup}
\newcommand*{\si@tab@end@s}{%
    \si@tab@lfill@s\relax
    \ignorespaces
    \expandafter\si\expandafter{\the\si@tab@toks}%
    \unskip
    \si@tab@rfill@s\relax
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@newline@S}
%\begin{macro}{\si@tab@newline@s}
%\begin{macro}{\si@tab@end}
% If the column is the final one read, then some work is needed with
% the \cs{tabularnewline} macro.  Output has to happen \emph{before}
% the new line, then the ending macro is made safe before calling the
% \LaTeX\ line end.  If the user makes use of the primitive \cs{cr}
% then this problem does not arise as \cs{si@tab@end@\ldots} is
% called correctly.
%    \begin{macrocode}
\newcommand*{\si@tab@newline@S}{%
  \si@tab@end@S
  \hfil\relax
  \let\si@tab@end\si@tab@end@S
  \renewcommand*{\si@tab@end@S}{\let\si@tab@end@S\si@tab@end}%
  \tabularnewline}
\newcommand*{\si@tab@newline@s}{%
  \si@tab@end@s
  \hfil\relax
  \let\si@tab@end\si@tab@end@s
  \renewcommand*{\si@tab@end@s}{\let\si@tab@end@s\si@tab@end}%
  \tabularnewline}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\si@tempcnta}
%\begin{macro}{\si@tempcntb}
% The second part of the tabular code is concerned with typesetting
% numbers in |S| columns with the appropriate alignment. Counters are
% needed for the digit-counting system.
%    \begin{macrocode}
\newcount\si@tempcnta
\newcount\si@tempcntb
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@numout}
% If a number is found, then some secondary processing is needed to
% format it correctly.
%    \begin{macrocode}
\newcommand*{\si@tab@numout}{%
  \si@num@intabtrue
  \ifsi@tab@fixed
    \ifsi@tabautofit
      \si@num@dp\si@tab@mantpostcnt\relax
      \expandafter\expandafter\expandafter\si@fixdptrue
    \fi
  \fi
  \expandafter\si@num\expandafter{\the\si@tab@toks}%
  \si@tab@format}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tab@prebox}
%\begin{macro}{\si@tab@postbox}
%\begin{macro}{\si@tab@midbox}
%\begin{macro}{\si@tab@expbox}
% The various boxes needed for the column centring are declared
% Unlike the \pkg{dcolumn} original, private boxes are used here.
% \cs{si@tempboxa} is used when a space to measure one of the
% constituents is needed; it is never used for output.
%    \begin{macrocode}
\newbox\si@tab@prebox
\newbox\si@tab@midbox
\newbox\si@tab@postbox
\newbox\si@tab@expbox
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@format}
% The formatting set up is taken from \pkg{dcolumn}, but with
% control of the output form the stored information.  The choice
% of a variable (decimal-centred) column or fixed width boxes is
% made.
%    \begin{macrocode}
\newcommand*{\si@tab@format}{%
  \ifsi@tab@fixed
    \expandafter\si@tab@fixed
  \else
    \expandafter\si@tab@unfixed
  \fi
%    \end{macrocode}
% A hack to get the correct colour everywhere without too much work.
%    \begin{macrocode}
  \ifsi@colourvalues
    \si@fam@colourcmd{\si@valuecolour}%
  \fi
  \box\si@tab@prebox\box\si@tab@midbox\box\si@tab@postbox%
    \box\si@tab@expbox}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tab@unfixed}
% When the width of the contents is not fixed, the system creates a
% block in which the decimal marker is always at the centre. This is
% achieved by placing the pre- and post-decimal parts of the number
% in boxes.  The wider one is then used to set up the column width,
% by resizing the other one.
%    \begin{macrocode}
\newcommand*\si@tab@unfixed{%
  \si@log@debug{Using variable width S column}%
  \protected@edef\si@num@out{\si@num@out\si@tab@expout}%
  \setbox\si@tab@prebox=\hbox
    {\expandafter\si@out@num\expandafter{\si@tab@out}}%
  \ifx\@empty\si@num@out\@empty
    \setbox\si@tab@midbox=\hbox
      {\phantom{\ensuremath{{\si@decimalsymbol}}}}%
  \else
    \setbox\si@tab@midbox=\hbox
      {\ensuremath{{\si@decimalsymbol}}}%
  \fi
  \setbox\si@tab@postbox=\hbox
    {\expandafter\si@out@num\expandafter{\si@num@out}}%
  \ifdim\wd\si@tab@prebox>\wd\si@tab@postbox\relax
    \setbox\si@tab@postbox=\hbox to\wd\si@tab@prebox%
      {\unhbox\si@tab@postbox\hfill}%
  \else
    \setbox\si@tab@prebox=\hbox to\wd\si@tab@postbox%
      {\hfill\unhbox\si@tab@prebox}%
  \fi
  \setbox\si@tab@expbox=\hbox{}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tab@predim}
%\begin{macro}{\si@tab@postdim}
%\begin{macro}{\si@tab@expdim}
%\begin{macro}{\si@tempdima}
%\begin{macro}{\si@tempdimb}
% Some storage dimensions are declared.
%    \begin{macrocode}
\newdimen\si@tab@predim
\newdimen\si@tab@postdim
\newdimen\si@tab@expdim
\newdimen\si@tempdima
\newdimen\si@tempdimb
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@tab@sp}
% A short macro to control superscript.
%    \begin{macrocode}
\newcommand*{\si@tab@sp}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tab@fixed}
% The column is not centred on the decimal marker; the user specifies
% how many characters on each side are allowed for.  First, the width
% of a character is measured, and stored.
%    \begin{macrocode}
\newcommand*{\si@tab@fixed}{%
  \si@log@debug{Using fixed-width S column}%
  \let\si@tab@sp\relax
  \setbox\si@tab@midbox=\hbox{}%
  \setbox\si@tab@expbox=\hbox{}%
  \setbox\si@tempboxa=\hbox{\si@out@num{1}}%
  \si@tempdima\wd\si@tempboxa\relax
%    \end{macrocode}
% The width for the two output boxes is set up.
%    \begin{macrocode}
  \si@tab@predim\the\si@tab@mantprecnt\si@tempdima\relax
  \si@tab@sepcorr{mantpre}{pre}%
  \si@tab@postdim\si@tab@mantpostcnt\si@tempdima\relax
  \setbox\si@tempboxa=\hbox{\ensuremath{{\si@decimalsymbol}}}%
  \advance\si@tab@postdim\wd\si@tempboxa\relax
  \si@tab@sepcorr{mantpost}{post}%
%    \end{macrocode}
% If space is needed for an exponent, it needs to be allowed for in
% the exponent box dimension.  First, the digits of the two parts are
% checked for; the width of a character is altered to be superscript.
%    \begin{macrocode}
  \setbox\si@tempboxa=\hbox{\si@out@num{^{1}}}%
  \si@tempdima\wd\si@tempboxa\relax
  \ifnum\si@tab@expprecnt>\z@\relax
    \si@tab@expdim\si@tab@expprecnt\si@tempdima\relax
    \si@tab@sepcorr{exppre}{exp}%
  \fi
  \let\si@tab@sp\sp
  \ifnum\si@tab@exppostcnt>\z@\relax
    \advance\si@tab@expdim\si@tab@exppostcnt\si@tempdima\relax
    \setbox\si@tempboxa=\hbox{%
      \ensuremath{^{\si@decimalsymbol}}}%
    \advance\si@tab@expdim\wd\si@tempboxa\relax
    \si@tab@sepcorr{exppost}{exp}%
  \fi
%    \end{macrocode}
% Space is reserved for signs.
%    \begin{macrocode}
  \setbox\si@tempboxa=\hbox{\ensuremath{-}}%
  \ifsi@tab@mantsign
    \advance\si@tab@predim\wd\si@tempboxa\relax
  \fi
  \setbox\si@tempboxa=\hbox{\ensuremath{^{-}}}%
  \ifsi@tab@expsign
    \advance\si@tab@expdim\wd\si@tempboxa\relax
  \fi
%    \end{macrocode}
% Now, if there is space to be saved for an exponent under any
% circumstances, the space for the ``$\times 10$'' part is needed.
% This is done by adding both counters together, then using this
% result for the logic.
%    \begin{macrocode}
  \si@tempcnta\si@tab@expprecnt\relax
  \advance\si@tempcnta\si@tab@exppostcnt\relax
  \ifnum\si@tempcnta>\z@\relax
    \setbox\si@tempboxa=\hbox{\ensuremath{%
      {}\si@expproduct{}\si@expbase}}%
    \advance\si@tab@expdim\wd\si@tempboxa\relax
  \fi
%    \end{macrocode}
% Finally for the box dimensions, if the exponent is not aligned,
% the space reserved for it is added to the post box.
%    \begin{macrocode}
  \ifsi@tabalignexp\else
    \advance\si@tab@postdim\si@tab@expdim\relax
  \fi
%    \end{macrocode}
% With the boxes set up, the contents can be sorted out.  A bit of
% shuffling may be needed, depending on the treatment of exponents.
%    \begin{macrocode}
  \setbox\si@tab@prebox=\hbox to\si@tab@predim{\hss\hfill
    \expandafter\si@out@num\expandafter{\si@tab@out}}%
  \ifx\@empty\si@num@out\@empty
    \setbox\si@tab@postbox=\hbox to\si@tab@postdim
      {\expandafter\si@out@num\expandafter{\si@num@out}\hfil}%
  \else
    \ifsi@tabalignexp\else
      \protected@edef\si@num@out{\si@num@out\si@tab@expout}%
    \fi
    \setbox\si@tab@postbox=\hbox to\si@tab@postdim
      {\ensuremath{{\si@decimalsymbol}}\expandafter\si@out@num
        \expandafter{\si@num@out}\hfil}%
  \fi
  \ifx\@empty\si@tab@expout\@empty
    \ifsi@tabalignexp
      \setbox\si@tab@expbox=\hbox to\si@tab@expdim{\hfil}%
    \fi
  \else
    \ifsi@tabalignexp
      \setbox\si@tab@expbox=\hbox to\si@tab@expdim
        {\expandafter\si@out@num\expandafter{\si@tab@expout}%
           \hfil}%
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@tab@sepcorr}
% A spacing correction is needed \emph{if} the number of digits to be
% allowed for will lead to the introduction of a separator.  A counter
% and dimension are needed for the testing.\\
%\cs{si@tab@sepcorr}\marg{count}\marg{dimen}
%    \begin{macrocode}
\newcommand*{\si@tab@sepcorr}[2]{%
  \expandafter\si@tempcnta\expandafter\the
    \csname si@tab@#1cnt\endcsname\relax
%    \end{macrocode}
% Calculate how many groups of three there are, then allow for not
% separating four characters if \cs{ifsi@sepfour} is false.
%    \begin{macrocode}
  \divide\si@tempcnta\thr@@\relax
  \ifsi@sepfour\else
    \expandafter\ifnum\expandafter\the
      \csname si@tab@#1cnt\endcsname=4\relax
      \si@tempcnta\z@\relax
    \fi
  \fi
%    \end{macrocode}
% The width of the separators is measured, and the correct number of
% separator widths are added to the box dimension.
%    \begin{macrocode}
  \setbox\si@tempboxa=\hbox{%
    \ensuremath{\si@tab@sp{\si@digitsep}}}%
  \expandafter\advance\csname si@tab@#2dim\endcsname
    \si@tempcnta\wd\si@tempboxa}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Units}
%\begin{macro}{\SI}
%\begin{macro}{\si}
% There are two types of user macros for the units system; those for
% defining new units, prefixes and powers, and those for using them.
% There are two macros for using units, \cs{SI} and \cs{si},
% which work in very similar ways.  \cs{si} is just an alias for
% \cs{SI} with no number; everything is handed off into an internal
% macro.  The internal macro also handles the optional prefix
% argument to \cs{SI}\\
%\cs{SI}\oarg{options}\marg{num}
%\cs{si}\oarg{options}\marg{unit}
%    \begin{macrocode}
\si@newrobustcmd*{\SI}[2][]{%
  \@ifnextchar[%]
    {\si@SI[#1]{#2}}
    {\si@SI[#1]{#2}[]}}
\si@newrobustcmd*{\si}[2][]{\si@SI[#1]{}[]{#2}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\newunit}
%\begin{macro}{\renewunit}
%\begin{macro}{\provideunit}
% The \cs{newunit} and \cs{renewunit} macros create the new unit
% macros. To allow a mechanism for checking an existing definition,
% these macros simply carry out the appropriate tests, before handing
% off to the internal macro.  \cs{@ifdefinable} is not used here as a
% customised error is desirable. Other than that, the code here gives
% very similar results to \cs{newcommand} and \cs{renewcommand}.
% Finally, \cs{provideunit} adds the unit definition only if it does
% not already exist.\\
%\cs{newunit}\oarg{options}\marg{unit}\marg{symbol}\\
%\cs{renewunit}\oarg{options}\marg{unit}\marg{symbol}\\
%\cs{provideunit}\oarg{options}\marg{unit}\marg{symbol}
%    \begin{macrocode}
\newcommand*{\newunit}[3][]{%
  \si@ifdefinable{#2}
    {\si@unt@defunit[#1]{#2}{#3}}
    {\si@log@err{Unit \string#2 already defined!}\@eha}}
\newcommand*{\renewunit}[3][]{%
  \si@ifdefinable{#2}
    {\si@log@err{Unit \string#2 undefined}\@ehc
     \si@unt@defunit[#1]{#2}{#3}}
    {\si@log@inf{Redefining unit \string#2}%
     \si@unt@defunit[#1]{#2}{#3}}}
\newcommand*{\provideunit}[3][]{%
  \si@ifdefinable{#2}
    {\si@unt@defunit[#1]{#2}{#3}}
    {}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\newprefix}
%\begin{macro}{\renewprefix}
%\begin{macro}{\provideprefix}
% The multiples of units are defined here; very similar code is used
% to the \cs{newunit}, \etc., macros.  The multiple prefixes cannot take
% an optional argument, and must represent some power.  Hence the arguments
% required are different.
%\cs{newprefix}\oarg{binary}\marg{multiple}\marg{powers-ten}^^A
%  \marg{symbol}\\
%\cs{renewprefix}\oarg{binary}\marg{multiple}\marg{powers-ten}^^A
%  \marg{symbol}\\
%\cs{provideprefix}\oarg{binary}\marg{multiple}\marg{powers-ten}^^A
%  \marg{symbol}
%    \begin{macrocode}
\newcommand*{\newprefix}[4][]{%
  \si@ifdefinable{#2}
    {\si@unt@defprefix[#1]{#2}{#3}{#4}}
    {\si@log@err{Prefix \string#2 already defined!}\@eha}}
\newcommand*{\renewprefix}[4][]{%
  \si@ifdefinable{#2}
    {\si@log@err{Prefix \string#2 undefined}\@ehc
     \si@unt@defprefix[#1]{#2}{#3}{#4}}
    {\si@log@inf{Redefining prefix \string#2}%
     \si@unt@defprefix[#1]{#2}{#3}{#4}}}
\newcommand*{\provideprefix}[4][]{%
  \si@ifdefinable{#2}
    {\si@unt@defprefix[#1]{#2}{#3}{#4}}
    {}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\newpower}
%\begin{macro}{\renewpower}
%\begin{macro}{\providepower}
% Here power multiples for units are set up.  As with units and
% multiples, a layered approach is used to keep things easy to
% maintain.  The optional argument here is \emph{not} a \pkg{keyval}
% one: only \opt{post} is a valid value.\\
%\cs{newpower}\oarg{post}\marg{num}\marg{power}\\
%\cs{renewpower}\oarg{post}\marg{num}\marg{power}\\
%\cs{providepower}\oarg{post}\marg{num}\marg{power}
%    \begin{macrocode}
\newcommand*{\newpower}[3][]{%
  \si@ifdefinable{#2}
    {\si@unt@defpower[#1]{#2}{#3}}
    {\si@log@err{Power \string#2 already defined!}\@eha}}
\newcommand*{\renewpower}[3][]{%
  \si@ifdefinable{#2}
    {\si@log@err{Power \string#2 undefined}\@ehc
     \si@unt@defpower[#1]{#2}{#3}}
    {\si@log@inf{Redefining power \string#2}%
     \si@unt@defpower[#1]{#2}{#3}}}
\newcommand*{\providepower}[3][]{%
  \si@ifdefinable{#2}
    {\si@unt@defpower[#1]{#2}{#3}}
    {}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@unt@num}
% A flag is needed to tell the processor whether there is a number,
% to get the correct spacing.
%    \begin{macrocode}
\newif\ifsi@unt@num
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@unitarg}
% A storage macro for the argument of the unit macro.
%    \begin{macrocode}
\newcommand*{\si@unt@unitarg}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@SI}
%\begin{macro}{\si@unt@SIopts}
% The internal processing starts with \cs{si@SI}, which processes the
% second optional argument to \cs{SI} (which is empty for
% \cs{si}).  Everything is set up in a group, and processing
% begins by handling the options.\\
%\cs{si@SI}\oarg{options}\marg{unit}\oarg{preunit}\marg{unit}
%    \begin{macrocode}
\newcommand*{\si@unt@SIopts}{}
\def\si@SI[#1]#2[#3]#4{%
  \begingroup
    \let\fg\SIfg
    \si@ifnotmtarg{#1}
      {\sisetup{#1}%
       \renewcommand*{\si@unt@SIopts}{#1}}%
%    \end{macrocode}
%\end{macro}
% The prefix unit is handled before any processing of the number; the
% flags are set to get spacing correct.
%    \begin{macrocode}
    \si@unt@numfalse
    \si@xspacefalse
    \si@ifnotmtarg{#3}
      {\si@log@debug{Prefix unit found}%
       \si@unt@printunit{#3}}%
%    \end{macrocode}
% The numerical argument may be empty, in which case no extra space
% should be produced.
%    \begin{macrocode}
    \si@ifnotmtarg{#4}
      {\renewcommand*{\si@unt@unitarg}{#4}}%
    \si@ifnotmtarg{#2}
      {\si@log@debug{Number found in \string\SI\space
         argument}%
       \ifsi@repeatunits\else
         \ifsi@trapambigerr
           \expandafter\expandafter\expandafter
             \si@num@ambigerrtrue
         \fi
       \fi
       \num{#2}%
       \si@unt@numtrue}%
%    \end{macrocode}
% If there is a unit, a check is needed in case the units need to
% have a power added.
%    \begin{macrocode}
    \si@ifnotmtarg{#4}
      {\si@ifmtarg{#2}
         {\si@unt@printunit{#4}}
         {\si@tempcnta\z@\relax
         \ifsi@addunitpower
           \si@unt@countx{#2}%
         \fi
          \ifnum\si@tempcnta>\z@\relax
            \advance\si@tempcnta\@ne\relax
            \edef\si@tempa{\noexpand\tothe{\si@tempcnta}}%
            \renewcommand*{\si@tempb}{#4}%
            \expandafter\expandafter\expandafter
            \si@unt@printunit\expandafter\expandafter
            \expandafter{%
              \expandafter\si@tempb\si@tempa}%
          \else
            \si@unt@printunit{#4}%
          \fi}}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@countx}
% A short macro to count up any multiplication in numerical input.
%    \begin{macrocode}
\newcommand*{\si@unt@countx}[1]{%
  \si@tempcnta\z@\relax
  \expandafter\si@unt@cntx#1\@empty\@empty}
\def\si@unt@cntx#1#2\@empty{%
  \si@str@ifchrstr{#1}{\si@numprod}
    {\advance\si@tempcnta\@ne\relax}
    {}%
  \ifx\@empty#2\@empty\else
    \si@unt@cntx#2\@empty\@empty
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@ifliteral}
%\begin{macro}{\ifsi@unt@littest}
% The next stage of the processor is to determine whether or not the
% argument of the unit macro is processable.  For literal arguments,
% this is not the case, and the argument is typeset ``as is''.  On
% the other hand, any units, \etc., declared by the package will work
% with the processor, and so need to be executed before typesetting
% the result.\\
%\cs{si@unt@ifliteral}\marg{text}
%    \begin{macrocode}
\newif\ifsi@unt@littest
\newcommand*{\si@unt@ifliteral}[1]{%
  \begingroup
    \si@unt@littesttrue
%    \end{macrocode}
% The test relies on any non-processable test having some width;
% hopefully, this should be the case.
%    \begin{macrocode}
    \setbox\si@tempboxa=\hbox{\si@unt@out{#1}}%
    \ifdim\wd\si@tempboxa>\z@\relax
      \aftergroup\@firstoftwo
    \else
      \aftergroup\@secondoftwo
    \fi
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ifsi@unt@litout}
%\begin{macro}{\si@unt@printunit}
% The printing macro uses the above test to determine how to act.  It
% then carries out the appropriate action: either typesetting or
% executing.  A flag is also provided so that any macro units inside
% a partially-literal argument will work (this is also needed to
% emulate \unitsdef).\\
%\cs{si@unt@printunit}\marg{unit}
%    \begin{macrocode}
\newif\ifsi@unt@litout
\newcommand*{\si@unt@printunit}[1]{%
  \si@unt@ifliteral{#1}
%    \end{macrocode}
% The unit includes one or more literal items; typeset using the
% unit typesetting macro.
%    \begin{macrocode}
    {\si@log@debug{Literal items found in unit
      argument:\MessageBreak outputting without further
      processing}%
     \si@unt@litouttrue
     \si@unt@addvaluesep
     \si@unt@out{#1}}
%    \end{macrocode}
% For processable output, the argument is executed; the macros are
% all designed for this.
%    \begin{macrocode}
    {\si@log@debug{Macro unit found:\MessageBreak
       processing to format output}%
     \si@unt@init
     \advance\si@unt@depthcnt\@ne\relax
     #1%
     \si@unt@final}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@addvaluesep}
%\begin{macro}{\si@unt@addvalsep}
%\begin{macro}{\si@unt@litvalsep}
%\begin{macro}{\si@unt@stackvalsep}
% To ensure no problems pop up with expansion, adding the value--unit
% space is handled by a macro.
%    \begin{macrocode}
\newcommand*{\si@unt@addvaluesep}{%
  \ifsi@unt@num
    \expandafter\si@unt@addvalsep
  \fi}
\newcommand*{\si@unt@addvalsep}{%
  \ifsi@unt@litout
    \expandafter\si@unt@litvalsep
  \else
    \expandafter\si@unt@stackvalsep
  \fi}
\newcommand*{\si@unt@stackvalsep}{%
  \protected@edef\si@unt@spstack{\si@valuesep}}
\newcommand*{\si@unt@litvalsep}{%
  \nobreak\ensuremath{\si@valuesep}\nobreak}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@spstack}
%\begin{macro}{\si@unt@stacka}
%\begin{macro}{\si@unt@stackb}
%\begin{macro}{\si@unt@unitcnta}
%\begin{macro}{\si@unt@unitcntb}
%\begin{macro}{\si@unt@depthcnt}
%\begin{macro}{\ifsi@unt@first}
%\begin{macro}{\ifsi@unt@first}
%\begin{macro}{\si@unt@init}
% The initialisation macro sets up the various switches, and clears
% the storage areas for the formatted output.  There are two stacks,
% as when typesetting as fractions, the two parts of the number have
% to be stored separately.  The depth counter is used to tell when
% recursion ends in the processor.  The ``first'' switch is needed as
% the depth counter will not be at one for items processed by
% \cs{SI}.
%    \begin{macrocode}
\newcommand*{\si@unt@spstack}{}
\newcommand*{\si@unt@stacka}{}
\newcommand*{\si@unt@stackb}{}
\newcount\si@unt@unitcnta
\newcount\si@unt@unitcntb
\newcount\si@unt@depthcnt
\newif\ifsi@unt@first
\si@unt@depthcnt\m@ne\relax
\newcommand*{\si@unt@init}{%
  \begingroup
    \si@unt@litoutfalse
    \si@unt@litprefixfalse
    \si@unt@firsttrue
    \si@unt@perfalse
    \si@unt@perseenfalse
    \si@unt@prepowerfalse
    \si@unt@depthcnt\z@\relax
    \si@unt@powerdim\z@\relax
    \si@unt@unitcnta\z@\relax
    \si@unt@unitcntb\z@\relax
    \si@unt@prefixcnt\z@\relax
    \renewcommand*{\si@unt@spstack}{}%
    \renewcommand*{\si@unt@stacka}{}%
    \renewcommand*{\si@unt@stackb}{}%
    \renewcommand*{\si@unt@holdstacka}{}%
    \renewcommand*{\si@unt@holdstackb}{}%
    \renewcommand*{\si@unt@lastadda}{space}%
    \renewcommand*{\si@unt@lastaddb}{space}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@final}
% The finalisation macro finishes off the output and resets the flags.
%    \begin{macrocode}
\newcommand*{\si@unt@final}{%
    \si@unt@third
    \si@unt@stackout
  \endgroup
  \ifsi@xspace
    \expandafter\expandafter\expandafter\xspace
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@defunit}
% The internal macro for defining a unit does not check for
% redefinition; that is done by the user macros.\\
%\cs{si@unt@defunit}\oarg{options}\marg{unit}\marg{symbol}
%    \begin{macrocode}
\newcommand*{\si@unt@defunit}[3][]{%
  \si@log@debug{Declaring unit \string#2 with \MessageBreak
    meaning \string#3}%
%    \end{macrocode}
% The optional argument needs to be saved. The macro name is reversed
% so that life is easier with the expansions here.
%    \begin{macrocode}
  \si@ifnotmtarg{#1}
    {\expandafter\@namedef\expandafter{%
      \expandafter\@gobble\string#2@opt@unt@si}{#1}}%
%    \end{macrocode}
% The unit macro itself is now defined.  The definition simply
% selects the correct path for the rest of the processing to go down.
%    \begin{macrocode}
  \protected\def#2{%
    \ifsi@allowoptarg
      \expandafter\si@unt@withopt
    \else
      \expandafter\si@unt@noopt
    \fi
    {#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@withopt}
%\begin{macro}{\si@unt@noopt}
% To allow the correct expansion, the potential optional argument to
% a unit macro has to come last.  So \cs{@ifnextchar} is needed to
% detect it and pass data through.  To keep variation down, when the
% argument is not allowed, the empty |[]| is supplied.\\
%\cs{si@unt@withopt}\marg{unit}\marg{symbol}\\
%\cs{si@unt@noopt}\marg{unit}\marg{symbol}
%    \begin{macrocode}
\newcommand*{\si@unt@withopt}[2]{%
  \@ifnextchar[%]
    {\si@unt@opt{#1}{#2}}
    {\si@unt@opt{#1}{#2}[]}}
\newcommand*{\si@unt@noopt}[2]{\si@unt@opt{#1}{#2}[]}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@opt}
% The optional argument to the unit macro (if present) is converted
% to a normal one for ease.  The correct route for processing is then
% picked.\\
%\cs{si@unt@opt}\marg{unit}\marg{symbol}\oarg{num}
%    \begin{macrocode}
\def\si@unt@opt#1#2[#3]{%
  \ifsi@unt@littest
    \expandafter\si@gobblethree
  \else
%    \end{macrocode}
% For literal output, the second argument is all that is needed.
%    \begin{macrocode}
    \ifsi@unt@litout
      \expandafter\expandafter\expandafter\@gobbletwo
    \else
      \expandafter\expandafter\expandafter\si@unt@unit
    \fi
  \fi
  {#3}{#1}{#2}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@gobblethree}
% \LaTeX\ does not have a \cs{@gobblethree} macro, but one is needed.
%    \begin{macrocode}
\long\def\si@gobblethree #1#2#3{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@defprefix}
%\begin{macro}{\ifsi@unt@litprefix}
% As with units, multiples are defined by an internal macro.\\
%\cs{si@unt@defprefix}\oarg{binary}\marg{multiple}\marg{powers-ten}^^A
%  \marg{symbol}
%    \begin{macrocode}
\newif\ifsi@unt@litprefix
\si@unt@litprefixtrue
\newcommand*{\si@unt@defprefix}[4][]{%
  \si@log@debug{Declaring multiple \string#1 with\MessageBreak
    meaning \string#4}%
%    \end{macrocode}
% The optional argument is saved, using \cs{def} as no check is made
% on an existing definition of the storage macro.
%    \begin{macrocode}
  \expandafter\expandafter\expandafter\def\expandafter
    \csname\expandafter\@gobble\string#2@opt@si\endcsname{#1}%
  \protected\def#2{%
    \ifsi@unt@littest
      \expandafter\si@gobblethree
    \else
      \ifsi@unt@litout
        \expandafter\expandafter\expandafter\@gobbletwo
      \else
        \ifsi@unt@litprefix
          \expandafter\expandafter\expandafter\expandafter
            \expandafter\expandafter\expandafter\@gobbletwo
        \else
          \expandafter\expandafter\expandafter\expandafter
            \expandafter\expandafter\expandafter\si@unt@prefix
        \fi
      \fi
    \fi
    {#2}{#3}{#4}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@defpower}
% The definition of powers is complicated by the need to handle both
% those given before units (such as \cs{cubic}) and those given after
% (\eg~\cs{cubed}).  This means that an optional argument is
% needed.\\
%\cs{si@unt@defpower}\oarg{post}\marg{power}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@unt@defpower}[3][]{%
  \si@log@debug{Declaring power \string#2 with\MessageBreak
    meaning \string#3}%
%    \end{macrocode}
% Once again the optional argument is saved.
%    \begin{macrocode}
  \expandafter\expandafter\expandafter\def\expandafter
    \csname\expandafter\@gobble\string#2@opt@si\endcsname{#1}%
  \protected\def#2{%
    \ifsi@unt@littest
      \expandafter\@gobbletwo
    \else
%    \end{macrocode}
% The literal output here does not need to gobble anything.
%    \begin{macrocode}
      \ifsi@unt@litout
        \expandafter\expandafter\expandafter\si@unt@litpower
      \else
        \expandafter\expandafter\expandafter\si@unt@power
      \fi
    \fi
    {#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@unithook}
%\begin{macro}{\si@unt@unit}
% The macro for units is actually a processor, rather than
% typesetting anything, which is handled elsewhere.  The first
% argument to the macro is optional, but does not have square
% brackets to keep things simple with gobbling.\\
%\cs{si@unt@unit}\marg{num}\marg{unit}\marg{symbol}
%    \begin{macrocode}
\newcommand*{\si@unt@unithook}{}
\newcommand*{\si@unt@unit}[3]{%
%    \end{macrocode}
% When the count is minus one at the start of the processor, then the
% unit is begin used on its own: initialisation occurs.
%    \begin{macrocode}
  \ifnum\si@unt@depthcnt=\m@ne\relax
    \expandafter\si@unt@init
  \fi
  \advance\si@unt@depthcnt\@ne\relax
  \si@log@debug{Unit processing: level \the\si@unt@depthcnt,
    \MessageBreak unit \string#2}%
  \si@unt@firstorsecond{#1}{#2}%
%    \end{macrocode}
% The core of the \cs{si@unt@unit} macro is testing if the symbol for
% the unit is a literal value or another macro.  Depending on the
% result, the symbol is either used as a literal or executed.
%    \begin{macrocode}
  \si@unt@ifliteral{#3}
    {\si@unt@addtostack{unit}{#3}%
     \ifsi@unt@prepower
       \expandafter\si@unt@stkpower
     \fi}
    {#3}%
%    \end{macrocode}
% The counter is now stepped down, before checking if this is
% the end of a compound unit.
%    \begin{macrocode}
  \advance\si@unt@depthcnt\m@ne\relax
  \ifnum\si@unt@depthcnt=\z@\relax
    \expandafter\si@unt@final
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@firstorsecond}
% At this stage, the flag will be set for the first item to be
% processed whichever route the unit has been called by.\\
%\cs{si@unt@firstorsecond}\marg{num}\marg{macro}
%    \begin{macrocode}
\newcommand*{\si@unt@firstorsecond}[2]{%
  \ifsi@unt@first
    \expandafter\si@unt@first
  \else
    \expandafter\si@unt@second
  \fi
  {#1}{#2}}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@first}
% For the first unit in the input, some extra tasks are needed.
% First, the optional argument for the unit macro needs to be
% tested.\\
%\cs{si@unt@first}\marg{num}\marg{unit}
%    \begin{macrocode}
\newcommand*{\si@unt@first}[2]{%
  \si@ifnotmtarg{#1}
    {\num{#1}%
     \si@unt@numtrue}%
  \si@unt@unithook
%    \end{macrocode}
% To avoid filling up the macro list with useless values, the \eTeX\
% primitive \cs{ifcsname} is employed here (it also avoids complex
% expansion issues).  If some options exist, they are set.
%    \begin{macrocode}
  \ifcsname\expandafter\@gobble\string#2@opt@unt@si\endcsname
    \expandafter\si@unt@setopts
  \else
    \expandafter\@gobble
  \fi
  {#2}%
  \si@unt@addvaluesep
  \si@unt@firstfalse}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@setopts}
%\begin{macro}{\si@unt@setSIopts}
% A rather long set of \cs{expandafter} commands to get the options
% to set safely.\\
%\cs{si@unt@setopts}\marg{unit}
%    \begin{macrocode}
\newcommand*{\si@unt@setopts}[1]{%
  \expandafter\expandafter\expandafter\expandafter\expandafter
    \expandafter\expandafter\si@temptoks\expandafter
    \expandafter\expandafter\expandafter\expandafter
    \expandafter\expandafter{\expandafter%
      \csname\expandafter\@gobble\string#1@opt@unt@si%
      \endcsname}%
  \expandafter\sisetup\expandafter{\the\si@temptoks}%
  \si@log@debug{Applying options `\the\si@temptoks'
    for\MessageBreak unit \string#1}%
%    \end{macrocode}
% The user options are reloaded, if defined, to ensure that they
% still work as expected.
%    \begin{macrocode}
  \@ifundefined{si@unt@SIopts}{}
    {\ifx\@empty\si@unt@SIopts\@empty\else
       \expandafter\expandafter\si@unt@setSIopts
     \fi}}
\newcommand*{\si@unt@setSIopts}{%
  \expandafter\si@temptoks\expandafter{\si@unt@SIopts}%
  \expandafter\sisetup\expandafter{\the\si@temptoks}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@second}
%\begin{macro}{\si@unt@third}
% For everything apart from the first item to be processed, spacing
% may need to be added to separated different units.  The macro is
% divided into two, so that everything except the space can be added
% in finalisation.\\
%\cs{si@unt@second}\marg{num}\marg{unit}
%    \begin{macrocode}
\newcommand*{\si@unt@second}[2]{%
  \si@ifnotmtarg{#1}
    {\si@log@warn{Optional argument to unit macro\MessageBreak
       allowed only for outer unit}}%
  \si@unt@third
  \si@unt@addtostack{space}{\ensuremath{\si@unitsep}}}
\newcommand*{\si@unt@third}{%
  \ifsi@unt@prepower\else
    \expandafter\si@unt@stkpower
  \fi
%    \end{macrocode}
% A check is made to avoid adding $-1$ to prefixes.  If \opt{frac} is
% active, then the |b| stack will be in use, otherwise it will be
% |a|.
%    \begin{macrocode}
  \renewcommand*{\si@tempa}{prefix}%
  \expandafter\ifx
    \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
  \else
    \expandafter\si@unt@spacecheck
  \fi
  \ifsi@unt@per
    \expandafter\si@unt@perseentrue
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@spacecheck}
% A check to prevent adding $-1$ at the very beginning of the unit,
% where there is a space on the stack.
%    \begin{macrocode}
\newcommand*{\si@unt@spacecheck}{%
  \renewcommand*{\si@tempa}{space}%
  \expandafter\ifx
    \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
  \else
    \expandafter\si@unt@reciptest
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@prefix}
% Actual output of the prefixes.\\
%\cs{si@unt@prefix}\marg{multiple}\marg{powers-ten}\marg{symbol}
%    \begin{macrocode}
\newcommand*{\si@unt@prefix}[3]{%
  \si@unt@firstorsecond{}{#1}%
  \ifsi@prefixsymbolic
    \expandafter\si@unt@addprefix
  \else
    \expandafter\si@unt@countprefix
  \fi
  {#1}{#2}{#3}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@addprefix}
% To add the prefix, a little translation is needed.\\
%\cs{si@unt@countprefix}\marg{gobble}\marg{gobble}\marg{symbol}
%    \begin{macrocode}
\newcommand*{\si@unt@addprefix}[3]{%
  \si@unt@addtostack{prefix}{#3}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@prefixcnt}
%\begin{macro}{\si@unt@countprefix}
%\begin{macro}{\si@unt@invprefix}
% On the other hand, to count the prefix numeral, the symbol is
% thrown away.\\
%\cs{si@unt@countprefix}\marg{multiple}\marg{powers-ten}\marg{gobble}
%    \begin{macrocode}
\newcount\si@unt@prefixcnt
\newcommand*{\si@unt@countprefix}[3]{%
%    \end{macrocode}
% A check is made for binary units.
%    \begin{macrocode}
  \renewcommand*{\si@tempa}{binary}%
  \expandafter\expandafter\expandafter\ifx\expandafter
    \csname\expandafter\@gobble\string#1@opt@si\endcsname
    \si@tempa
    \expandafter\sisetup
  \else
    \expandafter\@gobble
  \fi
  {prefixbase=two}%
  \si@tempcnta#2\relax
  \ifsi@unt@per
    \expandafter\si@unt@invprefix
  \fi
  \advance\si@unt@prefixcnt\si@tempcnta\relax}
\newcommand*{\si@unt@invprefix}{%
  \si@tempcntb\si@tempcnta\relax
  \si@tempcnta -\si@tempcntb\relax}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@litpower}
% For literal power output, the number can't simply be dumped, so
% a macro is needed.\\
%\cs{si@unt@litpower}\marg{gobble}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@unt@litpower}[2]{\textsuperscript{#2}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@unt@prepower}
%\begin{macro}{\si@unt@power}
% The handling of powers starts by ensuring that ``pre'' powers
% follow \cs{per} cleanly.  Then a check is needed for inversion.\\
%\cs{si@unt@power}\marg{power}\marg{num}
%    \begin{macrocode}
\newif\ifsi@unt@prepower
\newcommand*{\si@unt@power}[2]{%
  \renewcommand*{\si@tempa}{post}%
  \expandafter\expandafter\expandafter\ifx\expandafter
    \csname\expandafter\@gobble\string#1@opt@si\endcsname
    \si@tempa
    \expandafter\@gobbletwo
  \else
    \expandafter\si@unt@firstorsecond
  \fi
  {}{\power}%
  \si@unt@powerdim #2 pt\relax
  \ifsi@frac\else
    \ifsi@unt@per
      \expandafter\expandafter\expandafter\si@unt@invpower
    \fi
  \fi
  \renewcommand*{\si@tempa}{post}%
  \si@unt@prepowertrue
  \expandafter\expandafter\expandafter\ifx\expandafter
    \csname\expandafter\@gobble\string#1@opt@si\endcsname
    \si@tempa
    \expandafter\si@unt@stackpower
  \else
    \si@log@debug{Power \strip@pt\si@unt@powerdim\space saved
      to be added after\MessageBreak next unit}%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@powerdim}
% To do sign-inversion on the power, a dimension is used (this allows
% non-integer values to be handled).
%    \begin{macrocode}
\newdimen\si@unt@powerdim
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@stackpower}
%\begin{macro}{\si@unt@stkpower}
%\begin{macro}{\si@unt@stkpwr}
% Adding powers to the stack should also clear the power list.  If
% the number is already zero, then  of course nothing happens.
%    \begin{macrocode}
\newcommand*{\si@unt@stackpower}{%
  \si@unt@prepowerfalse
%    \end{macrocode}
% A trap is used for $-1$ added to the denominator of a fraction.
%    \begin{macrocode}
  \si@unt@stkpower
  \ifsi@stickyper\else
    \si@unt@perfalse
    \si@unt@perseenfalse
  \fi}
%    \end{macrocode}
% The \cs{si@unt@stkpower} macro needs to be called from a few
% places, so is spun out from the above.
%    \begin{macrocode}
\newcommand*{\si@unt@stkpower}{%
  \ifdim\si@unt@powerdim=\m@ne pt\relax
    \ifsi@frac\else
      \expandafter\expandafter\expandafter\si@unt@stkpwr
    \fi
  \else
    \expandafter\si@unt@stkpwr
  \fi}
%    \end{macrocode}
% Finally, the actual adding (set up to avoid problems with the
% \cs{if} above).
%    \begin{macrocode}
\newcommand*{\si@unt@stkpwr}{%
  \ifdim\si@unt@powerdim=\z@\relax\else
    \renewcommand*{\si@tempa}{unit}%
    \expandafter\ifx
      \csname si@unt@lastadd\si@unt@checkstack\endcsname
      \si@tempa
      \si@log@debug{Adding power
        \strip@pt\si@unt@powerdim\space to output stack}%
      \si@unt@addtostack{power}{^{\num[fixdp=false]{%
        \strip@pt\si@unt@powerdim}}}%
    \fi
  \fi
  \si@unt@powerdim\z@\relax}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@invpower}
% A macro to change the sign of the current power.
%    \begin{macrocode}
\newcommand*{\si@unt@invpower}{%
  \si@tempdima\si@unt@powerdim\relax
  \si@unt@powerdim -\si@tempdima\relax
%    \end{macrocode}
% The power might end up as ``1'', which is not wanted.  So it is
% chucked away.
%    \begin{macrocode}
  \ifdim\si@unt@powerdim=\p@\relax
    \si@unt@powerdim\z@\relax
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@unt@per}
%\begin{macro}{\ifsi@unt@perseen}
%\begin{macro}{\per}
%\begin{macro}{\si@per}
%\begin{macro}{\si@unt@per}
% The \cs{per} macro sets the correct flags; almost everything else
% is done elsewhere.  There is always the case of two \cs{per}
% instructions; so the flag is flipped rather than set arbitrarily.
% The second flag is needed so that \cs{per} can give powers of $-1$
% properly.
%    \begin{macrocode}
\newif\ifsi@unt@per
\newif\ifsi@unt@perseen
\si@newrobustcmd*{\si@per}{%
  \ifsi@unt@littest\else
    \ifsi@unt@litout
      \expandafter\expandafter\expandafter /%
    \else
      \ifsi@unt@litprefix
        \expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter /%
      \else
        \expandafter\expandafter\expandafter\expandafter
          \expandafter\expandafter\expandafter\si@unt@per
      \fi
    \fi
  \fi}
\newcommand*{\si@unt@per}{%
  \si@unt@firstorsecond{}{\per}%
  \ifsi@unt@per
    \ifsi@stickyper\else
      \expandafter\expandafter\expandafter\si@unt@perfalse
    \fi
  \else
    \expandafter\si@unt@pertrue
  \fi}
\let\per\si@per
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@reciptest}
%\begin{macro}{\si@unt@recip}
% A test is needed for adding $-1$ when needed. The second macro is
% fired only if the power should be reciprocal.
%    \begin{macrocode}
\newcommand*{\si@unt@reciptest}{%
  \ifsi@unt@per
    \ifsi@unt@perseen
      \expandafter\expandafter\expandafter\si@unt@recip
    \fi
  \fi}
\newcommand*{\si@unt@recip}{%
  \si@unt@powerdim\m@ne pt\relax
  \si@unt@stackpower}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@lastadda}
%\begin{macro}{\si@unt@lastaddb}
%\begin{macro}{\si@unt@addtostack}
% Items cannot be added directly to the stacks (except the spacing
% stack, a) as the fractional handling may need to add the item to
% either storage area.  By indicating the type of data to be added to
% the stack, problems can be avoided.\\
%\cs{si@unt@addtostack}\marg{type}\marg{token}
%    \begin{macrocode}
\newcommand*{\si@unt@lastadda}{}
\newcommand*{\si@unt@lastaddb}{}
\newcommand*{\si@unt@addtostack}[2]{%
  \renewcommand*{\si@tempa}{#1}%
%    \end{macrocode}
% Two consecutive items cannot be of the same type; there must be spaces
% between units, units between prefixes, \etc.
%    \begin{macrocode}
  \expandafter\ifx
    \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
    \expandafter\@gobbletwo
  \else
    \expandafter\si@unt@preplussp
  \fi
  {#1}{#2}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@preplussp}
% The space added after a prefix needs to be ignored.\\
%\cs{si@unt@preplussp}\marg{type}\marg{stack}\marg{token}^^A
%  \marg{gobble}
%    \begin{macrocode}
\newcommand*{\si@unt@preplussp}[2]{%
  \renewcommand*{\si@tempa}{prefix+space}%
  \edef\si@tempb{%
    \csname si@unt@lastadd\si@unt@checkstack\endcsname+#1}%
  \ifx\si@tempa\si@tempb
    \expandafter\@gobbletwo
  \else
    \expandafter\si@unt@stack
  \fi
  {#1}{#2}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@stack}
% The macro for actually doing the stacking up.\\
%\cs{si@unt@stack}\marg{type}\marg{tokens}
%    \begin{macrocode}
\newcommand*{\si@unt@stack}[2]{%
  \expandafter\renewcommand\expandafter*\expandafter{%
    \csname si@unt@lastadd\si@unt@checkstack\endcsname}{#1}%
%    \end{macrocode}
% A count is kept of the number of \emph{units} added to each stack.
%    \begin{macrocode}
  \renewcommand*{\si@tempa}{#1}%
  \renewcommand*{\si@tempb}{unit}%
  \ifx\si@tempa\si@tempb
    \expandafter\si@unt@inccnt
  \fi
%    \end{macrocode}
% If a space is added, it is actually held until the next add.
%    \begin{macrocode}
  \renewcommand*{\si@tempb}{space}%
  \ifx\si@tempa\si@tempb
    \expandafter\si@unt@holdspace
  \else
    \expandafter\si@unt@addstack
  \fi
  {#2}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@inccnt}
% The appropriate counter is added to.
%    \begin{macrocode}
\newcommand*{\si@unt@inccnt}{%
  \expandafter\advance
    \csname si@unt@unitcnt\si@unt@checkstack\endcsname
    \@ne\relax}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@holdspace}
%\begin{macro}{\si@unt@addstack}
%\begin{macro}{\si@unt@holdstacka}
%\begin{macro}{\si@unt@holdstackb}
% Depending on the nature of the addition, it is either held or added
% to the stack.  For the ``b'' space stack, a check is made to ensure
% that a space cannot be added before the first item.\\
%\cs{si@unt@holdspace}\marg{tokens}\\
%\cs{si@unt@addstack}\marg{tokens}
%    \begin{macrocode}
\newcommand*{\si@unt@holdstacka}{}
\newcommand*{\si@unt@holdstackb}{}
\newcommand*{\si@unt@holdspace}[1]{%
  \renewcommand*{\si@tempa}{b}%
  \edef\si@tempb{\si@unt@checkstack}%
  \ifx\si@tempa\si@tempb
    \ifx\@empty\si@unt@stackb\@empty
    \else
      \expandafter\protected@edef
      \csname si@unt@holdstack\si@unt@checkstack\endcsname{#1}%
    \fi
  \else
    \expandafter\protected@edef
    \csname si@unt@holdstack\si@unt@checkstack\endcsname{#1}%
  \fi}
\newcommand*{\si@unt@addstack}[1]{%
  \expandafter\protected@edef
    \csname si@unt@stack\si@unt@checkstack\endcsname
    {\csname si@unt@stack\si@unt@checkstack\endcsname
     \csname si@unt@holdstack\si@unt@checkstack\endcsname#1}%
  \expandafter\renewcommand\expandafter*\expandafter{%
    \csname si@unt@holdstack\si@unt@checkstack\endcsname}{}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@stackout}
% The stack contents are actually typeset here.  First the spacing
% between units and values is added.
%    \begin{macrocode}
\newcommand*{\si@unt@stackout}{%
  \si@unt@litouttrue
  \ifsi@frac
    \expandafter\si@unt@fracout
  \else
    \expandafter\si@unt@normout
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@checkstack}
% Which stack is in use needs to be tested.
%    \begin{macrocode}
\newcommand*{\si@unt@checkstack}{%
  \ifsi@frac
    \ifsi@unt@per
      \expandafter\expandafter\expandafter b%
    \else
      \expandafter\expandafter\expandafter a%
    \fi
  \else
    \expandafter a%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@spaceout}
% The space before a unit might not be needed, so it crops up a few
% times in the output routine.
%    \begin{macrocode}
\newcommand*{\si@unt@spaceout}{%
   \ensuremath{\si@unt@spstack}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@prefixout}
% If the prefix counter is not zero, then there is something to
% typeset.
%    \begin{macrocode}
\newcommand*{\si@unt@prefixout}{%
  \ifnum\si@unt@prefixcnt=\z@\relax\else
    \ifsi@unt@num
      \si@out{\ensuremath{{}\si@prefixproduct{}}}%
    \fi
    \si@unt@stackvalsep
    \let\si@expbase\si@prefixbase
    \num[fixdp=false]{e\the\si@unt@prefixcnt}%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@normout}
% The normal output mode is set up here; nothing much needs to be
% done as there is no need for complex checks.
%    \begin{macrocode}
\newcommand*{\si@unt@normout}{%
  \si@unt@prefixout
  \si@unt@spaceout
  \expandafter\si@unt@out\expandafter{\si@unt@stacka}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@fracout}
% For fractions, some checks are needed.
%    \begin{macrocode}
\newcommand*{\si@unt@fracout}{%
  \si@unt@notambig
  \ifx\@empty\si@unt@stacka\@empty
    \ifx\@empty\si@unt@stackb\@empty
      \ifsi@unt@litout\else
        \si@log@err{Empty fractional unit}{The unit
          argument\MessageBreak given does not contain any
          symbols}%
      \fi
    \else
%    \end{macrocode}
% With an empty numerator, no space is added
%    \begin{macrocode}
      \ifsi@slash
        \si@unt@prefixout
        \si@frac{}{\si@unt@stackb}%
      \else
        \si@unt@prefixout
        \si@unt@spaceout
        \si@frac{1}{\si@unt@stackb}%
      \fi
    \fi
  \else
%    \end{macrocode}
% If the denominator is empty, then the usual output system can be
% used.
%    \begin{macrocode}
    \ifx\@empty\si@unt@stackb\@empty
      \si@unt@normout
    \else
      \si@unt@prefixout
      \si@unt@spaceout
      \si@frac{\si@unt@stacka}{\si@unt@stackb}%
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@notambig}
%\begin{macro}{\si@unt@notabg}
% A trap is set for adding brackets to units using a slash, when more
% than one unit is in the denominator.
%    \begin{macrocode}
\newcommand*{\si@unt@notambig}{%
  \ifnum\si@unt@unitcntb>\@ne\relax
    \ifsi@slash
        \ifsi@trapambigfrac
          \expandafter\expandafter\expandafter\expandafter
            \expandafter\expandafter\expandafter\si@unt@notabg
        \fi
    \fi
  \fi}
\newcommand*{\si@unt@notabg}{%
  \protected@edef\si@unt@stackb{\si@openfrac\si@unt@stackb
    \si@closefrac}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\si@unt@out}
%\changes{v1.0d}{2008/06/25}{Sanitise one level of unit input
%  only}
% The final part of the units system is the output routine.  This has
% to cope with units not only as macros but also as direct input
% (\SIstyle-type input).  Non-Latin characters are also handled
% cleanly.  The \cs{scantokens} system deals with everything except
% full stops; these are left out so that a single level system can be
% used \latin{via} a token register.\\
%\cs{si@unt@out}\marg{unit}
%    \begin{macrocode}
\begingroup
  \catcode`\~=\active
  \catcode`\.=\active
  \gdef\si@unt@out#1{%
    \si@temptoks{#1}%
    \si@unt@fullstop
    \def.{\ensuremath{\si@unitsep}}%
    \def~{\ensuremath{\si@unitspace}}%
    \expandafter\protected@edef\expandafter\si@tempa
      \expandafter{\the\si@temptoks}%
    \begingroup
      \si@unt@nonlatin
      \makeatletter
      \endlinechar\m@ne
      \expandafter\si@out\expandafter{%
        \expandafter\scantokens\expandafter{\si@tempa}}%
    \endgroup}
\endgroup
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@fullstop}
%\begin{macro}{\si@unt@stp}
% Two macros modified from \pkg{kvsetkeys} to deal with a single
% level of active full stops only.
%    \begin{macrocode}
\begingroup
  \catcode`\.=\active
  \catcode`\&=12\relax
  \begingroup
    \lccode`\.=`\.\relax
    \lccode`\&=`\.\relax
  \lowercase{\endgroup
    \gdef\si@unt@fullstop{%
      \si@temptoks\expandafter{\expandafter}\expandafter
      \si@unt@stp\the\si@temptoks&\@nil}
  \gdef\si@unt@stp#1&#2\@nil{%
    \edef\si@tempa{\the\si@temptoks}%
    \ifx\si@tempa\@empty
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
      {\si@temptoks{#1}}
      {\si@temptoks\expandafter{\the\si@temptoks.#1}}%
    \si@ifmtarg{#2}
      {}
      {\si@unt@stp#2\@nil}}}
\endgroup
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@unt@nonlatin}
% To handle non-Latin symbols in the input, a single macro is
% provided.  If \XeTeX\ is in use, this can be detected immediately.
%    \begin{macrocode}
\newcommand*{\si@unt@nonlatin}{}
\ifdefined\XeTeXrevision
  \renewcommand*{\si@unt@nonlatin}{%
    \catcode176=\active
    \catcode181=\active
    \catcode197=\active
    \si@unt@sym{176}{\si@sym@degree}%
    \si@unt@sym{181}{\si@sym@mu}%
    \si@unt@sym{197}{\si@sym@ringA}}%
\fi
%    \end{macrocode}
% If \pkg{inputenc} has been loaded, then a check is made that the
% encoding is correct.  If all is well, the non-Latin symbols are
% handled.  The degree symbol is character 176, the micro
% symbol is character 181 and ring capital A is character 197 in
% latin1.
%    \begin{macrocode}
\AtBeginDocument{
  \@ifpackageloaded{inputenc}
    {\@for\si@tempa:=latin1,latin5,latin9\do{
       \ifx\inputencodingname\si@tempa
         \renewcommand*{\si@unt@nonlatin}{%
           \catcode176=\active
           \catcode181=\active
           \catcode197=\active
           \si@unt@sym{176}{\si@sym@degree}%
           \si@unt@sym{181}{\si@sym@mu}%
           \si@unt@sym{197}{\si@sym@ringA}}%
       \fi}}
    {}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@unt@sym}
% A macro for declaring symbols: a copy of \cs{DeclareInputMath} from
% \pkg{inputenc}.\\
%\cs{si@unt@sym}\marg{charcode}
%    \begin{macrocode}
\newcommand*{\si@unt@sym}[1]{%
  \bgroup
    \uccode`\~#1%
    \uppercase{%
      \egroup
      \def~}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\kilogram}
%\begin{macro}{\metre}
%\begin{macro}{\meter}
%\begin{macro}{\mole}
%\begin{macro}{\kelvin}
%\begin{macro}{\candela}
%\begin{macro}{\second}
%\begin{macro}{\ampere}
% With the system set up, the basic unit macros are implemented.  The
% only units defined whatever options are given are the base SI
% units.
%    \begin{macrocode}
\newunit{\kilogram}{kg}
\newunit{\metre}{m}
\newunit{\meter}{\metre}
\newunit{\mole}{mol}
\newunit{\second}{s}
\newunit{\ampere}{A}
\newunit{\kelvin}{K}
\newunit{\candela}{cd}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\Square}
%\begin{macro}{\ssquare}
%\begin{macro}{\squared}
%\begin{macro}{\cubic}
%\begin{macro}{\cubed}
% Unlike multiples (which can be skipped if needed), the basic powers
% are also always defined.
%    \begin{macrocode}
\newpower{\Square}{2}
\newpower{\ssquare}{2}
\newpower[post]{\squared}{2}
\newpower{\cubic}{3}
\newpower[post]{\cubed}{3}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\tothe}
%\begin{macro}{\si@tothe}
%\begin{macro}{\raiseto}
%\begin{macro}{\tothe@opt@si}
%\begin{macro}{\raiseto@opt@si}
% A macro for arbitrary powers, which comes after the unit and so
% needs to be marked as such.\\
%\cs{tothe}\marg{num}\\
%\cs{raiseto}\marg{num}
%    \begin{macrocode}
\newcommand*{\tothe}{\si@tothe{\tothe}}
\newcommand*{\raiseto}{\si@tothe{\raiseto}}
\newcommand*{\si@tothe}[2]{%
  \ifsi@unt@littest
    \expandafter\@gobbletwo
  \else
    \ifsi@unt@litout
      \expandafter\expandafter\expandafter\si@unt@litpower
    \else
      \expandafter\expandafter\expandafter\si@unt@power
    \fi
  \fi
  {#1}{#2}}
\newcommand*{\tothe@opt@si}{post}
\newcommand*{\raiseto@opt@si}{}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Locales}
%\begin{macro}{\si@loc@load}
%\begin{macro}{\si@loc@sisetup}
% When loading a locale, the setup is saved rather than applied.
% Anything other than simple settings should be inside
% \cs{addtolocale}, which is already defined.\\
%\cs{si@loc@load}\marg{locale}
%    \begin{macrocode}
\newcommand*{\si@loc@load}[1]{%
  \let\si@loc@sisetup\sisetup
  \renewcommand*{\sisetup}[1]{%
    \expandafter\gdef\csname si@loc@#1\endcsname{##1}}
  \si@loadfile{#1}%
  \let\sisetup\si@loc@sisetup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@loc@set}
% Setting the locale transfers the settings to \cs{sisetup}, and runs
% any extra macros.\\
%\cs{si@loc@set}\marg{locale}
%    \begin{macrocode}
\newcommand*{\si@loc@set}[1]{%
  \ifcsname si@loc@#1\endcsname
    \si@log@inf{Setting locale to `#1'}%
    \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter\si@temptoks
      \expandafter\expandafter\expandafter\expandafter
      \expandafter\expandafter\expandafter{%
        \expandafter\csname si@loc@#1\endcsname}%
    \expandafter\sisetup\expandafter{\the\si@temptoks}%
    \ifcsname si@loc@#1@extra\endcsname
      \csname si@loc@#1@extra\endcsname
    \fi
  \else
    \ifcsname si@loc@#1@extra\endcsname
      \si@log@inf{Setting locale to `#1'}%
      \csname si@loc@#1@extra\endcsname
    \else
      \si@log@warn{Unknown locale `#1'}%
    \fi
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@loc@ltol}
%\changes{v1.0a}{2008/06/20}{\pkg{babel} support fixed for default
%  document language}
% The necessary loading for language modules occurs.\\
%\cs{si@loc@ltol}\marg{list}
%    \begin{macrocode}
\newcommand*{\si@loc@ltol}[1]{%
  \def\si@tempa##1:##2\@nil{\si@loc@load{##1}}
  \@for\si@tempb:=#1\do{%
    \expandafter\si@tempa\si@tempb:\@nil}
  \AtBeginDocument{
    \@ifpackageloaded{babel}
      {\def\si@tempa##1:##2:##3\@nil{%
        \expandafter\addto\expandafter{%
          \csname extras##2\endcsname}%
          {\si@loc@set{##1}}}%
       \@for\si@tempb:=#1\do{%
         \expandafter\si@tempa\si@tempb::\@nil}%
       \expandafter\selectlanguage\expandafter{\languagename}}
      {\si@log@warn{babel not loaded \MessageBreak
        loctolang option ignored}}}}
\AtBeginDocument{
  \@ifpackageloaded{babel}
    {\renewcommand*{\si@loc@ltol}[1]{%
       \def\si@tempa##1:##2\@nil{\si@loc@load{##1}}%
       \@for\si@tempb:=#1\do{%
         \expandafter\si@tempa\si@tempb:\@nil}%
       \def\si@tempa##1:##2:##3\@nil{%
         \expandafter\addto\expandafter{%
           \csname extras##2\endcsname}%
           {\si@loc@set{##1}}}%
       \@for\si@tempb:=#1\do{%
         \expandafter\si@tempa\si@tempb::\@nil}}}
    {\renewcommand*{\si@loc@ltol}[1]{%
       \si@log@warn{babel not loaded \MessageBreak
         loctolang option ignored}}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\addtolocale}
% Arbitrary macros may need to be added to the locale.\\
%\cs{addtolocale}\marg{locale}\marg{commands}
%    \begin{macrocode}
\newcommand*{\addtolocale}[2]{%
  \si@addtocsname{si@loc@#1@extra}{#2}}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Output routine}
%\begin{macro}{\si@out}
% With all of the setup done, the text can finally be typeset.  This
% is done inside a \cs{text} block, which takes care of
% \cs{ensuremath}, \etc.  First of all, the various catcode settings
% needed to get maths-in-text mode are made.  \cs{makeatletter} is
% needed so that \cs{scantokens} still allows internal macros to
% work.\\
%\cs{si@out}\marg{text}
%    \begin{macrocode}
\begingroup
  \catcode`\^=\active
  \catcode`\-=\active
  \gdef\si@out#1{%
    \begingroup
      \catcode`\^=\active
      \makeatletter
      \endlinechar\m@ne
%    \end{macrocode}
% The various font families can now be set up.  First a check is made
% in case there are nested calls to \cs{si@out@text}.
%    \begin{macrocode}
      \ifsi@fam@set\else
        \expandafter\si@fam@set
      \fi
      \si@colourcmd{\si@colour}%
      \text{\si@fam@italic\si@fam@bold\si@fam@text
%    \end{macrocode}
%  The correct mode is selected, and the input is handed off for
%  typesetting.
%    \begin{macrocode}
        \ifsi@textmode
          \expandafter\si@out@text
        \else
          \expandafter\si@out@maths
        \fi
        {\scantokens{#1}}}%
    \endgroup
    \check@mathfonts}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@out@text}
%\begin{macro}{\si@out@maths}
% Output occurs with the correct changes to superscript behaviour.\\
%\cs{si@out@text}\marg{text}\\
%\cs{si@out@maths}\marg{text}
%    \begin{macrocode}
  \gdef\si@out@text#1{%
    \let^\si@out@sp
    \let\textsuperscript\si@out@sp
    \catcode`\-=\active\relax
    \let-\si@out@minus
    #1}
  \gdef\si@out@maths#1{%
    \let^\sp
    \let\textsuperscript\sp
    $\si@fam@maths{#1}$}
\endgroup
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@out@sp}
% \cs{textsuperscript} gives slightly different alignment of numbers
% to using |^| in text mode.  To avoid this, a slightly different
% definition is used.  Elsewhere \cs{textsuperscript} is used, as
% the code above sorts out the text/maths mode issues.\\
%\cs{si@out@sp}\marg{text}
%    \begin{macrocode}
\newcommand*{\si@out@sp}[1]{\ensuremath{^{\text{#1}}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@out@minus}
% An active minus sign is needed.
%    \begin{macrocode}
\newcommand*{\si@out@minus}{\ensuremath{-}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifsi@out@num}
% A flag is needed to control output settings.  This will be
% false unless inside \cs{si@out@num}.
%    \begin{macrocode}
\newif\ifsi@out@num
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@out@num}
% For numerical output, the default fonts are controlled slightly
% differently to text output.\\
%\cs{si@out@num}\marg{num}
%    \begin{macrocode}
\newcommand*{\si@out@num}[1]{%
  \begingroup
    \si@out@numtrue
    \si@out{#1}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Finalisation}
%\begin{macro}{\si@extension}
%\begin{macro}{\si@fileprefix}
% To keep the code easy to maintain, the reusable filename components
% are macros rather than literals.
%    \begin{macrocode}
\newcommand*{\si@extension}{cfg}
\newcommand*{\si@fileprefix}{si-}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@ifl@aded}
%\begin{macro}{\si@ifloaded}
% A bit of borrowing from the \LaTeX\ kernel.  A copy of \cs{@ifl@aded}
% is needed as things aren't always done in the preamble by
% \currpkg.\\
%\cs{si@ifloaded}\marg{package}
%    \begin{macrocode}
\newcommand*{\si@ifl@aded}{}
\let\si@ifl@aded\@ifl@aded
\newcommand*{\si@ifloaded}[1]{%
  \si@ifl@aded\si@extension{\si@fileprefix#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@loadfile}
% Loading configuration files is handled here.\\
%\cs{si@loadfile}\marg{file}
%    \begin{macrocode}
\newcommand*{\si@loadfile}[1]{%
  \si@ifloaded{#1}{}
    {\InputIfFileExists{\si@fileprefix#1.\si@extension}
      {}
      {\si@log@err{Failed to load file
         \si@fileprefix#1.\si@extension}
         {The configuration file requested could not be
          found}}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\requiresiconfigs}
% The configuration files depend on each other.\\
%\cs{requiresiconfigs}\marg{cfg-file}
%    \begin{macrocode}
\newcommand*{\requiresiconfigs}[1]{%
  \@for\si@tempb:=#1\do{\si@loadfile{\si@tempb}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@loademfile}
% For emulation files, an additional check is made.\\
%\cs{si@loademfile}\marg{file}
%    \begin{macrocode}
\newcommand*{\si@loademfile}[1]{%
  \@ifpackageloaded{#1}
    {\si@log@err{Emulation clash for package `#1'}
      {You have asked for emulation of package
       `#1'\MessageBreak
       (perhaps by giving siunitx a back-compatibility
       option)\MessageBreak but the package is already
       loaded!}}
    {\si@loadfile{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@emclash}
% A macro for emulation clashes.\\
%\cs{si@emclash}\marg{package}\marg{package}
%    \begin{macrocode}
\newcommand*{\si@emclash}[2]{%
  \si@log@err{Emulation clash: `#1' and `#2'}
    {You have asked for emulation of package `#1'\MessageBreak
     but have already loaded emulation of `#2'}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@emulating}
% For packages that are emulated, the \LaTeX\ mechanism to prevent
% re-loading is used.  The list of packages to check at the start
% of the document also has to be altered.\\
%\cs{si@emulating}\marg{package}\marg{version}
%    \begin{macrocode}
\newcommand*{\si@emulating}[2]{%
  \@namedef{ver@#1.sty}{#2 siunitx emulation of #1}%
  \let\si@tempa\si@blockpkgs
  \renewcommand*{\si@blockpkgs}{}%
  \@for\si@tempb:=\si@tempa\do{%
    \renewcommand*{\si@tempa}{#1}%
    \ifx\si@tempa\si@tempb\else
      \lowercase{\edef\si@tempa{#1}}%
      \lowercase{\edef\si@tempc{\si@tempb}}%
      \ifx\si@tempa\si@tempc
        \@namedef{ver@\si@tempc.sty}{#2 siunitx emulation of
          #1}%
      \else
        \si@addtolist{\si@blockpkgs}{\si@tempb}%
      \fi
    \fi}%
  \let\si@tempa\si@checkpkgs
  \renewcommand*{\si@checkpkgs}{}%
  \renewcommand*{\si@tempb}{#1}%
  \@for\si@tempc:=\si@tempa\do{%
    \ifx\si@tempb\si@tempc\else
      \si@addtolist{\si@checkpkgs}{\si@tempc}%
    \fi}}
%    \end{macrocode}
%\end{macro}
% With the \currpkg kernel macros defined, the package can now run
% through finalisation.  First, the default key values are set. The
% user options are then processed.
%    \begin{macrocode}
\sisetup{
  addsign=none,
  allowzeroexp=false,
  angformat=unchanged,
  astroang=false,%(
  closeerr=),%(
  closefrac=),
  colour=black,
  colourall=false,
  colourneg=false,
  decimalsymbol=fullstop,
  detectdisplay=true,
  digitsep=thin,
  dp=3,
  eVcorra=0.3ex,
  eVcorrb=0ex,
  errspace=none,
  fixdp=false,
  inlinebold=text,
  load=default,
  mathsrm=mathrm,
  mathssf=mathsf,
  mathstt=mathtt,
  mode=maths,
  negcolour=red,
  noload={},
  numaddn={},%(
  numcloseerr=),%
  numdecimal={.,},
  numdigits=0123456789,
  numexp=eEdD,
  numgobble={},
  numopenerr=(,%)
  numprod=x,
  numsign=+-\pm\mp,
  obeybold=false,
  obeyitalic=false,
  obeymode=false,
  openerr=(,%)
  openfrac=(,%)
  padangle=small,
  padnumber=lead,
  per=reciprocal,
  prefixbase=ten,
  prefixproduct=times,
  prefixsymbolic=true,
  prespace=false,
  redefsymbols=true,
  repeatunits=true,
  retainplus=false,
  seperr=false,
  sepfour=false,
  sign=plus,
  slash=slash,
  stickyper=false,
  strictarc=true,
  tabalignexp=true,
  tabautofit=false,
  tabformat=3.2,
  tabnumalign=centredecimal,
  tabtextalign=centre,
  tabunitalign=left,
  textrm=rmfamily,
  textsf=sffamily,
  texttt=ttfamily,
  tightpm=false,
  trapambigerr=true,
  trapambigfrac=true,
  unitsep=thin,
  valuesep=thin,
  xspace=false}
\ProcessOptionsX[si]<key>
%    \end{macrocode}
% A check is now made so that emulation takes place one file at a
% time, and that each file is loaded only once.
%    \begin{macrocode}
\ifx\@empty\si@emulate\@empty\else
  \@for\si@tempa:=\si@emulate\do{%
    \si@loademfile{\si@tempa}}
\fi
%    \end{macrocode}
%\begin{macro}{\si@expanddefault}
% For turning the list of default choices into a loadable list.
%    \begin{macrocode}
\newcommand*{\si@expanddefault}[2]{%
  \expandafter\ifx\expandafter\@empty\csname si@#1\endcsname
    \@empty
  \else
    \renewcommand*{\si@tempb}{default}%
    \renewcommand*{\si@tempc}{}%
    \expandafter\@for\expandafter\si@tempa\expandafter
      :\expandafter=\csname si@#1\endcsname\do{%
      \ifx\si@tempa\si@tempb
        \si@addtolist{\si@tempc}{#2}%
      \else
        \si@addtolist{\si@tempc}{\si@tempa}%
      \fi}
    \expandafter\edef\csname si@#1\endcsname{\si@tempc}%
    \expandafter\si@addtolist\expandafter{%
      \csname si@no#1\endcsname}%
      {default}%
    \renewcommand*{\si@tempc}{}%
    \expandafter\@for\expandafter\si@tempa\expandafter
      :\expandafter=\csname si@#1\endcsname\do{%
      \si@switchfalse
      \expandafter\@for\expandafter\si@tempb\expandafter
        :\expandafter=\csname si@no#1\endcsname\do{%
        \ifx\si@tempa\si@tempb
          \si@switchtrue
        \fi
        \ifsi@switch\else
          \si@addtolist{\si@tempc}{\si@tempa}%
        \fi}}
    \@for\si@tempa:=\si@tempc\do{%
      \si@loadfile{\si@tempa}}%
  \fi}
%    \end{macrocode}
%\end{macro}
% The configuration and abbreviation files are loaded.
%    \begin{macrocode}
\si@expanddefault{load}{prefix,named,addn,prefixed,accepted,%
  physical,abbr}
%    \end{macrocode}
% The very last job is to load a local configuration file, if one
% exists, and restore catcodes.
%    \begin{macrocode}
\IfFileExists{siunitx.cfg}
  {\si@log@inf{Local configuration file found}%
   \InputIfFileExists{siunitx.cfg}{}{}}
  {}
\si@catcodes
%    \end{macrocode}
%
%\iffalse
%</package>
%\fi
%
%\section{Loadable modules}
% To keep the package relatively clear, and to make maintenance
% easier, the only units defined in the package itself are the base
% units. Everything else is a loadable module (similar to the
% approach in \unitsdef).
%
%\iffalse
%<*prefix>
%\fi
%\subsection{Multiple prefixes}
%\begin{macro}{\yocto}
%\begin{macro}{\zepto}
%\begin{macro}{\atto}
%\begin{macro}{\femto}
%\begin{macro}{\pico}
%\begin{macro}{\nano}
%\begin{macro}{\micro}
%\begin{macro}{\Micro}
%\begin{macro}{\milli}
%\begin{macro}{\centi}
%\begin{macro}{\deci}
% The various SI multiple prefixes are defined here.  First the small
% powers.
%    \begin{macrocode}
\ProvidesFile{si-prefix.cfg}
  [\csname si@svn@version\endcsname siunitx:
   SI Multiple prefixes]
\newprefix{\yocto}{-24}{y}
\newprefix{\zepto}{-21}{z}
\newprefix{\atto}{-18}{a}
\newprefix{\femto}{-15}{f}
\newprefix{\pico}{-12}{p}
\newprefix{\nano}{-9}{n}
%    \end{macrocode}
% Some testing is needed for \unitsdef compatibility.
%    \begin{macrocode}
\ifsi@old@OHM
  \newprefix{\Micro}{-6}{\si@sym@mu}
\else
  \ifsi@gensymb\else
    \newprefix{\micro}{-6}{\si@sym@mu}
  \fi
\fi
\newprefix{\milli}{-3}{m}
\newprefix{\centi}{-2}{c}
\newprefix{\deci}{-1}{d}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\deca}
%\begin{macro}{\hecto}
%\begin{macro}{\kilo}
%\begin{macro}{\mega}
%\begin{macro}{\giga}
%\begin{macro}{\tera}
%\begin{macro}{\peta}
%\begin{macro}{\exa}
%\begin{macro}{\zetta}
%\begin{macro}{\yotta}
% Now the large ones.
%    \begin{macrocode}
\newprefix{\deca}{1}{da}
\newprefix{\hecto}{2}{h}
\newprefix{\kilo}{3}{k}
\newprefix{\mega}{6}{M}
\newprefix{\giga}{9}{G}
\newprefix{\tera}{12}{T}
\newprefix{\peta}{15}{P}
\newprefix{\exa}{18}{E}
\newprefix{\zetta}{21}{Z}
\newprefix{\yotta}{24}{Y}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\deka}
% Apparently, ``deka'' is common in the US for deca.
%    \begin{macrocode}
\newprefix{\deka}{1}{da}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gram}
%\begin{macro}{\kilogram}
% As the base unit of mass is the kilogram, rather than the gram, a
% bit of extra work is needed; by default the package only defines
% \cs{kilogram}, but with the prefixes available, this is altered to
% be \cs{kilo}\cs{gram}.  For that, the \cs{gram} must be defined first.
%    \begin{macrocode}
\newunit{\gram}{g}
\renewunit{\kilogram}{\kilo\gram}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\iffalse
%</prefix>
%<*named>
%\fi
%\subsection{Derived units with specific names}
%\begin{macro}{\becquerel}
%\begin{macro}{\coulomb}
%\begin{macro}{\farad}
%\begin{macro}{\Gray}
%\begin{macro}{\ggray}
%\begin{macro}{\hertz}
%\begin{macro}{\henry}
%\begin{macro}{\joule}
%\begin{macro}{\katal}
%\begin{macro}{\lumen}
%\begin{macro}{\lux}
%\begin{macro}{\newton}
% Derived units with specific names and symbols are defined.  Litre
% is an awkward one, but here the UK standard is used.
%    \begin{macrocode}
\ProvidesFile{si-named.cfg}
  [\csname si@svn@version\endcsname siunitx: SI Named units]
\newunit{\becquerel}{Bq}
\newunit{\coulomb}{C}
\newunit{\farad}{F}
\newunit{\Gray}{Gy}
\newunit{\ggray}{Gy}
\newunit{\hertz}{Hz}
\newunit{\henry}{H}
\newunit{\joule}{J}
\newunit{\katal}{kat}
\newunit{\lumen}{lm}
\newunit{\lux}{lx}
\newunit{\newton}{N}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ohm}
%\begin{macro}{\Ohm}
%\begin{macro}{\pascal}
%\begin{macro}{\siemens}
%\begin{macro}{\sievert}
%\begin{macro}{\tesla}
%\begin{macro}{\volt}
%\begin{macro}{\watt}
%\begin{macro}{\weber}
% Some testing is needed for \unitsdef compatibility.
%    \begin{macrocode}
\ifsi@old@OHM
  \newunit{\Ohm}{\si@sym@Omega}
\else
  \ifsi@gensymb\else
%    \end{macrocode}
% To be on the safe side, use \cs{provideunit}.
%    \begin{macrocode}
    \provideunit{\ohm}{\si@sym@Omega}
  \fi
\fi
\newunit{\pascal}{Pa}
\newunit{\siemens}{S}
\newunit{\sievert}{Sv}
\newunit{\tesla}{T}
\newunit{\volt}{V}
\newunit{\watt}{W}
\newunit{\weber}{Wb}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\celsius}
%\begin{macro}{\Celsius}
% The degree celsius is a named unit.
%    \begin{macrocode}
\ifsi@old@OHM
  \newunit{\Celsius}{\si@sym@celsius}
\else
  \ifsi@gensymb\else
    \newunit{\celsius}{\si@sym@celsius}
  \fi
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\radian}
%\begin{macro}{\steradian}
% The radian and steradian are officially derived units.
%    \begin{macrocode}
\newunit{\radian}{rad}
\newunit{\steradian}{sr}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\iffalse
%</named>
%<*prefixed>
%\fi
%\subsection{Units with prefixes}
% As in \unitsdef, some commonly used prefixed units are set up.
% This requires \file{si-prefix.cfg} and \file{si-named.cfg}.
%    \begin{macrocode}
\ProvidesFile{si-prefixed.cfg}
  [\csname si@svn@version\endcsname siunitx:
   SI Prefixed units]
\requiresiconfigs{prefix,named,accepted,physical}
%    \end{macrocode}
%\begin{macro}{\picometre}
%\begin{macro}{\nanometre}
%\begin{macro}{\micrometre}
%\begin{macro}{\millimetre}
%\begin{macro}{\centimetre}
%\begin{macro}{\decimetre}
%\begin{macro}{\kilometre}
% Extra distances.
%    \begin{macrocode}
\newunit{\picometre}{\pico\metre}
\newunit{\nanometre}{\nano\metre}
\newunit{\micrometre}{\micro\metre}
\newunit{\millimetre}{\milli\metre}
\newunit{\centimetre}{\centi\metre}
\newunit{\decimetre}{\deci\metre}
\newunit{\kilometre}{\kilo\metre}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\femtogram}
%\begin{macro}{\picogram}
%\begin{macro}{\nanogram}
%\begin{macro}{\microgram}
%\begin{macro}{\milligram}
% Extra masses.
%    \begin{macrocode}
\newunit{\femtogram}{\femto\gram}
\newunit{\picogram}{\pico\gram}
\newunit{\nanogram}{\nano\gram}
\newunit{\microgram}{\micro\gram}
\newunit{\milligram}{\milli\gram}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\femtomole}
%\begin{macro}{\picomole}
%\begin{macro}{\nanomole}
%\begin{macro}{\micromole}
%\begin{macro}{\millimole}
% Now some moles.
%    \begin{macrocode}
\newunit{\femtomole}{\femto\mole}
\newunit{\picomole}{\pico\mole}
\newunit{\nanomole}{\nano\mole}
\newunit{\micromole}{\micro\mole}
\newunit{\millimole}{\milli\mole}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\attosecond}
%\begin{macro}{\femtosecond}
%\begin{macro}{\picosecond}
%\begin{macro}{\nanosecond}
%\begin{macro}{\microsecond}
%\begin{macro}{\millisecond}
% Prefixed seconds.
%    \begin{macrocode}
\newunit{\attosecond}{\atto\second}
\newunit{\femtosecond}{\femto\second}
\newunit{\picosecond}{\pico\second}
\newunit{\nanosecond}{\nano\second}
\newunit{\microsecond}{\micro\second}
\newunit{\millisecond}{\milli\second}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\picoampere}
%\begin{macro}{\nanoampere}
%\begin{macro}{\microampere}
%\begin{macro}{\milliampere}
%\begin{macro}{\kiloampere}
% The last prefixed base units are amperes.
%    \begin{macrocode}
\newunit{\picoampere}{\pico\ampere}
\newunit{\nanoampere}{\nano\ampere}
\newunit{\microampere}{\micro\ampere}
\newunit{\milliampere}{\milli\ampere}
\newunit{\kiloampere}{\kilo\ampere}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\millivolt}
%\begin{macro}{\kilovolt}
%\begin{macro}{\milliwatt}
%\begin{macro}{\kilowatt}
%\begin{macro}{\megawatt}
%\begin{macro}{\femtofarad}
%\begin{macro}{\picofarad}
%\begin{macro}{\nanofarad}
%\begin{macro}{\microfarad}
%\begin{macro}{\millifarad}
%\begin{macro}{\millisiemens}
% More electricity-related units.
%    \begin{macrocode}
\newunit{\millivolt}{\milli\volt}
\newunit{\kilovolt}{\kilo\volt}
\newunit{\milliwatt}{\milli\watt}
\newunit{\kilowatt}{\kilo\watt}
\newunit{\megawatt}{\mega\watt}
\newunit{\femtofarad}{\femto\farad}
\newunit{\picofarad}{\pico\farad}
\newunit{\nanofarad}{\nano\farad}
\newunit{\microfarad}{\micro\farad}
\newunit{\millifarad}{\milli\farad}
\newunit{\millisiemens}{\milli\siemens}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\kiloohm}
%\begin{macro}{\megaohm}
%\begin{macro}{\gigaohm}
% For resistance, checks are needed again for the definition of
% \cs{ohm}.
%    \begin{macrocode}
\ifsi@old@OHM
  \newunit{\kiloohm}{\kilo\Ohm}
  \newunit{\megaohm}{\mega\Ohm}
  \newunit{\gigaohm}{\giga\Ohm}
\else
  \ifsi@gensymb\else
  \newunit{\kiloohm}{\kilo\ohm}
  \newunit{\megaohm}{\mega\ohm}
  \newunit{\gigaohm}{\giga\ohm}
  \fi
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\microlitre}
%\begin{macro}{\millilitre}
%\begin{macro}{\cubicmetre}
%\begin{macro}{\cubiccentimetre}
%\begin{macro}{\centimetrecubed}
%\begin{macro}{\cubicmicrometre}
%\begin{macro}{\cubicmillimetre}
%\begin{macro}{\cubicdecimetre}
% Volumes (unlike \unitsdef, with litre and metre spelled
% correctly).  \cs{millilitre} and \cs{microlitre} are defined
% as they are the two officially-sanctioned prefixes for the litre.
%    \begin{macrocode}
\newunit{\microlitre}{\micro\litre}
\newunit{\millilitre}{\milli\litre}
\newunit{\cubicmetre}{\metre\cubed}
\newunit{\cubiccentimetre}{\centi\metre\cubed}
\newunit{\centimetrecubed}{\centi\metre\cubed}
\newunit{\cubicmicrometre}{\micro\metre\cubed}
\newunit{\cubicmillimetre}{\milli\metre\cubed}
\newunit{\cubicdecimetre}{\cubic\deci\metre}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\squaremetre}
%\begin{macro}{\squarecentimetre}
%\begin{macro}{\centimetresquared}
%\begin{macro}{\squarekilometre}
% Areas, with metre spelled corrected; \cs{are} and \cs{hectare} are
% in the ``temporarily accepted'' file.
%    \begin{macrocode}
\newunit{\squaremetre}{\Square\metre}
\newunit{\squarecentimetre}{\Square\centi\metre}
\newunit{\centimetresquared}{\centi\metre\squared}
\newunit{\squarekilometre}{\Square\kilo\metre}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\millijoule}
%\begin{macro}{\kilojoule}
%\begin{macro}{\megajoule}
%\begin{macro}{\millielectronvolt}
%\begin{macro}{\kiloelectronvolt}
%\begin{macro}{\megaelectronvolt}
%\begin{macro}{\gigaelectronvolt}
%\begin{macro}{\teraelectronvolt}
%\begin{macro}{\kilowatthour}
% Some energy is needed by now!  Notice the definition of
% \cs{kilowatthour}
%    \begin{macrocode}
\newunit{\millijoule}{\milli\joule}
\newunit{\kilojoule}{\kilo\joule}
\newunit{\megajoule}{\mega\joule}
\newunit{\millielectronvolt}{\milli\electronvolt}
\newunit{\kiloelectronvolt}{\kilo\electronvolt}
\newunit{\megaelectronvolt}{\mega\electronvolt}
\newunit{\gigaelectronvolt}{\giga\electronvolt}
\newunit{\teraelectronvolt}{\tera\electronvolt}
\newunit[unitsep=none]{\kilowatthour}{\kilo\watt\hour}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\millihertz}
%\begin{macro}{\kilohertz}
%\begin{macro}{\megahertz}
%\begin{macro}{\gigahertz}
%\begin{macro}{\terahertz}
% Frequencies.
%    \begin{macrocode}
\newunit{\millihertz}{\milli\hertz}
\newunit{\kilohertz}{\kilo\hertz}
\newunit{\megahertz}{\mega\hertz}
\newunit{\gigahertz}{\giga\hertz}
\newunit{\terahertz}{\tera\hertz}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\millinewton}
%\begin{macro}{\kilonewton}
%\begin{macro}{\hectopascal}
%\begin{macro}{\megabecquerel}
%\begin{macro}{\millisievert}
% A few more from various areas.
%    \begin{macrocode}
\newunit{\millinewton}{\milli\newton}
\newunit{\kilonewton}{\kilo\newton}
\newunit{\hectopascal}{\hecto\pascal}
\newunit{\megabecquerel}{\mega\becquerel}
\newunit{\millisievert}{\milli\sievert}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</prefixed>
%<*abbr>
%\fi
%\subsection{Abbreviated units}
%\begin{macro}{\pA}
%\begin{macro}{\nA}
%\begin{macro}{\micA}
%\begin{macro}{\mA}
%\begin{macro}{\kA}
% The abbreviated units are sorted in one file.  To allow
% back-compatibility with \unitsdef, each one is inside an \cs{if}
% block for the appropriate option.  First currents.
%    \begin{macrocode}
\ProvidesFile{si-abbr.cfg}
  [\csname si@svn@version\endcsname siunitx: Abbreviated units]
\requiresiconfigs{prefix,named,accepted,physical}
\newunit{\pA}{\pico\ampere}
\newunit{\nA}{\nano\ampere}
\newunit{\micA}{\micro\ampere}
\newunit{\mA}{\milli\ampere}
\newunit{\kA}{\kilo\ampere}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\Hz}
%\begin{macro}{\mHz}
%\begin{macro}{\kHz}
%\begin{macro}{\MHz}
%\begin{macro}{\GHz}
%\begin{macro}{\THz}
% Then frequencies.
%    \begin{macrocode}
\newunit{\Hz}{\hertz}
\newunit{\mHz}{\milli\hertz}
\newunit{\kHz}{\kilo\hertz}
\newunit{\MHz}{\mega\hertz}
\newunit{\GHz}{\giga\hertz}
\newunit{\THz}{\tera\hertz}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\fmol}
%\begin{macro}{\pmol}
%\begin{macro}{\nmol}
%\begin{macro}{\micmol}
%\begin{macro}{\mmol}
% Amounts of substance.
%    \begin{macrocode}
\newunit{\fmol}{\femto\mole}
\newunit{\pmol}{\pico\mole}
\newunit{\nmol}{\nano\mole}
\newunit{\micmol}{\micro\mole}
\newunit{\mmol}{\milli\mole}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\kV}
%\begin{macro}{\mV}
% Potentials.
%    \begin{macrocode}
\newunit{\kV}{\kilo\volt}
\newunit{\mV}{\milli\volt}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\ml}
%\begin{macro}{\micl}
%\begin{macro}{\cmc}
%\begin{macro}{\dmc}
%\begin{macro}{\cms}
% Volumes and areas
%    \begin{macrocode}
\provideunit{\ml}{\milli\litre}
\provideunit{\micl}{\micro\litre}
\newunit{\cmc}{\centi\metre\cubed}
\newunit{\dmc}{\deci\metre\cubed}
\newunit{\cms}{\centi\metre\squared}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\fg}
%\begin{macro}{\SIfg}
%\begin{macro}{\kg}
%\begin{macro}{\fg}
%\begin{macro}{\pg}
%\begin{macro}{\nanog}
%\begin{macro}{\micg}
%\begin{macro}{\mg}
%\begin{macro}{\amu}
% Masses.
%    \begin{macrocode}
\newunit{\kg}{\kilo\gram}
%    \end{macrocode}
% There is a name clash with \pkg{babel} here in French; hopefully
% there will not be too many complaints.
%    \begin{macrocode}
\AtBeginDocument{\provideunit{\fg}{\femto\gram}}
\newunit{\SIfg}{\femto\gram}
\newunit{\pg}{\pico\gram}
\newunit{\nanog}{\nano\gram}
\newunit{\micg}{\micro\gram}
\newunit{\mg}{\milli\gram}
\newunit{\amu}{\atomicmass}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\kJ}
%\begin{macro}{\eV}
%\begin{macro}{\meV}
%\begin{macro}{\keV}
%\begin{macro}{\MeV}
%\begin{macro}{\GeV}
%\begin{macro}{\TeV}
%\begin{macro}{\kWh}
% Energies.
%    \begin{macrocode}
\newunit{\kJ}{\kilo\joule}
\newunit{\eV}{\electronvolt}
\newunit{\meV}{\milli\electronvolt}
\newunit{\keV}{\kilo\electronvolt}
\newunit{\MeV}{\mega\electronvolt}
\newunit{\GeV}{\giga\electronvolt}
\newunit{\TeV}{\tera\electronvolt}
\newunit[unitsep=none]{\kWh}{\kilo\watt\hour}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\picom}
%\begin{macro}{\nm}
%\begin{macro}{\micm}
%\begin{macro}{\mm}
%\begin{macro}{\cm}
%\begin{macro}{\dm}
%\begin{macro}{\km}
% Lengths.
%    \begin{macrocode}
\newunit{\picom}{\pico\metre}
\newunit{\nm}{\nano\metre}
\newunit{\micm}{\micro\metre}
\newunit{\mm}{\milli\metre}
\newunit{\cm}{\centi\metre}
\newunit{\dm}{\deci\metre}
\newunit{\km}{\kilo\metre}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\Sec}
%\begin{macro}{\as}
%\begin{macro}{\fs}
%\begin{macro}{\ps}
%\begin{macro}{\ns}
%\begin{macro}{\mics}
%\begin{macro}{\ms}
% Finally, times.
%    \begin{macrocode}
\newunit{\Sec}{\second}
\newunit{\as}{\atto\second}
\newunit{\fs}{\femto\second}
%    \end{macrocode}
% The letter class (and others) define \cs{ps} for postscripts, so
% \cs{provideunit} is best here.
%    \begin{macrocode}
\provideunit{\ps}{\pico\second}
\newunit{\ns}{\nano\second}
\newunit{\mics}{\micro\second}
\newunit{\ms}{\milli\second}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</abbr>
%<*addn>
%\fi
%\subsection{Additional (temporary) SI units}
%\begin{macro}{\angstrom}
%\begin{macro}{\are}
%\begin{macro}{\hectare}
%\begin{macro}{\barn}
%\begin{macro}{\BAR}
%\begin{macro}{\bbar}
%\begin{macro}{\millibar}
%\begin{macro}{\gal}
%\begin{macro}{\curie}
%\begin{macro}{\roentgen}
%\begin{macro}{\rad}
%\begin{macro}{\rem}
% Some units are ``temporarily'' acceptable for use in the SI system.
% These are defined here, although some are in very general use.
%    \begin{macrocode}
\ProvidesFile{si-addn.cfg}
  [\csname si@svn@version\endcsname siunitx:
   SI Additional units]
\newunit{\angstrom}{\si@sym@ringA}
\newunit{\are}{a}
\newunit{\hectare}{\hecto\are}
\newunit{\barn}{b}
\newunit{\BAR}{bar}
\newunit{\bbar}{bar}
\newunit{\millibar}{\milli\BAR}
\newunit{\gal}{Gal}
\newunit{\curie}{Ci}
\newunit{\roentgen}{R}
\newunit{\rad}{rad}
\newunit{\rem}{rem}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</addn>
%<*accepted>
%\fi
%\subsection{Units accepted for use with SI}
% The units which are accepted but do not fit in the above, plus
% \cs{percent} which seems to fit into this category.
%\begin{macro}{\minute}
%\begin{macro}{\hour}
%\begin{macro}{\Day}
%\begin{macro}{\dday}
%\begin{macro}{\degree}
%\begin{macro}{\Degree}
%\begin{macro}{\arcmin}
%\begin{macro}{\arcsec}
%\begin{macro}{\litre}
%\begin{macro}{\liter}
%\begin{macro}{\tonne}
%\begin{macro}{\neper}
%\begin{macro}{\bel}
%\begin{macro}{\percent}
%    \begin{macrocode}
\ProvidesFile{si-accepted.cfg}
  [\csname si@svn@version\endcsname siunitx: SI Accepted units]
\newunit{\minute}{min}
\newunit{\hour}{h}
\newunit{\Day}{d}
\newunit{\dday}{d}
\ifsi@old@OHM
  \newunit[valuesep=none]{\Degree}{\si@sym@degree}
\else
  \ifsi@gensymb\else
    \newunit[valuesep=none]{\degree}{\si@sym@degree}
  \fi
\fi
\newunit[valuesep=none]{\arcmin}{\si@sym@minute}
\newunit[valuesep=none]{\arcsec}{\si@sym@second}
\newunit{\litre}{l}
\newunit{\liter}{L}
\newunit{\tonne}{t}
\newunit{\neper}{Np}
\newunit{\bel}{B}
\newunit{\percent}{\%}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</accepted>
%<*physical>
%\fi
%\subsection{Units based on physical measurements}
%\begin{macro}{\si@eVspacea}
%\begin{macro}{\si@eVspaceb}
%\begin{macro}{\electronvolt}
%\begin{macro}{\atomicmassunit}
%\begin{macro}{\atomicmass}
% A few units based on physical measurements exist.  For \cs{eV}, the need
% for a negative kern does make things a bit complicated.
%    \begin{macrocode}
\ProvidesFile{si-physical.cfg}
  [\csname si@svn@version\endcsname siunitx:
   SI Physically-measured units]
\newcommand*{\si@eVspacea}{\text{\kern-\si@eVcorra}}%
\newcommand*{\si@eVspaceb}{\text{\kern-\si@eVcorrb}}%
\newunit{\electronvolt}{e\protect\si@eVspacea V\protect%
  \si@eVspaceb}
\newunit{\atomicmass}{u}
\newunit{\atomicmassunit}{u}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</physical>
%\fi
%
%\section{Additional configurations}
% To provide flexibility for people in specific areas, specialised
% units can be set up.  These are then stored separately to ease use.
%
%\iffalse
%<*synchem>
%\fi
%\subsection{Synthetic chemistry}
%\begin{macro}{\mmHg}
%\begin{macro}{\molar}
%\begin{macro}{\Molar}
%\begin{macro}{\torr}
%\begin{macro}{\dalton}
% Some useful units for synthetic chemists; although \cs{mmHg} and
% \cs{Molar} are outside of the SI system, they are used a lot.
% These are set up using \cs{provideunit} as people may have their
% own definitions.
%    \begin{macrocode}
\ProvidesFile{si-synchem.cfg}
  [\csname si@svn@version\endcsname siunitx: Units for
     synthetic chemists]
\requiresiconfigs{prefix}
\newunit{\mmHg}{mmHg}
\newunit{\molar}{\mole\per\cubic\deci\metre}
\newunit{\Molar}{\textsc{m}}
\newunit{\torr}{Torr}
\newunit{\dalton}{Da}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</synchem>
%<*hep>
%\fi
%\subsection{High-energy physics}
% Some units inspired by \pkg{hepunits}.
%    \begin{macrocode}
\ProvidesFile{si-hep.cfg}
  [\csname si@svn@version\endcsname siunitx: Units for
    high-energy physics]
\requiresiconfigs{prefix,named}
%    \end{macrocode}
%\begin{macro}{\micron}
%\begin{macro}{\mrad}
%\begin{macro}{\gauss}
% These specific to high-energy physics, but are not defined
% elsewhere in \currpkg.\footnote{It is not clear from
% \pkg{hepunits}, but the assumption is that \cs{mrad} represents
% millirad and not milliradian.}
%    \begin{macrocode}
\provideunit{\micron}{\micro\metre}
\newunit{\mrad}{\milli\rad}
\newunit{\gauss}{G}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\clight}
%\begin{macro}{\eVperc}
% The speed of light is used in units for the area, although of
% course it is not strictly a unit.  However, this makes it easier to
% use in other units.
%    \begin{macrocode}
\newunit{\clight}{\ensuremath{\mathnormal{c}}}
\newunit{\eVperc}{\eV\per\clight}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\nanobarn}
%\begin{macro}{\picobarn}
%\begin{macro}{\femtobarn}
%\begin{macro}{\attobarn}
%\begin{macro}{\zeptobarn}
%\begin{macro}{\yoctobarn}
% Various prefixed barns.
%    \begin{macrocode}
\newunit{\nanobarn}{\nano\barn}
\newunit{\picobarn}{\pico\barn}
\newunit{\femtobarn}{\femto\barn}
\newunit{\attobarn}{\atto\barn}
\newunit{\zeptobarn}{\zepto\barn}
\newunit{\yoctobarn}{\yocto\barn}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\nb}
%\begin{macro}{\pb}
%\begin{macro}{\fb}
%\begin{macro}{\ab}
%\begin{macro}{\zb}
%\begin{macro}{\yb}
% Abbreviations for the same, but using \cs{provideunit} to avoid any
% clashes.
%    \begin{macrocode}
\provideunit{\nb}{\nano\barn}
\provideunit{\pb}{\pico\barn}
\provideunit{\fb}{\femto\barn}
\provideunit{\ab}{\atto\barn}
\provideunit{\zb}{\zepto\barn}
\provideunit{\yb}{\yocto\barn}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</hep>
%<*astro>
%\fi
%\subsection{Astronomy}
%\begin{macro}{\parsec}
%\begin{macro}{\lightyear}
% For astronomy, the \cs{parsec} unit is needed.
%    \begin{macrocode}
\ProvidesFile{si-astro.cfg}
  [\csname si@svn@version\endcsname siunitx:
   Units for astronomy]
\newunit{\parsec}{pc}
\newunit{\lightyear}{ly}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\iffalse
%</astro>
%<*binary>
%\fi
%\subsection{Binary units}
%\begin{macro}{\kibi}
%\begin{macro}{\mebi}
%\begin{macro}{\gibi}
%\begin{macro}{\tebi}
%\begin{macro}{\pebi}
%\begin{macro}{\exbi}
%\begin{macro}{\zebi}
%\begin{macro}{\yobi}
% The binary units, as specified by the IEC and made available by
% \SIunits. First, the binary prefixes.
%    \begin{macrocode}
\ProvidesFile{si-binary.cfg}
  [\csname si@svn@version\endcsname siunitx: Binary units]
\newprefix[binary]{\kibi}{10}{Ki}
\newprefix[binary]{\mebi}{20}{Mi}
\newprefix[binary]{\gibi}{30}{Gi}
\newprefix[binary]{\tebi}{40}{Ti}
\newprefix[binary]{\pebi}{50}{Pi}
\newprefix[binary]{\exbi}{60}{Ei}
\newprefix[binary]{\zebi}{70}{Zi}
\newprefix[binary]{\yobi}{80}{Yi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\bit}
%\begin{macro}{\byte}
% Now the units.
%    \begin{macrocode}
\newunit{\bit}{bit}
\newunit{\byte}{B}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\iffalse
%</binary>
%\fi
%
%\section{Loadable locales}
% Some short files to provide the correct settings for various places.
%
%\iffalse
%<*UK>
%\fi
%\subsection{United Kingdom}
% This is identical to the USA locale, and contains the package
% default values.\footnote{The package author is in the UK.}
%    \begin{macrocode}
\ProvidesFile{si-UK.cfg}
  [\csname si@svn@version\endcsname siunitx: UK locale]
\sisetup{
  unitsep=thin,
  expproduct=times,
  valuesep=thin,
  decimalsymbol=fullstop,
  digitsep=thin,
  sepfour=false}
%    \end{macrocode}
%\iffalse
%</UK>
%<*USA>
%\fi
%\subsection{United States}
% The same as for the UK.
%    \begin{macrocode}
\ProvidesFile{si-USA.cfg}
  [\csname si@svn@version\endcsname siunitx: USA locale]
\sisetup{
  unitsep=thin,
  expproduct=times,
  valuesep=thin,
  decimalsymbol=fullstop,
  digitsep=thin,
  sepfour=false}
%    \end{macrocode}
%\iffalse
%</USA>
%<*DE>
%\fi
%\subsection{Germany}
% Germany, hopefully.
%    \begin{macrocode}
\ProvidesFile{si-DE.cfg}
  [\csname si@svn@version\endcsname siunitx: Germany locale]
\sisetup{
  unitsep=cdot,
  valuesep=thin,
  decimalsymbol=comma,
  expproduct=cdot,
  digitsep=thin,
  sepfour=false}
%    \end{macrocode}
%\iffalse
%</DE>
%<*ZA>
%\fi
%\subsection{South Africa}
% Design decisions taken from the same section of \SIstyle.
%    \begin{macrocode}
\ProvidesFile{si-ZA.cfg}
  [\csname si@svn@version\endcsname siunitx:
   South Africa locale]
\sisetup{
  unitsep=cdot,
  valuesep=thin,
  expproduct=times,
  decimalsymbol=comma,
  digitsep=thin,
  sepfour=false}
%    \end{macrocode}
%\iffalse
%</ZA>
%\fi
%
%\section{Emulation code}
% Each emulation mode loads an appropriate definition file.  This
% then alters the package defaults, and defines new macros provided
% by the emulated package.
%
%\iffalse
%<*units>
%\fi
%\subsection{\units}
% The very first thing to do here is a reload check, as things
% could go wrong with \unitsdef emulation.
%    \begin{macrocode}
\si@ifloaded{units}{\endinput}{}
%    \end{macrocode}
% The \units package is quite easy to emulate, as it only has a
% few options and macros. There is also no error checking in
% \units for conflicting options, so users probably expect none.
%    \begin{macrocode}
\ProvidesFile{si-units.cfg}
  [\csname si@svn@version\endcsname siunitx: Emulation of units]
\si@emulating{units}{1998/08/04 v0.9b}
\si@ifloaded{SIunits}
  {\si@emclash{units}{SIunits}\endinput}{}
\si@ifloaded{sistyle}
  {\si@emclash{units}{sistyle}\endinput}{}
%    \end{macrocode}
% To emulate \units, \cs{per} must give fractions.
%    \begin{macrocode}
\sisetup{per=fraction,fraction=nice,obeybold,inlinebold=maths,
  ,obeymode}
\ifsi@old@tight
  \sisetup{valuesep=thin}
\fi
\ifsi@old@loose
  \sisetup{valuesep=space}
\fi
\ifsi@old@ugly
  \sisetup{fraction=ugly}
\fi
%    \end{macrocode}
%\begin{macro}{\unit}
% The \units version of \cs{unit} is similar to \cs{SI}.  Here and
% in \cs{unitfrac} the \cs{num} macro is used; thus the number given
% really has to be a number.  However, if users are using \currpkg
% rather than \units they should expect more checking of input.  As
% the \units package uses the current mode, this has to be
% detected.\\
%\cs{unit}\oarg{num}\marg{unit}
%    \begin{macrocode}
\si@newrobustcmd*{\unit}[2][]{%
  \ifmmode
    \SI{#1}{#2}%
  \else
    \SI[obeyfamily,obeyitalic]{#1}{#2}%
  \fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\unitfrac}
% \cs{unitfrac} is a bit more of a hack.\\
%\cs{unitfrac}\oarg{num}\marg{numerator}\marg{denominator}
%    \begin{macrocode}
\si@newrobustcmd*{\unitfrac}[3][]{%
  \begingroup
    \si@fam@mode%
    \ifmmode\else
      \sisetup{obeyfamily,obeyitalic}%
    \fi
    \si@ifnotmtarg{#1}
      {\num{#1}\ensuremath{\si@valuesep}}%
    \si@frac{#2}{#3}
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\iffalse
%</units>
%\fi
%\iffalse
%<*unitsdef>
%\fi
%\subsection{\unitsdef}
% The package begins with the usual identification of what is
% happening.  Although \file{si-units.cfg} makes the same checks,
% the error will make more sense if it comes here, in the event of a
% clash.
%    \begin{macrocode}
\ProvidesFile{si-unitsdef.cfg}
  [\csname si@svn@version\endcsname siunitx:
   Emulation of unitsdef]
\si@emulating{unitsdef}{2005/01/04 v0.2}
\si@ifloaded{SIunits}
  {\si@emclash{unitsdef}{SIunits}\endinput}{}
\si@ifloaded{sistyle}
  {\si@emclash{unitsdef}{sistyle}\endinput}{}
%    \end{macrocode}
% Emulation of \units is needed for \unitsdef to work.
%    \begin{macrocode}
\requiresiconfigs{units}
%    \end{macrocode}
% The \unitsdef package loads some packages that \currpkg does not.
% In particular, it loads \pkg{textcomp} and \pkg{fontenc}.  This
% could be important for output, and so the same is done here.
%    \begin{macrocode}
\RequirePackage{textcomp}
\RequirePackage[T1]{fontenc}
%    \end{macrocode}
% The multitude of package options for \unitsdef need to be handled.
%    \begin{macrocode}
\sisetup{mode=text,allowoptarg,prespace}
\ifsi@old@noxspace
  \sisetup{xspace=false}
\fi
%    \end{macrocode}
% The various options for loading unit abbreviations have to be
% handled. Here, any request to avoid abbreviations prevents any
% loading.
%    \begin{macrocode}
\ifsi@old@noabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@nofrequncyabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@nomolabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@novoltageabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@novolumeabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@noweightabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@noenergyabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@nolengthabbr
  \sisetup{noload=abbr}
\fi
\ifsi@old@notimeabbr
  \sisetup{noload=abbr}
\fi
%    \end{macrocode}
%\begin{macro}{\unitvaluesep}
% To emulate the \cs{unitvaluesep} macro, a hack is needed of the original
% \pkg{xkeyval} macro for \opt{valuesep}, as well of course as a definition
% of the macro itself.
%    \begin{macrocode}
\newcommand*{\unitvaluesep}{\,}
\renewcommand*{\si@valuesep}{\text{\unitvaluesep}}
\define@choicekey*+[si]{key}{valuesep}[\si@tempa]
  {space,thin,med,medium,thick,none}
  {\renewcommand*\unitvaluesep\@nameuse{si@fix@##1}%
   \si@log@debug{Option valuesep set to ##1}}
  {\si@log@debug{Option valuesep set to ##1}%
   \renewcommand*\unitvaluesep{##1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\unitsignonly}
%\begin{macro}{\ilu}
%\begin{macro}{\arc}
% Some rather straight-forward definitions, with just a bit of fun to
% get the spacing correct.
%    \begin{macrocode}
\let\unitsignonly\si
\si@newrobustcmd*{\ilu}[2][]{%
  \begingroup
    #1\unitvaluesep%
    \unit{#2}%
  \endgroup}
\let\arc\ang
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\unitSIdef}
%\begin{macro}{\si@unitSIdef}
% The \unitsdef package uses a different approach to setting the font
% inside its version of \cs{SI}.  The problem is the same as for
% \cs{unitvaluesep}, but with the added problem that \currpkg uses
% \cs{csname} \ldots \cs{endcsname}.
%    \begin{macrocode}
\newcommand*{\unitSIdef}{\upshape}
\newcommand*{\si@unitSIdef}{\unitSIdef\selectfont}
\sisetup{textrm=si@unitSIdef}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\per}
% Rather awkwardly, \unitsdef uses \cs{per} in a different way to
% \currpkg.
%    \begin{macrocode}
\let\per\relax
\si@newrobustcmd*{\per}[2]{%
  \begingroup
    \si@xspacefalse
    \renewcommand*{\unitvaluesep}{}%
    \unitfrac{#1}{#2}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\unittimes}
%\begin{macro}{\unitsep}
%\begin{macro}{\unitsuperscript}
% Some pretty straight-forward stuff again; notice that the automatic
% analyser for units has to be turned off for this to work.
%    \begin{macrocode}
\newcommand*{\unittimes}{\ensuremath{\cdot}}
\newcommand*{\unitsep}{\,}
\renewcommand*{\si@unt@unithook}{\si@unt@litouttrue}
\sisetup{unitsep=none}
\newcommand*{\unitsuperscript}{\tothe}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\newnosepunit}
%\begin{macro}{\renewnosepunit}
% Simple aliases.
%    \begin{macrocode}
\newcommand*{\newnosepunit}{\newunit[valuesep=none]}
\newcommand*{\renewnosepunit}{\renewunit[valuesep=none]}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\setTextOmega}
%\begin{macro}{\setMathOmega}
%\begin{macro}{\setTextmu}
%\begin{macro}{\setMathmu}
%\begin{macro}{\setTextCelsius}
%\begin{macro}{\setMathCelsius}
%\begin{macro}{\setMathDegree}
%\begin{macro}{\setTextDegree}
% Controlling symbols is a simple translation job; as only one
% setting is used by \currpkg in text mode, a bit of extra work is
% needed.
%    \begin{macrocode}
\newcommand*{\setTextOmega}[2]{%
  \renewcommand*{\si@textOmega}{%
      \begingroup
      \edef\si@tempa{\sfdefault}%
      \ifx\f@family\si@tempa
        \expandafter#2%
      \else
        \expandafter#1%
      \fi
    \endgroup}}
\newcommand*{\setMathOmega}[1]{\sisetup{mathsOmega=#1}}
\newcommand*{\setTextmu}[2]{%
  \renewcommand*{\si@textmu}{%
    \begingroup
      \edef\si@tempa{\sfdefault}%
      \ifx\f@family\si@tempa
        \expandafter#2%
      \else
        \expandafter#1%
      \fi
    \endgroup}}
\newcommand*{\setMathmu}[1]{\sisetup{mathsmu=#1}}
\newcommand*{\setTextCelsius}[2]{%
  \renewcommand*{\si@textcelsius}{%
    \begingroup
      \edef\si@tempa{\sfdefault}%
      \ifx\f@family\si@tempa
        \expandafter#2%
      \else
        \expandafter#1%
      \fi
    \endgroup}}
\newcommand*{\setMathCelsius}[1]{\sisetup{mathscelsius=#1}}
\newcommand*{\setMathDegree}[2]{%
  \renewcommand*{\si@textdegree}{%
    \begingroup%
      \edef\si@tempa{\sfdefault}%
      \ifx\f@family\si@tempa
        \expandafter#2%
      \else
        \expandafter#1%
      \fi
    \endgroup}}
\newcommand*{\setTextDegree}[1]{\sisetup{textdegree=#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% The \opt{ohm} and \opt{OHM} options are checked, and some sanity is
% ensured.  This needs to happen before loading the configuration
% files.
%    \begin{macrocode}
\ifsi@old@OHM
  \ifsi@old@ohm
    \si@log@inf{Both `ohm' and `OHM' options given\MessageBreak
      Using default behaviour for unitsdef}
    \expandafter\expandafter\expandafter\si@old@OHMfalse
  \fi
\fi
%    \end{macrocode}
%\begin{macro}{\liter}
%\begin{macro}{\ton}
%\begin{macro}{\days}
% Tonne is spelled as ``ton'' by \unitsdef, which is wrong in the UK
% at least (\SI{1}{ton} $=$ \SI{40}{cwt} $=$ \SI{2240}{lb}!).
%    \begin{macrocode}
\ifsi@old@liter
  \ifsi@old@LITER
    \si@log@inf{Both `liter' and `LITER' options
      given\MessageBreak Using default behaviour for unitsdef}
  \else
    \renewunit{\liter}{l}
  \fi
\fi
\newunit{\ton}{t}
\newunit{\days}{d}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\picometer}
%\begin{macro}{\nanometer}
%\begin{macro}{\micrometer}
%\begin{macro}{\millimeter}
%\begin{macro}{\centimeter}
%\begin{macro}{\decimeter}
%\begin{macro}{\kilometer}
% Extra distances.
%    \begin{macrocode}
\newunit{\picometer}{\pico\meter}
\newunit{\nanometer}{\nano\meter}
\newunit{\micrometer}{\micro\meter}
\newunit{\millimeter}{\milli\meter}
\newunit{\centimeter}{\centi\meter}
\newunit{\decimeter}{\deci\meter}
\newunit{\kilometer}{\kilo\meter}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\femtoliter}
%\begin{macro}{\picoliter}
%\begin{macro}{\nanoliter}
%\begin{macro}{\microliter}
%\begin{macro}{\milliliter}
%\begin{macro}{\centiliter}
%\begin{macro}{\deciliter}
%\begin{macro}{\hectoliter}
%\begin{macro}{\cubicmeter}
%\begin{macro}{\cubicmicrometer}
%\begin{macro}{\cubicmillimeter}
% Volumes with US spellings.
%    \begin{macrocode}
\newunit{\femtoliter}{\femto\liter}
\newunit{\picoliter}{\pico\liter}
\newunit{\nanoliter}{\nano\liter}
\newunit{\microliter}{\micro\liter}
\newunit{\milliliter}{\milli\liter}
\newunit{\centiliter}{\centi\liter}
\newunit{\deciliter}{\deci\liter}
\newunit{\hectoliter}{\hecto\liter}
\newunit{\cubicmeter}{\meter\cubed}
\newunit{\cubicmicrometer}{\micro\meter\cubed}
\newunit{\cubicmillimeter}{\milli\meter\cubed}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\squaremeter}
%\begin{macro}{\squarecentimeter}
%\begin{macro}{\squarekilometer}
%\begin{macro}{\ar}
%\begin{macro}{\hectar}
% Areas, including the mis-spellings for \cs{are} and
% \cs{hectare}.
%    \begin{macrocode}
\newunit{\squaremeter}{\Square\meter}
\newunit{\squarecentimeter}{\Square\centi\meter}
\newunit{\squarekilometer}{\Square\kilo\meter}
\newunit{\ar}{a}
\newunit{\hectar}{\hecto\ar}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\kv}
%\begin{macro}{\mv}
% The code for \unitsdef has the capitalisation wrong for \cs{kV} and
% \cs{mV}.
%    \begin{macrocode}
\ifsi@old@noabbr
\else
  \ifsi@old@novoltageabbr\else
    \newunit{\kv}{\kilo\volt}
    \newunit{\mv}{\milli\volt}
  \fi
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\sek}
%\begin{macro}{\fg}
%\begin{macro}{\fl}
%\begin{macro}{\pl}
%\begin{macro}{\nl}
%\begin{macro}{\micl}
%\begin{macro}{\ml}
%\begin{macro}{\cl}
%\begin{macro}{\dl}
%\begin{macro}{\hl}
% There are some slightly different abbreviations, plus some which
% are not officially allowed.
%    \begin{macrocode}
\ifsi@old@noabbr\else
  \ifsi@old@notimeabbr\else
    \newunit{\sek}{\second}
  \fi
  \ifsi@old@noweightabbr\else
    \newunit{\fg}{\femto\gram}
  \fi
  \ifsi@old@novolumeabbr\else
    \newunit{\fl}{\femto\liter}
    \newunit{\pl}{\pico\liter}
    \newunit{\nl}{\nano\liter}
    \newunit{\micl}{\micro\liter}
    \newunit{\ml}{\milli\liter}
    \newunit{\cl}{\centi\liter}
    \newunit{\dl}{\deci\liter}
    \newunit{\hl}{\hecto\liter}
  \fi
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\calory}
%\begin{macro}{\kilocalory}
% \unitsdef spells calorie incorrectly, and it is also not an SI unit.
%    \begin{macrocode}
\newunit{\calory}{cal}
\newunit{\kilocalory}{\kilo\calory}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\uBar}
% \unitsdef uses \cs{ubar} for bar.
%    \begin{macrocode}
\newunit{\uBar}{ba}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gensymbohm}
%\begin{macro}{\gensymbcelsius}
%\begin{macro}{\gensymbmicro}
%\begin{macro}{\gensymbdegree}
% If the options relating to \pkg{gensymb} are given, then the
% package \emph{has} to be loaded.  The definitions are then renamed;
% a slight awkward feature is that the hyphen character needs to be a
% letter.  To avoid needing to worry about this again, a second
% switch is set up.
%    \begin{macrocode}
\catcode`\-=11\relax
\ifsi@old@redef-gensymb
  \expandafter\si@gensymbtrue
\fi
\catcode`\-=12\relax
\ifsi@gensymb
  \RequirePackage{gensymb}
  \AtBeginDocument{
    \let\gensymbohm\ohm
    \let\gensymbcelsius\celsius
    \let\gensymbmicro\micro
    \let\gensymbdegree\degree
    \let\ohm\@undefined
    \let\celsius\@undefined
    \let\micro\@undefined
    \let\degree\@undefined
    \ifsi@old@OHM\else
      \newunit{\ohm}{\si@sym@Omega}
      \newunit{\celsius}{\si@sym@celsius}
      \newprefix{\micro}{\si@sym@mu}{-6}
      \newunit{\degree}{\si@sym@degree}
    \fi}
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% The configuration files can now be loaded.
%    \begin{macrocode}
\requiresiconfigs{prefix,named,addn,accepted}
%    \end{macrocode}
% The \opt{noconfig} option could be ignored, but it costs little to
% let is be used.
%    \begin{macrocode}
\ifsi@old@noconfig\else
  \InputIfFileExists{unitsdef.cfg}
    {\si@log@inf{unitsdef config file loaded}}
    {\si@log@inf{unitsdef config file not found}}
\fi
%    \end{macrocode}
%
%\iffalse
%</unitsdef>
%<*sistyle>
%\fi
%\subsection{\SIstyle}
% After setting the necessary defaults, the emulation code defines
% the macros in \SIstyle as given in the manual for that package.
%    \begin{macrocode}
\ProvidesFile{si-sistyle.cfg}
  [\csname si@svn@version\endcsname siunitx: Emulation of
     SIstyle]
\si@emulating{sistyle}{2006/12/20 v2.3}
\sisetup{%
  sepfour=true,
  obeyfamily,
  obeyitalic=true,
  numsign=+-,
  strictarc=false,
  unitsep=cdot}
%    \end{macrocode}
%\begin{macro}{\SIobeyboldtrue}
%\begin{macro}{\SIobeyboldfalse}
% Some simple switches, but not using \cs{newif}.
%    \begin{macrocode}
\newcommand*{\SIobeyboldtrue}{\sisetup{obeybold=true}}
\newcommand*{\SIobeyboldfalse}{\sisetup{obeybold=false}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\num}
%\begin{macro}{\si@sis@num}
%\begin{macro}{\si@sis@numstar}
% To get the correct behaviour for \cs{num}, some redefinitions are
% needed to handle to optional |*|.
%    \begin{macrocode}
\let\num\relax
\si@newrobustcmd*{\num}{%
  \@ifstar
    {\si@sis@numstar}
    {\si@sis@num}}
\newcommand*{\si@sis@num}[2][]{%
  \begingroup%
    \sisetup{#1}%
    \expandafter\si@out@num\expandafter{\si@num{#2}}%
  \endgroup}
\newcommand*{\si@sis@numstar}[2][]{%
  \begingroup%
    \sisetup{mode=text,obeybold}%
    \sisetup{#1}%
    \expandafter\si@out@num\expandafter{\si@num{#2}}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\pnt}
% The \cs{pnt} macro is needed as |.| is active inside \cs{SI}.  The
% name is exactly the same as in \SIstyle, but the implementation is
% different.  This is not defined by the main package as there are
% better ways of including numbers in the output than this.
%    \begin{macrocode}
\newcommand*{\pnt}{\ensuremath{\si@decimalsymbol}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SIgroupfourtrue}
%\begin{macro}{\SIgroupfourfalse}
% Switches for grouping four characters.
%    \begin{macrocode}
\newcommand*{\SIgroupfourtrue}{\sisetup{sepfour=true}}
\newcommand*{\SIgroupfourfalse}{\sisetup{sepfour=false}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\SIunitsep}
%\begin{macro}{\SIunitspace}
%\begin{macro}{\SIunitdot}
% Whatever is given here is passed through to \cs{sisetup}.
%    \begin{macrocode}
\newcommand*{\SIunitsep}[1]{\sisetup{valuesep={#1}}}
\newcommand*{\SIunitspace}[1]{\sisetup{unitspace={#1}}}
\newcommand*{\SIunitdot}[1]{\sisetup{unitsep={#1}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\SIdecimalsymbol}
%\begin{macro}{\SIthousandsep}
%\begin{macro}{\SIproductsign}
%\begin{macro}{\SIdecimalsign}
% The same is true here, with the appropriate translation.
%    \begin{macrocode}
\newcommand*{\SIdecimalsymbol}[1]{\sisetup{decimalsymbol={#1}}}
\newcommand*{\SIthousandsep}[1]{\sisetup{digitsep={#1}}}
\newcommand*{\SIproductsign}[1]{\sisetup{expproduct={#1}}}
\newcommand*{\SIdecimalsign}[1]{\sisetup{decimalsymbol={#1}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\si@sis@savefont}
% The font definitions need a bit of extra work doing.  As both
% settings here have |@| as a letter, all should be fine.\\
%\cs{si@sis@savefont}\marg{setting}\marg{argument}
%    \begin{macrocode}
\newcommand*{\si@sis@savefont}[2]{%
  \@namedef{si@sis@#1}{#2}%
  \sisetup{#1=si@sis@#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SImathrm}
%\begin{macro}{\SImathsf}
%\begin{macro}{\SImathtt}
% The font control macros have to ensure that a macro name is passed
% to \cs{sisetup}.
%    \begin{macrocode}
\newcommand*{\SImathrm}[1]{\si@sis@savefont{mathrm}{#1}}
\newcommand*{\SImathsf}[1]{\si@sis@savefont{mathsf}{#1}}
\newcommand*{\SImathtt}[1]{\si@sis@savefont{mathtt}{#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\SIdefaultMfam}
%\begin{macro}{\SIdefaultNfam}
%\begin{macro}{\SIdefaultTfam}
% The same for the default keys.
%    \begin{macrocode}
\newcommand*{\SIdefaultMfam}[1]{\si@sis@savefont{mathrm}{#1}}
\newcommand*{\SIdefaultNfam}[1]{\si@sis@savefont{mathnumrm}{#1}}
\newcommand*{\SIdefaultTfam}[1]{\si@sis@savefont{textrm}{#1}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\ensureupmath}
% The \cs{ensureupmath} command guarantees processing by the
% font-matching system. The argument cannot be processed here, so
% care is needed.
%    \begin{macrocode}
\si@newrobustcmd*{\ensureupmath}[1]{%
  \begingroup
    \sisetup{mode=maths,obeyitalic=false}%
    \si@out{#1}%
  \endgroup}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\degC}
%\begin{macro}{\degF}
%\begin{macro}{\arcdeg}
% A few extra symbol names are needed.
%    \begin{macrocode}
\newcommand*{\degC}{\si@sym@celsius}
\newcommand*{\arcdeg}{\si@sym@degree}
\newcommand*{\degF}{\si@sym@degree F}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\AddToSIstyle}
%\begin{macro}{\SIstyle}
%\begin{macro}{\SIstyleToLang}
%\begin{macro}{\si@sis@addtolocale}
% Finally, the locale control.
%    \begin{macrocode}
\newcommand*{\SIstyle}[1]{\sisetup{locale=#1}}
\newcommand*{\SIstyleToLang}[2]{\sisetup{loctolang=#1:#2}}
\newcommand*{\AddToSIstyle}{%
  \si@switchfalse
  \@ifstar
    {\si@switchtrue
     \si@sis@addtolocale}
    {\si@sis@addtolocale}}
\newcommand*{\si@sis@addtolocale}[2]{%
  \ifsi@switch
    \expandafter\let\csname si@loc@#1@extra\endcsname\relax
  \fi
  \addtolocale{#1}{#2}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\iffalse
%</sistyle>
%<*SIunits>
%\fi
%\subsection{\SIunits}
% \SIunits emulation starts in much the same way.
%    \begin{macrocode}
\ProvidesFile{si-SIunits.cfg}
  [\csname si@svn@version\endcsname siunitx: Emulation of
     SIunits]
\si@emulating{SIunits}{2007/12/02 v1.36}
\sisetup{
  unitsep=thick,
  valuesep=thick,
  prefixproduct=\si@valuesep,
  trapambigfrac=false,
  stickyper}
\requiresiconfigs{prefix,named,accepted,physical}
%    \end{macrocode}
%\begin{macro}{\reciprocal}
%\begin{macro}{\rp}
%\begin{macro}{\per}
%\begin{macro}{\usk}
%\begin{macro}{\power}
%\begin{macro}{\rpsquare}
%\begin{macro}{\rpcubic}
%\begin{macro}{\fourth}
%\begin{macro}{\rpfourth}
% A few very simple translations, using the internal version of
% \cs{per} to allow changes of output style.
%    \begin{macrocode}
\newcommand*{\reciprocal}{\sisetup{per=reciprocal}\si@per}
\let\rp\reciprocal
\renewcommand*{\per}{\sisetup{per=slash}\si@per}
\newcommand*{\usk}{}
\newcommand*{\power}[1]{#1\tothe}
\newcommand*{\rpsquare}{\sisetup{per=reciprocal}\si@per\Square}
\newcommand*{\rpcubic}{\sisetup{per=reciprocal}\si@per\cubic}
\newpower{\fourth}{4}
\newcommand*{\rpfourth}{\sisetup{per=reciprocal}\si@per\fourth}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\rpsquared}
%\begin{macro}{\rpcubed}
% Here, some low-level switch changing is needed.
%    \begin{macrocode}
\newcommand*{\rpsquared}{%
  \sisetup{per=reciprocal}\si@unt@pertrue\si@unt@perseentrue%
    \squared}
\newcommand*{\rpcubed}{%
  \sisetup{per=reciprocal}\si@unt@pertrue\cubed}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\SIsetup}
%\begin{macro}{\si@siu@setup}
% The various package spacing options are processed.  They also have
% to be correctly handled by the \cs{SIsetup} macro.
%    \begin{macrocode}
\newcommand*{\SIsetup}[1]{%
  \@for\si@tempa:=#1\do{%
    \@ifundefined{ifsi@old@#1}
      {\si@log@warn{Unknown SIunits option `#1'}}
      {\csname si@old@#1true\endcsname}}
  \si@siu@setup}
\newcommand*{\si@siu@setup}{%
  \ifsi@old@cdot
    \sisetup{unitsep=cdot}%
  \fi
  \ifsi@old@thickspace
    \sisetup{unitsep=thick}%
  \fi
  \ifsi@old@mediumspace
    \sisetup{unitsep=medium}%
  \fi
  \ifsi@old@thinspace
    \sisetup{unitsep=thin}%
  \fi
  \ifsi@old@thickqspace
    \sisetup{valuesep=thick}%
  \fi
  \ifsi@old@mediumqspace
    \sisetup{valuesep=medium}%
  \fi
  \ifsi@old@thinqspace
    \sisetup{valuesep=thin}%
  \fi}
\si@siu@setup
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\square}
%\begin{macro}{\squaren}
% \SIunits does slightly different things about the clash with
% \cs{square}, and either redefines this macro or provides
% \cs{squaren}.
%    \begin{macrocode}
\ifsi@old@squaren
  \newpower{\squaren}{2}
\fi
\AtBeginDocument{%
  \@ifundefined{square}
    {\newpower{\square}{2}}
    {\ifsi@old@amssymb
       \renewpower{\square}{2}
     \else
       \ifsi@old@squaren\else
         \si@log@warn{\string\square\space already
           defined\MessageBreak SIunits mode may cause
           errors}%
       \fi
     \fi}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\gray}
% The potential clash with \pkg{PStricks} is also handled
% differently; here, \cs{Gray} will already be defined by the
%  \currpkg kernel.
%    \begin{macrocode}
\AtBeginDocument{
  \@ifundefined{gray}
    {\newunit{\gray}{Gy}}
    {\ifsi@old@pstricks
       \renewunit{\gray}{Gy}
     \else
       \ifsi@old@Gray\else
         \si@log@warn{\string\gray\space already
           defined\MessageBreak SIunits mode may cause
           errors}%
       \fi
     \fi}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\unit}
%\begin{macro}{\unita}
% The \cs{unit} macro is defined.
%    \begin{macrocode}
\ifsi@old@italian
  \let\unita\SI
\else
  \let\unit\SI
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
% The miscellaneous options are moped up.
%    \begin{macrocode}
\ifsi@old@textstyle
  \sisetup{mode=text}
\fi
\ifsi@old@binary
  \sisetup{alsoload=binary}
\fi
\ifsi@old@noams
  \AtBeginDocument{%
    \renewcommand*{\si@textmu}{\ensuremath\si@mathsmu}}
\fi
%    \end{macrocode}
%\begin{macro}{\arcminute}
%\begin{macro}{\arcsecond}
%\begin{macro}{\rperminute}
%\begin{macro}{\ton}
%\begin{macro}{\degreecelsius}
% The unit macros defined by \SIunits that are not defined by
% \currpkg (by default).
%    \begin{macrocode}
\newunit[valuesep=none]{\arcminute}{\si@sym@minute}
\newunit[valuesep=none]{\arcsecond}{\si@sym@second}
\newunit{\rperminute}{r/min}
\newunit{\ton}{t}
\newunit{\degreecelsius}{\celsius}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\addunit}
% This is an alias for \cs{newunit}.
%    \begin{macrocode}
\let\addunit\newunit
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\addprefix}
% A little more work for \cs{addprefix}.
%    \begin{macrocode}
\newcommand*{\addprefix}[2]{\newprefix{#1}{#2}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\si@siu@newunit}
%\begin{macro}{\si@siu@power}
%\begin{macro}{\si@siu@newunithook}
% To save some code, making new units which need a \texttt{\ldots np}
% variant is handled by a dedicated macro.\\
%\cs{si@siu@addunit}\oarg{power}\marg{pre}\marg{post}
%    \begin{macrocode}
\newcommand*{\si@siu@newunit}[3][]{%
%    \end{macrocode}
% A test is needed to sort out \cs{square}.
%    \begin{macrocode}
  \renewcommand*{\si@tempa}{#1}%
  \renewcommand*{\si@tempb}{square}%
  \renewcommand*{\si@siu@power}{}%
  \ifx\@empty\si@tempa\@empty\else
    \ifx\si@tempa\si@tempb
      \renewcommand*{\si@siu@power}{\ssquare}%
    \else
      \edef\si@siu@power{%
        \expandafter\noexpand\csname #1\endcsname}%
    \fi
  \fi
%    \end{macrocode}
% The necessary information is now stored in temporary macros.
%    \begin{macrocode}
  \edef\si@tempa{%
    \expandafter\noexpand\csname #2per#1#3\endcsname}%
  \edef\si@tempb{%
    \expandafter\noexpand\csname #2\endcsname\noexpand\per
    \expandafter\noexpand\si@siu@power
    \expandafter\noexpand\csname #3\endcsname}%
  \expandafter\expandafter\expandafter\newunit\expandafter%
    \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
      \expandafter{\si@tempb}
  \edef\si@tempa{%
    \expandafter\noexpand\csname #2per#1#3np\endcsname}%
  \edef\si@tempb{%
    \expandafter\noexpand\csname #2\endcsname\noexpand
    \reciprocal\expandafter\noexpand\si@siu@power
    \expandafter\noexpand\csname #3\endcsname}%
  \expandafter\expandafter\expandafter\newunit\expandafter
    \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
      \expandafter{\si@tempb}%
  \si@siu@newunithook[#1]{#2}{#3}}
\providecommand*{\si@siu@newunithook}[3][]{}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
% The basic units are now defined; these only have a single csname in
% each of the numerator and denominator.
%    \begin{macrocode}
\si@siu@newunit{gray}{second}
\si@siu@newunit[square]{metre}{second}
\si@siu@newunit{joule}{mole}
\si@siu@newunit[cubic]{mole}{metre}
\si@siu@newunit[square]{radian}{second}
\si@siu@newunit{radian}{second}
\si@siu@newunit[cubic]{squaremetre}{metre}
\si@siu@newunit[cubic]{katal}{metre}
\si@siu@newunit{coulomb}{mol}
\si@siu@newunit[square]{ampere}{metre}
\si@siu@newunit[cubic]{kilogram}{metre}
\si@siu@newunit[cubic]{coulomb}{metre}
\si@siu@newunit{volt}{metre}
\si@siu@newunit[square]{coulomb}{squaremetre}
\si@siu@newunit{farad}{metre}
\si@siu@newunit[square]{watt}{metre}
\si@siu@newunit[square]{joule}{metre}
\si@siu@newunit[cubic]{newton}{metre}
\si@siu@newunit{newton}{kilogram}
\si@siu@newunit{joule}{kelvin}
\si@siu@newunit{joule}{kilogram}
\si@siu@newunit{coulomb}{kilogram}
\si@siu@newunit{squaremetre}{second}
\si@siu@newunit[square]{squaremetre}{second}
\si@siu@newunit[square]{candela}{metre}
\si@siu@newunit{ampere}{metre}
\si@siu@newunit{joule}{tesla}
\si@siu@newunit{henry}{metre}
\si@siu@newunit{kilogram}{second}
\si@siu@newunit[square]{kilogram}{metre}
\si@siu@newunit{kilogram}{metre}
\si@siu@newunit[square]{newton}{metre}
\si@siu@newunit{watt}{kilogram}
\si@siu@newunit[cubic]{watt}{metre}
\si@siu@newunit{squaremetre}{kilogram}
\si@siu@newunit{cubicmetre}{kilogram}
\si@siu@newunit{newton}{metre}
\si@siu@newunit[cubic]{squaremetre}{second}
\si@siu@newunit{metre}{second}
\si@siu@newunit[cubic]{joule}{metre}
\si@siu@newunit{cubicmetre}{second}
%    \end{macrocode}
%\begin{macro}{\si@siu@newunitx}
%\begin{macro}{\si@siu@newunitxhook}
% For the more complex units, a slightly different approach is used;
% four arguments are required, and have to cover everything.
%    \begin{macrocode}
\newcommand*{\si@siu@newunitx}[4]{%
  \expandafter\newunit\expandafter{\csname #1per#2\endcsname}
    {#3\per#4}%
  \expandafter\newunit\expandafter{\csname #1per#2np\endcsname}
    {#3\reciprocal#4}
  \si@siu@newunitxhook{#1}{#2}{#3}{#4}}
\providecommand*{\si@siu@newunitxhook}[4]{}
%    \end{macrocode}
%\end{macro}
%\end{macro}
% The units are defined.
%    \begin{macrocode}
\si@siu@newunitx{kilogramsquaremetre}{second}
  {\kilogram\squaremetre}{\second}
\si@siu@newunitx{squaremetre}{newtonsecond}{\squaremetre}
  {\newton\second}
\si@siu@newunitx{kilogrammetre}{second}{\kilogram\metre}
  {\second}
\si@siu@newunitx{kilogram}{squaremetresecond}{\kilogram}
  {\squaremetre\second}
\si@siu@newunitx{joule}{molekelvin}{\joule}{\mole\kelvin}
\si@siu@newunitx{kilogram}{kilomole}{\kilogram}{\kilo\mole}
\si@siu@newunitx{kilogrammetre}{squaresecond}{\kilogram\metre}
  {\second\squared}
\si@siu@newunitx{watt}{squaremetresteradian}{\watt}
  {\squaremetre\steradian}
\si@siu@newunitx{joule}{kilogramkelvin}{\joule}
  {\kilogram\kelvin}
\si@siu@newunitx{watt}{metrekelvin}{\watt}{\metre\kelvin}
\si@siu@newunitx{kilogram}{cubicmetrecoulomb}{\kilogram}
  {\cubic\metre\coulomb}
\si@siu@newunitx{kilogram}{secondcubicmetre}{\kilogram}
  {\second\cubicmetre}
%    \end{macrocode}
%\begin{macro}{\si@siu@unity}
% A bit of cleverness to get the ``1'' correct; to avoid any clash, the unit
% is given an internal name.
%    \begin{macrocode}
\newunit{\si@siu@unity}{1}
\si@siu@newunitx{}{squaremetresecond}{\si@siu@unity}
  {\squaremetre\second}
%    \end{macrocode}
%\end{macro}
% A few compound units that are best defined directly.
%    \begin{macrocode}
\newunit{\pascalsecond}{\pascal\second}
\newunit{\amperemetresecond}{\ampere\metre\second}
\newunit{\ohmmetre}{\ohm\metre}
\newunit{\newtonmetre}{\newton\metre}
\let\newtonmetrenp\newtonmetre
\newunit{\kilogramsquaremetre}{\kilogram\squaremetre}
\let\kilogramsquaremetrenp\kilogramsquaremetre
%    \end{macrocode}
%\begin{macro}{\si@siu@newprefix}
% To generate the prefixes correctly, a small saving in repetition.\\
%\cs{si@siu@newprefix}\marg{prefix}
%    \begin{macrocode}
\newcommand*{\si@siu@newprefix}[1]{%
  \edef\si@tempa{\expandafter\noexpand\csname #1d\endcsname}%
  \edef\si@tempb{\expandafter\noexpand\csname #1\endcsname}%
  \expandafter\expandafter\expandafter\newcommand\expandafter
    \expandafter\expandafter*\expandafter\expandafter
    \expandafter{\expandafter\si@tempa\expandafter}\expandafter
      {\expandafter\si@prefixsymbolicfalse\si@tempb}}
%    \end{macrocode}
%\end{macro}
% This is now implemented.
%    \begin{macrocode}
\si@siu@newprefix{yocto}
\si@siu@newprefix{zepto}
\si@siu@newprefix{atto}
\si@siu@newprefix{femto}
\si@siu@newprefix{pico}
\si@siu@newprefix{nano}
\si@siu@newprefix{micro}
\si@siu@newprefix{milli}
\si@siu@newprefix{centi}
\si@siu@newprefix{deca}
\si@siu@newprefix{deka}
\si@siu@newprefix{hecto}
\si@siu@newprefix{kilo}
\si@siu@newprefix{mega}
\si@siu@newprefix{giga}
\si@siu@newprefix{tera}
\si@siu@newprefix{peta}
\si@siu@newprefix{exa}
\si@siu@newprefix{zetta}
\si@siu@newprefix{yotta}
\ifsi@old@binary
  \si@siu@newprefix{kibi}
  \si@siu@newprefix{mebi}
  \si@siu@newprefix{gibi}
  \si@siu@newprefix{tebi}
  \si@siu@newprefix{pebi}
  \si@siu@newprefix{exbi}
\fi
%    \end{macrocode}
%\begin{macro}{\derradian}
%\begin{macro}{\dersteradian}
%\begin{macro}{\derhertz}
%\begin{macro}{\dernewton}
%\begin{macro}{\derpascal}
%\begin{macro}{\derjoule}
%\begin{macro}{\derwatt}
%\begin{macro}{\dercoulomb}
%\begin{macro}{\dervolt}
%\begin{macro}{\derfarad}
%\begin{macro}{\derohm}
% The derived units may need to be defined.
%    \begin{macrocode}
\ifsi@old@derived
  \newunit{\derradian}{\metre\reciprocal\metre}
  \newunit{\dersteradian}{\squaremetre\rpsquare\metre}
  \newunit{\derhertz}{\reciprocal\second}
  \newunit{\dernewton}{\metre\kilogram\second\rpsquared}
  \newunit{\derpascal}{\newton\rpsquare\metre}
  \newunit{\derjoule}{\newton\metre}
  \newunit{\derwatt}{\joule\reciprocal\second}
  \newunit{\dercoulomb}{\ampere\second}
  \newunit{\dervolt}{\watt\reciprocal\ampere}
  \newunit{\derfarad}{\coulomb\reciprocal\volt}
  \newunit{\derohm}{\volt\reciprocal\ampere}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\dersiemens}
%\begin{macro}{\derweber}
%\begin{macro}{\dertesla}
%\begin{macro}{\derhenry}
%\begin{macro}{\dercelsius}
%\begin{macro}{\derlumen}
%\begin{macro}{\derlux}
%\begin{macro}{\derbecquerel}
%\begin{macro}{\dergray}
%\begin{macro}{\dersievert}
%\begin{macro}{\derkatal}
% In two blocks!
%    \begin{macrocode}
  \newunit{\dersiemens}{\ampere\reciprocal\volt}
  \newunit{\derweber}
    {\squaremetre\kilogram\second\rpsquared\reciprocal\ampere}
  \newunit{\dertesla}{\weber\rpsquare\metre}
  \newunit{\derhenry}{\weber\reciprocal\ampere}
  \newunit{\dercelsius}{\kelvin}
  \newunit{\derlumen}{\candela\steradian}
  \newunit{\derlux}{\lumen\rpsquare\metre}
  \newunit{\derbecquerel}{\derhertz}
  \newunit{\dergray}{\joule\reciprocal\kilogram}
  \newunit{\dersievert}{\dergray}
  \newunit{\derkatal}{\rp\second\usk\mole}
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\radianbase}
%\begin{macro}{\steradianbase}
%\begin{macro}{\hertzbase}
%\begin{macro}{\newtonbase}
%\begin{macro}{\pascalbase}
%\begin{macro}{\joulebase}
%\begin{macro}{\wattbase}
%\begin{macro}{\coulombbase}
%\begin{macro}{\voltbase}
%\begin{macro}{\faradbase}
%\begin{macro}{\ohmbase}
% Also the ``derived-in-base''.
%    \begin{macrocode}
\ifsi@old@derivedinbase
  \newunit{\radianbase}{\metre\reciprocal\metre}
  \newunit{\steradianbase}{\squaremetre\rpsquare\metre}
  \newunit{\hertzbase}{\reciprocal\second}
  \newunit{\newtonbase}{\metre\kilogram\second\rpsquared}
  \newunit{\pascalbase}{\reciprocal\metre\kilogram\second%
    \rpsquared}
  \newunit{\joulebase}{\squaremetre\kilogram\second\rpsquared}
  \newunit{\wattbase}{\squaremetre\kilogram\rpcubic\second}
  \newunit{\coulombbase}{\ampere\second}
  \newunit{\voltbase}
    {\squaremetre\kilogram\rpcubic\second\reciprocal\ampere}
  \newunit{\faradbase}
    {\rpsquare\metre\reciprocal\kilogram\fourth\second\ampere%
      \squared}
  \newunit{\ohmbase}
    {\squaremetre\kilogram\rpcubic\second\rpsquare\ampere}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\siemensbase}
%\begin{macro}{\weberbase}
%\begin{macro}{\teslabase}
%\begin{macro}{\henrybase}
%\begin{macro}{\celsiusbase}
%\begin{macro}{\lumenbase}
%\begin{macro}{\luxbase}
%\begin{macro}{\becquerelbase}
%\begin{macro}{\graybase}
%\begin{macro}{\sievertbase}
%\begin{macro}{\katalbase}
% Also in two blocks.
%    \begin{macrocode}
  \newunit{\siemensbase}
    {\rpsquare\metre\reciprocal\kilogram\cubic\second\ampere%
       \squared}
  \newunit{\weberbase}
    {\squaremetre\kilogram\second\rpsquared\reciprocal\ampere}
  \newunit{\teslabase}{\kilogram\second\rpsquared\reciprocal%
     \ampere}
  \newunit{\henrybase}
    {\squaremetre\kilogram\second\rpsquared\rpsquare\ampere}
  \newunit{\celsiusbase}{\kelvin}
  \newunit{\lumenbase}{\candela\squaremetre\rpsquare\metre}
  \newunit{\luxbase}{\candela\squaremetre\rpfourth\metre}
  \newunit{\becquerelbase}{\hertzbase}
  \newunit{\graybase}{\squaremetre\second\rpsquared}
  \newunit{\sievertbase}{\graybase}
  \newunit{\katalbase}{\rp\second\mole}
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% Any configuration file is used if found.
%    \begin{macrocode}
\InputIfFileExists{SIunits.cfg}
  {\si@log@inf{SIunits config file loaded}}
  {\si@log@inf{SIunits config file not found}}
%    \end{macrocode}
%\iffalse
%</SIunits>
%<*hepunits>
%\fi
%\subsection{\pkg{hepunits}}
% The \pkg{hepunits} package provides some rather odd unit names,
% which are not really to be encouraged.
%    \begin{macrocode}
\ProvidesFile{si-hepunits.cfg}
  [\csname si@svn@version\endcsname Emulation of siunitx:
     hepunits]
\si@emulating{hepunits}{2007/09/27}
\requiresiconfigs{SIunits,accepted,prefix,hep}
%    \end{macrocode}
%\begin{macro}{\invbarn}
%\begin{macro}{\invnanobarn}
%\begin{macro}{\invpicobarn}
%\begin{macro}{\invfemtobarn}
%\begin{macro}{\invattobarn}
%\begin{macro}{\invzeptobarn}
%\begin{macro}{\invyoctobarn}
% Inverses barn units.
%    \begin{macrocode}
\ifsi@old@noprefixcmds\else
  \newunit{\invbarn}{\per\barn}
  \newunit{\invnanobarn}{\per\nano\barn}
  \newunit{\invpicobarn}{\per\pico\barn}
  \newunit{\invfemtobarn}{\per\femto\barn}
  \newunit{\invattobarn}{\per\atto\barn}
  \newunit{\invzeptobarn}{\per\zepto\barn}
  \newunit{\invyoctobarn}{\per\yocto\barn}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\invnb}
%\begin{macro}{\invpb}
%\begin{macro}{\invfb}
%\begin{macro}{\invab}
%\begin{macro}{\invzb}
%\begin{macro}{\invyb}
% Also available abbreviated.
%    \begin{macrocode}
  \newunit{\invnb}{\per\nano\barn}
  \newunit{\invpb}{\per\pico\barn}
  \newunit{\invfb}{\per\femto\barn}
  \newunit{\invab}{\per\atto\barn}
  \newunit{\invzb}{\per\zepto\barn}
  \newunit{\invyb}{\per\yocto\barn}
\fi
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\invcmsqpersecond}
%\begin{macro}{\invcmsqpersec}
%\begin{macro}{\lumiunits}
% Luminosity.
%    \begin{macrocode}
\newunit{\invcmsqpersecond}{\per\Square\centi\metre\per\second}
\newunit{\invcmsqpersec}{\per\Square\centi\metre\per\second}
\newunit{\lumiunits}{\per\Square\centi\metre\per\second}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\inveV}
%\begin{macro}{\minveV}
%\begin{macro}{\minveV}
%\begin{macro}{\kinveV}
%\begin{macro}{\MinveV}
%\begin{macro}{\GinveV}
%\begin{macro}{\TinveV}
% The inverse of an electron-volt, plus prefixes.
%    \begin{macrocode}
\newunit{\inveV}{\per\electronvolt}
\newunit{\minveV}{\per\milli\electronvolt}
\newunit{\kinveV}{\per\kilo\electronvolt}
\newunit{\MinveV}{\per\mega\electronvolt}
\newunit{\GinveV}{\per\giga\electronvolt}
\newunit{\TinveV}{\per\tera\electronvolt}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\eVoverc}
%\begin{macro}{\eVovercsq}
% Some combinations of electron-volts and the speed of light.  As
% these are called |over|, they are set with a slash.  The
% \opt{eVcorrb} values have been set for Computer Modern.
%    \begin{macrocode}
\newunit[per=slash,eVcorrb=0.6ex]{\eVoverc}
  {\electronvolt\per\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\eVovercsq}
  {\electronvolt\per\Square\clight}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\meVoverc}
%\begin{macro}{\keVoverc}
%\begin{macro}{\MeVoverc}
%\begin{macro}{\GeVoverc}
%\begin{macro}{\TeVoverc}
% Prefixed combinations, first of the speed of light.
%    \begin{macrocode}
\newunit[per=slash,eVcorrb=0.6ex]{\meVoverc}
  {\milli\electronvolt\per\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\keVoverc}
  {\kilo\electronvolt\per\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\MeVoverc}
  {\mega\electronvolt\per\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\GeVoverc}
  {\giga\electronvolt\per\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\TeVoverc}
  {\tera\electronvolt\per\clight}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\meVovercsq}
%\begin{macro}{\keVovercsq}
%\begin{macro}{\MeVovercsq}
%\begin{macro}{\GeVovercsq}
%\begin{macro}{\TeVovercsq}
% Then of the square.
%    \begin{macrocode}
\newunit[per=slash,eVcorrb=0.6ex]{\meVovercsq}
  {\milli\electronvolt\per\Square\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\keVovercsq}
  {\kilo\electronvolt\per\Square\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\MeVovercsq}
  {\mega\electronvolt\per\Square\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\GeVovercsq}
  {\giga\electronvolt\per\Square\clight}
\newunit[per=slash,eVcorrb=0.6ex]{\TeVovercsq}
  {\tera\electronvolt\per\Square\clight}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\iffalse
%</hepunits>
%<*fancynum>
%\fi
%\subsection{\pkg{fancynum}}
% \pkg{fancynum} only does things with numbers, so there is only
% a little emulation and a few macros needed.
%    \begin{macrocode}
\ProvidesFile{si-fancynum.cfg}
  [\csname si@svn@version\endcsname Emulation of siunitx:
     fancynum]
\si@emulating{fancynum}{2000/08/08 0.92}
\sisetup{decimalsymbol=cdot,digitsep=comma}
%    \end{macrocode}
%\begin{macro}{\fnum}
% The \cs{fnum} macro is rather restricted, but this is not
% reproduced.  Instead, it is \cs{let} as an alias to the \cs{num}
% macro.
%    \begin{macrocode}
\let\fnum\num
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\setfnumdsym}
%\begin{macro}{\setfnumgsym}
%\begin{macro}{\setfnummsym}
% The control macros are defined.
%    \begin{macrocode}
\newcommand*{\setfnumdsym}[1]{\sisetup{decimalsymbol={#1}}}
\newcommand*{\setfnumgsym}[1]{\sisetup{digitsep={#1}}}
\newcommand*{\setfnummsym}[1]{\sisetup{expproduct={#1}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
% The various package options are now processed if necessary.
%    \begin{macrocode}
\ifsi@old@english
  \sisetup{decimalsymbol=cdot,digitsep=comma}
\fi
\ifsi@old@french
  \sisetup{decimalsymbol=comma,digitsep=fullstop}
\fi
\ifsi@old@tight
  \sisetup{expproduct=tighttimes}
\fi
\ifsi@old@loose
  \sisetup{expproduct=times}
\fi
\ifsi@old@thinspaces
  \sisetup{digitsep=thin}
\fi
\ifsi@old@commas
  \sisetup{digitsep=comma}
\fi
\ifsi@old@plain
  \sisetup{digitsep=none}
\fi
%    \end{macrocode}
%
%\iffalse
%</fancynum>
%<*fancyunits>
%\fi
%\subsection{\pkg{fancyunits}}
% The \pkg{fancyunits} package is not available on \textsc{ctan}, but
% is available from its authors homepage \cite{fancyunits}.  It is
% similar to \SIunits, and so most of the code is shared here.
% However, a few bits of set up occur first, and an emulation-clash
% test is needed.
%    \begin{macrocode}
\ProvidesFile{si-fancyunits.cfg}
  [\csname si@svn@version\endcsname Emulation of siunitx:
     fancyunits]
\si@emulating{fancyunits}{2007/02/01 v1.0.1}
\si@ifloaded{SIunits}
  {\si@log@err{SIunits emulation loaded\MessageBreak before
    fancyunits emulation}{You need to load the fancyunits
    emualtion\MessageBreak code before that for
    SIunits.\MessageBreak Try emulate=fancyunits as the first
    option when\MessageBreak loading siunitx}}{}
%    \end{macrocode}
%\begin{macro}{\si@siu@newunithook}
%\begin{macro}{\si@siu@newunitxhook}
% To create the extra macros provided by \pkg{fancyunits}, the
% \SIunits emulation code is changed to add the ``\texttt{uf}''
% variants.
%    \begin{macrocode}
\newcommand*{\si@siu@newunithook}[3][]{%
  \edef\si@tempa{%
    \expandafter\noexpand\csname #2per#1#3uf\endcsname}%
  \renewcommand*{\si@tempb}{stickyper,per=fraction,
    fraction=nice}%
  \edef\si@tempc{%
    \noexpand\sisetup{\si@tempb}%
    \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
    \expandafter\noexpand\si@siu@power%
    \expandafter\noexpand\csname #3\endcsname}%
  \expandafter\expandafter\expandafter\newunit\expandafter
    \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
      \expandafter{\si@tempc}%
  \edef\si@tempa{%
    \expandafter\noexpand\csname #2per#1#3Uf\endcsname}%
  \renewcommand*{\si@tempb}{stickyper,per=fraction,
    fraction=frac}%
  \edef\si@tempc{%
    \noexpand\sisetup{\si@tempb}%
    \noexpand\def\noexpand\si@frc@hook{\noexpand\textstyle}%
    \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
    \expandafter\noexpand\si@siu@power%
    \expandafter\noexpand\csname #3\endcsname}%
  \expandafter\expandafter\expandafter\newunit\expandafter
    \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
      \expandafter{\si@tempc}%
  \edef\si@tempa{%
    \expandafter\noexpand\csname #2per#1#3UF\endcsname}%
  \edef\si@tempc{%
    \noexpand\sisetup{\si@tempb}%
    \noexpand\def\noexpand\si@frc@hook{\noexpand\displaystyle}%
    \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
    \expandafter\noexpand\si@siu@power%
    \expandafter\noexpand\csname #3\endcsname}%
  \expandafter\expandafter\expandafter\newunit\expandafter
    \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
      \expandafter{\si@tempc}}
\newcommand*{\si@siu@newunitxhook}[4]{%
  \expandafter\newunit\expandafter{\csname #1per#2uf\endcsname}
    {\sisetup{stickyper,per=fraction,fraction=nice}%
     #3\si@per#4}%
  \expandafter\newunit\expandafter{\csname #1per#2Uf\endcsname}
    {\sisetup{stickyper,per=fraction,fraction=frac}%
     \renewcommand*{\si@frc@hook}{\textstyle}%
     #3\si@per#4}%
  \expandafter\newunit\expandafter{\csname #1per#2UF\endcsname}
    {\sisetup{stickyper,per=fraction,fraction=frac}%
     \renewcommand*{\si@frc@hook}{\displaystyle}%
     #3\si@per#4}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
% With that done, the emulation modules can be loaded.
%    \begin{macrocode}
\requiresiconfigs{SIunits,addn,astro}
\sisetup{obeyall}
%    \end{macrocode}
% There is one \pkg{fancyunits}-specific option to handle.  The other
% options all get sent through to the \SIunits system.\footnote{As
% \SIunits is rather more widely known than \pkg{fancyunits}, any
% other options which could be for either are assumed to be for
% \SIunits.}
%    \begin{macrocode}
\ifsi@old@spaceqspace
  \sisetup{valuesep=space}
\fi
%    \end{macrocode}
%\begin{macro}{\paminute}
%\begin{macro}{\parsecond}
%\begin{macro}{\AstroE}
%\begin{macro}{\oersted}
%\begin{macro}{\ton}
% \pkg{fancyunits} provides some extra units, plus tonne spelled
% incorrectly (again).
%    \begin{macrocode}
\newunit{\paminute}{'}
\newunit{\parsecond}{''}
\newunit{\AstroE}{AE}
\newunit{\oersted}{OE}
\provideunit{\ton}{t}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\decaD}
% An additional prefix.
%    \begin{macrocode}
\let\decaD\decad
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ufrac}
%\begin{macro}{\Ufrac}
%\begin{macro}{\UFrac}
% The fractional unit macros need to be reproduced.
%    \begin{macrocode}
\newcommand*{\ufrac}[2]{%
  \si[stickyper,per=fraction,fraction=nice]{#1\si@per#2}}
\newcommand*{\Ufrac}[2]{%
  \ensuremath{\textstyle{%
    \si[stickyper,per=fraction,fraction=frac]{#1\si@per#2}}}}
\newcommand*{\UFrac}[2]{%
  \ensuremath{\displaystyle{%
    \si[stickyper,per=fraction,fraction=frac]{#1\si@per#2}}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\pow}
% A slightly-shorted named \cs{power}.
%    \begin{macrocode}
\let\pow\power
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Squaremetre}
% An alias for \cs{squaremetre}.
%    \begin{macrocode}
\let\Squaremetre\squaremetre
%    \end{macrocode}
%\end{macro}
% As with \SIunits, there is now a list of compound units to add.
% Only a few are not covered by the \SIunits emulation.
%    \begin{macrocode}
\si@siu@newunit{Gray}{second}
\si@siu@newunit[square]{Squaremetre}{metre}
\si@siu@newunitx{Squaremetre}{newtonsecond}{\Square\metre}
  {\newton\second}
\si@siu@newunit{Squaremetre}{second}
\si@siu@newunit[square]{Squaremetre}{squaresecond}
\si@siu@newunit{Squaremetre}{kilogram}
\si@siu@newunit[cubic]{Squaremetre}{second}
%    \end{macrocode}
%\iffalse
%</fancyunits>
%\fi
%
%\Finale
%\iffalse
%<*refs>
@misc{BIPM:EN,
  note = {\url{http://www.bipm.org/en/si/}},
}

@misc{BIPM:FR,
  note = {\url{http://www.bipm.org/fr/si/}},
}

@misc{BIPM:PDF,
  note = {\url{http://www.bipm.org/en/si/si_brochure/}},
}

@misc{Eijkhout,
  author =       {Victor Eijkhout},
  note =         {\url{http://www.eijkhout.net/tbt/}},
  title =        {{\TeX} by {T}opic},
  year =         {2007},
}

@misc{fancyunits,
  author = {Heiko Bauke},
  note = {\url{http://www.mpi-hd.mpg.de/personalhomes/bauke/LaTeX/Tips_und_Tricks/fancyunits/index.php}},
  title = {\pkg{fancyunits}},
  year = 2007,
}

@misc{IUPAC,
  note = {\url{http://old.iupac.org/publications/books/gbook/green_book_2ed.pdf}},
  title = {The \textsc{iupac} {G}reen {B}ook},
  year = 1993,
}

@misc{NIST,
  note = {\url{http://physics.nist.gov/cuu/Units/index.html}},
}
%</refs>
%<*jawltxdoc>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{jawltxdoc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[final]{listings,graphicx,microtype}
\usepackage[scaled=0.95]{helvet}
\usepackage[version=3]{mhchem}
\usepackage[osf]{mathpazo}
\usepackage{booktabs,array,url,courier,xspace,etoolbox,varioref}
\usepackage{upgreek,ifpdf,float,caption,longtable,babel}
\floatstyle{plaintop}
\restylefloat{table}
\labelformat{figure}{\figurename~#1}
\labelformat{table}{\tablename~#1}
\ifpdf
  \usepackage{embedfile}
  \embedfile[%
    stringmethod=escape,%
    mimetype=plain/text,%
    desc={LaTeX docstrip source archive for package `\jobname'}%
    ]{\jobname.dtx}
\fi
\IfFileExists{\jobname.sty}
  {\usepackage{\jobname}}{}
\usepackage[numbered]{hypdoc}
\setcounter{IndexColumns}{2}
\newlength\LaTeXwidth
\newlength\LaTeXoutdent
\newlength\LaTeXgap
\setlength\LaTeXgap{1em}
\setlength\LaTeXoutdent{-0.15\textwidth}
\newbox\lst@samplebox
\edef\LaTeXexamplefile{\jobname.tmp}
\lst@RequireAspects{writefile}
\lstnewenvironment{LaTeXexample}[1][example]{%
  \global\let\lst@intname\@empty
  \ifcsname LaTeXcode#1\endcsname
    \expandafter\let\expandafter\LaTeXcode
      \csname LaTeXcode#1\endcsname
    \expandafter\let\expandafter\LaTeXcodeend
      \csname LaTeXcode#1end\endcsname
  \else
    \PackageError{jawltxdoc}
      {Undefined example type `#1'}
      \@ehd
    \let\LaTeXcode\relax
    \let\LaTeXcodeend\relax
  \fi
  \LaTeXcode}
  {\lst@EndWriteFile
   \LaTeXcodeend}
\newcommand*{\LaTeXcodeexample}{%
  \setbox\lst@samplebox=\hbox\bgroup
  \LaTeXcodefloat}
\let\LaTeXcoderesultonly\LaTeXcodeexample
\newcommand*{\LaTeXcodeexampleend}{%
  \egroup
  \setlength\LaTeXwidth{\wd\lst@samplebox}%
  \begin{list}{}{%
    \setlength\itemindent{0pt}
    \setlength\leftmargin\LaTeXoutdent
    \setlength\rightmargin{0pt}}%
    \item
      \setlength\LaTeXoutdent{-0.15\textwidth}
      \begin{minipage}[c]{%
        \textwidth-\LaTeXwidth-\LaTeXoutdent-\LaTeXgap}
        \LaTeXcodefloatend
      \end{minipage}%
      \hfill
      \begin{minipage}[c]{\LaTeXwidth}%
        \hbox to\linewidth{\box\lst@samplebox\hss}%
      \end{minipage}%
  \end{list}}
\let\LaTeXcodenoexample\LaTeXcodeexample
\newcommand*{\LaTeXcodenoexampleend}{%
  \egroup
  \setlength\LaTeXwidth{\wd\lst@samplebox}%
  \begin{list}{}{%
    \setlength\itemindent{0pt}
    \setlength\leftmargin{0pt}
    \setlength\rightmargin{0pt}}%
    \item
      \begin{minipage}[c]{\LaTeXwidth}
        \hbox to\linewidth{\box\lst@samplebox\hss}%
      \end{minipage}%
  \end{list}}
\newcommand*{\LaTeXcodefloat}{%
  \setkeys{lst}{tabsize=4,gobble=3,breakindent=0pt,
    basicstyle=\small\ttfamily,basewidth=0.51em,
    keywordstyle=\color{blue}}%
  \lst@BeginAlsoWriteFile{\LaTeXexamplefile}}
\newcommand*{\LaTeXcodefloatend}{%
  \MakePercentComment\catcode`\^^M=10\relax
  \small
  {\setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}%
    {\lst@ProcessTabulator}}%
    \leavevmode \input{\LaTeXexamplefile}}%
  \MakePercentIgnore}
\newcommand*{\LaTeXcoderesultonlyend}{\egroup\LaTeXcodefloatend}
\lstnewenvironment{BibTeXexample}{%
  \global\let\lst@intname\@empty
  \setbox\lst@samplebox=\hbox\bgroup
  \setkeys{lst}{tabsize=4,gobble=3,breakindent=0pt,
    basicstyle=\small\ttfamily,basewidth=0.51em,
    keywordstyle=\color{black}}
  \lst@BeginAlsoWriteFile{\LaTeXexamplefile}}
 {\lst@EndWriteFile
   \LaTeXcodeexampleend}
\newcommand*{\DescribeOption}{%
  \leavevmode\@bsphack\begingroup\MakePrivateLetters
  \Describe@Option}
\newcommand*{\Describe@Option}[1]{\endgroup
              \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
              \SpecialOptionIndex{#1}\@esphack\ignorespaces}
\newcommand*{\SpecialOptionIndex}[1]{\@bsphack
    \index{#1\actualchar{\protect\ttfamily#1}
           (option)\encapchar usage}%
    \index{options:\levelchar#1\actualchar{\protect\ttfamily#1}%
      \encapchar usage}\@esphack}
\newcommand*{\indexopt}[1]{\DescribeOption{#1}\opt{#1}}
\newcommand*{\DescribeOptionInfo}[2]{%
  \DescribeOption{#1}%
  \opt{#1=\meta{#2}}\xspace}
\newcommand*{\ofixarg}[1]{%
  {\ttfamily[}%
  \ifmmode \expandafter \nfss@text \fi
  {%
    \meta@font@select
    \edef\meta@hyphen@restore{%
      \hyphenchar\the\font\the\hyphenchar\font}%
    \hyphenchar\font\m@ne
    \language\l@nohyphenation
    #1\/%
    \meta@hyphen@restore
    }%
    {\ttfamily]}}
\newcommand*{\pkg}[1]{\textsf{#1}}
\newcommand*{\currpkg}{\pkg{\jobname}\xspace}
\newcommand*{\opt}[1]{\texttt{#1}}
\newcommand*{\defaultopt}[1]{\opt{\textbf{#1}}}
\newcommand*{\file}[1]{\texttt{#1}}
\newcommand*{\ext}[1]{\file{.#1}}
\newcommand*{\latin}[1]{\emph{#1}}
\newcommand*{\etc}{%
  \@ifnextchar.
    {\latin{etc}}
    {\latin{etc}.\xspace}}
\newcommand*{\eg}{%
  \@ifnextchar.
    {\latin{e.g}}
    {\latin{e.g}.\xspace}}
\newcommand*{\ie}{%
  \@ifnextchar.
    {\latin{i.e}}
    {\latin{i.e}.\xspace}}
\newcommand*{\etal}{%
  \@ifnextchar.
    {\latin{et~al.}}
    {\latin{et~al}.\xspace}}
\newcommand*{\AMS}{{\protect\usefont{OMS}{cmsy}{m}{n}%
  A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
\providecommand*{\eTeX}{\ensuremath{\varepsilon}-\TeX}
\DeclareRobustCommand*{\XeTeX}
  {X\kern-.125em\lower.5ex\hbox{\reflectbox{E}}\kern-.1667em\TeX}
\providecommand*{\CTAN}{\textsc{ctan}}
\patchcmd{\@addmarginpar}
  {\@latex@warning@no@line {Marginpar on page \thepage\space moved}}
  {\relax}{}{}
%</jawltxdoc>
%\fi