summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/siunitx/siunitx.dtx
blob: ef4d8b5653d6e7fb2b149b75d21807cd51bbdd22 (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
12777
12778
12779
12780
12781
12782
12783
12784
12785
12786
12787
12788
12789
12790
12791
12792
12793
12794
12795
12796
12797
12798
12799
12800
12801
12802
12803
12804
12805
12806
12807
12808
12809
12810
12811
12812
12813
12814
12815
12816
12817
12818
12819
12820
12821
12822
12823
12824
12825
12826
12827
12828
12829
12830
12831
12832
12833
12834
12835
12836
12837
12838
12839
12840
12841
12842
12843
12844
12845
12846
12847
12848
12849
12850
12851
12852
12853
12854
12855
12856
12857
12858
12859
12860
12861
12862
12863
12864
12865
12866
12867
12868
12869
12870
12871
12872
12873
12874
12875
12876
12877
12878
12879
12880
12881
12882
12883
12884
12885
12886
12887
12888
12889
12890
12891
12892
12893
12894
12895
12896
12897
12898
12899
12900
12901
12902
12903
12904
12905
12906
12907
12908
12909
12910
12911
12912
12913
12914
12915
12916
12917
12918
12919
12920
12921
12922
12923
12924
12925
12926
12927
12928
12929
12930
12931
12932
12933
12934
12935
12936
12937
12938
12939
12940
12941
12942
12943
12944
12945
12946
12947
12948
12949
12950
12951
12952
12953
12954
12955
12956
12957
12958
12959
12960
12961
12962
12963
12964
12965
12966
12967
12968
12969
12970
12971
12972
12973
12974
12975
12976
12977
12978
12979
12980
12981
12982
12983
12984
12985
12986
12987
12988
12989
12990
12991
12992
12993
12994
12995
12996
12997
12998
12999
13000
13001
13002
13003
13004
13005
13006
13007
13008
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018
13019
13020
13021
13022
13023
13024
13025
13026
13027
13028
13029
13030
13031
13032
13033
13034
13035
13036
13037
13038
13039
13040
13041
13042
13043
13044
13045
13046
13047
13048
13049
13050
13051
13052
13053
13054
13055
13056
13057
13058
13059
13060
13061
13062
13063
13064
13065
13066
13067
13068
13069
13070
13071
13072
13073
13074
13075
13076
13077
13078
13079
13080
13081
13082
13083
13084
13085
13086
13087
13088
13089
13090
13091
13092
13093
13094
13095
13096
13097
13098
13099
13100
13101
13102
13103
13104
13105
13106
13107
13108
13109
13110
13111
13112
13113
13114
13115
13116
13117
13118
13119
13120
13121
13122
13123
13124
13125
13126
13127
13128
13129
13130
13131
13132
13133
13134
13135
13136
13137
13138
13139
13140
13141
13142
13143
13144
13145
13146
13147
13148
13149
13150
13151
13152
13153
13154
13155
13156
13157
13158
13159
13160
13161
13162
13163
13164
13165
13166
13167
13168
13169
13170
13171
13172
13173
13174
13175
13176
13177
13178
13179
13180
13181
13182
13183
13184
13185
13186
13187
13188
13189
13190
13191
13192
13193
13194
13195
13196
13197
13198
13199
13200
13201
13202
13203
13204
13205
13206
13207
13208
13209
13210
13211
13212
13213
13214
13215
13216
13217
13218
13219
13220
13221
13222
13223
13224
13225
13226
13227
13228
13229
13230
13231
13232
13233
13234
13235
13236
13237
13238
13239
13240
13241
13242
13243
13244
13245
13246
13247
13248
13249
13250
13251
13252
13253
13254
13255
13256
13257
13258
13259
13260
13261
13262
13263
13264
13265
13266
13267
13268
13269
13270
13271
13272
13273
13274
13275
13276
13277
13278
13279
13280
13281
13282
13283
13284
13285
13286
13287
13288
13289
13290
13291
13292
13293
13294
13295
13296
13297
13298
13299
13300
13301
13302
13303
13304
13305
13306
13307
13308
13309
13310
13311
13312
13313
13314
13315
13316
13317
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327
13328
13329
13330
13331
13332
13333
13334
13335
13336
13337
13338
13339
13340
13341
13342
13343
13344
13345
13346
13347
13348
13349
13350
13351
13352
13353
13354
13355
13356
13357
13358
13359
13360
13361
13362
13363
13364
13365
13366
13367
13368
13369
13370
13371
13372
13373
13374
13375
13376
13377
13378
13379
13380
13381
13382
13383
13384
13385
13386
13387
13388
13389
13390
13391
13392
13393
13394
13395
13396
13397
13398
13399
13400
13401
13402
13403
13404
13405
13406
13407
13408
13409
13410
13411
13412
13413
13414
13415
13416
13417
13418
13419
13420
13421
13422
13423
13424
13425
13426
13427
13428
13429
13430
13431
13432
13433
13434
13435
13436
13437
13438
13439
13440
13441
13442
13443
13444
13445
13446
13447
13448
13449
13450
13451
13452
13453
13454
13455
13456
13457
13458
13459
13460
13461
13462
13463
13464
13465
13466
13467
13468
13469
13470
13471
13472
13473
13474
13475
13476
13477
13478
13479
13480
13481
13482
13483
13484
13485
13486
13487
13488
13489
13490
13491
13492
13493
13494
13495
13496
13497
13498
13499
13500
13501
13502
13503
13504
13505
13506
13507
13508
13509
13510
13511
13512
13513
13514
13515
13516
13517
13518
13519
13520
13521
13522
13523
13524
13525
13526
13527
13528
13529
13530
13531
13532
13533
13534
13535
13536
13537
13538
13539
13540
13541
13542
13543
13544
13545
13546
13547
13548
13549
13550
13551
13552
13553
13554
13555
13556
13557
13558
13559
13560
13561
13562
13563
13564
13565
13566
13567
13568
13569
13570
13571
13572
13573
13574
13575
13576
13577
13578
13579
13580
13581
13582
13583
13584
13585
13586
13587
13588
13589
13590
13591
13592
13593
13594
13595
13596
13597
13598
13599
13600
13601
13602
13603
13604
13605
13606
13607
13608
13609
13610
13611
13612
13613
13614
13615
13616
13617
13618
13619
13620
13621
13622
13623
13624
13625
13626
13627
13628
13629
13630
13631
13632
13633
13634
13635
13636
13637
13638
13639
13640
13641
13642
13643
13644
13645
13646
13647
13648
13649
13650
13651
13652
13653
13654
13655
13656
13657
13658
13659
13660
13661
13662
13663
13664
13665
13666
13667
13668
13669
13670
13671
13672
13673
13674
13675
13676
13677
13678
13679
13680
13681
13682
13683
13684
13685
13686
13687
13688
13689
13690
13691
13692
13693
13694
13695
13696
13697
13698
13699
13700
13701
13702
13703
13704
13705
13706
13707
13708
13709
13710
13711
13712
13713
13714
13715
13716
13717
13718
13719
13720
13721
13722
13723
13724
13725
13726
13727
13728
13729
13730
13731
13732
13733
13734
13735
13736
13737
13738
13739
13740
13741
13742
13743
13744
13745
13746
13747
13748
13749
13750
13751
13752
13753
13754
13755
13756
13757
13758
13759
13760
13761
13762
13763
13764
13765
13766
13767
13768
13769
13770
13771
13772
13773
13774
13775
13776
13777
13778
13779
13780
13781
13782
13783
13784
13785
13786
13787
13788
13789
13790
13791
13792
13793
13794
13795
13796
13797
13798
13799
13800
13801
13802
13803
13804
13805
13806
13807
13808
13809
13810
13811
13812
13813
13814
13815
13816
13817
13818
13819
13820
13821
13822
13823
13824
13825
13826
13827
13828
13829
13830
13831
13832
13833
13834
13835
13836
13837
13838
13839
13840
13841
13842
13843
13844
13845
13846
13847
13848
13849
13850
13851
13852
13853
13854
13855
13856
13857
13858
13859
13860
13861
13862
13863
13864
13865
13866
13867
13868
13869
13870
13871
13872
13873
13874
13875
13876
13877
13878
13879
13880
13881
13882
13883
13884
13885
13886
13887
13888
13889
13890
13891
13892
13893
13894
13895
13896
13897
13898
13899
13900
13901
13902
13903
13904
13905
13906
13907
13908
13909
13910
13911
13912
13913
13914
13915
13916
13917
13918
13919
13920
13921
13922
13923
13924
13925
13926
13927
13928
13929
13930
13931
13932
13933
13934
13935
13936
13937
13938
13939
13940
13941
13942
13943
13944
13945
13946
13947
13948
13949
13950
13951
13952
13953
13954
13955
13956
13957
13958
13959
13960
13961
13962
13963
13964
13965
13966
13967
13968
13969
13970
13971
13972
13973
13974
13975
13976
13977
13978
13979
13980
13981
13982
13983
13984
13985
13986
13987
13988
13989
13990
13991
13992
13993
13994
13995
13996
13997
13998
13999
14000
14001
14002
14003
14004
14005
14006
14007
14008
14009
14010
14011
14012
14013
14014
14015
14016
14017
14018
14019
14020
14021
14022
14023
14024
14025
14026
14027
14028
14029
14030
14031
14032
14033
14034
14035
14036
14037
14038
14039
14040
14041
14042
14043
14044
14045
14046
14047
14048
14049
14050
14051
14052
14053
14054
14055
14056
14057
14058
14059
14060
14061
14062
14063
14064
14065
14066
14067
14068
14069
14070
14071
14072
14073
14074
14075
14076
14077
14078
14079
14080
14081
14082
14083
14084
14085
14086
14087
14088
14089
14090
14091
14092
14093
14094
14095
14096
14097
14098
14099
14100
14101
14102
14103
14104
14105
14106
14107
14108
14109
14110
14111
14112
14113
14114
14115
14116
14117
14118
14119
14120
14121
14122
14123
14124
14125
14126
14127
14128
14129
14130
14131
14132
14133
14134
14135
14136
14137
14138
14139
14140
14141
14142
14143
14144
14145
14146
14147
14148
14149
14150
14151
14152
14153
14154
14155
14156
14157
14158
14159
14160
14161
14162
14163
14164
14165
14166
14167
14168
14169
14170
14171
14172
14173
14174
14175
14176
14177
14178
14179
14180
14181
14182
14183
14184
14185
14186
14187
14188
14189
14190
14191
14192
14193
14194
14195
14196
14197
14198
14199
14200
14201
14202
14203
14204
14205
14206
14207
14208
14209
14210
14211
14212
14213
14214
14215
14216
14217
14218
14219
14220
14221
14222
14223
14224
14225
14226
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247
14248
14249
14250
14251
14252
14253
14254
14255
14256
14257
14258
14259
14260
14261
14262
14263
14264
14265
14266
14267
14268
14269
14270
14271
14272
14273
14274
14275
14276
14277
14278
14279
14280
14281
14282
14283
14284
14285
14286
14287
14288
14289
14290
14291
14292
14293
14294
14295
14296
14297
14298
14299
14300
14301
14302
14303
14304
14305
14306
14307
14308
14309
14310
14311
14312
14313
14314
14315
14316
14317
14318
14319
14320
14321
14322
14323
14324
14325
14326
14327
14328
14329
14330
14331
14332
14333
14334
14335
14336
14337
14338
14339
14340
14341
14342
14343
14344
14345
14346
14347
14348
14349
14350
14351
14352
14353
14354
14355
14356
14357
14358
14359
14360
14361
14362
14363
14364
14365
14366
14367
14368
14369
14370
14371
14372
14373
14374
14375
14376
14377
14378
14379
14380
14381
14382
14383
14384
14385
14386
14387
14388
14389
14390
14391
14392
14393
14394
14395
14396
14397
14398
14399
14400
14401
14402
14403
14404
14405
14406
14407
14408
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429
14430
14431
14432
14433
14434
14435
14436
14437
14438
14439
14440
14441
14442
14443
14444
14445
14446
14447
14448
14449
14450
14451
14452
14453
14454
14455
14456
14457
14458
14459
14460
14461
14462
14463
14464
14465
14466
14467
14468
14469
14470
14471
14472
14473
14474
14475
14476
14477
14478
14479
14480
14481
14482
14483
14484
14485
14486
14487
14488
14489
14490
14491
14492
14493
14494
14495
14496
14497
14498
14499
14500
14501
14502
14503
14504
14505
14506
14507
14508
14509
14510
14511
14512
14513
14514
14515
14516
14517
14518
14519
14520
14521
14522
14523
14524
14525
14526
14527
14528
14529
14530
14531
14532
14533
14534
14535
14536
14537
14538
14539
14540
14541
14542
14543
14544
14545
14546
14547
14548
14549
14550
14551
14552
14553
14554
14555
14556
14557
14558
14559
14560
14561
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575
14576
14577
14578
14579
14580
14581
14582
14583
14584
14585
14586
14587
14588
14589
14590
14591
14592
14593
14594
14595
14596
14597
14598
14599
14600
14601
14602
14603
14604
14605
14606
14607
14608
14609
14610
14611
14612
14613
14614
14615
14616
14617
14618
14619
14620
14621
14622
14623
14624
14625
14626
14627
14628
14629
14630
14631
14632
14633
14634
14635
14636
14637
14638
14639
14640
14641
14642
14643
14644
14645
14646
14647
14648
14649
14650
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669
14670
14671
14672
14673
14674
14675
14676
14677
14678
14679
14680
14681
14682
14683
14684
14685
14686
14687
14688
14689
14690
14691
14692
14693
14694
14695
14696
14697
14698
14699
14700
14701
14702
14703
14704
14705
14706
14707
14708
14709
14710
14711
14712
14713
14714
14715
14716
14717
14718
14719
14720
14721
14722
14723
14724
14725
14726
14727
14728
14729
14730
14731
14732
14733
14734
14735
14736
14737
14738
14739
14740
14741
14742
14743
14744
14745
14746
14747
14748
14749
14750
14751
14752
14753
14754
14755
14756
14757
14758
14759
14760
14761
14762
14763
14764
14765
14766
14767
14768
14769
14770
14771
14772
14773
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792
14793
14794
14795
14796
14797
14798
14799
14800
14801
14802
14803
14804
14805
14806
14807
14808
14809
14810
14811
14812
14813
14814
14815
14816
14817
14818
14819
14820
14821
14822
14823
14824
14825
14826
14827
14828
14829
14830
14831
14832
14833
14834
14835
14836
14837
14838
14839
14840
14841
14842
14843
14844
14845
14846
14847
14848
14849
14850
14851
14852
14853
14854
14855
14856
14857
14858
14859
14860
14861
14862
14863
14864
14865
14866
14867
14868
14869
14870
14871
14872
14873
14874
14875
14876
14877
14878
14879
14880
14881
14882
14883
14884
14885
14886
14887
14888
14889
14890
14891
14892
14893
14894
14895
14896
14897
14898
14899
14900
14901
14902
14903
14904
14905
14906
14907
14908
14909
14910
14911
14912
14913
14914
14915
14916
14917
14918
14919
14920
14921
14922
14923
14924
14925
14926
14927
14928
14929
14930
14931
14932
14933
14934
14935
14936
14937
14938
14939
14940
14941
14942
14943
14944
14945
14946
14947
14948
14949
14950
14951
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962
14963
14964
14965
14966
14967
14968
14969
14970
14971
14972
14973
14974
14975
14976
14977
14978
14979
14980
14981
14982
14983
14984
14985
14986
14987
14988
14989
14990
14991
14992
14993
14994
14995
14996
14997
14998
14999
15000
15001
15002
15003
15004
15005
15006
15007
15008
15009
15010
15011
15012
15013
15014
15015
15016
15017
15018
15019
15020
15021
15022
15023
15024
15025
15026
15027
15028
15029
15030
15031
15032
15033
15034
15035
15036
15037
15038
15039
15040
15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
15052
15053
15054
15055
15056
15057
15058
15059
15060
15061
15062
15063
15064
15065
15066
15067
15068
15069
15070
15071
15072
15073
15074
15075
15076
15077
15078
15079
15080
15081
15082
15083
15084
15085
15086
15087
15088
15089
15090
15091
15092
15093
15094
15095
15096
15097
15098
15099
15100
15101
15102
15103
15104
15105
15106
15107
15108
15109
15110
15111
15112
15113
15114
15115
15116
15117
15118
15119
15120
15121
15122
15123
15124
15125
15126
15127
15128
15129
15130
15131
15132
15133
15134
15135
15136
15137
15138
15139
15140
15141
15142
15143
15144
15145
15146
15147
15148
15149
15150
15151
15152
15153
15154
15155
15156
15157
15158
15159
15160
15161
15162
15163
15164
15165
15166
15167
15168
15169
15170
15171
15172
15173
15174
15175
15176
15177
15178
15179
15180
15181
15182
15183
15184
15185
15186
15187
15188
15189
15190
15191
15192
15193
15194
15195
15196
15197
15198
15199
15200
15201
15202
15203
15204
15205
15206
15207
15208
15209
15210
15211
15212
15213
15214
15215
15216
15217
15218
15219
15220
15221
15222
15223
15224
15225
15226
15227
15228
15229
15230
15231
15232
15233
15234
15235
15236
15237
15238
15239
15240
15241
15242
15243
15244
15245
15246
15247
15248
15249
15250
15251
15252
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262
15263
15264
15265
15266
15267
15268
15269
15270
15271
15272
15273
15274
15275
15276
15277
15278
15279
15280
15281
15282
15283
15284
15285
15286
15287
15288
15289
15290
15291
15292
15293
15294
15295
15296
15297
15298
15299
15300
15301
15302
15303
15304
15305
15306
15307
15308
15309
15310
15311
15312
15313
15314
15315
15316
15317
15318
15319
15320
15321
15322
15323
15324
15325
15326
15327
15328
15329
15330
15331
15332
15333
15334
15335
15336
15337
15338
15339
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350
15351
15352
15353
15354
15355
15356
15357
15358
15359
15360
15361
15362
15363
15364
15365
15366
15367
15368
15369
15370
15371
15372
15373
15374
15375
15376
15377
15378
15379
15380
15381
15382
15383
15384
15385
15386
15387
15388
15389
15390
15391
15392
15393
15394
15395
15396
15397
15398
15399
15400
15401
15402
15403
15404
15405
15406
15407
15408
15409
15410
15411
15412
15413
15414
15415
15416
15417
15418
15419
15420
15421
15422
15423
15424
15425
15426
15427
15428
15429
15430
15431
15432
15433
15434
15435
15436
15437
15438
15439
15440
15441
15442
15443
15444
15445
15446
15447
15448
15449
15450
15451
15452
15453
15454
15455
15456
15457
15458
15459
15460
15461
15462
15463
15464
15465
15466
15467
15468
15469
15470
15471
15472
15473
15474
15475
15476
15477
15478
15479
15480
15481
15482
15483
15484
15485
15486
15487
15488
15489
15490
15491
15492
15493
15494
15495
15496
15497
15498
15499
15500
15501
15502
15503
15504
15505
15506
15507
15508
15509
15510
15511
15512
15513
15514
15515
15516
15517
15518
15519
15520
15521
15522
15523
15524
15525
15526
15527
15528
15529
15530
15531
15532
15533
15534
15535
15536
15537
15538
15539
15540
15541
15542
15543
15544
15545
15546
15547
15548
15549
15550
15551
15552
15553
15554
15555
15556
15557
15558
15559
15560
15561
15562
15563
15564
15565
15566
15567
15568
15569
15570
15571
15572
15573
15574
15575
15576
15577
15578
15579
15580
15581
15582
15583
15584
15585
15586
15587
15588
15589
15590
15591
15592
15593
15594
15595
15596
15597
15598
15599
15600
15601
15602
15603
15604
15605
15606
15607
15608
15609
15610
15611
15612
15613
15614
15615
15616
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627
15628
15629
15630
15631
15632
15633
15634
15635
15636
15637
15638
15639
15640
15641
15642
15643
15644
15645
15646
15647
15648
15649
15650
15651
15652
15653
15654
15655
15656
15657
15658
15659
15660
15661
15662
15663
15664
15665
15666
15667
15668
15669
15670
15671
15672
15673
15674
15675
15676
15677
15678
15679
15680
15681
15682
15683
15684
15685
15686
15687
15688
15689
15690
15691
15692
15693
15694
15695
15696
15697
15698
15699
15700
15701
15702
15703
15704
15705
15706
15707
15708
15709
15710
15711
15712
15713
15714
15715
15716
15717
15718
15719
15720
15721
15722
15723
15724
15725
15726
15727
15728
15729
15730
15731
15732
15733
15734
15735
15736
15737
15738
15739
15740
15741
15742
15743
15744
15745
15746
15747
15748
15749
15750
15751
15752
15753
15754
15755
15756
15757
15758
15759
15760
15761
15762
15763
15764
15765
15766
15767
15768
15769
15770
15771
15772
15773
15774
15775
15776
15777
15778
15779
15780
15781
15782
15783
15784
15785
15786
15787
15788
15789
15790
15791
15792
15793
15794
15795
15796
15797
15798
15799
15800
15801
15802
15803
15804
15805
15806
15807
15808
15809
15810
15811
15812
15813
15814
15815
15816
15817
15818
15819
15820
15821
15822
15823
15824
15825
15826
15827
15828
15829
15830
15831
15832
15833
15834
15835
15836
15837
15838
15839
15840
15841
15842
15843
15844
15845
15846
15847
15848
15849
15850
15851
15852
15853
15854
15855
15856
15857
15858
15859
15860
15861
15862
15863
15864
15865
15866
15867
15868
15869
15870
15871
15872
15873
15874
15875
15876
15877
15878
15879
15880
15881
15882
15883
15884
15885
15886
15887
15888
15889
15890
15891
15892
15893
15894
15895
15896
15897
15898
15899
15900
15901
15902
15903
15904
15905
15906
15907
15908
15909
15910
15911
15912
15913
15914
15915
15916
15917
15918
15919
15920
15921
15922
15923
15924
15925
15926
15927
15928
15929
15930
15931
15932
15933
15934
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947
15948
15949
15950
15951
15952
15953
15954
15955
15956
15957
15958
15959
15960
15961
15962
15963
15964
15965
15966
15967
15968
15969
15970
15971
15972
15973
15974
15975
15976
15977
15978
15979
15980
15981
15982
15983
15984
15985
15986
15987
15988
15989
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*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
----------------------------------------------------------------

Physical quantities have both numbers and units, and each
physical quantity should be expressed as the product of a number
and a unit. Typesetting physical quantities requires care to
ensure that the combined mathematical meaning of the number-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 package provides a set of tools for authors to 
typeset quantities 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.

Installation
------------

The package is supplied in dtx format and as a pre-extracted zip
file, siunitx.tds.zip. The later is most convenient for most 
users: simply unzip this in your local texmf directory and run 
texhash to update the database of file locations. If you want to
unpack the dtx yourself, running 'tex siunitx.dtx' will extract
the package whereas 'latex siunitx.dtx will extract it and also 
typeset the documentation.

The package requires LaTeX3 support as provided in the expl3 
and xpackages bundles. Both of these are available on CTAN
(http://www.ctan.org/) as ready-to-install zip files. Suitable
versions are available in MiKTeX 2.9 and TeX Live 2010 
(updating the relevant packages online may be necessary). 
LaTeX3, and so siunitx, requires the e-TeX extensions: these 
are available on all modern TeX systems.

Typesetting the documentation requires a number of packages in
addition to those needed to use the package. This is mainly 
because of the number of demonstration items included in the 
text. To compile the documentation without error, you will 
need the packages:
 - amsmath
 - booktabs
 - caption
 - cleveref
 - csquotes
 - datatool
 - helvet
 - mathpazo
 - listings
 - pgfplots
 - xcolor
The xfrac package is also loaded if available, but is not 
required to typeset the documentation.
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*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
\postamble

Copyright (C) 2008-2011 by
  Joseph Wright <joseph.wright@morningstar2.co.uk>

It may be distributed and/or modified under the conditions of
the LaTeX Project Public License (LPPL), either version 1.3c of
this license or (at your option) any later version.  The latest
version of this license is in the file:

   http://www.latex-project.org/lppl.txt

This work is "maintained" (as per LPPL maintenance status) by
  Joseph Wright.

This work consists of the file  siunitx.dtx
          and the derived files siunitx.pdf,
                                siunitx.sty and
                                siunitx.ins.

\endpostamble
\usedir{tex/latex/siunitx}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\usedir{tex/latex/siunitx/config}
\generate{  
  \file{siunitx-abbreviations.cfg}
    {\from{\jobname.dtx}{config,abbreviations}}
  \file{siunitx-binary.cfg}{\from{\jobname.dtx}{config,binary}}
  \file{siunitx-version-1.cfg}{\from{\jobname.dtx}{config,version-1}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/siunitx}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/siunitx}
\generate{
  \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*driver|package>
\RequirePackage{expl3}
%</driver|package>
%<*driver>
\documentclass[german,french,english,UKenglish]{l3doc}

\usepackage{amsmath,babel,booktabs,caption,colortbl,csquotes,datatool}
\usepackage{helvet,pgfplots,siunitx,xcolor,xtab}
\IfFileExists{xfrac.sty}
  {\usepackage{xfrac}}
  {%
    \PackageWarningNoLine{siunitx}
      {%
        xfrac unavailable: \string\sfrac\space fraction \MessageBreak
        will have wrong appearance%
      }
  }
\ProvideDocumentCommand\sfrac{mm}{\frac{#1}{#2}}
\usepackage[capitalise]{cleveref}
\usepackage[final]{listings}
\usepackage[osf]{mathpazo}

% Silence annoying fp package messages
\FPmessagesfalse

\pgfplotsset{compat = newest}

\sisetup{
  load-configurations = 
    {
      abbreviations,
      binary,
    }
}
\DeclareSIUnit{\KWH}{kWh}
\DeclareSIPrePower\quartic{4}
\DeclareSIPostPower\tothefourth{4}
\DeclareSIQualifier\catalyst{cat}
\DeclareSIQualifier\isotropic{i}
\DeclareSIQualifier\polymer{pol}
%\DisableImplementation
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
% 
%\makeatletter
%
%^^A Some short cuts for the tables
%\NewDocumentCommand\DescribePrefix{m}{^^A
%  \expandafter\SpecialUsageIndex\expandafter{\csname #1\endcsname}^^A
%    #1 & \cs{#1} & \expandafter\si\expandafter{\csname #1\endcsname} 
%}
%\NewDocumentCommand\DescribeUnit{m}{^^A
%  \expandafter\SpecialUsageIndex\expandafter{\csname #1\endcsname}^^A
%  #1 &
%  \cs{#1} &
%  \expandafter\si\expandafter{\csname #1\endcsname}
%}
%\NewDocumentCommand\DescribeNamedUnit{mm}{^^A
%  \expandafter\SpecialUsageIndex\expandafter{\csname #2\endcsname}^^A
%  #1 &
%  \cs{#2} &
%  \expandafter\si\expandafter{\csname #2\endcsname}
%}
%
%^^A For creating examples with nice highlighting of code, and so
%^^A on; based on the system used in the listings source (lstsample).
%\lst@RequireAspects{writefile}
%\newsavebox{\LaTeXdemo@box}
%\lstnewenvironment{LaTeXdemo}[1][code and example]
%  {^^A
%    \global\let\lst@intname\@empty
%    \expandafter\let\expandafter\LaTeXdemo@end
%      \csname LaTeXdemo@#1@end\endcsname
%    \@nameuse{LaTeXdemo@#1}^^A
%  }
%  {\LaTeXdemo@end}
%\newcommand*\LaTeXdemo@new[3]{^^A
%  \expandafter\newcommand\expandafter*\expandafter
%    {\csname LaTeXdemo@#1\endcsname}{#2}^^A
%  \expandafter\newcommand\expandafter*\expandafter
%    {\csname LaTeXdemo@#1@end\endcsname}{#3}^^A
%}
%\newcommand*\LaTeXdemo@common{^^A
%  \setkeys{lst}
%    {
%      basicstyle   = \small\ttfamily,
%      basewidth    = 0.51em,
%      gobble       = 3,
%      keywordstyle = \color{blue},
%      language     = [LaTeX]{TeX},
%      moretexcs    = 
%        {
%          addto,
%          ampere,
%          ang,
%          angstrom,
%          becquerel,
%          bel,
%          bit,
%          bottomrule,
%          byte,
%          candela,
%          centi,
%          color,
%          coulomb,
%          cubed,
%          cubic,
%          deci,
%          decibel,
%          degree,
%          degreeCelsius,
%          DeclareBinaryPrefix,
%          DeclareRobustCommand,
%          DeclareSIPostPower,
%          DeclareSIPrefix,
%          DeclareSIPrePower,
%          DeclareSIQualifier,
%          DeclareSIUnit,
%          DeclareSIUnitWithOptions,
%          DTLdisplaydb,
%          DTLforeach,
%          DTLiffirstrow,
%          DTLmul,
%          DTLnewdb,
%          DTLnewdbentry,
%          DTLnewrow,
%          farad,
%          gram,
%          gray,
%          henry,
%          hour,
%          Hz,
%          joule,
%          kelvin,
%          kibi,
%          kilo,
%          kilogram,
%          litre,
%          lumen,
%          lux,
%          mathnormal,
%          metre,
%          mebi,
%          micro,
%          midrule,
%          milli,
%          mm,
%          mole,
%          num,
%          numlist,
%          numrange,
%          of,
%          pascal,
%          per,
%          percent,
%          protected,
%          radian,
%          raiseto,
%          robustify,
%          rowcolor,
%          second,
%          selectlanguage,
%          SendSettingsToPgf,
%          si,
%          SI,
%          sievert,
%          SIlist,
%          SIrange,
%          sisetup,
%          SIUnitSymbolDegree,
%          square,
%          squared,
%          tesla,
%          texorpdfstring,
%          text,
%          toprule,
%          tothe,
%          translate,
%          volt,
%          kWh,
%        }
%    }^^A 
%}
%\newcommand*\LaTeXdemo@input{^^A
%  \MakePercentComment
%  \catcode`\^^M=10\relax
%  \small
%  \begingroup
%    \setkeys{lst}
%      {
%        SelectCharTable=\lst@ReplaceInput{\^\^I}{\lst@ProcessTabulator}
%      }^^A
%    \leavevmode 
%      \input{\jobname.tmp}^^A
%  \endgroup
%  \MakePercentIgnore
%}
%\LaTeXdemo@new{code and example}
%  {^^A
%    \setbox\LaTeXdemo@box=\hbox\bgroup
%      \lst@BeginAlsoWriteFile{\jobname.tmp}^^A
%      \LaTeXdemo@common
%  }
%  {^^A
%      \lst@EndWriteFile
%    \egroup
%    \begin{center}
%      \ifdim\wd\LaTeXdemo@box>0.48\linewidth\relax
%        \hbox to\linewidth{\box\LaTeXdemo@box\hss}^^A
%          \begin{minipage}{\linewidth}
%            \LaTeXdemo@input
%          \end{minipage}
%      \else
%        \begin{minipage}{0.48\linewidth}
%          \LaTeXdemo@input
%        \end{minipage}
%        \hfill
%        \begin{minipage}{0.48\linewidth}
%          \hbox to\linewidth{\box\LaTeXdemo@box\hss}^^A
%        \end{minipage}
%      \fi
%    \end{center}
%  }
%\LaTeXdemo@new{code and float}{^^A
%  \lst@BeginAlsoWriteFile{siunitx.tmp}^^A
%  \LaTeXdemo@common
%}{^^A
%  \lst@EndWriteFile
%  \LaTeXdemo@input
%}
%\LaTeXdemo@new{code only}
%  {\LaTeXdemo@common}{}
%  
%^^A Turning of the marginpar warnings is a bit awkward.
%^^A It is achieved by temporarily disabling \@latex@warning@no@line
%\let\latex@addmarginpar\@addmarginpar
%\let\latex@warning@no@line\@latex@warning@no@line
%\def\@addmarginpar{^^A
%  \let\@latex@warning@no@line\@gobble
%  \latex@addmarginpar
%  \let\@latex@warning@no@line\latex@warning@no@line
%}
%
%\ProvideDocumentCommand\opt{m}{\texttt{#1}}
%
%\makeatother
%
%\GetFileInfo{\jobname.sty}
% 
%\title{^^A
%  \textsf{siunitx} --- A comprehensive (SI) units package\thanks{^^A
%    This file describes \fileversion, last revised \filedate.^^A
%  }^^A
%}
%\author{^^A
%  Joseph Wright\thanks{E-mail: joseph.wright@morningstar2.co.uk}^^A
%}
%\date{Released \filedate}
%
%\maketitle
%
%\changes{v0.6}{2008/02/18}{First public testing release (as \pkg{si})}
%\changes{v1.0}{2008/06/15}{First official release}
%\changes{v1.1}{2008/09/28}{Package extended to a greater range of unit
%  types}
%\changes{v1.2}{2009/01/22}{Correct handling for ranges of numbers 
%  added}
%\changes{v1.3}{2009/09/20}{Better definition for micro symbol}
%\changes{v1.4}{2010/01/16}{Detect entire document in non-serif font}
%\changes{v2.0}{2010/05/23}{Complete re-write of package to add many new
%  features}
%\changes{v2.0}{2010/05/23}{Introduced \cs{numlist} and \cs{SIlist}
%  functions}
%\changes{v2.0a}{2010/05/28}{Make \cs{SendSettingsToPgf} available
%  in document body}
%\changes{v2.0a}{2010/05/28}{Fix various errors in \file{version-1}
%  configuration file}
%\changes{v2.0a}{2010/05/28}{Detect use of version 1 options and
%  automatically load appropriate configuration file}
%\changes{v2.0a}{2010/05/28}{Include high energy physics units in 
%  discussion of old configurations and in \file{version-1}
%  configuration file}
%\changes{v2.0b}{2010/06/01}{Further improvements to \file{version-1}
%  configuration file}
%\changes{v2.0c}{2010/06/07}{Mixed literal and macro units now print
%  more reliably}
%\changes{v2.0d}{2010/06/10}{Document special case situations for last
%  cell in table row}
%\changes{v2.0d}{2010/06/10}{Fix error in \opt{table-format} option
%  concerning exponent signs}
%\changes{v2.0e}{2010/06/20}{Correct behaviour of \cs{pm} in numbers
%  when \texttt{abbreviations} configuration is loaded: problem 
%  introduced in v2.0c}
%\changes{v2.0f}{2010/06/27}{Fix issue with spacing of multiplication
%  sign in text mode}
%\changes{v2.0g}{2010/06/28}{Fix issue with complex numbers in 
%  quotients}
%\changes{v2.0g}{2010/06/28}{Repair broken \opt{bracket-numbers}
%  option}
%\changes{v2.0g}{2010/06/28}{Improve handling of complex root token}
%\changes{v2.0g}{2010/06/28}{Introduce localisation for text values}
%\changes{v2.0h}{2010/06/29}{Actually get localisation into the 
%  code}
%\changes{v2.0i}{2010/06/29}{Correct behaviour of \cs{of} function
%  so it actually works (bug introduced in v2.0d)}
%\changes{v2.0j}{2010/06/30}{Correct \cs{hartree} unit appearance}
%\changes{v2.0j}{2010/06/30}{Ensure symbols specified in 
%  \opt{input-symbols} are always printed in math mode}
%\changes{v2.0k}{2010/07/04}{Fix for \pkg{babel} French settings with
%  \cs{fg} in tabular material}
%\changes{v2.0l}{2010/07/07}{Further adjustments to \pkg{babel} support}
%\changes{v2.0m}{2010/07/09}{Re-introduce \opt{locale} option}
%\changes{v2.0n}{2010/07/15}{More abbreviated units}
%\changes{v2.0o}{2010/07/21}{Extend \opt{detect-italic} option
%  to other shapes, renaming as \opt{detect-shape} as a result}
%\changes{v2.0p}{2010/07/28}{Actually get change from v2.0o working}
%\changes{v2.0q}{2010/07/29}{Errors with free-standing unit code fixed}
%\changes{v2.0q}{2010/07/29}{Deal with bad definition of \cs{color}
%  by \pkg{textpos} package}
%\changes{v2.0r}{2010/08/02}{Error in definition for old 
%  \opt{decimalsymbol} option corrected}
%\changes{v2.0s}{2010/08/08}{Correct errors in rounding code when 
%  precision requested is zero decimal places}
%\changes{v2.0s}{2010/08/12}{Document how to do mixed bold and normal
%  numbers in tables}
%\changes{v2.0t}{2010/08/24}{Replace \cs{exp_afer:wN} in code for
%  \cs{per} with \cs{exp_after:wN}}
%\changes{v2.0u}{2010/09/14}{Fix second possible issue with 
%  \pkg{textpos} package and \cs{color}}
%\changes{v2.0u}{2010/09/14}{Prevent infinite loop if \cs{SI} function
%  is used with an empty number}
%\changes{v2.0v}{2010/09/26}{Internal changes reflecting \pkg{expl3}
%  updates}
%\changes{v2.0w}{2010/09/29}{Deal with internal function used by
%  REV\TeX\ in tables}
%\changes{v2.0x}{2010/10/05}{Fix bug when detecting single prefixes
%  and converting prefixes to numbers}
%\changes{v2.0y}{2010/10/09}{Error with \opt{tight-spacing} option
%  and exponents corrected}
%\changes{v2.1}{2010/10/02}{New \opt{copy-complex-root} option for
%  moving input complex root to output}
%\changes{v2.1}{2010/10/12}{New \opt{table-align-exponent} and
%  \opt{table-align-uncertainty} options for additional choices of 
%  table formatting}
%\changes{v2.1}{2010/10/12}{New \opt{power-font} option for controlling
% whether superscript powers are treated as numbers or units}
%\changes{v2.1}{2010/10/13}{New \opt{scientific-notation} option
% for to use exponent form for numbers in all cases}
%\changes{v2.1}{2010/10/13}{New \opt{table-omit-exponent} option
% for simplifying tables}
%\changes{v2.1}{2010/10/25}{New \opt{round-integer-to-decimal} option
% to convert integers to decimals on rounding}
%\changes{v2.1}{2010/10/26}{New \opt{input-comparators} option
% for numbers greater than, less than and so on}
%\changes{v2.1}{2010/10/26}{New \opt{table-comparator} option
% for reserving space for comparators in tables}
%\changes{v2.1}{2010/10/27}{New \opt{round-minimum} option
% to set a floor for rounding numbers downward}
%\changes{v2.1a}{2010/11/05}{Ensure that output of list separators is
% in text mode}
%\changes{v2.1a}{2010/11/05}{Print prefixes correctly in text mode
%  when converting to numerical value}
%\changes{v2.1b}{2010/11/05}{Bug in printing code for complex part with
%  no number fixed}
%\changes{v2.1b}{2010/11/05}{Bug in hyphen printing when detecting mode
%  sorted}
%\changes{v2.1c}{2010/11/11}{Discourage line break between number and
%  unit even when it is permitted}
%\changes{v2.1c}{2010/11/13}{New \opt{text} choice for
%  \opt{qualifier-mode} option}
%\changes{v2.1c}{2010/11/14}{After reviewing internals, \cs{numlist},
%  \cs{numrange}, \cs{SIlist} and \cs{SIrange} are documented as
%  requiring text mode due to issues with spacing and line breaks}
%\changes{v2.1c}{2010/11/14}{Auto-detect math mode in tables and
%  correct output accordingly}
%\changes{v2.1d}{2010/11/14}{Apply unit options when
%  \opt{free-standing-units} is active}
%\changes{v2.1d}{2010/11/14}{Error with definition of version 1 option
%  \opt{xspace} corrected}
%\changes{v2.1e}{2010/11/22}{Further corrections when applying unit 
%  options when \opt{free-standing-units} is active}
%\changes{v2.1e}{2010/11/22}{Fix issues with text mode symbols and
%  \pkg{fontspec} package}
%\changes{v2.1f}{2010/11/24}{Typo in definition for
%  \opt{unit-optional-argument} implementation corrected}
%\changes{v2.1g}{2010/12/21}{Checks on the versions of \pkg{expl3} and
%  \pkg{xparse} installed}
%\changes{v2.1h}{2011/01/18}{Detect AMS display-like environments}
%\changes{v2.1i}{2011/01/27}{Improved logic for
% \opt{per-mode} setting \opt{symbol-or-fraction}}
%\changes{v2.1j}{2011/02/01}{Allow for loading of \pkg{inputenc} package
%  with no options}
%\changes{v2.1k}{2011/02/09}{Remove \opt{combined} choice for option
%  \opt{detect-inline-weight}}
%\changes{v2.1k}{2011/02/09}{New option \opt{detect-inline-family}}
%\changes{v2.1k}{2011/02/09}{Bug fix when printing superscript minus
%  signs and using \pkg{fontspec} package}
%\changes{v2.1l}{2011/02/10}{Error in font family detection introduced
% in v2.1k corrected}
%\changes{v2.1m}{2011/03/18}{Avoid expansion of erroneous literal
%  units when these are forbidden}
%\changes{v2.1m}{2011/03/20}{Ensure some output occurs in all cases
%  when \opt{round-precision} is set to \opt{0} and \opt{round-mode}
%  is set to \opt{places}}
%  
%\begin{abstract}
% Physical quantities have both numbers and units, and each physical
% quantity should be expressed as the product of a number and a unit.
% Typesetting physical quantities requires care to ensure that the
% combined mathematical meaning of the number--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 \pkg{siunitx} package provides a set of tools for authors
% to typeset quantities 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.
%\end{abstract}
%
%\tableofcontents
%
%\begin{documentation}
%
%\section{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
% \emph{Conf\'erence G\'en\'erale des Poids et
% Mesures} (CGPM): this has resulted in the \emph{Syst\`eme 
% International d'Unit\'es} (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.
%
% \pkg{siunitx} aims to provide a unified method for \LaTeX\ users to
% typeset numbers and units correctly and easily.  The design
% philosophy of \pkg{siunitx} is to follow the agreed rules by 
% default, but to allow variation through option settings.  In this way,
% users can use \pkg{siunitx} to follow the requirements of 
% publishers, co-authors, universities, \emph{etc}.~without needing to 
% alter the input at all.
% 
%\section{Installation}
%
% The package is supplied in \file{dtx} format and as a pre-extracted
% zip file, \file{\jobname.tds.zip}. The later is most convenient for
% most users: simply unzip this in your local texmf directory and
% run \texttt{texhash} to update the database of file locations. If
% you want to unpack the \file{dtx} yourself, running 
% \texttt{tex \jobname.dtx} will extract the package whereas
% \texttt{latex \jobname.dtx} will extract it and also typeset the
% documentation.
%
% The package requires \LaTeX3 support as provided in the 
% \pkg{expl3} and \pkg{xpackages} bundles. Both of these are available
% on \href{http://www.ctan.org}{\textsc{ctan}} as ready-to-install
% zip files. Suitable versions are available in MiK\TeX~2.9 and
% \TeX~Live 2010 (updating the relevant packages online may be
% necessary). \LaTeX3, and so \pkg{siunitx}, requires the \eTeX\
% extensions: these are available on all modern \TeX\ systems.
% 
% Typesetting the documentation requires a number of packages in
% addition to those needed to use the package. This is mainly 
% because of the number of demonstration items included in the text. To
% compile the documentation without error, you will need the packages:
%\begin{itemize} 
% \item \pkg{amsmath}
% \item \pkg{booktabs}
% \item \pkg{caption}
% \item \pkg{cleveref}
% \item \pkg{csquotes}
% \item \pkg{helvet}
% \item \pkg{mathpazo}
% \item \pkg{listings}
% \item \pkg{pgfplots}
% \item \pkg{xcolor}
%\end{itemize}
% The \pkg{xfrac} package is also loaded if available, but is not 
% required to typeset the documentation.
% 
%\section{\pkg{siunitx} for the impatient}
%
% The package provides the user macros:
%\begin{itemize}
%  \item \cs{num}\oarg{options}\marg{number}
%  \item \cs{si}\oarg{options}\marg{unit}
%  \item \cs{SI}\oarg{options}\marg{number}\oarg{pre-unit}\marg{unit}
%  \item \cs{numlist}\oarg{options}\marg{numbers}
%  \item \cs{numrange}\oarg{options}\marg{numbers}\marg{number2}
%  \item \cs{SIlist}\oarg{options}\marg{numbers}\marg{unit}
%  \item \cs{SIrange}\oarg{options}\marg{number1}\marg{number2}^^A
%    \marg{unit}
%  \item \cs{ang}\oarg{options}\marg{angle}
%  \item \cs{sisetup}\marg{options}
%\end{itemize}
% plus the \texttt{S} and \texttt{s} column types for decimal 
% alignments and units in tables.  These macros are designed for 
% typesetting numbers and units with control of appearance and with 
% intelligent processing.
% 
% Numbers are processed with understanding of exponents, complex numbers
% and multiplication.
%\begin{LaTeXdemo}
%  \num{12345,67890} \\
%  \num{1+-2i}       \\
%  \num{.3e45}       \\
%  \num{1.654 x 2.34 x 3.430}
%\end{LaTeXdemo} 
%
% The unit  system can interpret units given as text to be used directly
% or as macro-based units. In the later case, different formatting is
% possible.
%\begin{LaTeXdemo}
%  \si{kg.m.s^{-1}}                \\
%  \si{\kilogram\metre\per\second} \\
%  \si[per-mode=symbol]
%    {\kilogram\metre\per\second}  \\
%  \si[per-mode=symbol]
%    {\kilogram\metre\per\ampere\per\second}      
%\end{LaTeXdemo}
%
% Simple lists and ranges of numbers can be handled.
%\begin{LaTeXdemo}
%  \numlist{10;20;30}                    \\
%  \SIlist{0.13;0.67;0.80}{\milli\metre} \\
%  \numrange{10}{20}                     \\
%  \SIrange{0.13}{0.67}{\milli\metre}
%\end{LaTeXdemo}
% 
% By default, all text is typeset in the current upright, serif math
% font.  This can be changed by setting the appropriate options: 
% "\sisetup{detect-all}" will use the current font for typesetting.
% 
%\section{Using the \pkg{siunitx} package}
%
%\subsection{Loading the package}
%
% The package should be loaded in the usual \LaTeXe\ way.
%\begin{LaTeXdemo}[code only]
%  \usepackage{siunitx}
%\end{LaTeXdemo} 
% The key--value options described later in this document can be used
% when loading the package, for example
%\begin{LaTeXdemo}[code only]
%  \usepackage[load-configurations = version-1]{siunitx}
%\end{LaTeXdemo} 
% to use options from version 1 of the package.
%
%\subsection{Numbers}
%
%\DescribeMacro{\num}
%\begin{syntax}
%  \cs{num}\oarg{options}\marg{number}
%\end{syntax}
% Numbers are automatically formatted by the \cs{num} macro.  This
% takes one optional argument, \meta{options}, and one mandatory one,
% \meta{number}.  The contents of \meta{number} are automatically 
% formatted.  The formatter removes \enquote{hard} spaces 
% (\cs{,} and "~"), automatically identifies exponents (by default 
% marked using \texttt{e}, \texttt{E}, \texttt{d} or \texttt{D}) and 
% adds the appropriate spacing of large numbers.  With the standard
% settings a leading zero is added before a decimal marker, if needed: 
% both \enquote{\texttt{.}} and \enquote{\texttt{,}} are recognised as 
% decimal markers.
%\begin{LaTeXdemo}
%  \num{123}     \\
%  \num{1234}    \\
%  \num{12345}   \\
%  \num{0.123}   \\
%  \num{0,1234}  \\
%  \num{.12345}  \\
%  \num{3.45d-4} \\
%  \num{-e10}
%\end{LaTeXdemo}
% Note that numbers are parsed before typesetting, which does 
% have a performance overhead (only obvious with very large amounts
% of numerical input). The parser understands a range of input syntaxes,
% as demonstrated above.
% 
%\DescribeMacro{\numlist}
%\begin{syntax}
%  \cs{numlist}\oarg{options}\marg{numbers}
%\end{syntax}
% Lists of numbers may be processed using the \cs{numlist} function.
% Each \meta{number} is given within the list of \meta{numbers} within
% a brace pair, as the list can have a flexible length. This function
% should be used in text mode, a common feature of all of the list and 
% range functions provided by \pkg{siunitx}.\footnote{The reason for
% this restriction is that the separators between items may involve
% text-mode spaces which must be able to vanish at line breaks. It is
% not possible to achieve this effect from inside math mode.}
%\begin{LaTeXdemo}
%  \numlist{10;30;50;70}
%\end{LaTeXdemo}
%
%\DescribeMacro{\numrange}
%\begin{syntax}
%  \cs{numrange}\oarg{options}\marg{number1}\marg{number2}
%\end{syntax}
% Simple ranges of numbers can be handled using the \cs{numrange}
% function. This acts in the same way as \cs{num}, but inserts a 
% phrase or other text between the two entries. This function should
% be used in text mode.
%\begin{LaTeXdemo}
%  \numrange{10}{30}
%\end{LaTeXdemo}
%
%\DescribeMacro{\ang}
%\begin{syntax}
%  \cs{ang}\oarg{options}\marg{angle}
%\end{syntax}
% Angles can be typeset using the \cs{ang} command.  The
% \meta{angle} can be given either as a decimal number or as a
% semi-colon separated list of degrees, minutes and seconds, which 
% is called \enquote{arc format} in this document. The numbers which 
% make up an angle are processed using the same system as other numbers.
%\begin{LaTeXdemo}
%  \ang{10}    \\
%  \ang{12.3}  \\
%  \ang{4,5}   \\
%  \ang{1;2;3} \\
%  \ang{;;1}   \\
%  \ang{+10;;} \\
%  \ang{-0;1;}
%\end{LaTeXdemo}
%
%\subsection{Units}
%
%\DescribeMacro{\si}
%\begin{syntax}
%  \cs{si}\oarg{options}\marg{unit}
%\end{syntax}
% The symbol for a unit can be typeset using the \cs{si} macro: this 
% provides full control over output format for the unit. Like the
% \cs{num} macro, \cs{si} takes  one optional and one mandatory 
% argument. The unit formatting system can accept two types of input. 
% When the \meta{unit} contains literal items (for example letters or
% numbers) then \pkg{siunitx} converts \texttt{.} and "~" into
% inter-unit separators and correctly positions sub- and superscripts
% specified using "_" and "^". The formatting methods will work with
% both math and text mode.
%\begin{LaTeXdemo}
%  \si{kg.m/s^2} \\
%  \si{g_{polymer}~mol_{cat}.s^{-1}}
%\end{LaTeXdemo}
% The second operation mode for the \cs{si} macro is an 
% \enquote{interpreted} system, 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{LaTeXdemo}
%  \si{\kilo\gram\metre\per\square\second} \\
%  \si{\gram\per\cubic\centi\metre}        \\
%  \si{\square\volt\cubic\lumen\per\farad} \\
%  \si{\metre\squared\per\gray\cubic\lux}  \\
%  \si{\henry\second}                      
%\end{LaTeXdemo}
% On its own, this is less convenient than the direct method, although
% it does use meaning rather than appearance for input. 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 input, new
% functionality is made available.  By altering the settings used by the
% package, the same input can yield a variety of different output 
% formats. For example, the \cs{per} macro can give reciprocal powers,
% slashes or be used to construct units as fractions.
%
%\DescribeMacro{\SI}
%\begin{syntax}
%  \cs{SI}\oarg{options}\marg{number}\oarg{preunit}\marg{unit}
%\end{syntax}
% Very often, numbers and units are given together. Formally, the
% value of a quantity is the product of the number and the unit, the
% space being regarded as a multiplication sign \cite{SI:5.3.3}. The
% \cs{SI} macro combines the functionality of \cs{num} and
% \cs{si}, and makes this both possible and easy. The \meta{number} and 
% \meta{unit} arguments work exactly like those for the \cs{num} and 
% \cs{si} macros, respectively. \meta{preunit} is a unit to be typeset 
% \emph{before} the numerical value (most likely to be a currency).
%\begin{LaTeXdemo}
%  \SI[mode=text]{1.23}{J.mol^{-1}.K^{-1}}          \\
%  \SI{.23e7}{\candela}                             \\
%  \SI[per-mode=symbol]{1.99}[\$]{\per\kilogram}    \\
%  \SI[per-mode=fraction]{1,345}{\coulomb\per\mole}
%\end{LaTeXdemo}
%
% It is possible to set up the unit macros to be available outside of
% the \cs{SI} and \cs{si} functions. This is not the standard behaviour
% as there is the risk of name clashes (for example, \cs{bar} is used
% by other packages, and several packages define \cs{degree}). Full
% details of using \enquote{stand alone} units are found in 
% \cref{sec:units:creating}.
% 
%\DescribeMacro{\SIlist}
%\begin{syntax}
%  \cs{SIlist}\oarg{options}\marg{numbers}\marg{unit} 
%\end{syntax}
% Lists of numbers with units can be handled using the \cs{SIlist}
% function. The behaviour of this function is similar to \cs{numlist},
% but with the addition of a unit to each number.  This function should
% be used in text mode.
%\begin{LaTeXdemo}
%  \SIlist{10;30;45}{\metre}
%\end{LaTeXdemo}
% 
%\DescribeMacro{\SIrange}
%\begin{syntax}
%  \cs{SIrange}\oarg{options}\marg{number1}\marg{number2}\marg{unit} 
%\end{syntax}
% Ranges of numbers with units can be handled using the \cs{SIrange}
% function. The behaviour of this function is similar to \cs{numrange},
% but with the addition of a unit to each number.  This function should
% be used in text mode.
%\begin{LaTeXdemo}
%  \SIrange{10}{30}{\metre}
%\end{LaTeXdemo}
%
%\subsection{The unit macros}
%
% The package always defines the basic set of SI units with macro names.
% This includes the base SI units, the derived units with special names
% and the prefixes. A small number of powers are also given pre-defined
% names. Full details of units in the SI are available 
% on-line~\cite{BIPM}.
% 
%\DescribeMacro{\meter}
% The seven base SI units are always defined 
% (\cref{tab:unit:base}). In addition, the macro \cs{meter} is
% available as an alias for \cs{metre}, for users of US spellings.
% The full details of the base units are given in the SI 
% Brochure~\cite{SI:2.1}.
%\begin{table}
%  \caption{SI base units.}
%  \label{tab:unit:base}
%  \centering
%  \begin{tabular}{lll}
%    \toprule
%     Unit & Macro & Symbol \\
%    \midrule
%      \DescribeUnit{ampere}   \\
%      \DescribeUnit{candela}  \\
%      \DescribeUnit{kelvin}   \\
%      \DescribeUnit{kilogram} \\ 
%      \DescribeUnit{metre}    \\
%      \DescribeUnit{mole}     \\
%      \DescribeUnit{second}   \\ 
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeMacro{\celsius}
% The SI also lists a number of units which have special names and 
% symbols \cite{SI:2.2.2}: these are listed in 
% \cref{tab:unit:derived}. As a short-cut for the degree Celsius,
% the unit \cs{celsius} is defined equivalent to \cs{degreeCelsius} .
%\begin{table}
%  \caption{Coherent derived units in the SI with special names and 
%    symbols.}
%  \label{tab:unit:derived}
%  \centering
%  \begin{tabular}{lll>{\qquad}lll}
%    \toprule
%      Unit & Macro & Symbol & Unit & Macro & Symbol \\
%    \midrule
%      \DescribeUnit{becquerel} &
%      \DescribeUnit{newton}    \\ 
%      \DescribeNamedUnit{degree Celsius}{degreeCelsius} &
%      \DescribeUnit{ohm}       \\
%      \DescribeUnit{coulomb}   &
%      \DescribeUnit{pascal}    \\
%      \DescribeUnit{farad}     &
%      \DescribeUnit{radian}    \\
%      \DescribeUnit{gray}      &
%      \DescribeUnit{siemens}   \\
%      \DescribeUnit{hertz}     &
%      \DescribeUnit{sievert}   \\
%      \DescribeUnit{henry}     &
%      \DescribeUnit{steradian} \\
%      \DescribeUnit{joule}     &
%      \DescribeUnit{tesla}     \\
%      \DescribeUnit{katal}     &
%      \DescribeUnit{volt}      \\
%      \DescribeUnit{lumen}     &
%      \DescribeUnit{watt}      \\
%      \DescribeUnit{lux}       &
%      \DescribeUnit{weber}     \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
% In addition to the official SI units, \pkg{siunitx} also provides
% macros for a number of units which are accepted for use in the SI
% although they are not SI units. \cref{tab:unit:accepted} lists 
% the \enquote{accepted} units \cite{SI:4.1.T6}. Some units are 
% fundamental physical quantities, and these are non-SI but can be used 
% within the SI (\cref{tab:unit:physical}, \cite{SI:4.1.T7}). 
% There are also a set of non-SI units which are used in certain 
% defined circumstances (\cref{tab:unit:other}), although they are 
% not necessarily official sanctioned \cite{SI:4.1.T8}.
%\begin{table}
%  \caption{Non-SI units accepted for use with the 
%    International System of Units.}
%  \label{tab:unit:accepted}
%  \centering
%  \begin{tabular}{lll}
%    \toprule
%      Unit & Macro & Symbol \\
%    \midrule
%      \DescribeUnit{day}     \\
%      \DescribeUnit{degree}  \\
%      \DescribeUnit{hectare} \\
%      \DescribeUnit{hour}    \\
%      \DescribeUnit{litre}   \\
%        \SpecialUsageIndex{\liter}^^A 
%       & \cs{liter} & \si{\liter} \\
%      \DescribeNamedUnit{minute (plane angle)}{arcminute} \\ 
%      \DescribeNamedUnit{minute (time)}{minute} \\
%      \DescribeNamedUnit{second (plane angle)}{arcsecond} \\ 
%      \DescribeUnit{tonne}   \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%\begin{table}
%  \caption{Non-SI units whose values in SI units must be obtained 
%    experimentally.}
%  \label{tab:unit:physical}
%  \centering
%  \begin{tabular}{lll}
%    \toprule
%      Unit & Macro & Symbol \\
%    \midrule
%      \DescribeNamedUnit{astronomical unit}{astronomicalunit} \\
%      \DescribeNamedUnit{atomic mass unit}{atomicmassunit} \\
%      \DescribeUnit{bohr}         \\
%      \DescribeNamedUnit{speed of light}{clight} \\
%      \DescribeUnit{dalton}       \\
%      \DescribeNamedUnit{electron mass}{electronmass} \\
%      \DescribeUnit{electronvolt} \\
%      \DescribeNamedUnit{elementary charge}{elementarycharge} \\
%      \DescribeUnit{hartree} \\
%      \DescribeNamedUnit{reduced Planck constant}{planckbar} \\ 
%    \bottomrule
%  \end{tabular}
%\end{table}
%\begin{table}
%  \caption{Other non-SI units.}
%  \label{tab:unit:other}
%  \centering
%  \begin{tabular}{lll}
%    \toprule
%      Unit & Macro & Symbol  \\
%    \midrule
%      \DescribeNamedUnit{{\aa}ngstr{\"o}m}{angstrom} \\
%      \DescribeUnit{bar}  \\
%      \DescribeUnit{barn} \\
%      \DescribeUnit{bel}  \\
%      \DescribeUnit{decibel} \\
%      \DescribeUnit{knot} \\
%      \DescribeNamedUnit{millimetre of mercury}{mmHg} \\
%      \DescribeNamedUnit{nautical mile}{nauticalmile} \\ 
%      \DescribeUnit{neper} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeMacro{\deka}
% In addition to the units themselves, \pkg{siunitx} provides 
% pre-defined macros for all of the SI prefixes 
% (\cref{tab:unit:prefix}, \cite{SI:3.1}). The spelling
% \enquote{\cs{deka}} is provided for US users as an alternative to 
% \cs{deca}.
%\begin{table}
%  \caption{SI prefixes.}
%  \label{tab:unit:prefix}
%  \centering
%  \begin{tabular}{llc>{$}l<{$}>{\qquad}llc>{$}l<{$}}
%    \toprule
%      Prefix & Macro & Symbol & \multicolumn{1}{l}{Power} & 
%        Prefix & Macro & Symbol & \multicolumn{1}{l}{Power} \\
%    \midrule
%      \DescribePrefix{yocto} & -24 &
%      \DescribePrefix{deca}  &   1 \\
%      \DescribePrefix{zepto} & -21 &
%      \DescribePrefix{hecto} &   2 \\
%      \DescribePrefix{atto}  & -18 &
%      \DescribePrefix{kilo}  &   3 \\
%      \DescribePrefix{femto} & -15 &
%      \DescribePrefix{mega}  &   6 \\
%      \DescribePrefix{pico}  & -12 &
%      \DescribePrefix{giga}  &  9 \\
%      \DescribePrefix{nano}  &  -9 &
%      \DescribePrefix{tera}  &  12 \\
%      \DescribePrefix{micro} & -6 &
%      \DescribePrefix{peta}  &  15 \\
%      \DescribePrefix{milli} &  -3 &
%      \DescribePrefix{exa}   &  18 \\
%      \DescribePrefix{centi} &  -2 &
%      \DescribePrefix{zetta} &  21 \\
%      \DescribePrefix{deci}  &  -1 &
%      \DescribePrefix{yotta} &  24 \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeMacro{\square}
%\DescribeMacro{\squared}
%\DescribeMacro{\cubic}
%\DescribeMacro{\cubed}
% A small number of pre-defined powers are provided as macros. 
% \cs{square} and \cs{cubic} are intended for use before units, with
% \cs{squared} and \cs{cubed} going after the unit.
%\begin{LaTeXdemo} 
%  \si{\square\becquerel} \\
%  \si{\joule\squared\per\lumen} \\
%  \si{\cubic\lux\volt\tesla\cubed}
%\end{LaTeXdemo}
%\DescribeMacro{\tothe}
%\DescribeMacro{\raiseto}
% Generic powers can be inserted on a one-off basis using the \cs{tothe}
% and \cs{raiseto} macros. These are the only macros for units which
% take an argument:
%\begin{LaTeXdemo} 
%  \si{\henry\tothe{5}} \\
%  \si{\raiseto{4.5}\radian}
%\end{LaTeXdemo}
%\DescribeMacro{\per}
% Reciprocal powers are indicated using the \cs{per} macro. This applies
% to the next unit only, unless the \opt{sticky-per} option
% is turned on.
%\begin{LaTeXdemo} 
%  \si{\joule\per\mole\per\kelvin} \\
%  \si{\joule\per\mole\kelvin} \\
%  \si{\per\henry\tothe{5}} \\
%  \si{\per\square\becquerel} 
%\end{LaTeXdemo}
%\DescribeMacro{\of}
% As for generic powers, generic qualifiers are also available using
% the \cs{of} function:
%\begin{LaTeXdemo} 
%  \si{\kilogram\of{metal}} \\
%  \SI[qualifier-mode = brackets]
%    {0.1}{\milli\mole\of{cat}\per\kilogram\of{prod}}
%\end{LaTeXdemo}
%
% When using the unit macros, the package is able to validate the
% input given. As part of this, stand-alone unit prefixes can be used
% with the \cs{si} macro
%\begin{LaTeXdemo} 
%  \si{\kilo}  \\
%  \si{\micro} \\
%  \si[prefixes-as-symbols = false]{\kilo}
%\end{LaTeXdemo}
% However, the package only allows a single prefix to be used in this
% way: multiple prefixes will give an error, as will trying to give 
% a number without a unit. So the following will raise errors:
%\begin{LaTeXdemo}[code only] 
%  \si{\kilo\gram\micro} \\
%  \SI{10}{\micro}
%\end{LaTeXdemo}
% 
%\subsection{Creating new macros}
%
% The various macro components of a unit have to be defined before
% they can be used. The package supplies a number of common definitions,
% but new definitions are also possible. As the definition of a logical
% unit should remain the same in a single document, these creation
% functions are all preamble-only. 
%
%\DescribeMacro{\DeclareSIUnit}
%\DescribeMacro{\DeclareSIUnitWithOptions}
%\begin{syntax}
%  \cs{DeclareSIUnit}\marg{unit}\marg{symbol}
%  \cs{DeclareSIUnitWithOptions}\marg{unit}\marg{symbol}\marg{options}
%\end{syntax}
% New units are produced using the \cs{DeclareSIUnit} macro. 
% \meta{symbol} can contain literal input, other units, multiple
% prefixes, powers and \cs{per}, although literal text should not be
% intermixed with unit macros. Units can be created with options
% using the \cs{DeclareSIUnitWithOptions} function, where the 
% \meta{options} argument can be any suitable options, and applies the
% specific unit macro only. The (first) optional argument to \cs{SI} 
% and \cs{si} can be used to override the settings for the unit. A 
% typical example is the \cs{degree} unit.
%\begin{LaTeXdemo}
%  \SI{3.1415}{\degree}
%\end{LaTeXdemo} 
% This is declared in the package as:
%\begin{LaTeXdemo}[code only]
%  \DeclareSIUnitWithOptions\degree{\SIUnitSymbolDegree}
%    {number-unit-separator={}}
%\end{LaTeXdemo}
% The spacing can still be altered at point of use:
%\begin{LaTeXdemo}
%  \SI{67890}{\degree} \\
%  \SI[number-unit-separator = \;]{67890}{\degree}
%\end{LaTeXdemo}
% The meaning of a pre-defined unit can be altered by using
% \cs{DeclareSIUnit} after loading \pkg{siunitx}. This will overwrite
% the original definition with the newer version.
% 
%\DescribeMacro{\DeclareSIPrefix}
%\DescribeMacro{\DeclareBinaryPrefix}
%\begin{syntax}
%  \cs{DeclareSIPrefix}\marg{prefix}\marg{symbol}\marg{powers-ten}
%  \cs{DeclareBinaryPrefix}\marg{prefix}\marg{symbol}\marg{powers-two}
%\end{syntax}
% The standard SI powers of ten are defined by the package, and are
% described above.  However, the user can define new prefixes with
% \cs{DeclareSIPrefix}. The \cs{DeclareBinaryPrefix} function is also
% available for creating binary prefixes, with the same syntax 
% (\meta{powers-ten} being replaced by \meta{powers-two}). For 
% example, \cs{kilo} and \cs{kibi} are defined:
%\begin{LaTeXdemo}[code only]
%  \DeclareSIPrefix\kilo{k}{3}
%  \DeclareBinaryPrefix\kibi{Ki}{10}
%\end{LaTeXdemo}
%
%\DescribeMacro{\DeclareSIPostPower}
%\DescribeMacro{\DeclareSIPrePower}
%\begin{syntax}
%  \cs{DeclareSIPostPower}\marg{power}\marg{num}
%  \cs{DeclareSIPrePower}\marg{power}\marg{num}
%\end{syntax}
% These create power macros to appear before or after the unit they
% apply to. For example, the preamble to a document might contain:
%\begin{LaTeXdemo}[code only]
%  \DeclareSIPrePower\quartic{4}
%  \DeclareSIPostPower\tothefourth{4}
%\end{LaTeXdemo}
% with the functions then used in the document as:
%\begin{LaTeXdemo}
%  \si{\kilogram\tothefourth}\\
%  \si{\quartic\metre}
%\end{LaTeXdemo}
%
%\DescribeMacro{\DeclareSIQualifier}
% Following the syntax of the other macros, qualifiers are created
% with the syntax \cs{DeclareSIQualifier}\marg{qualifier}\marg{symbol}.
% In contrast to the other parts of a unit, there are no pre-defined
% qualifiers. It is therefore entirely up to the user to create these.
% For example, to identify the mass of a product created when using
% a particular catalyst, the preamble could contain:
%\begin{LaTeXdemo}[code only]
%  \DeclareSIQualifier\polymer{pol}
%  \DeclareSIQualifier\catalyst{cat}
%\end{LaTeXdemo}
% and then in the body the document could read:
%\begin{LaTeXdemo}
%  \SI{1.234}{\gram\polymer\per\mole\catalyst\per\hour}
%\end{LaTeXdemo}
%
%\subsection{Tabular material}
%
% Aligning numbers in tabular content is handled by a new column
% type, the \texttt{S} column. This new column type can align material
% using a number of different strategies, with the aim of flexibility 
% of output without needing to alter the input. The method used
% as standard is to place the decimal marker in the number at the
% centre of the cell and to align the material appropriately
% (\cref{tab:S:standard}).
%
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Standard behaviour of the \texttt{S} column type.}
%    \label{tab:S:standard}
%    \centering
%    \begin{tabular}{S}
%    \toprule
%      {Some Values} \\
%    \midrule
%         2.3456 \\
%        34.2345 \\
%        -6.7835 \\
%        90.473  \\
%      5642.5    \\
%          1.2e3 \\
%            e4  \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
% 
% The \texttt{S} column will attempt to automatically detect 
% material which should be placed before or after a number, and will
% maintain the alignment of the numerical data 
% (\cref{tab:S:extras}). If the material could be mistaken for
% part of a number, it should be protected by braces. The use of
% \cs{color} in a table cell will also be detected an will override any
% general colour applied by \pkg{siunitx}.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Detection of surrounding material in an \texttt{S} 
%      column.}
%    \label{tab:S:extras}
%    \centering
%    \begin{tabular}{S[color=orange]}
%    \toprule
%      {Some Values} \\
%    \midrule
%      12.34 \\
%      \color{purple} 975,31 \\
%      44.268 \textsuperscript{\emph{a}} \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
% As a complement to the \texttt{S} column, \pkg{siunitx} also provides
% a second column type, \texttt{s}.  This is intended for producing 
% columns of units. The letters chosen are intended to be similar to 
% \cs{SI} and \cs{si}, respectively. This allows both macro-based and 
% explicit units to be printed easily (\cref{tab:s:demo}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{Units in tables.}
%    \label{tab:s:demo}
%    \begin{tabular}{s}
%      \toprule
%        \multicolumn{1}{c}{Unit} \\
%      \midrule
%        \metre\squared\per\second \\
%        \pascal \\
%        m.s^{-1} \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
% As the \cs{si} macro can take literal or macro input, the \texttt{s}
% column cannot validate the input.  \emph{Everything} in an \texttt{s}
% column is therefore passed to the \cs{si} macro for processing.  To
% prevent this, you have to use \cs{multicolumn}, as is shown in
% \cref{tab:s:processing}.  Notice that the braces do not prevent
% processing and colouring of the cell contents.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{The \texttt{s} column processes everything.}
%    \label{tab:s:processing}
%    \sisetup{color = orange}
%    \begin{tabular}{ss}      
%      \toprule
%        {Unit}     & \multicolumn{1}{c}{Unit}\\
%      \midrule
%        {\si{m^3}} & \multicolumn{1}{c}{\si{m^3}} \\
%        \kilogram  & \kilogram \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\section{The key--value control system}
%
%\DescribeMacro{\sisetup}
% The behaviour of the \pkg{siunitx} package is controlled by a 
% number of key--value options. These can be given globally using
% the \cs{sisetup} function or locally as the optional argument to the
% user macros. 
%  
% The package uses a range of different key types:
%\begin{description}
%  \item[\texttt{Choice}] Takes a limited number of choices, which 
%    are described separately for each key. 
%  \item[\texttt{Integer}] Requires a number as the argument.
%  \item[\texttt{Literal}] A key which uses the value(s) given directly,
%    either to check input (for example the \texttt{input-digits} key)
%    or in output.
%  \item[\texttt{Math}] Similar to a \texttt{literal} option, but the
%    input is always used in math mode, irrespective of other 
%    \pkg{siunitx} settings. Thus to text-mode only input must be
%    placed inside the argument of a \cs{text} macro.
%  \item[\texttt{Macro}] Requires a macro, which may need a single 
%    argument.
%  \item[\texttt{Meta}] These are options which actually apply 
%    a number of other options. As such, they do not take any
%    value at all.
%  \item[\texttt{Switch}] These are on--off switches, and recognise
%    \opt{true} and \opt{false}.  Giving just the key name also 
%    turns the key on.
%\end{description}
% The tables of option names use these descriptions to indicate how the
% keys should be used.
%
%\subsection{Detecting fonts}
%
% The \pkg{siunitx} package controls the font used to print output
% independently of the surrounding material.  The standard method is to
% ignore the surroundings entirely, and to use the current body fonts.
% However, the package can detect and follow surrounding bold, italic 
% and font family changes. The font detection options are summarised in 
% \cref{tab:opt:font:det}.
%\begin{table}
%  \centering
%  \caption{Font detection options.}
%  \label{tab:opt:font:det}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule
%      detect-all           & Meta   & \meta{none} \\
%      detect-display-math  & Switch & false       \\
%      detect-family        & Switch & false       \\
%      detect-inline-family & Choice & text        \\
%      detect-inline-weight & Choice & text        \\
%      detect-mode          & Switch & false       \\
%      detect-none          & Meta   & \meta{none} \\ 
%      detect-shape         & Switch & false       \\
%      detect-weight        & Switch & false       \\ 
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{detect-weight}
%\DescribeOption{detect-family}
%\DescribeOption{detect-shape}
%\DescribeOption{detect-mode}
% The options \opt{detect-weight} and \opt{detect-shape} set detection
% of the prevailing font weight and font shape states, respectively. The 
% font shape state is only checked if the surrounding material is not in 
% math mode (as math text is always italic). The \opt{detect-shape}
% option is an extension of the older \opt{detect-italic} option, which
% is retained for backward compatibility. Detecting the current 
% family (roman, sans serif or monospaced) is controlled by the 
% \opt{detect-family} setting, while the current mode (text or math) 
% is detected using the \opt{detect-mode} switch. 
%\DescribeOption{detect-all}
%\DescribeOption{detect-none}
% For convenience, all of the preceding options can be turned on or
% off in one go using the \opt{detect-all} and \opt{detect-none}
% options.  As the names indicate, \opt{detect-all} sets all
% of \opt{detect-weight}, \opt{detect-family}, \opt{detect-shape}
% and \opt{detect-mode} to \texttt{true}, while \opt{detect-none}
% sets all of them to \texttt{false}.
% 
%\DescribeOption{detect-inline-family}
%\DescribeOption{detect-inline-weight}
% When \pkg{siunitx} macros are used in in-line math, the detection
% of font weight and font family can be tuned using the
% \opt{detect-inline-family} and \opt{detect-inline-weight} options.
% Both of these take the choices \opt{text} and \opt{math}.
%\begin{LaTeXdemo}
%  \sisetup{
%    detect-family        = true, 
%    detect-inline-family = math
%  }%
%  $\num{1234}$ \\
%  { \sffamily $\num{1234}$ } \\ 
%  $ \mathsf { \num{1234}} $  \\
%   \sisetup{detect-inline-family = text}
%  { \sffamily $\num{1234}$ } \\ 
%  $ \mathsf { \num{1234} } $ \\
%  \sisetup{
%    detect-weight        = true, 
%    detect-inline-weight = math
%  }%
%  $\num{5678}$ \\
%  { \boldmath $\num{5678}$ } \\ 
%  { \bfseries $\num{5678}$ } \\
%   \sisetup{detect-inline-weight = text}
%  { \boldmath $\num{5678}$ } \\
%  { \bfseries $\num{5678}$ }
%\end{LaTeXdemo} 
%
%\DescribeOption{detect-display-math}
% The font detection system can treat displayed mathematical content
% in two ways.  This is controlled by the \opt{detect-display-math}
% option. When set \opt{true}, display mathematics is treated 
% independently from the body of the document.  Thus the local 
% \emph{math} font is checked for matching.  In contrast, when set 
% \opt{false}, display material is treated with the current running 
% text font.\footnote{Here, \enquote{display} math means either typeset
% in \TeX's display math mode or using the AMS display-like
% environments. Simply using \cs{displaystyle} will not make otherwise
% in line math be detected as display math.}
%\begin{LaTeXdemo}
%  \sffamily
%  Some text
%  \sisetup{
%    detect-family,
%    detect-display-math = true
%  }
%  \[ x = \SI{1.2e3}{\kilogram\kelvin\candela} \]
%  More text
%  \sisetup{detect-display-math = false}
%  \[ y = \SI{3}{\metre\second\mole} \]
%\end{LaTeXdemo}
%
%\subsection{Output font families}
%
% The relationship between font family detected and font family used
% for output is not fixed. The font detected by the package in the 
% surrounding material does not have to match that used for output.
% 
%\begin{table}
%  \centering
%  \caption{^^A
%    Font options (also available as \opt{number-\ldots} and 
%    \opt{unit-\ldots} versions).
%  }
%  \label{tab:opt:font:set}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule
%      color   & Literal & \meta{none}   \\
%      math-rm & Macro   & \cs{mathrm}   \\
%      math-sf & Macro   & \cs{mathsf}   \\ 
%      math-tt & Macro   & \cs{mathtt}   \\
%      mode    & Choice  & math          \\
%      text-rm & Macro   & \cs{rmfamily} \\
%      text-sf & Macro   & \cs{sffamily} \\ 
%      text-tt & Macro   & \cs{ttfamily} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{mode}
% The \opt{mode} option determines whether \pkg{siunitx} uses
% math or text mode when printing output. The choices are \opt{math} and
% \opt{text}. When using math mode, text is printed using a math font 
% whereas in text mode a text font is used.  The extent to which this is 
% visually obvious depends on the fonts in use in the document. This 
% manual uses old style (lower-case) figures in text mode to highlight 
% the differences. This option has no effect if the \opt{detect-mode} 
% switch is \opt{true}.
% 
%\DescribeOption{math-rm}
%\DescribeOption{math-sf}
%\DescribeOption{math-tt}
%\DescribeOption{text-rm}
%\DescribeOption{text-sf}
%\DescribeOption{text-tt}
% If font family detection is inactive, \pkg{siunitx} uses the font
% family stored in either \opt{math-rm} or \opt{text-rm} for
% output. The choice of \opt{math} or \opt{text} depends on the
% \opt{mode} setting. If font family detection is active, 
% \pkg{siunitx} may be using a sans serif or monospaced font for 
% output. In math mode, these are stored in \opt{math-sf} and 
% \opt{math-tt}, and for text mode in \opt{text-sf} and \opt{text-tt}. 
% Notice that the detected and output font families can differ.
%\begin{LaTeXdemo}
%  \sisetup{detect-family}%
%  \num{1234} \\
%  { \sffamily \num{1234} } \\
%  \SI{99}{\metre} \\
%  \sisetup{math-rm = \mathtt}%
%  \SI{99}{\metre} 
%\end{LaTeXdemo}
% 
%\DescribeOption{color} 
% The colour of printed output can be set using the \opt{color} 
% option. When no colour is given, printing follows the surrounding 
% text. In contrast, when a specific colour is given, it is used 
% irrespective of the surroundings. As there are a number of different
% colour models available, it is left to to user to load \pkg{color} or
% a more powerful colour package.
%\begin{LaTeXdemo}
%  \color{red}
%  Some text \\
%  \SI{4}{\metre\per\sievert} \\
%  More text \\
%  \SI[color = blue]{4}{\metre\per\sievert} \\
%  Still red here!
%\end{LaTeXdemo}
%
% Every one of the font options can be given independently for units 
% and number, with the prefixes \opt{unit-} and \opt{number-}, 
% respectively. This allows fine control of output.
%\begin{LaTeXdemo}
%  \SI{4}{\angstrom} \\
%  \SI[number-color = green]{4}{\angstrom} \\
%  \SI[unit-color = green]{4}{\angstrom}
%\end{LaTeXdemo}
% 
%\subsection{Parsing numbers}
% 
% The package uses a sophisticated parsing system to understand 
% numbers. This allows \pkg{siunitx} to carry out a range of
% formatting, as described later. All of the input options take lists of
% literal tokens, and are summarised in \cref{tab:opt:num:in}.
% 
%\begin{table}
%  \centering
%  \caption{Options for number parsing.}
%  \label{tab:opt:num:in}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule ^^A (
%      input-close-uncertainty & Literal & )                \\ 
%      input-comparators       & Literal & 
%        <=>\cs{approx}\cs{ge}\cs{geq} \\
%        & & \cs{gg}\cs{le}\cs{leq}\cs{ll} \cs{sim} \\
%      input-complex-roots     & Literal & ij               \\ 
%      input-decimal-markers   & Literal & .,               \\
%      input-digits            & Literal & 0123456789       \\
%      input-exponent-markers  & Literal & dDeE             \\
%      input-ignore            & Literal & \meta{none}      \\
%      input-open-uncertainty  & Literal & (                \\ ^^A ) 
%      input-protect-tokens    & Literal & 
%        \cs{approx}\cs{ge}\cs{geq}\cs{gg}\cs{le} \\
%        & & \cs{leq}\cs{ll}\cs{mp}\cs{pi}\cs{pm}\cs{sim} \\
%      input-signs             & Literal & +-\cs{pm}\cs{mp} \\
%      input-symbols           & Literal & \cs{pi}          \\
%      parse-numbers           & Switch  & true             \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{input-digits}
%\DescribeOption{input-decimal-markers}
%\DescribeOption{input-signs}
%\DescribeOption{input-exponent-markers} 
% The basic parts of a number are the digits, any sign and a separator
% between the integer and decimal parts. These are stored in the input
% options \opt{input-digits}, \opt{input-decimal-markers} and 
% \opt{input-signs}, respectively. More than one input decimal marker 
% can be used: it will be converted by the package to the appropriate 
% output marker. Numbers which include an exponent part also require 
% a marker for the exponent: this again is taken from the range of 
% tokens in the \opt{input-exponent-markers} option.
% 
%\DescribeOption{input-symbols}
%\DescribeOption{input-ignore}
% As well as \enquote{normal} digits, the package will interpret 
% symbolic \enquote{numbers} (such as \cs{pi}) correctly if they are 
% included in the \opt{input-symbols} list. Symbols are always
% printed in math mode. Tokens given in the \opt{input-ignore} list 
% are totally passed over by \pkg{siunitx}: they will be removed from 
% the input with no further processing.
% 
%\DescribeOption{input-comparators}
% In addition to signs, \pkg{siunitx} can recognise comparators, such
% as \texttt{<}. The package will automatically carry out conversions
% for "<<", ">>", "<=" and ">=" to \cs{ll}, \cs{gg}, \cs{le} and
% \cs{ge}, respectively:
%\begin{LaTeXdemo}
%  \num{< 10} \\
%  \SI{>> 5}{\metre} \\
%  \num{\le 0.12}
%\end{LaTeXdemo} 
% 
%\DescribeOption{input-open-uncertainty}
%\DescribeOption{input-close-uncertainty} 
% In some fields, it is common to give the uncertainty in a number 
% in brackets after the main part of the number, for example 
% \enquote{\num{1.234(5)}}. The opening and closing symbols used for 
% this type of input are set as \opt{input-open-uncertainty} and 
% \opt{input-close-uncertainty}.
%
%\DescribeOption{input-complex-roots}
% When using complex numbers in input, the complex root 
% (\( \mathrm{i} = \sqrt{-1}\)) is indicated by one of the tokens stored
% in \opt{input-complex-roots}. The parser understands complex root 
% symbols given either before or after the associated number (but will
% detect any invalid arrangement):
%\begin{LaTeXdemo}
%  \num{9.99 + 88.8i} \\
%  \num{9.99 + i88.8}
%\end{LaTeXdemo} 
% 
%\DescribeOption{input-protect-tokens}
% Some symbols can be problematic under expansion in \LaTeXe. To allow 
% these to be used in input without issue, the package can protect these
% tokens while expanding input. Symbols to be protected in this way 
% should be listed in \opt{input-protect-tokens}.
% 
%\DescribeOption{parse-numbers}
% The \opt{parse-numbers} option turns the entire parsing system on
% and off. The option is made available for two reasons. First, if
% all of the numbers in a document are to be reproduced \enquote{as 
% given}, turning off the parser will represent a significant saving in
% processing required. Second, it allows the use of arbitrary \TeX\
% code in numbers. If the parser is turned off, the input will be
% printed in math mode (requiring \cs{text} to protect any text
% in the number).
%\begin{LaTeXdemo}
%  \num[parse-numbers = false]{\sqrt{2}}        \\
%  \SI[parse-numbers = false]{\sqrt{3}}{\metre}
%\end{LaTeXdemo}
%
%\subsection{Post-processing numbers}
%
% Before typesetting numbers, various post-processing steps can be 
% carried out. These involve adding or removing information from the 
% number in a systematic way; the options are summarised in 
% \cref{tab:opt:num:post}.
%
%\begin{table}
%  \centering
%  \caption{Number post-processing options.}
%  \label{tab:opt:num:post}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule
%      add-decimal-zero             & Switch  & true     \\
%      add-integer-zero             & Switch  & true     \\
%      explicit-sign                & Literal & \m{none} \\
%      retain-explicit-plus         & Switch  & false    \\
%      retain-unity-mantissa        & Switch  & true     \\
%      retain-zero-exponent         & Switch  & false    \\
%      round-integer-to-decimal     & Switch  & false    \\
%      round-minimum                & Literal & 0        \\
%      round-mode                   & Choice  & off      \\
%      round-precision              & Integer & 2        \\
%      scientific-notation          & Switch  & false    \\
%      scientific-notation-exponent & Integer & 0        \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{round-mode}
%\DescribeOption{round-precision}
% The \pkg{siunitx} package can round numerical input to a fixed
% number of significant figures or decimal places. This is controlled by
% the \opt{round-mode} option, which takes the choices \opt{off},
% \opt{figures} and \opt{places}. When rounding is turned on, the
% number of digits used (either decimal places or significant figures)
% is set using the \opt{round-precision} option. No rounding will take
% place if the number contains an uncertainty component.
%\begin{LaTeXdemo}
%  \num{1.23456} \\
%  \num{14.23} \\
%  \num{0.12345(9)} \\
%  \sisetup{
%    round-mode      = places,
%    round-precision = 3
%  }%
%  \num{1.23456} \\
%  \num{14.23} \\
%  \num{0.12345(9)} \\
%  \sisetup{
%    round-mode      = figures,
%    round-precision = 3
%  }%
%  \num{1.23456} \\
%  \num{14.23} \\
%  \num{0.12345(9)}
%\end{LaTeXdemo}
%\DescribeOption{round-integer-to-decimal}
% The standard settings for \pkg{siunitx} do not add a decimal part
% if none was given in the input. The \opt{round-integer-to-decimal}
% option can be used to allow this conversion as part of the rounding
% process.
%\begin{LaTeXdemo}
%  \num[round-mode = figures]{1} \\
%  \num[round-mode = places]{1} \\
%  \sisetup{round-integer-to-decimal}
%  \num[round-mode = figures]{1} \\
%  \num[round-mode = places]{1}
%\end{LaTeXdemo}
%\DescribeOption{round-minimum}
% There are cases in which rounding will result in the number reaching
% zero. It may be desirable to show such results as below a threshold
% value. This can be achieved by setting \opt{round-minimum} to the
% threshold value. There will be no effect when rounding to a number of
% significant figures as it is not possible to obtain the value zero in
% these cases.
%\begin{LaTeXdemo}
%  \sisetup{round-mode = places}
%  \num{0.0055} \\
%  \num{0.0045} \\
%  \sisetup{round-minimum = 0.01}%
%  \num{0.0055} \\
%  \num{0.0045}
%\end{LaTeXdemo}
%
%\DescribeOption{add-decimal-zero}
%\DescribeOption{add-integer-zero}
% It is possible to give real (floating point) numbers as input omitting
% the decimal or the integer parts of the number (for example \num{.123} 
% or \num{123.}). The options \opt{add-decimal-zero} and 
% \opt{add-integer-zero} allow the package to \enquote{fill in} the
% missing zero.
%\begin{LaTeXdemo}
%  \num{123.} \\
%  \num{456}  \\
%  \num{.789} \\
%  \sisetup{
%    add-decimal-zero = false,
%    add-integer-zero = false,
%  }%
%  \num{123.} \\
%  \num{456}  \\
%  \num{.789} 
%\end{LaTeXdemo}
%
%\DescribeOption{explicit-sign}
%\DescribeOption{retain-explicit-plus}
% The inclusion of a leading plus sign is usually unnecessary for
% positive numbers, and so the \opt{retain-explicit-plus} option is
% available to control whether these are printed. At the same time, it
% may be useful to force all numbers to have a sign. This behaviour
% is controlled by the \opt{explicit-sign} option: this is used if
% given and if no sign was present in the input.
%\begin{LaTeXdemo}
%  \num{+345} \\
%  \num[retain-explicit-plus]{+345} \\
%  \num[explicit-sign = -]{345}     \\
%  \num[explicit-sign = -]{+345} 
%\end{LaTeXdemo}
%
%\DescribeOption{retain-unity-mantissa}
%\DescribeOption{retain-zero-exponent}
% The retention of a zero exponent is controlled by the 
% \opt{retain-zero-exponent} option. The retention of a mantissa of one
% is likewise controlled by the \opt{retain-unity-mantissa} option.
%\begin{LaTeXdemo}
%  \num{1e4} \\
%  \num[retain-unity-mantissa = false]{1e4} \\
%  \num{444e0} \\
%  \num[retain-zero-exponent = true]{444e0} 
%\end{LaTeXdemo}
%
%\DescribeOption{scientific-notation}
%\DescribeOption{fixed-exponent}
% Numbers can be converted to scientific notation by the package. This
% is controlled by the \opt{scientific-notation} option, which takes
% choices \opt{false}, \opt{true} and \opt{fixed}. In the later case,
% the exponent value used will be set by the \opt{fixed-exponent}
% option.
%\begin{LaTeXdemo}
%  \num{0.001}   \\
%  \num{0.00100} \\
%  \num{1200}    \\
%  \sisetup{scientific-notation = true}%
%  \num{0.001}   \\
%  \num{0.00100} \\
%  \num{1200}    \\
%  \sisetup{
%    fixed-exponent      = 2,
%    scientific-notation = fixed,
%  }%
%  \num{0.001}   \\
%  \num{0.00100} \\
%  \num{1200}
%\end{LaTeXdemo}
%
%\subsection{Printing numbers}
%
% Actually printing numbers is controlled by a number of settings,
% which apply ideas such as differing decimal markers, digit
% grouping and so on.  All of these options are concerned with the
% appearance of output, rather than the data it conveys. The options are
% summarised in \cref{tab:opt:num:out}.
% 
%\begin{table}
%  \centering
%  \caption{Output options for numbers.}
%  \label{tab:opt:num:out}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule 
%      bracket-numbers          & Switch  & true              \\ ^^A (
%      close-bracket            & Literal & )                 \\ 
%      complex-root-position    & Choice  & after-number      \\
%      copy-complex-root        & Choice  & false             \\
%      copy-decimal-marker      & Choice  & false             \\
%      exponent-base            & Literal & 10                \\
%      exponent-product         & Math    & \cs{times}        \\
%      group-decimal-digits     & Switch  & true              \\
%      group-digits             & Switch  & true              \\
%      group-four-digits        & Switch  & false             \\
%      group-integer-digits     & Switch  & true              \\
%      group-separator          & Math    & \cs{,}            \\
%      negative-color           & Literal & \meta{none}       \\
%      open-bracket             & Literal & (                 
%        \\ ^^A ) (
%      output-close-uncertainty & Literal & )                 \\ 
%      output-complex-root      & Math    & \verb=\mathrm{i}= \\
%      output-decimal-marker    & Math    & .                 \\
%      output-open-uncertainty  & Literal & (                 \\ ^^A )
%      separate-uncertainty     & Switch  & false             \\
%      tight-spacing            & Switch  & false             \\
%      uncertainty-separator    & Math    & \meta{none}       \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{group-digits}
%\DescribeOption{group-decimal-digits}
%\DescribeOption{group-integer-digits}
%\DescribeOption{group-four-digits}
%\DescribeOption{group-separator}
% Grouping digits into blocks of three is a common method to increase
% the ease of reading of numbers.  The \opt{group-digits} choice
% turns this behaviour on and off, with grouping for numbers of exactly
% four digits controlled by the \opt{group-four-digits} choice. Note
% that the later only applies if \opt{group-digits} is turned on.
% The separator used between groups of digits is stored by the 
% \opt{group-separator} option.  This takes literal input and is
% used in math mode: for a text-mode full space use "\text{~}".
%\begin{LaTeXdemo}
%  \num{12345} \\
%  \num[group-digits = false]{12345} \\
%  \num{1234} \\
%  \num[group-four-digits = true]{1234} \\
%  \num{12345} \\
%  \num[group-separator = {,}]{12345} \\
%  \num[group-separator = \text{~}]{12345} 
%\end{LaTeXdemo} 
% Grouping can be activated separately for the integer and decimal
% parts of a number using the \opt{group-integer-digits} and 
% \opt{group-decimal-digits} options.
%\begin{LaTeXdemo}
%  \sisetup{group-digits = false}%
%  \num{12345.67890} \\
%  \num[group-decimal-digits]{12345.67890} \\
%  \num[group-integer-digits]{12345.67890} 
%\end{LaTeXdemo}
%
%\DescribeOption{output-complex-root}
%\DescribeOption{output-decimal-marker}
%\DescribeOption{copy-complex-root}
%\DescribeOption{copy-decimal-marker}
% The decimal marker used in output is set using the 
% \opt{output-decimal-marker} option. This can differ from the input 
% marker, as can the root of $\sqrt{-1}$, which is stored in the 
% \opt{output-complex-root} option. The later is always in math mode, 
% but the standard setting uses \cs{mathrm} to give an upright 
% \enquote{i}: this can easily be altered. The complex root or decimal
% marker from the input can be used in the output by setting the
% \opt{copy-complex-root} and \opt{copy-decimal-marker} options,
% respectively.
%\begin{LaTeXdemo}
%  \num{1.23} \\
%  \num[output-decimal-marker = {,}]{1.23} \\
%  \num{1+2i} \\
%  \num[output-complex-root = \text{\ensuremath{i}}]{1+2i} \\
%  \num[output-complex-root = j]{1+2i} \\
%  \num[copy-complex-root]{1+2j} \\
%  \num[copy-decimal-marker]{555,555}
%\end{LaTeXdemo}
%
%\DescribeOption{complex-root-position}
% The position of the complex root can be adjusted to place it
% either before or after the associated numeral in a complex number
% using the \opt{complex-root-position} option.
%\begin{LaTeXdemo}
%  \num{67-0.9i} \\
%  \num[complex-root-position = before-number]{67-0.9i} \\
%  \num[complex-root-position = after-number]{67-0.9i}
%\end{LaTeXdemo}
% 
%\DescribeOption{exponent-base}
%\DescribeOption{exponent-product}
% When exponents are present in the input, the 
% \opt{exponent-base} and \opt{exponent-product} options set the obvious
% parts of the output.  Notice that the base is in the current mode, but
% the product sign is always in math mode.
%\begin{LaTeXdemo}
%  \num[exponent-product = \times]{1e2} \\
%  \num[exponent-product = \cdot]{1e2} \\
%  \num[exponent-base = 2]{1e2}
%\end{LaTeXdemo}
%
%\DescribeOption{separate-uncertainty}
%\DescribeOption{uncertainty-separator}
%\DescribeOption{output-open-uncertainty}
%\DescribeOption{output-close-uncertainty}
% When input is given including an uncertainty in a number, it can be 
% printed either with the uncertainty in brackets or as a separate 
% number. This behaviour is controlled by the 
% \opt{separate-uncertainty} choice. If the uncertainty is given in 
% brackets, a space may be added between the main number and the 
% uncertainty: this is stored using the \opt{uncertainty-separator}
% option. The opening and closing brackets used are stored in 
% \opt{output-open-uncertainty} and
% \opt{output-close-uncertainty}, respectively.
%\begin{LaTeXdemo}
%  \num{1.234(5)} \\
%  \num[separate-uncertainty = true]{1.234(5)} \\
%  \sisetup{
%    output-open-uncertainty  = [,
%    output-close-uncertainty = ],
%    uncertainty-separator    = {\,}
%  }
%  \num{1.234(5)}
%\end{LaTeXdemo}
% Notice that \pkg{siunitx} correctly interprets uncertainties which
% cross the decimal marker position whether these are separated out
% or not.
%\begin{LaTeXdemo} 
%  \num{8.2(13)} \\
%  \num[separate-uncertainty]{8.2(13)}
%\end{LaTeXdemo}
%
%\DescribeOption{bracket-numbers}
%\DescribeOption{open-bracket}
%\DescribeOption{close-bracket}
% There are certain combinations of numerical input which can be
% ambiguous. This can be corrected by adding brackets in the appropriate
% place, and is controlled by the \opt{bracket-numbers} switch.  The 
% opening and closing brackets used are stored in \opt{open-bracket} and
% \opt{close-bracket}, respectively. Note that \opt{bracket-numbers}
% only applies to numbers without units: for numbers with units
% see the \opt{multi-part-units} option.
%\begin{LaTeXdemo}
%  \num{1+2i e10} \\
%  \num[bracket-numbers = false]{1+2i e10} \\
%  \sisetup{
%    open-bracket  = \{,
%    close-bracket = \},
%  }
%  \num{1+2i e10}
%\end{LaTeXdemo}
%
%\DescribeOption{negative-color}
% \pkg{siunitx} can detect negative mantissa values and alter print
% colour accordingly. This is disabled by setting the option to an empty
% value.
%\begin{LaTeXdemo}
%  \num{-15673} \\
%  \num[negative-color = red]{-15673}
%\end{LaTeXdemo}
%
%\DescribeOption{tight-spacing}
% Under some circumstances is may be desirable to \enquote{squeeze}
% the output spacing.  This is turned on using the \opt{tight-spacing}
% switch, which compresses spacing where possible.
%\begin{LaTeXdemo}
%  \num{1 \pm 2i e3} \\
%  \num[tight-spacing = true]{1 \pm 2i e3} 
%\end{LaTeXdemo}
%
% Lists and ranges of numbers have a small number of specialised
% options, which apply on to these more unusual input forms 
% (\cref{tab:opt:num:list}).
%
%\begin{table}
%  \centering
%  \caption{Output options for lists and ranges of numbers.}
%  \label{tab:opt:num:list}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule 
%      list-final-separator & Literal & \verb*= and =  \\
%      list-separator       & Literal & \verb*=, =     \\
%      range-phrase         & Literal & \verb*= to =   \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{list-final-separator}
%\DescribeOption{list-separator}
% Lists of numbers are printed with a separator between each item,
% which is stored using the \opt{list-separator} option. The
% separator before the last item of a list may be different, and
% is therefore set using the \opt{list-final-separator} option. Any
% spaces needed should be included in the option settings: none are
% added within the code. These two items are printed in text mode.
%\begin{LaTeXdemo}
%  \numlist{0.1;0.2;0.3}                              \\
%  \numlist[list-separator = {; }]{0.1;0.2;0.3}       \\
%  \numlist[list-final-separator = {, }]{0.1;0.2;0.3} \\
%  \numlist[
%    list-separator       = { and },
%    list-final-separator = { and finally }
%  ]{0.1;0.2;0.3}
%\end{LaTeXdemo}
%
%\DescribeOption{range-phrase}
% Ranges of numbers can be given as input. These will have an 
% appropriate word or symbol inserted between the two entries: this
% is stored using the \opt{range-phrase} option. The phrase should 
% include any necessary spaces: no extra space is added.
%\begin{LaTeXdemo}
%  \numrange{5}{100} \\
%  \numrange[range-phrase = --]{5}{100}
%\end{LaTeXdemo}
%
%\subsection{Multi-part numbers}
%
% \pkg{siunitx} recognises the idea of products and quotients in 
% numbers, both with and without units. These multi-part numbers have
% a number of options affecting how they are processed. The options are
% summarised in \cref{tab:opt:num:multi}.
% 
%\begin{table}
%  \centering
%  \caption{Multi-part number options.}
%  \label{tab:opt:num:multi}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule ^^A (
%      fraction-function  & Macro   & \cs{frac}  \\
%      input-product      & Literal & x          \\
%      input-quotient     & Literal & /          \\
%      output-product     & Math    & \cs{times} \\
%      output-quotient    & Math    & /          \\
%      quotient-mode      & Choice  & symbol     \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{input-product}
%\DescribeOption{input-quotient}
% The options \opt{input-product} and \opt{input-quotient} contain the
% tokens used to determine if a number contains multiple parts.
%\begin{LaTeXdemo}
%  \num{1 x 2 x 3} \\
%  \num{1e4 x 2(3) x 3/4} \\
%  \num[input-product=*]{4 * 5 * 6} \\
%  \num{ 1 / 2e4 } \\
%  \num{ 1e2 / 3e4 }
%\end{LaTeXdemo}
%\DescribeOption{output-product}
%\DescribeOption{output-quotient}
% The symbols used for printing products and quotients are stored using
% the options \opt{output-product} and \opt{output-quotient}.
%\begin{LaTeXdemo}
%  \num[output-product = \cdot]{4.87 x 5.321 x 6.90545} \\
%  \num[output-quotient = \text{ div }]{1 / 2}
%\end{LaTeXdemo}
%
%\DescribeOption{quotient-mode}
% For quotients, there is the possibility to print output either using
% a slash, or using the \cs{frac} macro. This is controlled by the 
% \opt{quotient} choice option, which takes values \opt{symbol} and
% \opt{fraction}.
%\begin{LaTeXdemo}
%  \num{1 / 2e4} \\
%  \num[quotient-mode = fraction]{1 / 2e4}
%\end{LaTeXdemo}
%
%\DescribeOption{fraction-function}
% The function used when \opt{quotient-mode = fraction} is set is 
% determined by the \opt{fraction-function} option. This should
% be set to a function which takes two arguments, and presumably
% creates some type of fraction. Most alternatives to the standard
% \cs{frac} function will involve loading additional packages: the
% demonstrations here need \pkg{amsmath} and 
% \pkg{xfrac}.\footnote{If \pkg{xfrac} is not available when typesetting
% this document, the demonstration of \cs{sfrac} will have the wrong
% appearance.}
%\begin{LaTeXdemo}
%  \sisetup{quotient-mode = fraction}
%  \num{1 / 1}
%  \num[fraction-function = \dfrac]{1 / 2} 
%  \num[fraction-function = \sfrac]{1 / 3} 
%  \num[fraction-function = \tfrac]{1 / 4} 
%\end{LaTeXdemo}
%
%\subsection{Angles}
%
% Angle processing provided by the \cs{ang} function has a set of options 
% which apply in addition to the general ones set up for number processing
% (\cref{tab:opt:ang}).
%
%\begin{table}
%  \centering
%  \caption{Angle options.}
%  \label{tab:opt:ang}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule
%      add-arc-degree-zero       & Switch & false        \\
%      add-arc-minute-zero       & Switch & false        \\ 
%      add-arc-second-zero       & Switch & false        \\ 
%      angle-symbol-over-decimal & Switch & false        \\
%      arc-separator             & Math   & false        \\
%      number-angle-separator    & Math   & \meta{empty} \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{number-angle-separator}
% The separator between the number and angle symbol (degrees, minutes
% or seconds) can be set using the \opt{number-angle-separator}
% option, independent of the related \opt{number-unit-separator}
% option used by the \cs{SI} function.
%\begin{LaTeXdemo}
%  \ang{2.67} \\
%  \ang[number-angle-separator = \,]{2.67}
%\end{LaTeXdemo}
%
%\DescribeOption{arc-separator}
% When angles are printed in arc format, the separation of the different
% parts is set up using the \opt{arc-separator} option.
%\begin{LaTeXdemo}
%  \ang{6;7;6.5} \\
%  \ang[arc-separator = \,]{6;7;6.5}
%\end{LaTeXdemo}
%
%\DescribeOption{add-arc-degree-zero}
%\DescribeOption{add-arc-minute-zero}
%\DescribeOption{add-arc-second-zero}
% Zero-filling for the degree, minute or second parts of an arc is
% controlled using the \opt{add-arc-degree-zero}, 
% \opt{add-arc-minute-zero} and \opt{add-arc-second-zero} options.
% All are off as standard.
%\begin{LaTeXdemo}
%  \ang{-1;;} \\
%  \ang{;-2;} \\
%  \ang{;;-3} \\
%  \sisetup{add-arc-degree-zero}
%  \ang{-1;;} \\
%  \ang{;-2;} \\
%  \ang{;;-3} \\
%  \sisetup{add-arc-minute-zero}
%  \ang{-1;;} \\
%  \ang{;-2;} \\
%  \ang{;;-3} \\
%  \sisetup{add-arc-second-zero}
%  \ang{-1;;} \\
%  \ang{;-2;} \\
%  \ang{;;-3}
%\end{LaTeXdemo}
%
%\DescribeOption{angle-symbol-over-decimal}
% In some subject areas, most notably astronomy, the angle symbols
% are given over the decimal marker, rather than at the end of the
% number. This behaviour is available using the 
% \opt{angle-symbol-over-decimal} option.
%\begin{LaTeXdemo}
%  \ang{45.697}  \\
%  \ang{6;7;6.5} \\
%  \ang[angle-symbol-over-decimal]{45.697} \\
%  \ang[angle-symbol-over-decimal]{6;7;6.5}
%\end{LaTeXdemo}
%
%\subsection{Creating units}
%\label{sec:units:creating}
%
% The various macro units are created at the start of the document. 
% \pkg{siunitx} can define these such that they are only available for 
% use within the \cs{si} and \cs{SI} functions, or can make the unit
% macros available throughout the document body. There are a number of
% settings which control this creation process 
% (\cref{tab:opt:units:def}). As a result, these options all apply
% in the preamble only.
% 
%\begin{table}
%  \centering
%  \caption{Unit creation options.}
%  \label{tab:opt:units:def}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule ^^A (
%      free-standing-units    & Switch & false \\
%      overwrite-functions    & Switch & false \\
%      space-before-unit      & Switch & false \\
%      unit-optional-argument & Switch & false \\
%      use-xspace             & Switch & false \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{free-standing-units}
%\DescribeOption{overwrite-functions}
% The \opt{free-standing-units} option controls whether the unit macros 
% exist outside of the \cs{si} and \cs{SI} arguments. When this option
% is \opt{true}, \pkg{siunitx} creates the macros for general use.
% The standard method to achieve this does not overwrite any existing
% macros: this behaviour can be altered using the 
% \opt{overwrite-functions} switch.
% 
%\DescribeOption{space-before-unit}
%\DescribeOption{unit-optional-argument}
%\DescribeOption{use-xspace}
% When \enquote{free standing} unit macros are created, their behaviour
% can be adjusted by a number of options. These are mainly intended for
% emulating the input syntax of older packages. The option 
% \opt{unit-optional-argument} gives the same behaviour for the
% inputs
%\begin{LaTeXdemo}[code only]
%  \SI{10}{\metre}
%\end{LaTeXdemo}
% and
%\begin{LaTeXdemo}[code only]
%  \metre[10].
%\end{LaTeXdemo}
% The \opt{space-before-unit} and \opt{use-xspace} options control
% the behaviour at the \enquote{ends} of the unit macros. Activating 
% \opt{space-before-unit} inserts the number--unit space before the
% unit is printed. This is suitable for the input syntax
%\begin{LaTeXdemo}[code only]
%  30\metre
%\end{LaTeXdemo}
% but does mean that the unit macros are incorrectly spaced in running
% text.  On the other hand, the \opt{use-xspace} option attempts to
% correctly space input such as
%\begin{LaTeXdemo}[code only]
%  \metre is the symbol for metres.
%\end{LaTeXdemo}
%
%\subsection{Loading additional units}
%
%\DescribeOption{load-configurations}
% \pkg{siunitx} includes a set of configuration files which are intended
% to make life easier for the user. The files are loaded using the
% \opt{load-configurations} option, which accepts a comma-separated of
% file names.
% 
% The first configuration file provides a number of convenient 
% abbreviations for the SI units (\cref{tab:unit:abbr}). The 
% standard \pkg{siunitx} settings only create these abbreviations within
% the scope of the \cs{si} and \cs{SI} functions, meaning that no 
% clashes should occur (for example with the standard \cs{pm} symbol). 
% 
%\begin{center} 
%  \tablecaption{Abbreviated units \endgraf
%    (\opt{load-configurations=abbreviations}).}
%  \label{tab:unit:abbr}
%  \tablefirsthead{^^A
%    \toprule
%      \multicolumn{1}{l}{Unit}   &
%      \multicolumn{1}{l}{Abbreviation}  &
%      \multicolumn{1}{l}{Symbol} \\
%    \midrule
%  }
%  \tablehead{^^A
%    \multicolumn{3}{l}{\emph{Continued from previous page}} \\
%    \toprule
%      \multicolumn{1}{l}{Unit}   &
%      \multicolumn{1}{l}{Abbreviation}  &
%      \multicolumn{1}{l}{Symbol} \\
%    \midrule
%  }
%  \tabletail{^^A
%    \bottomrule
%    \multicolumn{3}{r}{\emph{Continued on next page}} \\
%  }
%  \tablelasttail{\bottomrule}
%  \begin{xtabular}{lcc}
%      \DescribeNamedUnit{femtogram}{fg} \\
%      \DescribeNamedUnit{picogram}{pg}  \\
%      \DescribeNamedUnit{nanogram}{ng}  \\
%      \DescribeNamedUnit{microgram}{ug} \\
%      \DescribeNamedUnit{milligram}{mg} \\ 
%      \DescribeNamedUnit{gram}{g}       \\ 
%      \DescribeNamedUnit{kilogram}{kg}  \\
%      \DescribeNamedUnit{atomic mass unit}{amu} \\
%      
%      \midrule
%      
%      \DescribeNamedUnit{picometre}{pm}  \\
%      \DescribeNamedUnit{nanometre}{nm}  \\
%      \DescribeNamedUnit{micrometre}{um} \\
%      \DescribeNamedUnit{millimetre}{mm} \\
%      \DescribeNamedUnit{centimetre}{cm} \\
%      \DescribeNamedUnit{decimetre}{dm}  \\
%      \DescribeNamedUnit{metre}{m}       \\
%      \DescribeNamedUnit{kilometre}{km}  \\
%      
%      \midrule
%      
%      \DescribeNamedUnit{attosecond}{as}  \\
%      \DescribeNamedUnit{femtosecond}{fs} \\
%      \DescribeNamedUnit{picosecond}{ps}  \\
%      \DescribeNamedUnit{nanosecond}{ns}  \\
%      \DescribeNamedUnit{microsecond}{us} \\
%      \DescribeNamedUnit{millisecond}{ms} \\
%      \DescribeNamedUnit{second}{s}       \\
%      
%      \midrule
%      
%      \DescribeNamedUnit{femtomole}{fmol} \\
%      \DescribeNamedUnit{picomole}{pmol}  \\
%      \DescribeNamedUnit{nanomole}{nmol}  \\
%      \DescribeNamedUnit{micromole}{umol} \\
%      \DescribeNamedUnit{millimole}{mmol} \\
%      \DescribeNamedUnit{mole}{mol}       \\
%      \DescribeNamedUnit{kilomole}{kmol}  \\
%      
%      \midrule
%      
%      \DescribeNamedUnit{picoampere}{pA}  \\
%      \DescribeNamedUnit{nanoampere}{nA}  \\
%      \DescribeNamedUnit{microampere}{uA} \\
%      \DescribeNamedUnit{milliampere}{mA} \\
%      \DescribeNamedUnit{ampere}{A}       \\
%      \DescribeNamedUnit{kiloampere}{kA}  \\
%      
%      \midrule
%      
%      \DescribeNamedUnit{microlitre}{ul} \\
%      \DescribeNamedUnit{millilitre}{ml} \\
%      \DescribeNamedUnit{litre}{l}       \\
%      \DescribeNamedUnit{microliter}{uL} \\
%      \DescribeNamedUnit{milliliter}{mL} \\
%      \DescribeNamedUnit{liter}{L}       \\
%      
%      \midrule
%      
%      \DescribeNamedUnit{millihertz}{mHz} \\
%      \DescribeNamedUnit{hertz}{Hz}       \\
%      \DescribeNamedUnit{kilohertz}{kHz}  \\
%      \DescribeNamedUnit{megahertz}{MHz}  \\
%      \DescribeNamedUnit{gigahertz}{GHz}  \\
%      \DescribeNamedUnit{terahertz}{THz}  \\
%      
%      \midrule
%  
%      \DescribeNamedUnit{newton}{N}       \\
%      \DescribeNamedUnit{millinewton}{mN} \\
%      \DescribeNamedUnit{kilonewton}{kN}  \\
%      \DescribeNamedUnit{meganewton}{MN}  \\
%      
%      \midrule
%  
%      \DescribeNamedUnit{pascal}{Pa}      \\
%      \DescribeNamedUnit{kilopascal}{kPa} \\
%      \DescribeNamedUnit{megapacal}{MPa}  \\
%      \DescribeNamedUnit{gigapascal}{GPa} \\
%      
%      \midrule
%  
%      \DescribeNamedUnit{milliohm}{mohm} \\
%      \DescribeNamedUnit{kilohm}{kohm}   \\
%      \DescribeNamedUnit{megohm}{Mohm}   \\
%      
%      \midrule
%  
%      \DescribeNamedUnit{millivolt}{mV} \\
%      \DescribeNamedUnit{volt}{V}       \\
%      \DescribeNamedUnit{kilovolt}{kV}  \\
%  
%      \midrule
%      
%      \DescribeNamedUnit{watt}{W}                \\
%      \DescribeNamedUnit{milliwatt}{mW}          \\
%      \DescribeNamedUnit{kilowatt}{kW}           \\
%      \DescribeNamedUnit{megawatt}{MW}           \\
%      \DescribeNamedUnit{gigawatt}{GW}           \\
%      \DescribeNamedUnit{joule}{J}               \\
%      \DescribeNamedUnit{kilojoule}{kJ}          \\
%      \DescribeNamedUnit{electronvolt}{eV}       \\
%      \DescribeNamedUnit{millielectronvolt}{meV} \\
%      \DescribeNamedUnit{kiloelectronvolt}{keV}  \\
%      \DescribeNamedUnit{megaelectronvolt}{MeV}  \\
%      \DescribeNamedUnit{gigaelectronvolt}{GeV}  \\
%      \DescribeNamedUnit{teraelectronvolt}{TeV}  \\
%      \DescribeNamedUnit{kilowatt hour}{kWh}     \\
%      
%      \midrule
%      
%      \DescribeNamedUnit{kelvin}{K} \\
%      
%  \end{xtabular}
%\end{center}  
%
%\DescribeMacro{\bit}
%\DescribeMacro{\byte}
% Binary data is expressed in units of bits and bytes. These are
% normally given prefixes which use powers of two, rather than the
% powers of ten used by the SI prefixes. As these binary prefixes are
% closely related to the SI prefixes, they are defined by \pkg{siunitx}
% (\cref{tab:unit:binary}). The units \cs{bit} and \cs{byte} are
% also available.
%\begin{LaTeXdemo}
%  \SI{100}{\mebi\byte} \\
%  \SI[prefixes-as-symbols=false]{30}{\kibi\bit}
%\end{LaTeXdemo}
%
%\begin{table}
%  \caption{Binary prefixes \protect \\
%  (\opt{load-configurations=binary}).}
%  \label{tab:unit:binary}
%  \centering
%  \begin{tabular}{llc>{$}l<{$}}
%    \toprule
%      Prefix & Macro & Symbol & \multicolumn{1}{l}{Power} \\
%    \midrule
%      \DescribePrefix{kibi} & 10 \\
%      \DescribePrefix{mebi} & 20 \\
%      \DescribePrefix{gibi} & 30 \\
%      \DescribePrefix{tebi} & 40 \\
%      \DescribePrefix{pebi} & 50 \\
%      \DescribePrefix{exbi} & 60 \\
%      \DescribePrefix{zebi} & 70 \\
%      \DescribePrefix{yobi} & 80 \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
% A configuration file is also included which will use settings
% and define macros as defined by version 1 of \pkg{siunitx}: this
% can be accessed with the option \opt{load-configurations = version-1}.
% This is intended to allow easy transition to version 2: users
% should update their source to use the new interfaces and functions. 
%
% Users upgrading from version 1 of \pkg{siunitx} will notice that
% the various \enquote{specialist} units available in version 1 are
% no longer provided as loadable options.\footnote{They are included
% in the loaded configuration file \opt{version-1}, but this is intended
% purely to ease transition to version 2.} These are not included in
% version 2 as the criteria for inclusion of such units are far from
% clear, and it is difficult to justify providing clearly non-SI 
% units in the package. For reference, appropriate definitions for 
% the units which where provided in version 1 are as follows.
%\begin{LaTeXdemo}[code only]
%  % Astronomy
%  \DeclareSIUnit\parse{pc}
%  \DeclareSIUnit\lightyear{ly}
%  
%  % Chemical engineering
%  \DeclareSIUnit\gmol{g\text{-}mol}
%  \DeclareSIUnit\kgmol{kg\text{-}mol}
%  \DeclareSIUnit\lbmol{lb\text{-}mol}
%  
%  % Chemistry
%  \DeclareSIUnit\molar{\mole\per\cubic\deci\metre}
%  \DeclareSIUnit\Molar{\textsc{m}}
%  \DeclareSIUnit\torr{torr}
%  
%  % Geophysics
%  \DeclareSIUnit\gon{gon}
%  
%  % High energy physics
%  \DeclareSIUnit\micron{\micro\metre}
%  \DeclareSIUnit\mrad{\milli\rad}
%  \DeclareSIUnit\gauss{G}
%  \DeclareSIUnit\eVperc{\eV\per\clight}
%  \DeclareSIUnit\nanobarn{\nano\barn}
%  \DeclareSIUnit\picobarn{\pico\barn}
%  \DeclareSIUnit\femtobarn{\femto\barn}
%  \DeclareSIUnit\attobarn{\atto\barn}
%  \DeclareSIUnit\zeptobarn{\zepto\barn}
%  \DeclareSIUnit\yoctobarn{\yocto\barn}
%  \DeclareSIUnit\nb{\nano\barn}
%  \DeclareSIUnit\pb{\pico\barn}
%  \DeclareSIUnit\fb{\femto\barn}
%  \DeclareSIUnit\ab{\atto\barn}
%  \DeclareSIUnit\zb{\zepto\barn}
%  \DeclareSIUnit\yb{\yocto\barn}
%\end{LaTeXdemo} 
% Users can use a local configuration file to make additional units
% available on a local basis, as described in \cref{sec:config:local}.
%
%\subsection{Using units}
%
% Part of the power of \pkg{siunitx} is the ability to alter the output
% format for units without changing the input. The behaviour of units
% is therefore controlled by a number of options which alter either the
% processing of units or the output directly 
% (\cref{tab:opt:units:out}).
% 
%\begin{table}
%  \centering
%  \caption{Unit output options.}
%  \label{tab:opt:units:out}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule ^^A (
%      bracket-unit-denominator & Switch & true       \\
%      forbid-literal-units     & Switch & false      \\
%      inter-unit-separator     & Math   & \cs{,}     \\
%      parse-units              & Switch & true       \\
%      per-mode                 & Choice & reciprocal \\
%      per-symbol               & Math   & /          \\
%      power-font               & Choice & number     \\    
%      prefixes-as-symbols      & Switch & true       \\
%      qualifier-mode           & Choice & subscript  \\
%      sticky-per               & Switch & false      \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{forbid-literal-units}
% Some users may prefer to completely disable the use of literal input
% in units, for example to enforce consistency. This can be
% accomplished by setting the \opt{forbid-literal-units} switch. With 
% this option enabled, only macro-based units can be used in a document.
% 
%\DescribeOption{inter-unit-separator} 
% The separator between each unit is stored using the 
% \opt{inter-unit-separator} option. The standard setting is a thin 
% space: another common choice is a centred dot. To get the correct
% spacing it is necessary to use "{}\cdot{}" in the later case.
%\begin{LaTeXdemo}
%  \si{\farad\squared\lumen\candela} \\
%  \si[inter-unit-separator={}\cdot{}]{\farad\squared\lumen\candela} 
%\end{LaTeXdemo} 
% 
%\DescribeOption{per-mode}
%\DescribeOption{per-symbol}
%\DescribeOption{bracket-unit-denominator}
% The handling of \cs{per} is altered using the \opt{per-mode} choice
% option.  The standard setting is \opt{reciprocal}, meaning that 
% \cs{per} generates reciprocal powers for units.  Setting the option
% to \opt{fraction} uses the \cs{frac} function to typeset the positive
% and negative powers of a unit separately. 
%\begin{LaTeXdemo}
%  \si{\joule\per\mole\per\kelvin} \\
%  \si{\metre\per\second\squared} \\
%  \si[per-mode=fraction]{\joule\per\mole\per\kelvin} \\
%  \si[per-mode=fraction]{\metre\per\second\squared} 
%\end{LaTeXdemo}
% The closely-related \opt{reciprocal-positive-first} setting acts in 
% the same way but places all of the positive powers before any negative
% ones.
%\begin{LaTeXdemo}
%  \si{\ampere\per\mole\second} \\
%  \si[per-mode = reciprocal-positive-first]
%    {\ampere\per\mole\second}
%\end{LaTeXdemo}
% It is possible to use a symbol (usually \texttt{/}) to separate the
% two parts of a unit by setting \opt{per-mode} to \opt{symbol}; the 
% symbol used is stored using the setting \opt{per-symbol}. This method
% for displaying units can be ambiguous, and so brackets are added 
% unless \opt{bracket-unit-denominator} is set to \opt{false}.
% Notice that \opt{bracket-unit-denominator} only applies when
% \opt{per-mode} is set to \opt{symbol} or \opt{symbol-or-fraction}.
% The output for \opt{per-symbol} is always made in math mode, and so
% \cs{text} will be needed to print textual information.
%\begin{LaTeXdemo}
%  \sisetup{per-mode = symbol}%
%  \si{\joule\per\mole\per\kelvin} \\
%  \si{\metre\per\second\squared} \\
%  \si[per-symbol = \text{~div~}]{\joule\per\mole\per\kelvin} \\
%  \si[bracket-unit-denominator = false]{\joule\per\mole\per\kelvin}
%\end{LaTeXdemo}
% The often-requested (but mathematically invalid) 
% \opt{repeated-symbol} option is also available to repeat the symbol 
% for each \cs{per}.
%\begin{LaTeXdemo}
%  \si[per-mode=repeated-symbol]{\joule\per\mole\per\kelvin}
%\end{LaTeXdemo}
% Finally, it is possible for the behaviour of the \cs{per} function
% to depend on the prevailing math style. Setting \opt{per-mode} to
% \opt{symbol-or-fraction} will use the \opt{symbol} setting for
% in line math, and the \opt{fraction} setting when used in
% \cs{displaystyle} math.
%\begin{LaTeXdemo}
%  \sisetup{per-mode = symbol-or-fraction}%
%  \( \si{\joule\per\mole\per\kelvin} \) 
%  \[ \si{\joule\per\mole\per\kelvin} \]
%     \si{\joule\per\mole\per\kelvin} \\
%  \( 
%    \displaystyle 
%    \si{\joule\per\mole\per\kelvin}
%  \)
%  \[ 
%    \textstyle 
%    \si{\joule\per\mole\per\kelvin}
%  \]
%\end{LaTeXdemo}
% 
%\DescribeOption{sticky-per}
% 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
% \enquote{joules per mole per kelvin}.}  By setting the 
% \opt{sticky-per} flag, this behaviour is changed so that \cs{per} 
% applies to all subsequent units.
%\begin{LaTeXdemo}
%  \si{\pascal\per\gray\henry} \\
%  \si[sticky-per]{\pascal\per\gray\henry}
%\end{LaTeXdemo}
%
%\DescribeOption{power-font}
% The font used for the powers in units can be typeset using the
% current number or unit font. This may be of use when the font used
% for numbers and units are very different, for example when the 
% \pkg{euler} package is loaded.
%\begin{LaTeXdemo}
%  \sisetup{unit-mode = text}%
%  \si{\metre\per\second\squared} \\
%  \si[power-font = unit]{\metre\per\second\squared}
%\end{LaTeXdemo}
%
%\DescribeOption{qualifier-mode}
% Unit qualifiers can be printed in three different formats, set by the
% \opt{qualifier-mode} option. The standard setting is \opt{subscript},
% while the options \opt{brackets}, \opt{space} and \opt{text} are also
% possible. With the last settings, powers can lead to ambiguity and are
% automatically detected and brackets added as appropriate.
%\begin{LaTeXdemo}
%  \si{\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
%  \si[qualifier-mode = brackets]
%    {\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
%  \si[qualifier-mode = subscript]
%    {\kilogram\polymer\squared\per\mole\catalyst\per\hour} \\
%  \si[qualifier-mode = space]
%    {\kilogram\polymer\squared\per\mole\catalyst\per\hour}  \\
%  \si[qualifier-mode = text]
%    {\deci\bel\isotropic} 
%\end{LaTeXdemo}
%
%\DescribeOption{prefixes-as-symbols}
% The unit prefixes (\cs{kilo}, \emph{etc}.) are normally given as 
% letters. However, the package can convert these into numerical powers.
% This is controlled by the \opt{prefixes-as-symbols} switch option.
% This correctly deals with the kilogram, which is a base unit even
% though it involves a prefix.
%\begin{LaTeXdemo}
%  \si{\milli\litre\per\mole\deci\ampere} \\
%  \SI{10}{\kilo\gram\squared\deci\second} \\
%  \si[prefixes-as-symbols=false]{\milli\litre\per\mole\deci\ampere} \\
%  \SI[prefixes-as-symbols=false]{10}{\kilo\gram\squared\deci\second}
%\end{LaTeXdemo}
%
%\DescribeOption{parse-units}
% Normally, \pkg{siunitx} is used with the unit parse enabled, and
% only prints units directly if there is literal input. However, if
% the input is known to be essentially consistent and high performance
% is desired, then the parser can be turned off using the
% \opt{parse-units} switch.
%\begin{LaTeXdemo}
%  \SI{300}{\MHz} \\
%  \SI[parse-units = false]{300}{\MHz}
%\end{LaTeXdemo}
%
%\subsection{Numbers with units}
%
% Some options apply to the combination of units and numbers, rather
% than to units or numbers alone (\cref{tab:opt:units:numbers}).
% 
%\begin{table}
%  \centering
%  \caption{Options for numbers with units.}
%  \label{tab:opt:units:numbers}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule ^^A (
%      allow-number-unit-breaks & Switch & false    \\
%      list-units               & Choice & repeat   \\
%      multi-part-units         & Choice & brackets \\
%      number-unit-separator    & Math   & \cs{,}   \\
%      product-units            & Choice & repeat   \\
%      range-units              & Choice & repeat   \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{allow-number-unit-breaks}
% Usually, the combination of a number and unit is regarded as a single
% mathematical entity which should not be split across lines. However,
% there are cases (very long units, narrow columns, \emph{etc}.) where 
% breaks may be needed. This can be turned on using the 
% \opt{allow-number-unit-breaks} option.
%\begin{LaTeXdemo}
%  \begin{minipage}{2.55 cm}
%    % Gives an underfull hbox
%    Some filler text \SI{10}{\metre} \\
%    \sisetup{allow-number-unit-breaks}
%    Some filler text \SI{10}{\metre} 
%  \end{minipage}    
%\end{LaTeXdemo}
%
%\DescribeOption{number-unit-separator}
% The separator between the number and unit is set using the 
% \opt{number-unit-separator} option. This is always printed in math
% mode, and so anything which must be printed as text should be placed
% inside a \cs{text} macro.
%\begin{LaTeXdemo}
%  \SI{2.67}{\farad} \\
%  \SI[number-unit-separator=\text{~}]{2.67}{\farad} \\
%  \SI[number-unit-separator=]{2.67}{\farad} 
%\end{LaTeXdemo}
%
%\DescribeOption{multi-part-units}
% When a number has multiple parts (such as a separate uncertainty) then
% the unit must apply to all parts of the number. How this is shown is
% controlled using the \opt{multi-part-units} options. The standard
% setting is \opt{brackets}, which will place the entire numerical part
% in brackets and use a single unit symbol. Alternative options are
% \opt{repeat} (print the unit for each part of the number) and
% \opt{single} (print only one unit symbol: mathematically incorrect).
%\begin{LaTeXdemo}
%  \sisetup{separate-uncertainty}%
%  \SI{12.3(4)}{\kilo\gram} \\
%  \SI[multi-part-units = brackets]{12.3(4)}{\kilo\gram} \\
%  \SI[multi-part-units = repeat]{12.3(4)}{\kilo\gram}   \\
%  \SI[multi-part-units = single]{12.3(4)}{\kilo\gram}   
%\end{LaTeXdemo}
% It is important to notice that numbers with units are not affected by
% the setting of \opt{bracket-numbers}, which applies to \enquote{pure}
% numbers only. For example:
%\begin{LaTeXdemo}
%  \sisetup{separate-uncertainty,bracket-numbers = false}%
%  \num{1.234(5)e-4} \\
%  \SI{1.234(5)e-4}{\metre}   
%\end{LaTeXdemo}
% The reason is that the requirements to bracket values with units are
% fundamentally different from those for numbers alone. Some combinations
% which are mathematically valid in the absence of a unit become invalid
% when a unit is present.
%
%\DescribeOption{product-units}
% When a product of quantities is given, the resulting units can be 
% displayed in a number of ways, set using the \opt{product-units}
% option. The standard setting is \opt{repeat}, which prints one
% unit symbol for each numbers. Alternatives are \opt{brackets},
% \opt{brackets-power}, \opt{power}, \opt{repeat} and \opt{single}.
% This option does not affect the application of brackets for each
% number within the product list: it only sets those around the
% entire list.
%\begin{LaTeXdemo}
%  \SI{2 x 3 x 4}{\metre} \\ 
%  \SI[product-units = brackets]{2 x 3 x 4}{\metre}       \\
%  \SI[product-units = brackets-power]{2 x 3 x 4}{\metre} \\
%  \SI[product-units = power]{2 x 3 x 4}{\metre}          \\
%  \SI[product-units = repeat]{2 x 3 x 4}{\metre}         \\
%  \SI[product-units = single]{2 x 3 x 4}{\metre}         
%\end{LaTeXdemo}
%
%\DescribeOption{list-units}
%\DescribeOption{range-units}
% The \opt{list-units} and \opt{range-units} options determines how 
% the \cs{SIlist} and\cs{SIrange} function displays units, respectively.
% The standard setting for both is \opt{repeat}, where each number will
% be printed with a unit. Alternatives are \opt{brackets} and 
% \opt{single}. Any brackets needed on individual numbers within a 
% product are controlled by the \opt{brackets-numbers} option
% (\emph{i.e}.~they are treated as pure numbers).
% These options do not affect the application of brackets for each
% number within the list or range: they only sets those around the
% entire group.
%\begin{LaTeXdemo}
%  \SIlist{2;4;6;8}{\tesla} \\ 
%  \SIlist[list-units = brackets]{2;4;6;8}{\tesla} \\
%  \SIlist[list-units = repeat]{2;4;6;8}{\tesla} \\
%  \SIlist[list-units = single]{2;4;6;8}{\tesla} \\
%  \SIrange{2}{4}{\degreeCelsius} \\ 
%  \SIrange[range-units = brackets]{2}{4}{\degreeCelsius} \\
%  \SIrange[range-units = repeat]{2}{4}{\degreeCelsius} \\
%  \SIrange[range-units = single]{2}{4}{\degreeCelsius}
%\end{LaTeXdemo}
%
%\subsection{Tabular material}
%
% Processing of material in tables obeys the same settings as described
% for the functions already described. However, there are some settings
% which apply only to the layout of tabular material 
% (\cref{tab:opt:tables}).
% 
%\begin{table}
%  \centering
%  \caption{Options for tabular material.}
%  \label{tab:opt:tables}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule ^^A (
%      table-align-exponent      & Switch  & true      \\
%      table-align-text-post     & Switch  & true      \\
%      table-align-uncertainty   & Switch  & true      \\
%      table-alignment           & Choice  & \m{none}  \\
%      table-auto-round          & Switch  & false     \\
%      table-comparator          & Switch  & false     \\
%      table-figures-decimal     & Integer & 2         \\
%      table-figures-exponent    & Integer & 0         \\
%      table-figures-integer     & Integer & 3         \\
%      table-figures-uncertainty & Integer & 0         \\
%      table-format              & Special & \m{none}  \\
%      table-number-alignment    & Choice  & 
%        center-decimal-marker \\
%      table-parse-only          & Switch  & false     \\
%      table-omit-exponent       & Switch  & true      \\
%      table-space-text-pre      & Literal & \m{empty} \\
%      table-space-text-post     & Literal & \m{empty} \\
%      table-sign-exponent       & Switch  & false     \\
%      table-sign-mantissa       & Switch  & false     \\
%      table-text-alignment      & Choice  & center    \\
%      table-unit-alignment      & Choice  & center    \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeOption{table-parse-only}
% The main use of the \texttt{S} column is to control the alignment of
% the resulting output. However, it is possible to turn off alignment
% entirely and only use the number parser of \pkg{siunitx}. This is
% achieved using the \opt{table-parse-only} switch, as illustrated
% in \cref{tab:S:parse}.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{Parsing without aligning in an \texttt{S} column.}
%    \label{tab:S:parse}
%    \begin{tabular}
%      {
%        S
%        S[table-parse-only]
%      }      
%      \toprule
%        {Decimal-centred} &
%        {Simple centring} \\
%      \midrule
%        12.345   & 12.345   \\
%        6,78     & 6,78     \\
%        -88.8(9) & -88.8(9) \\
%        4.5e3    & 4.5e3    \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-number-alignment}
% The alignment of numbers with the boundaries of the \texttt{S}
% column is controlled using the \opt{table-number-alignment} option,
% which takes the values \opt{center-decimal-marker}, \opt{center},
% \opt{left} and \opt{right}. The \opt{center-decimal-marker} places the
% decimal marker for the number at the centre of the column. This does
% not need any information in advance, and so is the standard setting.
% It works best for approximately symmetrical input (equal numbers of
% digits before and after the decimal). On the other hand, the
% \opt{center}, \opt{left} and \opt{right} options require space to be
% reserved for the numbers, and then use this fixed space to align with
% the edges of the column. The different alignment choices are 
% illustrated in \cref{tab:S:align}, which uses somewhat 
% exaggerated column headings to show the relative position of the 
% cell contents.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Aligning the \texttt{S} column.}
%    \label{tab:S:align}
%    \centering
%    \sisetup{
%      table-figures-integer = 2,
%      table-figures-decimal = 4
%    }
%    \begin{tabular}{
%      S
%      S[table-number-alignment = center]
%      S[table-number-alignment = left]
%      S[table-number-alignment = right]
%    }
%    \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{LaTeXdemo}
% Many of the other table options do not apply when 
% \opt{table-number-alignment = center-decimal-marker} is set, as this 
% mode always centres the marker at the expense of any other 
% choices.
%
%\DescribeOption{table-figures-decimal}
%\DescribeOption{table-figures-exponent}
%\DescribeOption{table-figures-integer}
%\DescribeOption{table-figures-uncertainty}
% The space reserved by \pkg{siunitx} for a number is controlled by
% two families of options. The first family cover the number of digits
% allowed for in different parts of the number, for example
% \opt{table-figures-integer} controls the space for integer digits in
% the mantissa. If the number of figures is set to \num{0}, then no
% space is reserved and some output will either be out of position
% or not printed at all (although a warning will result). Reserving
% space for a given part of number will automatically include space
% for any associated items (for example the \enquote{\( \times \)} 
% symbol for exponents).
%\DescribeOption{table-sign-exponent}
%\DescribeOption{table-sign-mantissa}
% The second family of options are switches which govern whether
% space is reserved for a sign: \opt{table-sign-exponent} and
% \opt{table-sign-mantissa}. The effect of altering some of these
% settings is shown in \cref{tab:S:space}.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Reserving space in \texttt{S} columns.}
%    \label{tab:S:space}
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 2
%    }
%    \centering
%    \begin{tabular}{
%      S
%      S[table-number-alignment = right]
%      S[table-figures-uncertainty = 1]
%      S[
%        separate-uncertainty,
%        table-figures-uncertainty = 1
%      ]
%      S[table-sign-mantissa]
%      S[table-figures-exponent = 1]
%      }
%    \toprule
%        {Values}
%      & {Values}
%      & {Values}
%      & {Values}
%      & {Values}
%      & {Values} \\
%    \midrule
%       2.3  &  2.3  &  2.3(5)  &  2.3(5)  &   2.3  &  2.3e8  \\
%      34.23 & 34.23 & 34.23(4) & 34.23(4) &  34.23 & 34.23   \\
%      56.78 & 56.78 & 56.78(3) & 56.78(3) & -56.78 & 56.78e3 \\
%       3,76 &  3,76 &  3,76(2) &  3.76(2) & +-3.76 &      e6 \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%\DescribeOption{table-comparator}
% Space can also be reserved in a table for a comparator (greater than,
% less than, and so forth). This is activated using the 
% \opt{table-comparator} switch (\cref{tab:S:comparators}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Reserving space for comparators in \texttt{S} columns.}
%    \label{tab:S:comparators}
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 2,
%      table-figures-decimal  = 2,
%      table-figures-exponent = 2,
%    }
%    \centering
%    \begin{tabular}{
%      S
%      S[table-comparator = true]
%      }
%    \toprule
%        {Values}
%      & {Values} \\
%    \midrule
%       2.3  & <   2.3e8  \\
%      34.23 & =  34.23   \\
%      56.78 & >= 56.78e3 \\
%       3,76 & \gg     e6 \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
% The table-printing code will omit any part of a number which has no
% space reserved, placing a warning in the \LaTeX\ log. This means that
% uncertainties and exponents will not be printed if no space is reserved 
% for them.
%
%\DescribeOption{table-format}
% As a short cut for the preceding options, \pkg{siunitx} also 
% provides the \opt{table-format} option. This can be used to give the
% same information about the space to reserve for a number in a 
% \enquote{compressed} manner. The input to \opt{table-format} should
% consist of a number showing how many figures to reserve in each part
% of the input. Thus
%\begin{LaTeXdemo}[code only]
%  \sisetup{
%    table-format = 3.2
%  }  
%\end{LaTeXdemo} 
% is equivalent to 
%\begin{LaTeXdemo}[code only]
%  \sisetup{
%    table-figures-integer = 3,
%    table-figures-decimal = 2
%  }  
%\end{LaTeXdemo} 
% The \opt{table-format} option will also correctly interpret the 
% presence of a sign, so that
%\begin{LaTeXdemo}[code only]
%  \sisetup{
%    table-format = +3.2e+4
%  }  
%\end{LaTeXdemo} 
% will have the same effect as
%\begin{LaTeXdemo}[code only]
%  \sisetup{
%    table-figures-integer  = 3,
%    table-figures-decimal  = 2,
%    table-figures-exponent = 4,
%    table-sign-mantissa,
%    table-sign-exponent
%  }  
%\end{LaTeXdemo} 
% It is important to note that any parts of a number \emph{not} 
% specified in the table format argument are set to be absent (the
% number of figures is set to zero). Setting the \opt{table-format}
% option also resets \opt{table-number-alignment} to \opt{center}
% (\cref{tab:S:format}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Using the \opt{table-format} option.}
%    \label{tab:S:format}
%    \centering
%    \begin{tabular}{
%      S
%      S[table-format =  2.2]
%      S[table-format =  2.2(1)]
%      S[table-format = +2.2]
%      S[table-format =  2.2e1]
%      }
%    \toprule
%        {Values}
%      & {Values}
%      & {Values}
%      & {Values}
%      & {Values} \\
%    \midrule
%       2.3  &  2.3  &  2.3(5)  &   2.3  &  2.3e8  \\
%      34.23 & 34.23 & 34.23(4) &  34.23 & 34.23   \\
%      56.78 & 56.78 & 56.78(3) & -56.78 & 56.78e3 \\
%       3,76 &  3,76 &  3.76(2) & +-3.76 &      e6 \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-space-text-pre}
%\DescribeOption{table-space-text-post}
% Space for material before and after the \texttt{S} column can
% be reserved by giving model text for the options
% \opt{table-space-text-pre} and \opt{\ldots -post}.
% This is then used to provide the necessary gap while maintaining 
% alignment (\cref{tab:S:ends}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Text before and after numbers.}
%    \label{tab:S:ends}
%    \centering
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 2,
%      table-figures-decimal  = 4,
%      table-space-text-pre   = now~,
%      table-space-text-post  = 
%        \textsuperscript{\emph{a}}
%    }
%    \begin{tabular}{S}
%    \toprule
%    {Values} \\
%    \midrule
%            2.3456  \\
%           34.2345  \textsuperscript{\emph{a}}\\
%           56.7835  \\
%      now~ 90.473   \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-align-exponent}
%\DescribeOption{table-align-uncertainty}
% When printing exponents in tables, there is a choice of aligning 
% the exponent parts or having these close up to the mantissa. This
% is controlled by the \opt{table-align-exponent} option 
% (\cref{tab:align:exp}). Similarly, uncertainty parts which are printed
% separately from the mantissa can be aligned or closed up. This is
% set by the \opt{table-align-uncertainty} option 
% (\cref{tab:align:uncert}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{The \opt{table-align-exponent} option}
%    \label{tab:align:exp}
%    \sisetup{table-format = 1.3e2, table-number-alignment = center}
%    \begin{tabular}{SS[table-align-exponent = false]}
%      \toprule
%        {Header} & {Header} \\
%      \midrule
%        1.2e3    & 1.2e3    \\
%        1.234e56 & 1.234e56 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{The \opt{table-align-uncertainty} option}
%    \label{tab:align:uncert}
%    \sisetup{
%      separate-uncertainty,
%      table-format = 1.3(1), 
%    }
%    \begin{tabular}{SS[table-align-uncertainty = false]}
%      \toprule
%        {Header} & {Header} \\
%      \midrule
%        1.2(1)   & 1.2(3)    \\
%        1.234(5) & 1.234(5) \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-omit-exponent}
% In cases where data cover a range of values, printing using a fixed
% exponent in a table may make presentation clearer. In these cases,
% omitting the exponent value from the table is useful. The package
% offers the \opt{table-omit-exponent} option to do this
% (\cref{tab:exp:omit}); this automatically sets 
% \opt{scientific-notation = fixed} for the table column.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{The \opt{table-omit-exponent} option}
%    \label{tab:exp:omit}
%    \begin{tabular}{
%      S[table-format = 1.1e1]
%      S[
%        fixed-exponent      = 3,
%        table-format        = 2.1,
%        table-omit-exponent
%      ]
%    }
%      \toprule
%        {Header} & {Header / \num{e3}} \\
%      \midrule
%        1.2e3 & 1.2e3 \\
%         3e2  &   3e2 \\
%       1.0e4  & 1.0e4 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-align-text-post}
% Note markers are often given in tables after the numerical content. It
% may be desirable for these to close up to the numbers. Whether this 
% takes place is controlled by the \opt{table-align-text-post} 
% option (\cref{tab:S:notes}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Closing notes up to text.}
%    \label{tab:S:notes}
%    \newcommand\NoteMark[1]{%
%      \textsuperscript{\emph{#1}}%
%    }
%    \centering
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 2,
%      table-figures-decimal  = 4,
%    }
%    \begin{tabular}{
%      S
%      S[table-align-text-post = false]
%    }
%    \toprule
%      {Values}             & {Values} \\
%    \midrule
%       2.3456              & 2.3456 \\
%      34.234  \NoteMark{a} & 34.234 \NoteMark{a} \\
%      56.78   \NoteMark{b} & 56.78  \NoteMark{b} \\
%      90.4    \NoteMark{c} & 90.4   \NoteMark{c} \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-auto-round}
% The contents of table cells can automatically be rounded or
% zero-filled to the number of decimal digits given for the 
% \opt{table-figures-decimal} option. This mode is activated using
% the \opt{table-auto-round} switch, as illustrated in 
% \cref{tab:S:auto}.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{The \opt{table-auto-round} option.}
%    \label{tab:S:auto}
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 1,
%      table-figures-decimal  = 3
%    }
%    % Notice the overfull hbox which results with
%    % the first column
%    \begin{tabular}{
%      S
%      S[table-auto-round]
%    }
%      \toprule
%        {Header} & {Header} \\
%      \midrule
%        1.2    & 1.2    \\
%        1.2345 & 1.2345 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{parse-numbers}
% When the \opt{parse-numbers} option is set to \opt{false}, then
% the alignment code for tables takes a different approach. The
% output is always set in math mode, and alignment takes place
% at the first decimal marker. This is achieved by making it 
% active in math mode. When reserving space for content only
% the integer and decimal values for the mantissa are considered
% (\cref{tab:S:nonparsed}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Aligning without parsing.}
%    \label{tab:S:nonparsed}
%    \sisetup{
%      parse-numbers = false,
%      table-figures-integer = 2,
%      table-figures-decimal = 3
%    }
%    \centering
%    \begin{tabular}{
%      S
%      S[table-number-alignment = center]
%      S[table-number-alignment = right]
%      S[table-number-alignment = left]
%      }
%    \toprule
%        \multicolumn{1}{c}{Some values}
%      & \multicolumn{1}{c}{Some values}
%      & \multicolumn{1}{c}{Some values}
%      & \multicolumn{1}{c}{Some values} \\
%    \midrule
%       2.35  &    2.35  &    2.35  &   2.35   \\
%      34.234 &   34.234 &   34.234 &  34.234  \\
%      56.783 &   56.783 &   56.783 &  56.783  \\
%       3,762 &    3,762 &    3,762 &   3.762  \\
%    \sqrt{2} & \sqrt{2} & \sqrt{2} & \sqrt{2} \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-text-alignment}
% Cell contents which are not part of a number can be protected
% using braces, as illustrated. Cells which contain no numerical data
% at all are aligned using the setting specified by the 
% \opt{table-text-alignment} option, which recognises the values
% \opt{center}, \opt{left} and \opt{right} (\cref{tab:S:text}).
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Aligning text in \texttt{S} columns.}
%    \label{tab:S:text}
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 4,
%      table-figures-decimal  = 4
%    }
%    \centering
%    \begin{tabular}{
%      S
%      S[table-text-alignment = left]
%      S[table-text-alignment = right]
%      }
%    \toprule
%        {Values}
%      & {Values}
%      & {Values} \\
%    \midrule
%      992.435  &  992.435  &  992.435  \\
%     7734.2344 & 7734.2344 & 7734.2344 \\
%       56.7834 &   56.7834 &   56.7834 \\
%        3,7462 &    3,7462 &    3,7462 \\
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
% 
%\DescribeOption{table-unit-alignment}
% The contents of \texttt{s} columns can be centred or aligned to the
% left or right using the \opt{table-unit-alignment} option. As for the
% other alignment options, this recognises the choices \opt{center},
% \opt{left} and \opt{right}. 
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{Alignment options in \texttt{s} columns.}
%    \label{tab:s:align}
%    \begin{tabular}
%      {
%        s[table-unit-alignment = right]
%        s
%        s[table-unit-alignment = left]
%      }      
%      \toprule
%        {Left-aligned}  &   
%        {Centred text}  &
%        {Right-aligned} \\
%      \midrule
%        \metre\per\second & \metre\per\second & \metre\per\second \\
%        \kilogram         & \kilogram         & \kilogram         \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\DescribeOption{table-alignment}
% The three table alignment options (\opt{table-number-alignment}, 
% \opt{table-text-alignment} and \opt{table-unit-alignment}) can be set 
% to the same value using the \opt{table-alignment} option. This will 
% set all three alignment options to the same value (one of \opt{center}, 
% \opt{right} or \opt{left}).
% 
%\subsection{Symbols}
%
% Most units use letters as the symbol for the unit, and these are all
% very easy to control.  However, a small number of units use other
% symbols, and matching these to the body text requires more work.
% \pkg{siunitx} provides appropriate symbols for commonly-used units,
% but the definitions may need adjustment depending on the body font
% used in a document.
% 
%\DescribeOption{redefine-symbols}
% The package provides one general option for the handling of symbols.
% If the packages \pkg{textcomp} or \pkg{upgreek} are loaded, symbols 
% can be taken from these for units, rather than using the
% \pkg{siunitx} default values. The switch \opt{redefine-symbols} 
% can be used to turn this behaviour on or off: the standard setting
% is \opt{true}.
% 
% The individual symbols are set up independently for math and text
% output, and are summarised in \cref{tab:opt:symbols}.  Many of 
% the definitions are variations using \cs{text} or \cs{ensuremath} to
% produce the correct output, as the symbols available in the document
% may vary considerably. In the case of the micro symbol 
% (\SIUnitSymbolMicro), \pkg{sunitx} provides a suitable low-level 
% definition for the symbol. Depending on the fonts available, this
% may need to be replaced by an alternative by the user. The 
% ohm symbol (\SIUnitSymbolOhm) is usually set to \cs{Omega}, but
% will check that this has not been redefined as a slanted letter. If
% \cs{Omega} has been redefined, an alternative definition is used.
% 
%\begin{table}
%  \centering
%  \caption{Symbol options.}
%  \label{tab:opt:symbols}
%  \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
%    \toprule
%      \multicolumn{1}{l}{Option name} & 
%      Type &
%      \multicolumn{1}{l}{Default} \\
%    \midrule ^^A (
%      math-angstrom    & Literal & \verb=\text{\AA}=                 \\ 
%      math-arcminute   & Literal & \verb={}^{\prime}=                \\
%      math-arcsecond   & Literal & \verb={}^{\prime\prime}=          \\
%      math-celsius     & Literal & \verb={}^{\circ}=                 \\
%        & & \verb=\kern -\scriptspace \mathrm{C}= \\ 
%      math-degree      & Literal & \verb={}^{\circ}=                 \\
%      math-micro       & Literal & \meta{see text}                   \\
%      math-ohm         & Literal & \cs{Omega}                        \\
%      redefine-symbols & Switch & true \\
%      text-angstrom    & Literal & \cs{AA}                           \\ 
%      text-arcminute   & Literal & \verb=\ensuremath{{}^{\prime}}=   \\
%      text-arcsecond   & Literal & 
%        \verb=\ensuremath{{}^{\prime\prime}}= \\ 
%      text-celsius     & Literal &  \verb=\ensuremath{{}^{\circ}=    \\
%        & & \verb=\kern -\scriptspace \text{C}}= \\ 
%      text-degree      & Literal & \verb=\ensuremath{{}^{\circ}}=    \\ 
%      text-micro       & Literal & \meta{see text}                   \\
%      text-ohm         & Literal & \verb=\ensuremath{\Omega}=        \\
%    \bottomrule
%  \end{tabular}
%\end{table}
%
%\DescribeMacro{\SIUnitSymbolAngstrom}
%\DescribeMacro{\SIUnitSymbolArcminute}
%\DescribeMacro{\SIUnitSymbolArcsecond}
%\DescribeMacro{\SIUnitSymbolCelsius}
%\DescribeMacro{\SIUnitSymbolDegree}
%\DescribeMacro{\SIUnitSymbolMicro}
%\DescribeMacro{\SIUnitSymbolOhm}
% The math and text symbols defined above are wrapped up into mode
% independent functions with user names.  These are then used in the
% definitions of the appropriate units.  For example, the micro
% symbol can be accessed using the macro \cs{SIUnitSymbolMicro}.
% Notice that these names capitalise the unit name (to make reading 
% the macro name easier!).\footnote{The function 
% \cs{SIUnitSymbolAngstrom} uses the name without accents.}
% 
%\subsection{Other options}
%
%\DescribeOption{locale}
% \pkg{siunitx} allows the user to switch between the typographic
% conventions of different (geographical) areas by using locales.  
% Currently, the package is supplied with configurations for locales 
% \opt{UK}, \opt{US}, \opt{DE} (Germany), \opt{FR} (French) and \opt{ZA}
% (South Africa). The \opt{locale} option is used to switch to a 
% particular locale.
%\begin{LaTeXdemo}
%  \SI{1.234}{\metre}\\
%  \SI[locale = DE]{6.789}{\metre}
%\end{LaTeXdemo}
%
%\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
% preamble-only 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 using the upright serif font.
% 
%\subsection{Local configurations}
%\label{sec:config:local}
% 
% The \pkg{siunitx} package will check for a local configuration file
% \file{siunitx.cfg} during package loading.  This occurs before
% applying any setting given in the optional argument to 
% \cs{usepackage}.  A typical configuration file may include 
% settings (using \cs{sisetup}) and locally-defined units, for
% example
%\begin{LaTeXdemo}[code only]
%  \ProvidesFile{siunitx.cfg}
%  \sisetup{
%    output-decimal-marker = {,},
%    per-mode              = symbol,
%  }
%  \DeclareSIUnit\torr{torr}
%\end{LaTeXdemo}
% As units are always declared, overwriting any existing definition,
% units may safely be created in the configuration file even when also
% included in individual \LaTeX\ document headers.
% 
%\section{Localisation}
% 
% The \pkg{translator} package provides a structured framework for 
% localisation of words and phrases, and is part of the larger
% \pkg{beamer} bundle. The \pkg{translator} package provides the
% \cs{translate} macro, which will provide appropriate translations 
% based on the current \pkg{babel} or \pkg{polyglossia} language 
% setting.
% 
% If \pkg{translator} is available, \pkg{siunitx} will load it and alter 
% the standard settings for the \opt{list-final-separator} and 
% \opt{range-phrase} options to read:
%\begin{LaTeXdemo}[code only]
%  \sisetup{
%    list-final-separator = { \translate{and} },
%    range-phrase         = { \translate{to (numerical range)} },
%  }
%\end{LaTeXdemo} 
% If the current language is known to the \pkg{translator} package
% then the result will be localised text. The preamble for this manual
% loads English, French and German as options, and also loads the
% \pkg{babel} package:
%\begin{LaTeXdemo}
%  % In English by default
%  \SIlist{1;2;3}{\metre} \\
%  \SIrange{1}{10}{\degreeCelsius} \\
%  \selectlanguage{french}%
%  \SIlist{1;2;3}{\metre} \\
%  \SIrange{1}{10}{\degreeCelsius} \\
%  \selectlanguage{german}%
%  \SIlist{1;2;3}{\metre} \\
%  \SIrange{1}{10}{\degreeCelsius} \\
%\end{LaTeXdemo} 
% 
%\section{Hints for using \pkg{siunitx}}   
% 
%\subsection{Ensuring text or math output}
%
% The macros \cs{ensuremath} and \cs{text} should be used to ensure that
% a particular item is always printed in the desired mode. Some 
% mathematical output does not work well in \cs{mathrm} (the standard
% font used by \pkg{siunitx} for printing). The easiest way to solve
% this is to use the construction "\text{\ensuremath{...}}", which will
% print the material in the standard mathematics font without affecting
% the rest of the output. In some cases, simply forcing \cs{mathnormal}
% will suffice, but this is less reliable with non-Latin characters.
% 
%\subsection{Expanding content in tables}
%\label{sec:expanding}
%
% When processing tables, \pkg{siunitx} will expand anything stored
% inside a macro, unless it is long or protected. \LaTeXe\ robust
% commands are also detected and are not expanded 
% (\cref{tab:xmpl:macro}). Values which would otherwise be expanded
% can be protected by wrapping them in a set of braces. As \TeX\ itself
% will expand the first token in a table cell before \pkg{siunitx}
% can act on it, using the \eTeX\ protected mechanism is the 
% recommended course of action to prevent expansion of macros in
% table cells. (As is shown in the table, \TeX's expansion of
% \LaTeXe\ robust commands can lead to unexpected results.)
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{Values as macros in \texttt{S} columns.}
%    \label{tab:xmpl:macro}
%    \newcommand*\myvaluea{1234}
%    \newcommand\myvalueb{1234}
%    \DeclareRobustCommand*\myvaluec{1234}
%    \protected\def\myvalued{1234}
%    \begin{tabular}{S}
%    \toprule
%      {Some Values} \\
%    \midrule
%       \myvaluea  8.8 \myvaluea  \\ % Both expanded
%       \myvalueb  8.8 \myvalueb  \\ % First expanded by TeX
%                                    % to numbers
%       \myvaluec  8.8 \myvaluec  \\ % First expanded by TeX
%                                    % but not to numbers!
%       \myvalued  8.8 \myvalued  \\ % Neither expanded
%      {\myvaluea\ 8.8 \myvaluea} \\ % Neither expanded
%    \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
% It is possible to use calculated values in tables. For this to
% work, the calculation must take place before attempting to parse
% the number. An added complication is that \TeX\ itself will
% expand the first macro in a table cell until it finds 
% something unexpandable. The \eTeX\ protected mechanism can be
% used to prevent this; using the \pkg{etoolbox} package provides
% a convenient way to apply this protection to existing functions.
% The general approach is illustrated in \cref{tab:xmpl:calc}.
% The macro \cs{DTLmul} is made robust inside the table using
% the \cs{robustify} command from \pkg{etoolbox}, before 
% constructing the table using an extra column to contain the
% calculation.
%\begin{LaTeXdemo}[code and float]
%  \DTLnewdb{data}
%  \DTLnewrow{data}\DTLnewdbentry{data}{value}{66.7012}
%  \DTLnewrow{data}\DTLnewdbentry{data}{value}{66.0212}
%  \DTLnewrow{data}\DTLnewdbentry{data}{value}{64.9026}
%  \begin{table}
%    \caption{Calculated values.}
%    \label{tab:xmpl:calc}
%    \centering
%    \robustify\DTLmul
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 2,
%      table-figures-decimal  = 4
%    }
%    \begin{tabular}{
%      S
%      S[table-figures-integer = 3]
%      @{}l
%    }
%      \toprule
%        {Value} & {Doubled}  &
%      \DTLforeach{data}{\myvalue=value}{%
%        \DTLiffirstrow {\\ \midrule}{\\}%
%        \myvalue & % First column
%        \DTLmul{\myvalue}{\myvalue}{2} \myvalue % second column
%        & }\\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%
%\subsection{Using \pkg{siunitx} with \pkg{datatool}}
%
% As illustrated in \cref{tab:xmpl:calc}, \pkg{siunitx} can be used
% to typeset data stored using \pkg{datatool}. For quickly displaying
% the contents of tables, \pkg{datatool} offers the \cs{DTLshowtable}
% macro. This will only work with \texttt{S} columns if number parsing
% is turned off (\cref{tab:xmpl:datatool}).
%\begin{LaTeXdemo}[code and float]
%  \DTLnewdb{moredata}
%  \DTLnewrow{moredata}\DTLnewdbentry{moredata}{value}{ 6.7012}
%  \DTLnewrow{moredata}\DTLnewdbentry{moredata}{value}{66.0212}
%  \DTLnewrow{moredata}\DTLnewdbentry{moredata}{value}{64.902 }
%  \begin{table}
%    \caption{Displaying a \textsf{datatool} table.}
%    \label{tab:xmpl:datatool}
%    \centering
%    \sisetup{
%      parse-numbers          = false,
%      table-number-alignment = center,
%      table-figures-integer  = 2,
%      table-figures-decimal  = 4
%    }
%    \renewcommand*\dtlrealalign{S}
%    \DTLdisplaydb{moredata}
%  \end{table}
%\end{LaTeXdemo}
% 
%\subsection{Using units such as \si{\micro\metre\per\second} in 
%  headings}
%
% The \pkg{siunitx} code is designed to work correctly with functions 
% in headings. They will print correctly in headings and in the table
% of contents. As illustrated here, the standard behaviour is to ignore
% font changes. When the \pkg{hyperref} package is loaded, the
% functions automatically \enquote{degrade gracefully} to produce 
% useful information in PDF bookmarks. If you want more control over
% the bookmark text, use the \cs{texorpdfstring} function from 
% \pkg{hyperref}, for example:
%\begin{LaTeXdemo}[code only]
%  \section{Some text 
%    \texorpdfstring
%      {\si{\joule\per\mole\per\kelvin}}
%      {J mol-1 K-1}%
%    }
%\end{LaTeXdemo}
%
%\subsection{Symbols and \texorpdfstring{\XeTeX}{XeTeX}}
%
% A small number of non-Latin symbols are needed by \pkg{siunitx},
% notably \SIUnitSymbolOhm\ and \SIUnitSymbolMicro. The package picks
% glyphs for these which are correct in the sense that they are upright
% (not italic) symbols, and match the \LaTeX\ standard Computer Modern
% font. However, this does not make them the best choice if other
% fonts are in use, which is particularly common when \XeTeX\ is 
% being used. 
% 
% \XeTeX\ users will probably need to choose appropriate symbols 
% themselves. The correct choice depends on the fonts in use, but many
% system fonts include Greek letters and other symbols (which is not
% the case with most \TeX-specific fonts). An appropriate setting
% could then be to use the text \SIUnitSymbolMicro\ symbol in all
% cases:
%^^A This document cannot be UTF-8, as it has to work correctly with
%^^A pdfLaTeX. So there is a bit of work to do here to get the right
%^^A output.
%\begin{flushleft}
%  \ttfamily
%  \textbackslash \textcolor{blue}{sisetup}\{\\
%  \ \ math-micro  = \textbackslash 
%    \textcolor{blue}{text}\{\SIUnitSymbolMicro\}, \\
%  \ \ text-micro \ = \SIUnitSymbolMicro \\
%  \}
%\end{flushleft}
%
%\subsection{Scaled document fonts with \texorpdfstring{\XeTeX}{XeTeX}}
%
% The \pkg{fontspec} package makes it possible to scale the document
% body font. This can lead to unexpected problems with printing 
% for \pkg{siunitx}, as some symbols will not scale while numbers
% and text will. The problem is best avoided by forcing \pkg{siunitx}
% to use the default math font for all output:
%\begin{LaTeXdemo}[code only]
%  \sisetup{
%    mode    = math,
%    math-rm = \ensuremath
%  }
%\end{LaTeXdemo}
% This will cause all \pkg{siunitx} output \emph{not} to scale at all,
% consistent with other mathematical content.
% 
% \subsection{Interaction with \pkg{tex4ht}}
%
% \pkg{siunitx} will detect when \pkg{tex4ht} is in use, and makes 
% some changes to the way output is printed. Text mode printing is
% automatically selected, and certain items (such as spaces) are
% printed in text mode rather than as math. This is designed to 
% reduce the likelihood of spurious formulae appearing in, for
% example, output converted to OpenOffice format.
%
%\subsection{Maximising performance}
%
% Both the number and unit parsers require significant effort in
% terms of \TeX\ programming. For input that does not require 
% such processing, the maximum performance for \pkg{siunitx} can
% therefore be obtained by turning off both systems:
%\begin{LaTeXdemo}
%  \SI{7.3}{\Hz} \\
%  \SI[parse-units = false]{7.3}{\Hz} \\
%  \SI[
%    parse-numbers = false,
%    parse-units   = false
%  ]{7.3}{\Hz} 
%\end{LaTeXdemo}
%
%\subsection{Transferring settings to \pkg{pgf}}
%
%\DescribeMacro{\SendSettingsToPgf}
% The numerical engine in the \pkg{pgf} package has settings similar
% to those in \pkg{siunitx}. To enable working with both packages
% easily, the macro \cs{SendSettingsToPgf} is available. It will
% set some commonly-used numerical formatting options in \pkg{pgf}
% to the current values used by \pkg{siunitx} to make using the 
% two packages together more convenient for end users. This
% function can be used at any point after loading both the 
% \pkg{pgf} and \pkg{siunitx} packages.
%\begin{LaTeXdemo}[code only]
%  \documentclass{article}
%  \usepackage{pgf,siunitx}
%  \sisetup{...}
%  \SendSettingsToPgf
%  ...
%\end{LaTeXdemo} 
%
%\subsection{Using \pkg{siunitx} with the \pkg{cellspace} package}
%
% Both \pkg{siunitx} and \pkg{cellspace} use the letter \texttt{S} for a 
% new column type. This obviously leads to a problem. If both are 
% loaded, \pkg{siunitx} will retain the \texttt{S} column, and moves the
% functionality of \pkg{cellspace} to the letter \texttt{C}. This 
% allows the normal use of \pkg{cellspace} with standard column types:
% it does \emph{not} work with the \pkg{siunitx} \texttt{S} or 
% \texttt{s} columns.
% 
%\subsection{Special considerations for the \cs{kWh} unit}
%
% The \file{abbreviations} configuration file provides the unit 
% \cs{kWh}, which is set up with no spacing between the 
% \enquote{\si{\kilo\watt}} and the \enquote{\si{\hour}} unit to give 
% \enquote{\si{\kWh}}. However, this only applies when the unit is given
% on its own: combinations will follow the normal rules
%\begin{LaTeXdemo}
%  \si{\kWh} \\
%  \si{\kWh\per\metre} 
%\end{LaTeXdemo} 
% This is because the unit \cs{kWh} is defined so that it can still be
% varied by altering \cs{kilo}, \cs{watt} and \cs{hour}, and so that
% the prefix can still be turned into a number. However, some users
% may prefer to have a non-flexible macro which never adds a space.
% This can be achieved by redefining \cs{kWh} with \cs{DeclareSIUnit},
% by added an alternative definition
%\begin{LaTeXdemo}[code only]
%  \DeclareSIUnit\kWh{kWh}
%  \DeclareSIUnit\KWH{kWh}
%\end{LaTeXdemo} 
% or of course by using literal unit input.
%\begin{LaTeXdemo}
%  \si{\KWH\per\metre}\\
%  \si{kWh.m^{-1}}
%\end{LaTeXdemo}
% 
% Another point to notice is that the \cs{per} macro applies to
% the next unit, and not an entire unit combination. Thus in
%\begin{LaTeXdemo}
%  \si{\candela\per\kWh}
%\end{LaTeXdemo}
% \cs{per} applies to the watts but not to the hours. In this case,
% the units need to be written out in full or the \opt{sticky-per}
% option should be used.
%\begin{LaTeXdemo}
%  \si{\candela\per\kilo\watt\per\hour} \\
%  \si[sticky-per]{\candela\per\kWh}
%\end{LaTeXdemo}
%
%\subsection{Adding items after the last column of a tabular}
%
% When using the \pkg{array} package \enquote{\texttt{<}} construct
% to insert material after an \texttt{S} or \texttt{s} column, the 
% spacing will be wrong. This is due to the way that \LaTeX\ constructs
% tables at a low level. The incorrect spacing can be avoided by using
% the \TeX\ \cs{cr} primitive to end the table rows instead 
% (\cref{tab:cr}).
%\begin{LaTeXdemo}[code and 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{LaTeXdemo}
%
%\subsection{Creating a column with numbers and units}
%
% Usually, numbers in a table should be given with the units in the
% column heading. However, there are cases where a series of data are
% best presented in a table but have different units. There are two
% ways to do this (\cref{tab:xmpl:mixed}). The first is to place the  
% units in the first column of the table, which makes sense if there 
% are several related items in the table. The second method is to 
% generate two columns, one for numbers and a second for units, and then
% to format these to give the visual effect of a single column. The 
% later effect is most appropriate when only one set of numbers are 
% presented in a table. 
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Tables where numbers have different units}
%    \label{tab:xmpl:mixed}
%    \hfil
%    \begin{tabular}
%      {
%        >{$}l<{$}
%        S[table-format = 2.3(1)]
%        S[table-format = 3.3(1)]
%      }
%      \toprule
%        & {One} & {Two} \\
%      \midrule
%      a / \si{\angstrom}   &  1.234(2) &   5.678(4) \\
%      \beta / \si{\degree} & 90.34(4)  & 104.45(5)  \\
%      \mu / \si{\per\mm}   &  0.532    &   0.894    \\
%      \bottomrule
%    \end{tabular}
%    \hfil
%    \begin{tabular}
%      {S[table-format=1.3]@{\,}s[table-unit-alignment = left]}
%      \toprule
%      \multicolumn{2}{c}{Heading} \\
%      \midrule
%      1.234 & \metre   \\
%      0.835 & \candela \\
%      4.23  & \joule\per\mole \\
%      \bottomrule
%    \end{tabular}  
%    \hfil
%  \end{table}
%\end{LaTeXdemo}
%
%\subsection{Tables with heading rows}
%
% A common format for tables is to make the heading row visually
% distinct using a background colour and bold text. If numbers appear
% in such a heading row within an \texttt{S} column then getting the
% appearance right can be challenging. The best approach is to 
% make the \cs{bfseries} macro \enquote{robust} (as demonstrated in
% \cref{sec:expanding}), then to use this macro to make the heading
% cells bold. This approach is illustrated in \cref{tab:xmpl:headers},
% along with the use of \cs{rowcolor} to provide a background colour.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \caption{Header row in a table}
%    \label{tab:xmpl:headers}
%    \robustify\bfseries
%    \centering
%    \begin{tabular}
%      {S[detect-weight,table-format = 3.3]}
%      \rowcolor[gray]{0.9}
%      \bfseries 123.456 \\
%       23.45  \\
%      123.4   \\
%        3.456 \\
%    \end{tabular}  
%  \end{table}
%\end{LaTeXdemo}
%
%\subsection{Associating a locale with a \pkg{babel} language}
%
% It is possible to instruct the \pkg{babel} package to switch
% to a particular \pkg{siunitx} locale when changing language. This
% can be done using the \pkg{babel} \cs{extras\meta{language}}
% system. For example, to associate the \texttt{DE} locale with
% the \texttt{german} \pkg{babel} language, the appropriate
% code would be
%\begin{LaTeXdemo}[code only]
%  \addto\extrasgerman{\sisetup{locale = DE}}
%\end{LaTeXdemo}
%
%\section{Information for those upgrading from version 1}
%
% The key--value control system of \pkg{siunitx} has been completely
% rewritten for version 2, and at the same time some of the macros
% provided by the package have been renamed and reworked. The package 
% can be loaded with a configuration file to provide most of the
% same options and defaults as in version 1:
%\begin{LaTeXdemo}[code only]
%  \usepackage[load-configurations = version-1]{siunitx}
%\end{LaTeXdemo} 
% Many of the options from version 1 map to similar ones in version 2
% (\cref{tab:opt:map}). The correspondence often includes a syntax
% change: consult details of the new options for the correct syntax for
% the new options. In some cases, the new approach is different to the
% older one, and in these cases the most appropriate option new has been
% listed in the table.
%\begin{center} 
%  \tablecaption{Mapping of version 1 options to version 2.}
%  \label{tab:opt:map}
%  \tablefirsthead{^^A
%    \toprule
%      \multicolumn{1}{l}{Version 1}  &
%      \multicolumn{1}{l}{See in version 2}  \\
%    \midrule  
%  }
%  \tablehead{^^A
%    \multicolumn{2}{l}{\emph{Continued from previous page}} \\
%    \toprule
%      \multicolumn{1}{l}{Version 1}  &
%      \multicolumn{1}{l}{See in version 2}  \\
%    \midrule
%  }
%  \tabletail{^^A
%    \bottomrule
%    \multicolumn{2}{r}{\emph{Continued on next page}} \\
%  }     
%  \tablelasttail{\bottomrule}
%  
%  \begin{xtabular}{>{\ttfamily}l>{\ttfamily}l}
%    addsign        & explicit-sign             \\
%    allowlitunits  & free-standing-units       \\
%    allowoptarg    & unit-optional-argument    \\
%    allowzeroexp   & retain-zero-exponent      \\
%    anglesep       & arc-separator             \\
%    astroang       & angle-symbol-over-decimal \\
%    closeerr       & close-bracket             \\
%    closefrac      & close-bracket             \\
%    closerange     & close-bracket             \\
%    colour         & color                     \\
%    colorall       & color                     \\
%    colourall      & color                     \\
%    colorunits     & unit-color                \\
%    colorneg       & negative-color            \\
%    colourneg      & negative-color            \\
%    colourunits    & unit-color                \\
%    colorvalues    & value-color               \\
%    colourvalues   & value-color               \\
%    decimalsymbol  & output-decimal-marker     \\
%    detectdisplay  & detect-display-math       \\
%    digitsep       & group-separator           \\
%    dp             & round-mode                \\
%                   & round-precision           \\
%    errspace       & uncertainty-separator     \\
%    expbase        & exponent-base             \\
%    expproduct     & exponent-product          \\
%    fixdp          & round-mode                \\
%    fixsf          & round-mode                \\
%    fraction       & fraction-function         \\
%    inlinebold     & detect-inline-weight      \\
%    locale         & locale                    \\
%    mathOmega      & math-ohm                  \\
%    mathcelsius    & math-celsius              \\
%    mathdegree     & math-degree               \\
%    mathminute     & math-arcminute            \\ 
%    mathmu         & math-micro                \\
%    mathringA      & math-angstrom             \\
%    mathrm         & math-rm                   \\
%    mathsOmega     & math-ohm                  \\
%    mathscelsius   & math-celsius              \\
%    mathsdegree    & math-degree               \\
%    mathsecond     & math-arcsecond            \\
%    mathsf         & math-sf                   \\
%    mathsminute    & math-arcminute            \\ 
%    mathsmu        & math-micro                \\
%    mathsringA     & math-angstrom             \\
%    mathsrm        & math-rm                   \\
%    mathssecond    & math-arcsecond            \\
%    mathssf        & math-sf                   \\
%    mathstt        & math-tt                   \\
%    mathtt         & math-tt                   \\
%    mode           & mode                      \\
%    negcolor       & negative-color            \\
%    negcolour      & negative-color            \\
%    numaddn        & input-symbols             \\
%    numcloseerr    & input-close-uncertainty   \\
%    numdecimal     & input-decimal-markers     \\
%    numdigits      & input-digits              \\
%    numdiv         & input-quotient            \\
%    numexp         & input-exponent-markers    \\
%    numgobble      & input-ignore              \\
%    numopenerr     & input-open-uncertainty    \\
%    numprod        & input-product             \\
%    numsign        & input-signs               \\
%    obeyall        & detect-all                \\
%    obeybold       & detect-weight             \\
%    obeyfamily     & detect-family             \\
%    obeyitalic     & detect-shape              \\
%    obeymode       & detect-mode               \\
%    openerr        & open-bracket              \\
%    openfrac       & open-bracket              \\
%    openrange      & open-bracket              \\
%    padangle       & add-arc-degree-zero       \\
%                   & add-arc-minute-zero       \\
%                   & add-arc-second-zero       \\
%    padnumber      & add-decimal-zero          \\
%                   & add-integer-zero          \\
%    per            & per-mode                  \\
%    prefixsymbolic & prefixes-as-symbols       \\
%    prespace       & space-before-unit         \\
%    redefsymbols   & redefine-symbols          \\
%    repeatunits    & multi-part-units          \\
%                   & product-units             \\
%    retainplus     & retain-explicit-plus      \\
%    seperr         & separate-uncertainty      \\
%    sepfour        & group-four-digits         \\
%    sf             & round-mode                \\
%                   & round-precision           \\
%    sign           & explicit-sign             \\
%    slash          & per-symbol                \\
%    stickyper      & sticky-per                \\
%    strict         & strict                    \\
%    tabalign       & table-alignment           \\
%    tabalignexp    & table-align-exponent      \\
%    tabautofit     & table-auto-round          \\
%    tabformat      & table-format              \\
%    tabnumalign    & table-number-alignment    \\
%    tabparseonly   & table-parse-only          \\
%    tabexpalign    & table-align-exponent      \\
%    tabtextalign   & table-text-alignment      \\
%    tabunitalign   & table-unit-alignment      \\
%    textcelsius    & text-celsius              \\
%    textdegree     & text-degree               \\
%    textminute     & text-arcminute            \\
%    textmode       & mode                      \\
%    textmu         & text-micro                \\
%    textOmega      & text-ohm                  \\
%    textringA      & text-angstrom             \\
%    textrm         & text-rm                   \\
%    textsecond     & text-arcsecond            \\
%    textsf         & text-sf                   \\
%    texttt         & text-tt                   \\
%    tightpm        & tight-spacing             \\
%    tophrase       & range-phrase              \\
%    trapambigerr   & multi-part-units          \\
%    trapambigfrac  & bracket-numbers           \\
%    trapambigrange & range-units               \\
%    unitcolor      & unit-color                \\
%    unitcolour     & unit-color                \\
%    unitmathrm     & unit-math-rm              \\
%    unitmathsf     & unit-math-sf              \\
%    unitmathsrm    & unit-math-rm              \\
%    unitmathssf    & unit-math-sf              \\
%    unitmathstt    & unit-math-tt              \\
%    unitmathtt     & unit-math-tt              \\
%    unitmode       & unit-mode                 \\
%    unitsep        & inter-unit-separator      \\
%    unitspace      & inter-unit-separator      \\
%    valuecolor     & value-color               \\
%    valuecolour    & value-color               \\
%    valuemathrm    & value-math-rm             \\
%    valuemathsf    & value-math-sf             \\
%    valuemathsrm   & value-math-rm             \\
%    valuemathssf   & value-math-sf             \\
%    valuemathstt   & value-math-tt             \\
%    valuemathtt    & value-math-tt             \\
%    valuemode      & value-mode                \\
%    valuesep       & number-unit-separator     \\
%    xspace         & use-xspace                \\
%  \end{xtabular}
%\end{center}
% A small number of the options from version 1 are used unchanged in 
% version 2, for example the \opt{mode} setting. These are listed above
% but require no action on the part of the user. There are also a
% few options which are no longer used at all, and are therefore ignored
% by the current code. 
% 
% Loading configuration files has been completely changed, and this 
% means that the options \opt{alsoload}, \opt{load} and \opt{noload} are
% ignored by version 2. In the same way the options \opt{debug} and 
% \opt{log} are not used by the current release of \pkg{siunitx}, as 
% this information is usually only needed by the package author.
% Emulation of older packages is no longer offered (it was intended
% to help with the transition form earlier packages), and so the
% \opt{emulate} option no longer applies.
%
%\section{Correct application of (SI) units}
%
% 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 \emph{Conf{\'e}rence G{\'e}n{\'e}rale 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 \emph{Bureau International des
% Poids et Mesures} \cite{BIPM}.
%
% \pkg{siunitx} takes account of the information given here, so far as 
% is possible.  Thus the package defaults follow the recommendations
% made for typesetting numbers and units.  Spacing and so forth is
% handled in such a way as to make implementing the rules
% (relatively) easy.
%
%\subsection{Units}
%
% There are seven base SI units, listed in \cref{tab:unit:base}. 
% 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 \enquote{prototype} held in
% Paris.
%
% All other units within the SI system are regarded as \enquote{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 \cref{tab:unit:derived,tab:unit:accepted}) have a 
% special name and symbol. 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 (\cref{tab:unit:physical}).
%
% A series of SI prefixes for decimal multiples and sub-multiples 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 \cref{tab:unit: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\degreeCelsius}. 
%
% 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 \enquote{gram} and the prefix symbols are used with
% the unit symbol \si{\gram}.  For example 
% \( \SI[prefixes-as-symbols = false]{1}{\milli\gram} =
% \SI{1}{\milli\gram} \).
%
% 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 \pkg{siunitx} by default do not include
% 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 (\cref{tab:unit:binary}) are the most obvious 
% example.  These are \emph{not} part of the SI specifications, but the 
% prefix names are derived from those in \cref{tab:unit:prefix}.
%
% Other units 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 particularly true of units derived from basic physical
% constants.
%
% 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,
% \pkg{siunitx} does define non-SI units.
%
%\subsection{Mathematical meaning}
%
% As explained earlier, a number--unit 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{\arcminute} and \si{\arcsecond}), it is usual to 
% have a space between the unit and the number.  This should therefore
% be a thin non-breaking space between the two.
%\begin{LaTeXdemo}
%  A space for \SI{10}{\percent}\\
%  and also for \SI{100}{\degreeCelsius}\\
%  but not for \ang{1.23}.
%\end{LaTeXdemo}
%
% 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.  The \pkg{siunitx} 
% package defaults again follow this convention: any local settings are
% ignored, and uses the current upright serif math 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{LaTeXdemo}
%  Units should \textbf{not be bold: \SI{54}{\farad}}\\
%  \textbf{But perhaps in a running block,\\
%  it might look better: \SI[detect-weight]{54}{\farad}}
%\end{LaTeXdemo}
%
% 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. 
%\begin{LaTeXdemo}
%  \( \si{\metre\second} = \text{metre second} \) \\
%  \( \si{\milli\second} = \text{millisecond}  \) \\
%  \sisetup{inter-unit-separator = { } \cdot { } }
%  \( \si{\metre\second} = \text{metre second} \) \\
%  \( \si{\milli\second} = \text{millisecond}  \)
%\end{LaTeXdemo}
% There are some circumstances under which it is permissible to omit
% any spaces.  The classic example is \si{\kWh}, where
% \enquote{\si[inter-unit-separator = \,]{\kWh}} does not add any 
% useful information. If using such a unit repeatedly, users of 
% \pkg{siunitx} are advised to create a custom unit to ensure 
% consistency.
%
% 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 
% \pkg{siunitx}, which will \enquote{trap} repeated division and format
% it correctly.  In complicated cases, negative exponents are to be
% preferred over other formats.
%\begin{LaTeXdemo}
%  \si{\joule\per\mole\per\kelvin}\\
%  \si[per-mode = fraction]{\joule\per\mole\per\kelvin}\\
%  \si[per-mode = symbol]{\joule\per\mole\per\kelvin}
%\end{LaTeXdemo}
%
% Products and errors should show what unit applies to each number
% given.  Thus \SI[product-units = brackets]{2x3}{\metre} is an 
% ordered set of lengths of a geometric area, whereas 
% \SI[product-units = single]{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[product-units = power]{2 x 3}{\metre}. Although this does 
% display the correct overall units, it is potentially-confusing and is
% not encouraged.
%
% Care must be taken when writing ranges of numbers.  For purely
% numerical values, it is common to use a en-dash to show a range, for
% example \enquote{see pages 1--5}.  On the other hand, physical 
% quantities could be misinterpret as negative values if written in this 
% way. As the unit--number combination is a single mathematical entity, 
% writing the values with an en-dash followed by a single unit is also
% incorrect.  As a result, using the word \enquote{to} is strongly
% recommended.
%\begin{LaTeXdemo}
%  \SIrange{1}{5}{\metre} long.
%\end{LaTeXdemo}
%
%\subsection{Graphs and tables}
%
% In graphs and tables, 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\), \emph{i.e.}~length per time 
% squared in this case.}  Much better is to show division of all 
% quantities by the unit, which leaves the entries as unitless ratios.  
% This is illustrated in \cref{tab:xmpl:unitless} and 
% \cref{fig:xmpl:unitless}.
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{An example of table labelling.}
%    \label{tab:xmpl:unitless}
%    \sisetup{
%      table-number-alignment = center,
%      table-figures-integer  = 1,
%      table-figures-decimal  = 4
%    }
%    \begin{tabular}{cS}
%      \toprule
%        Entry & {Length/\si{\metre}} \\
%      \midrule
%        1 & 1.1234 \\
%        2 & 1.1425 \\
%        3 & 1.7578 \\
%        4 & 1.9560 \\
%      \bottomrule
%    \end{tabular}
%  \end{table}
%\end{LaTeXdemo}
%\begin{LaTeXdemo}[code and float]
%  \begin{figure}
%    \centering
%    \begin{tikzpicture}
%      \begin{axis}[
%        xlabel = \( t/\si{\second} \),
%        xmax   = 6,
%        xmin   = 0,
%        ylabel = \( d/\si{\metre}  \),
%        ymin   = 0
%      ]
%        \addplot[smooth,mark=*]
%          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:xmpl:unitless}
%  \end{figure}
%\end{LaTeXdemo}
%
% 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 \cref{tab:good}.  The use of \cs{multicolumn} is
% needed here due to the \enquote{\texttt{<}}; without \cs{multicolumn}, 
% the titles are followed by \enquote{\si{\kilo\gram}}!
%\begin{LaTeXdemo}[code and float]
%  \begin{table}
%    \centering
%    \caption{Good and bad columns.}
%    \label{tab:good}
%    \sisetup{table-number-alignment = center}
%    \begin{tabular}{
%      c
%      S[
%        table-figures-integer  = 1,
%        table-figures-decimal  = 3,
%        table-figures-exponent = 1
%      ]
%      @{\,\si{\kilogram}}
%      S[
%        table-figures-integer  = 2,
%        table-figures-decimal  = 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{LaTeXdemo}
%
%\section{Making suggestions and reporting bugs}
%
% Feedback on \pkg{siunitx} is always welcome, either to make 
% suggestions or to report problems. When sending feedback, it is
% always useful if a small example file is included, showing the
% bug being reported or illustrating the desired output.  It is
% helpful if a \enquote{reference rendering} is included, showing what
% the output should look like.  A typical example file might read
%\begin{LaTeXdemo}[code only]
%  \listfiles
%  % Use the article class unless the problem is class-dependent
%  \documentclass{article}
%  \usepackage{siunitx}
%  % Other packages loaded as required
%  \begin{document}
%  Reference output: $ 1.23\,\mathrm{m} $
%  
%  siunitx output: \SI{1.23}{\metre}
%  \end{document}
%\end{LaTeXdemo}
% As illustrated, it is usually best to use the \texttt{article}
% class and to only load packages which are needed to show the issue. 
% It is also useful to include a copy of the log file generate by
% \TeX\ when reporting a bug (as the versions of packages can be
% important to solving the issue).
% 
% Feedback can be sent in a range of ways.  The development code 
% is hosted by 
% \href{http://bitbucket.org/josephwright/siunitx}{BitBucket},
% and the site includes an issue tracker.  Adding feedback directly
% to the database means that other users can see it, and also 
% ensures that it does not get forgotten.  E-mailing directly is 
% will also definitely get attention:
% \href{mailto:joseph.wright@morningstar2.co.uk}
% {\texttt{joseph.wright@morningstar2.co.uk}}. I also keep an eye
% on various groups, for example 
% \href{http://groups.google.com/group/comp.text.tex/topics}
% {\texttt{comp.text.tex}} and 
% \href{http://www.latex-community.org/forum/}{The \LaTeX\ Community}.
% Sometimes I miss posts to these places, so it's useful if you also
% e-mail me pointing to the appropriate thread.
%
%\section{Thanks}
%
% Many users have provided feedback, bug reports and ideas for new
% features for \pkg{siunitx}: thanks to all of them. Particular thanks
% to Stefan Pinnow, who has taken the lead role as beta tester for
% \pkg{siunitx}, finding incorrect output, bad documentation and the 
% odd spelling mistake in the documentation. Thanks also to 
% Danie Els and Marcel Heldoorn for the \pkg{SIstyle} and \pkg{SIunits}
% packages, respectively, which provided the starting point for the
% development of \pkg{siunitx}.
%
%\end{documentation}
%
%\begin{implementation}
%
%\section{Implementation}
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%\subsection{Preliminaries}
%
% The usual preliminaries.  
%    \begin{macrocode}
\ProvidesExplPackage {siunitx} {2011/03/20} {2.1m}
  {A comprehensive (SI) units package}
%    \end{macrocode}
% 
% Various problems pop up if the support files are too old. First,
% a check on \pkg{expl3}. There is also a check on \pkg{xparse}, but
% that comes a bit later. If the version of \pkg{expl3} is \emph{really}
% old then the message system may not be in place at all: there is a 
% back up for that case.
%    \begin{macrocode}
\cs_if_exist:NTF \msg_set:nnnn
  {
    \msg_set:nnnn { siunitx } { support-outdated } 
      { Support~package~#1~too~old. }
      {
        Please~install~an~up~to~date~version~of~#1. \\
        Loading~siunitx~will~abort!
      }
  }
  {
    \PackageError { siunitx } { Support~package~expl3~too~old. }
      {
        Please~install~an~up~to~date~version~of~expl3. \\
        Loading~siunitx~will~abort!
      }
    \tex_endinput:D  
  }
\@ifpackagelater { expl3 } { 2010/11/13 } 
  { }
  {
    \msg_error:nnx { siunitx } { support-outdated } { expl3 }
    \tex_endinput:D
  }
%    \end{macrocode}
%    
%\begin{macro}{\siunitx_load_check:}
% There are also a number of packages that are incompatible with
% \pkg{siunitx}. These are all checked for next.  Some of the 
% incompatible packages will not raise an error if loaded after 
% \pkg{siunitx}.  So a test is made at the beginning of the 
% document as well. The message for this may be needed immediately, so
% it is created here not with the other messages.
%    \begin{macrocode}
\msg_set:nnnn { siunitx } { incompatible-package } 
  { Package~'#1'~incompatible. }
  { The~#1~package~and~siunitx~are~incompatible. }
\cs_new_protected_nopar:Npn \siunitx_load_check:n #1 {
  \group_begin:
    \@ifpackageloaded {#1} 
      { \msg_error:nnx { siunitx } { incompatible-package } {#1} } 
      { }
  \group_end:
}
\clist_map_function:nN 
  { SIunits , sistyle , siunits , SIstyle , unitsdef , fancyunits }
  \siunitx_load_check:n
\AtBeginDocument {
  \clist_map_function:nN { SIunits , sistyle , siunits , SIstyle }
    \siunitx_load_check:n
}
%    \end{macrocode}
%\end{macro}
%
% The version of \pkg{xparse} available is checked to avoid any weird
% errors.
%    \begin{macrocode}
\RequirePackage{ xparse }
\@ifpackagelater { xparse } { 2010/10/13 } 
  { }
  {
    \msg_error:nnx { siunitx } { support-outdated } { xparse }
    \tex_endinput:D
  }
%    \end{macrocode}
%
% Now load the support packages.
%    \begin{macrocode}
\RequirePackage{ amstext , array , l3keys2e }
%    \end{macrocode}
%    
%\begin{macro}{\siunitx_tmp:w}
%\begin{macro}{\l_siunitx_tmp_bool}
%\begin{macro}{\l_siunitx_tmp_box}
%\begin{macro}{\l_siunitx_tmp_int}
%\begin{macro}{\l_siunitx_tmpa_tl}
%\begin{macro}{\l_siunitx_tmpb_tl}
% Scratch items.
%    \begin{macrocode}
\cs_new:Npn \siunitx_tmp:w { }
\bool_new:N \l_siunitx_tmp_bool
\box_new:N \l_siunitx_tmp_box
\int_new:N \l_siunitx_tmp_int
\tl_new:N \l_siunitx_tmpa_tl
\tl_new:N \l_siunitx_tmpb_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_error_bool}
%\begin{macro}{\siunitx_error:nxx}
%\begin{macro}{\siunitx_error:nx}
%\begin{macro}{\siunitx_error:n}
% General-purpose functions for throwing errors.
%    \begin{macrocode}
\bool_new:N \l_siunitx_error_bool
\cs_new_protected:Npn \siunitx_error:nxx #1#2#3 {
  \bool_set_true:N \l_siunitx_error_bool
  \msg_error:nnxx { siunitx } {#1} {#2} {#3}
}
\cs_new_protected:Npn \siunitx_error:nx #1#2 {
  \siunitx_error:nxx {#1} {#2} { }
}
\cs_new_protected:Npn \siunitx_error:n #1 {
  \siunitx_error:nxx {#1} { } { }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%    
% Some of the \texttt{TS1} encoding is needed to provide symbols in 
% text mode. If the user has not loaded the encoding themselves, it is
% done here.
%    \begin{macrocode}
\AtBeginDocument { 
  \cs_if_free:cT { T@TS1 } 
    {
      \DeclareFontEncoding { TS1 } { } { } 
      \DeclareFontSubstitution { TS1 } { cmr } { m } { n } 
    }
}
%    \end{macrocode}
%
%\begin{macro}{\c_siunitx_minus_tl}
%\begin{macro}{\c_siunitx_minus_int}
% To allow the correct symbol to appear in text mode: this is the same
% as \cs{textminus} from \pkg{textcomp}. If \pkg{fontspec} is loaded
% then the real character can be used.
%    \begin{macrocode}
\DeclareTextSymbolDefault \c_siunitx_minus_tl { TS1 }
\DeclareTextSymbol \c_siunitx_minus_tl { TS1 } { 61 }
\AtBeginDocument {
  \@ifpackageloaded { fontspec }
    { 
      \int_const:Nn \c_siunitx_minus_int { 8722 }
      \tl_set:Nn \c_siunitx_minus_tl { \char \c_siunitx_minus_int }
    }
    { }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%
%\begin{macro}{\c_siunitx_mu_tl}
% The lack of an upright mu has to be sorted out. The same consideration
% for \pkg{fontspec} as above.
%    \begin{macrocode}
\DeclareTextSymbol \c_siunitx_mu_tl { TS1 } { 181 }
\DeclareTextSymbolDefault \c_siunitx_mu_tl { TS1 }
\AtBeginDocument {
  \@ifpackageloaded { fontspec }
    { \tl_set:Nx \c_siunitx_mu_tl { \char 181 } }
    { }
}
%    \end{macrocode}
%\end{macro}
%
% Some package redefine \cs{Omega} to be slanted and move the original
% symbol to \cs{upOmega}. This is handled here.
%    \begin{macrocode}
\tl_new:N \c_siunitx_omega_tl
\tl_set:Nn \c_siunitx_omega_tl { \Omega }
\AtBeginDocument {
  \cs_if_exist:NT \upOmega 
    { \tl_set:Nn \c_siunitx_omega_tl { \upOmega } }
}
%    \end{macrocode}
%
%\begin{macro}{\siunitx_tl_put_left_math:Nn}
%\begin{macro}{\siunitx_tl_put_left_math:NV}
%\begin{macro}{\siunitx_tl_put_left_math:cV}
%\begin{macro}{\siunitx_tl_put_right_math:Nn}
%\begin{macro}{\siunitx_tl_put_right_math:NV}
%\begin{macro}{\siunitx_tl_put_right_math:cV}
% To add stuff in math mode.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_tl_put_left_math:Nn #1#2 {
  \tl_put_left:Nn #1 { \siunitx_ensuremath:n {#2} }
}
\cs_generate_variant:Nn \siunitx_tl_put_left_math:Nn { NV }
\cs_generate_variant:Nn \siunitx_tl_put_left_math:Nn { cV }
\cs_new_protected:Npn \siunitx_tl_put_right_math:Nn #1#2 {
  \tl_put_right:Nn #1 { \siunitx_ensuremath:n {#2} }
}
\cs_generate_variant:Nn \siunitx_tl_put_right_math:Nn { NV }
\cs_generate_variant:Nn \siunitx_tl_put_right_math:Nn { cV }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\c_siunitx_old_options_seq}
% To pick up old options, all of the names need to be known.
%    \begin{macrocode}
\seq_new:N \c_siunitx_old_options_seq
\cs_set_protected_nopar:Npn \siunitx_tmp:w #1 {
  \seq_put_right:No \c_siunitx_old_options_seq { \tl_to_str:n {#1} }
}
\siunitx_tmp:w { addsign }
\siunitx_tmp:w { allowlitunits }
\siunitx_tmp:w { allowoptarg }
\siunitx_tmp:w { allowzeroexp }
\siunitx_tmp:w { alsoload }
\siunitx_tmp:w { angformat }
\siunitx_tmp:w { anglesep }
\siunitx_tmp:w { astroang }
\siunitx_tmp:w { closeerr }
\siunitx_tmp:w { closrfrac }
\siunitx_tmp:w { closerange }
\siunitx_tmp:w { colour }
\siunitx_tmp:w { colorall }
\siunitx_tmp:w { colourall }
\siunitx_tmp:w { colorneg }
\siunitx_tmp:w { colourneg }
\siunitx_tmp:w { colourunits }
\siunitx_tmp:w { colourunits }
\siunitx_tmp:w { colorvalues }
\siunitx_tmp:w { colourvalues }
\siunitx_tmp:w { decimalsymbol }
\siunitx_tmp:w { debug }
\siunitx_tmp:w { detectdisplay }
\siunitx_tmp:w { digitsep }
\siunitx_tmp:w { dp }
\siunitx_tmp:w { emulate }
\siunitx_tmp:w { errspace }
\siunitx_tmp:w { eVcorra }
\siunitx_tmp:w { eVcorrb }
\siunitx_tmp:w { expbase }
\siunitx_tmp:w { expproduct }
\siunitx_tmp:w { fixdp }
\siunitx_tmp:w { fixsf }
\siunitx_tmp:w { fraction }
\siunitx_tmp:w { inlinebold }
\siunitx_tmp:w { loctolang }
\siunitx_tmp:w { log }
\siunitx_tmp:w { load }
\siunitx_tmp:w { mathOmega }
\siunitx_tmp:w { mathcelsius }
\siunitx_tmp:w { mathdegree }
\siunitx_tmp:w { mathminute }
\siunitx_tmp:w { mathmu }
\siunitx_tmp:w { mathringA }
\siunitx_tmp:w { mathrm }
\siunitx_tmp:w { mathsOmega }
\siunitx_tmp:w { mathscelsius }
\siunitx_tmp:w { mathsdegree }
\siunitx_tmp:w { mathsecond }
\siunitx_tmp:w { mathsf }
\siunitx_tmp:w { mathsminute }
\siunitx_tmp:w { mathsmu }
\siunitx_tmp:w { mathsringA }
\siunitx_tmp:w { mathsrm }
\siunitx_tmp:w { mathssecond }
\siunitx_tmp:w { mathssf }
\siunitx_tmp:w { mathstt }
\siunitx_tmp:w { mathtt }
\siunitx_tmp:w { negcolor }
\siunitx_tmp:w { negcolour }
\siunitx_tmp:w { noload }
\siunitx_tmp:w { numaddn }
\siunitx_tmp:w { numcloseerr }
\siunitx_tmp:w { numdecimal }
\siunitx_tmp:w { numdigits }
\siunitx_tmp:w { numdiv }
\siunitx_tmp:w { numexp }
\siunitx_tmp:w { numgobble }
\siunitx_tmp:w { numopenerr }
\siunitx_tmp:w { numprod }
\siunitx_tmp:w { numsign }
\siunitx_tmp:w { obeyall }
\siunitx_tmp:w { obeybold }
\siunitx_tmp:w { obeyfamily }
\siunitx_tmp:w { obeymode }
\siunitx_tmp:w { obeyitalic }
\siunitx_tmp:w { openerr }
\siunitx_tmp:w { openfrac }
\siunitx_tmp:w { openrange }
\siunitx_tmp:w { padangle }
\siunitx_tmp:w { padnumber }
\siunitx_tmp:w { per }
\siunitx_tmp:w { prefixbase }
\siunitx_tmp:w { prefixproduct }
\siunitx_tmp:w { prefixsymbolic }
\siunitx_tmp:w { prespace }
\siunitx_tmp:w { redefsymbols }
\siunitx_tmp:w { repeatunits }
\siunitx_tmp:w { retainplus }
\siunitx_tmp:w { seperr }
\siunitx_tmp:w { sepfour }
\siunitx_tmp:w { sf }
\siunitx_tmp:w { sign }
\siunitx_tmp:w { slash }
\siunitx_tmp:w { stickyper }
\siunitx_tmp:w { strictarc }
\siunitx_tmp:w { tabalign }
\siunitx_tmp:w { tabalignexp }
\siunitx_tmp:w { tabautofit }
\siunitx_tmp:w { tabexpalign }
\siunitx_tmp:w { tabformat }
\siunitx_tmp:w { tabnumalign }
\siunitx_tmp:w { tabparseonly }
\siunitx_tmp:w { tabtextalign }
\siunitx_tmp:w { textOmega }
\siunitx_tmp:w { textcelsius }
\siunitx_tmp:w { textdegree }
\siunitx_tmp:w { textminute }
\siunitx_tmp:w { textmode }
\siunitx_tmp:w { textmu }
\siunitx_tmp:w { textringA }
\siunitx_tmp:w { textrm }
\siunitx_tmp:w { textsecond }
\siunitx_tmp:w { textsf }
\siunitx_tmp:w { texttt }
\siunitx_tmp:w { tightpm }
\siunitx_tmp:w { tophrase }
\siunitx_tmp:w { trapamigerr }
\siunitx_tmp:w { trapambigfrac }
\siunitx_tmp:w { trapambigrange }
\siunitx_tmp:w { unitcolor }
\siunitx_tmp:w { unitcolour }
\siunitx_tmp:w { unitmathrm }
\siunitx_tmp:w { unitmathsf }
\siunitx_tmp:w { unitmathsrm }
\siunitx_tmp:w { unitmathssf }
\siunitx_tmp:w { unitmathstt }
\siunitx_tmp:w { unitmathtt }
\siunitx_tmp:w { unitmode }
\siunitx_tmp:w { unitsep }
\siunitx_tmp:w { unitspace }
\siunitx_tmp:w { valuecolor }
\siunitx_tmp:w { valuecolour }
\siunitx_tmp:w { valuemathrm }
\siunitx_tmp:w { valuemathsf }
\siunitx_tmp:w { valuemathsrm }
\siunitx_tmp:w { valuemathssf }
\siunitx_tmp:w { valuemathstt }
\siunitx_tmp:w { valuemathtt }
\siunitx_tmp:w { valuemode }
\siunitx_tmp:w { valuesep }
\siunitx_tmp:w { xpace }
%    \end{macrocode}
%\end{macro}    
%
%\begin{macro}{\l_siunitx_key_tl}
% Unknown options should raise an \pkg{siunitx}-specific error message.
%    \begin{macrocode}
\tl_new:N  \l_siunitx_key_tl
\keys_define:nn { siunitx } {
  unknown .code:n = 
    { 
      \seq_if_in:NVTF \c_siunitx_old_options_seq \l_keys_key_tl
        {
          \msg_warning:nnx { siunitx } { version-1-option } 
            { \exp_not:V \l_keys_key_tl } 
          \tl_set:Nx \l_siunitx_key_tl
            { 
              \keys_set:nn { siunitx } 
                { 
                  \exp_not:V \l_keys_key_tl 
                    \tl_if_blank:nF {#1} { = \exp_not:n {#1} }
                }
            }
          \keys_set:nn { siunitx } { load-configurations = version-1 }
          \tl_use:N \l_siunitx_key_tl          
        }
        {
          \msg_error:nnx { siunitx } { unknown-option } 
            { \exp_not:V \l_keys_key_tl } 
        }  
    }
}
\AtBeginDocument {
  \keys_define:nn { siunitx } {
    unknown .code:n = 
      { 
        \seq_if_in:NVTF \c_siunitx_old_options_seq \l_keys_key_tl
          {
            \msg_error:nnx { siunitx } { version-1-option } 
              { \exp_not:V \l_keys_key_tl }          
          }
          {
            \msg_error:nnx { siunitx } { unknown-option } 
              { \exp_not:V \l_keys_key_tl } 
          }  
      }
}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_option_deactivate_clist}
%\begin{macro}{\siunitx_option_deactivate:n}
%\begin{macro}[aux]{\siunitx_option_deactivate_aux:n}
% Some options need to be deactivated at the start of the document.
%    \begin{macrocode}
\clist_new:N \l_siunitx_option_deactivate_clist
\cs_new_protected_nopar:Npn \siunitx_option_deactivate:n #1 {
  \clist_put_right:Nn \l_siunitx_option_deactivate_clist {#1}
}
\cs_new_protected_nopar:Npn \siunitx_option_deactivate_aux:n #1 {
  \keys_define:nn { siunitx } 
    {
      #1 .code:n = 
        { \msg_warning:nnx { siunitx } { option-preamble-only } {#1} }
    }
}
\AtBeginDocument {
  \clist_map_function:NN \l_siunitx_option_deactivate_clist
    \siunitx_option_deactivate_aux:n
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\prop_del:cn}
%\begin{macro}{\prop_put:cnV}
%\begin{macro}{\tl_replace_all_in:NnV}
% Variants needed which are not in \pkg{expl3}.
%    \begin{macrocode}
\cs_generate_variant:Nn \prop_del:Nn { c }
\cs_generate_variant:Nn \prop_put:Nnn { cnV }
\cs_generate_variant:Nn \tl_replace_all_in:Nnn { NnV }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_cs_if_tl_p:N}
%\begin{macro}[TF]{\siunitx_cs_if_tl:N}
%\begin{macro}[aux]{\siunitx_cs_if_tl_aux:w}
%\begin{macro}{\siunitx_cs_if_macro_p:N}
%\begin{macro}[TF]{\siunitx_cs_if_macro:N}
% This is basically a re-hash of stuff from \pkg{expl3}, but to test for
% short macros only. The second test (with the \cs{cs_to_str:N} part)
% is checking for \LaTeXe\ robust commands.
%    \begin{macrocode}
\group_begin:
\tl_map_inline:nn { \M \A \C \R \O } 
  { \char_make_other:n { `#1 } }
\tl_map_inline:nn { \F \N \T }
  { \char_set_lccode:nn { `#1 } { `#1 } } 
\tl_to_lowercase:n {
  \group_end:
  \prg_new_conditional:Npnn \siunitx_cs_if_tl:N #1 { T , F, TF , p } 
    {
      \exp_last_unbraced:No \siunitx_cs_if_tl_aux:w
        { \token_to_meaning:N #1 MACRO \q_stop }
          { 
            \cs_if_exist:cTF { \cs_to_str:N #1 ~ }
              { \prg_return_false: }
              { \prg_return_true: }
          } 
          { \prg_return_false: }
    }
  \cs_new_nopar:Npn \siunitx_cs_if_tl_aux:w #1 MACRO #2 \q_stop 
    { \tl_if_empty:nTF {#1} }
  \prg_new_conditional:Npnn \siunitx_cs_if_macro:N #1 
    { T , F , TF , p } 
    {
      \exp_last_unbraced:No \siunitx_cs_if_tl_aux:w
        { \token_to_meaning:N #1 MACRO \q_stop }
          { \prg_return_true: }
          { \prg_return_false: }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_ensuremath:n}
% A copy is made of \cs{ensuremath}: if \pkg{tex4ht} is in use, it
% is possible to deactivate this to give nicer looking conversion to
% other formats.
%    \begin{macrocode}
\cs_new_eq:NN \siunitx_ensuremath:n \ensuremath
\AtBeginDocument {
  \@ifpackageloaded { tex4ht }
    { 
      \cs_set_eq:NN \siunitx_ensuremath:n \use:n 
      \keys_set:nn { siunitx } { mode = text }
    }
    { }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_display_math_bool}
% To test for display math, a flag is added to the start of every
% display environment.
%    \begin{macrocode}
\bool_new:N \l_siunitx_display_math_bool
\toks_put_right:Nn \tex_everydisplay:D 
  { \bool_set_true:N \l_siunitx_display_math_bool }
%    \end{macrocode}
%\end{macro}
%
%\subsection{Font detection}
%
% A number of controls and tests are needed to control the font used
% for output.  The detection routines set up various functions which can
% then be used inside the \cs{text} macro from the \pkg{amstext}
% package.  By carrying out the changes outside math mode, bold can
% reliably be applied to math output.
% 
%\begin{macro}{\c_siunitx_mathsf_int}
%\begin{macro}{\c_siunitx_mathtt_int}
%\begin{macro}{\siunitx_set_math_fam:n}
% The detection routine needs some basic data about the sans serif and
% monospaced fonts in use.  This is collected up at the start of the 
% document. The families used can change between here and the start of 
% the document. This is run as a hook onto \cs{document}, rather than
% using \cs{AtBeginDocument} as it has to come after anything that
% \pkg{fontspec} does (nasty errors arise otherwise). 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_set_math_fam:n #1 {
  \int_new:c { c_siunitx_math #1 _int }
  \group_begin:
    \hbox_set:Nn \l_siunitx_tmp_box 
      {
        \ensuremath 
          {
            \use:c { math #1 } 
              {
                \int_gset:cn { c_siunitx_math #1 _int } { \fam }  
              }
          }
      }  
  \group_end:
}
\tl_put_right:Nn \document {
  \siunitx_set_math_fam:n { sf }
  \siunitx_set_math_fam:n { tt }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_font_set_text_fam:n}
%\begin{macro}{\c_siunitx_textsf_tl}
%\begin{macro}{\c_siunitx_texttt_tl}
% The text families are done in a somewhat different manner: there are 
% no issues with \cs{AtBeginDocument}, luckily. The need to define 
% new macros here arises as \cs{sfdefault} and \cs{ttdefault} are 
% \cs{long}, whereas \cs{f@family} is not.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_set_text_fam:n #1 {
  \tl_new:c { c_siunitx_text #1 _tl }
  \tl_set:cx { c_siunitx_text #1 _tl } { \use:c { #1 default } }
}
\AtBeginDocument {
  \siunitx_set_text_fam:n { sf }
  \siunitx_set_text_fam:n { tt }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_detect_inline_weight_tl}
% Used by the keys, but needs to be created here.
%    \begin{macrocode}
\tl_new:N \l_siunitx_detect_inline_weight_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_detect_display_math_bool}
%\begin{macro}{\l_siunitx_detect_family_bool}
%\begin{macro}{\l_siunitx_detect_inline_family_tl}
%\begin{macro}{\l_siunitx_detect_inline_weight_tl}
%\begin{macro}{\l_siunitx_detect_shape_bool}
%\begin{macro}{\l_siunitx_detect_mode_bool}
%\begin{macro}{\l_siunitx_detect_weight_bool}
% Font detection is all about creating switches, with just a little
% gloss for \texttt{detect-all} and \texttt{detect-none}.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  detect-all .choice:,
  detect-all .default:n = true,
  detect-all / false .meta:n = 
    {
      detect-family = false,
      detect-mode   = false,
      detect-shape  = false,
      detect-weight = false
    },
  detect-all / true .meta:n = 
    {
      detect-family = true,
      detect-mode   = true,
      detect-shape  = true,
      detect-weight = true
    },
  detect-display-math  .bool_set:N = 
    \l_siunitx_detect_display_math_bool,
  detect-family        .bool_set:N = \l_siunitx_detect_family_bool,
  detect-inline-family .choice:,
  detect-inline-family .value_required:,
  detect-inline-family / 
    math               .code:n     = 
      { \tl_set:Nn \l_siunitx_detect_inline_family_tl { math } },
  detect-inline-family / 
    text               .code:n     = 
      { \tl_set:Nn \l_siunitx_detect_inline_family_tl { text } },
  detect-inline-weight .choice:,
  detect-inline-weight .value_required:,
  detect-inline-weight / 
    math               .code:n     = 
      { \tl_set:Nn \l_siunitx_detect_inline_weight_tl { math } },
  detect-inline-weight / 
    text               .code:n     = 
      { \tl_set:Nn \l_siunitx_detect_inline_weight_tl { text } },
  detect-italic        .bool_set:N = \l_siunitx_detect_shape_bool,
  detect-mode          .bool_set:N = \l_siunitx_detect_mode_bool,
  detect-none          .choice:,
  detect-none          .default:n = true,
  detect-none / false .meta:n = 
    {
      detect-family = true,
      detect-mode   = true,
      detect-shape  = true,
      detect-weight = true
    },
  detect-none / true .meta:n = 
    {
      detect-family = false,
      detect-mode   = false,
      detect-shape  = false,
      detect-weight = false
    },
  detect-shape         .bool_set:N = \l_siunitx_detect_shape_bool,
  detect-weight        .bool_set:N = \l_siunitx_detect_weight_bool
}
\keys_set:nn { siunitx } {
  detect-inline-family = text ,
  detect-inline-weight = text ,
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_font_set_bool}
%\begin{macro}{\l_siunitx_font_math_mode_bool}
% The internals of the package need a number of switches to track what
% is happening.
%    \begin{macrocode}
\bool_new:N \l_siunitx_font_set_bool
\bool_new:N \l_siunitx_font_math_mode_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_font_family_tl}
% Also some token storage.
%    \begin{macrocode}
\tl_new:N \l_siunitx_font_family_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_font_shape:}
%\begin{macro}{\siunitx_font_weight:}
% These could be token lists or functions!
%    \begin{macrocode}
\cs_new_nopar:Npn \siunitx_font_shape: { }
\cs_new_nopar:Npn \siunitx_font_weight: { }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_detect_font:}
% The main font-setting macro is a control point for the other
% functions.  Nesting font-control should not happen, so the first
% test is to ensure this is not happening.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font: {
  \bool_if:NF \l_siunitx_font_set_bool 
    {
      \siunitx_detect_font_init:
      \bool_if:NT \l_siunitx_detect_weight_bool 
        { \siunitx_detect_font_weight: }
      \bool_if:NT \l_siunitx_detect_family_bool 
        { \siunitx_detect_font_family: }
      \bool_if:NT \l_siunitx_detect_shape_bool 
        { \siunitx_detect_font_shape: }
      \bool_if:NT \l_siunitx_detect_mode_bool 
        { \siunitx_detect_font_mode: }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_detect_font_init:}
% Set up the basic macros on the assumption nothing happens.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font_init: {
  \bool_set_true:N \l_siunitx_font_set_bool
  \cs_set:Npn \siunitx_font_weight: 
    {
      \unboldmath 
      \mdseries
    }
  \cs_set:Npn \siunitx_font_shape: { \upshape }
  \tl_set:Nn \l_siunitx_font_family_tl { rm }
  \bool_set_true:N \l_siunitx_font_math_mode_bool
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_detect_font_weight:}
% The font weight detection code depends on whether the current text is 
% math or text, and also the type of math (if appropriate).  For 
% inline math, there is a choice of what test to apply.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font_weight: {
  \mode_if_math:TF 
    {
      \bool_if:NTF \l_siunitx_display_math_bool
        {
          \bool_if:NTF \l_siunitx_detect_display_math_bool 
            { \siunitx_detect_font_weight_math: }
            { \siunitx_detect_font_weight_text: }
        }
        {
          \use:c 
            {
              siunitx_detect_font_weight_ 
              \l_siunitx_detect_inline_weight_tl
              :
            }
        }
    }
    { \siunitx_detect_font_weight_text: }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_detect_font_weight_math:}
%\begin{macro}{\siunitx_detect_font_weight_text:}
% The tests for font weight depend on whether the module is testing 
% text or math content.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font_weight_math: {
  \str_if_eq:VnT \math@version { bold }
    {
      \cs_set:Npn \siunitx_font_weight: 
        {
          \boldmath
          \bfseries
        }
    }
  \str_if_eq:VnT \math@version { light } 
    { \cs_set:Npn \siunitx_font_weight: { \lseries } }
}
\cs_new_protected_nopar:Npn \siunitx_detect_font_weight_text: {
  \tl_set:Nx \l_siunitx_tmpa_tl { \tl_head:V \f@series }
  \str_if_eq:VnT \l_siunitx_tmpa_tl { b }
    {
      \cs_set:Npn \siunitx_font_weight: 
        {
          \boldmath
          \bfseries
        }
    }
  \str_if_eq:VnT \l_siunitx_tmpa_tl { l }
    { \cs_set:Npn \siunitx_font_weight: { \lseries } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_detect_font_family:}
% Family detection usually picks up the surrounding text.  However, for
% display math there are two options, and so a second test may be made.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font_family: {
  \mode_if_math:TF 
    {
      \bool_if:NTF \l_siunitx_display_math_bool
        {
          \bool_if:NTF \l_siunitx_detect_display_math_bool 
            { \siunitx_detect_font_family_math: }
            { \siunitx_detect_font_family_text: }
        }
        {
          \use:c 
            {
              siunitx_detect_font_family_ 
              \l_siunitx_detect_inline_family_tl
              :
            }
        }
    }
    { \siunitx_detect_font_family_text: }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_detect_font_family_math:}
%\begin{macro}{\siunitx_detect_font_family_text:}
% The two detections routines check if the current font is sans serif or
% monospaced.  The method used depends on whether the current math or
% text font is of interest. The math detection routine re-applies the 
% default (\texttt{rm}), as the text function is always called and may
% have changed things.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font_family_math: {
  \tl_set:Nn \l_siunitx_font_family_tl { rm }
  \int_compare:nNnT { \fam } = { \c_siunitx_mathsf_int } 
    { \tl_set:Nn \l_siunitx_font_family_tl { sf } }
  \int_compare:nNnT { \fam } = { \c_siunitx_mathtt_int } 
    { \tl_set:Nn \l_siunitx_font_family_tl { tt } }
}
\cs_new_protected_nopar:Npn \siunitx_detect_font_family_text: {
  \tl_if_eq:NNT \f@family \c_siunitx_textsf_tl 
    { \tl_set:Nn \l_siunitx_font_family_tl { sf } }
  \tl_if_eq:NNT \f@family \c_siunitx_texttt_tl 
    { \tl_set:Nn \l_siunitx_font_family_tl { tt } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_detect_font_shape:}
% The shape test uses \cs{f@shape} as a handy indicator.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font_shape: {
  \str_if_eq:VnT \f@shape { it }
    { \cs_set_nopar:Npn \siunitx_font_shape: { \itshape } }
  \str_if_eq:VnT \f@shape { sl }
    { \cs_set_nopar:Npn \siunitx_font_shape: { \slshape } }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_detect_font_mode:}
% The mode switch works from the fact that math mode output it the
% standard.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_detect_font_mode: {
  \mode_if_math:F 
    { 
      \bool_set_false:N \l_siunitx_font_math_mode_bool
      \bool_set_false:N \l_siunitx_number_math_mode_bool
      \bool_set_false:N \l_siunitx_unit_math_mode_bool
    }
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Font macros}
%
% With the detection routines in place, the module can apply the result
% to control the font used for output. This requires a series of font 
% names to be available. The appropriate storage areas will be selected
% by name, based on output type (\texttt{unit} or \texttt{value}) and
% the family selected by the detector.
% 
%\begin{macro}{\l_siunitx_number_math_mode_bool}
%\begin{macro}{\l_siunitx_unit_math_mode_bool}
% Most of the variables are created by the keys system: these are not.
%    \begin{macrocode}
\bool_new:N \l_siunitx_number_math_mode_bool
\bool_new:N \l_siunitx_unit_math_mode_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_color_tl}
%\begin{macro}{\siunitx_number_mathrm:n}
%\begin{macro}{\siunitx_number_mathsf:n}
%\begin{macro}{\siunitx_number_mathtt:n}
%\begin{macro}{\siunitx_number_textrm:}
%\begin{macro}{\siunitx_number_textsf:}
%\begin{macro}{\siunitx_number_texttt:}
% The settings are actually created separately for numbers and units:
% numbers first.
%    \begin{macrocode}
\cs_new:Npn \siunitx_number_mathrm:n #1 { }
\cs_new:Npn \siunitx_number_mathsf:n #1 { }
\cs_new:Npn \siunitx_number_mathtt:n #1 { }
\cs_new_nopar:Npn \siunitx_number_textrm: { }
\cs_new_nopar:Npn \siunitx_number_textsf: { }
\cs_new_nopar:Npn \siunitx_number_texttt: { }
\keys_define:nn { siunitx } {
  number-color  .tl_set:N    = \l_siunitx_number_color_tl,
  number-math-rm .code:n  =
    { \cs_set_nopar:Npn \siunitx_number_mathrm:n ##1 { #1 {##1} } },
  number-math-sf .code:n  =
    { \cs_set_nopar:Npn \siunitx_number_mathsf:n ##1 { #1 {##1} } },
  number-math-tt .code:n  = 
    { \cs_set_nopar:Npn \siunitx_number_mathtt:n ##1 { #1 {##1} } },
  number-mode .choice:,
  number-mode / math .code:n = 
    { \bool_set_true:N \l_siunitx_number_math_mode_bool },
  number-mode / text .code:n =
    { \bool_set_false:N \l_siunitx_number_math_mode_bool },
  number-text-rm .code:n  = 
    { \cs_set_nopar:Npn \siunitx_number_textrm: {#1} },
  number-text-sf .code:n  = 
    { \cs_set_nopar:Npn \siunitx_number_textsf: {#1} },
  number-text-tt .code:n  = 
    { \cs_set_nopar:Npn \siunitx_number_texttt: {#1} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}  
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%    
%\begin{macro}{\l_siunitx_unit_color_tl}
%\begin{macro}{\siunitx_unit_mathrm:n}
%\begin{macro}{\siunitx_unit_mathsf:n}
%\begin{macro}{\siunitx_unit_mathtt:n}
%\begin{macro}{\siunitx_unit_textrm:}
%\begin{macro}{\siunitx_unit_textsf:}
%\begin{macro}{\siunitx_unit_texttt:}
% Units look exactly the same. 
%    \begin{macrocode}
\cs_new_nopar:Npn \siunitx_unit_mathrm: { }
\cs_new_nopar:Npn \siunitx_unit_mathsf: { }
\cs_new_nopar:Npn \siunitx_unit_mathtt: { }
\cs_new_nopar:Npn \siunitx_unit_textrm: { }
\cs_new_nopar:Npn \siunitx_unit_textsf: { }
\cs_new_nopar:Npn \siunitx_unit_texttt: { }
\keys_define:nn { siunitx } {
  unit-color  .tl_set:N  = \l_siunitx_unit_color_tl,
  unit-math-rm .code:n =
    { \cs_set_nopar:Npn \siunitx_unit_mathrm:n ##1 { #1 {##1} } },
  unit-math-sf .code:n = 
    { \cs_set_nopar:Npn \siunitx_unit_mathsf:n ##1 { #1 {##1} } },
  unit-math-tt .code:n = 
    { \cs_set_nopar:Npn \siunitx_unit_mathtt:n ##1 { #1 {##1} } },
  unit-mode .choice:,
  unit-mode / math .code:n = 
    { \bool_set_true:N \l_siunitx_unit_math_mode_bool },
  unit-mode / text .code:n = 
    { \bool_set_false:N \l_siunitx_unit_math_mode_bool },
  unit-text-rm .code:n = 
    { \cs_set_nopar:Npn \siunitx_unit_textrm: {#1} },
  unit-text-sf .code:n =
    { \cs_set_nopar:Npn \siunitx_unit_textsf: {#1} },
  unit-text-tt .code:n =
    { \cs_set_nopar:Npn \siunitx_unit_texttt: {#1} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}  
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
% The general settings are all meta-keys. A few initial values are set
% here as they are needed for everything to work.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  color .meta:n = 
    {
      number-color = #1,
      unit-color   = #1
    },
  math-rm .meta:n = 
    {
      number-math-rm = #1,
      unit-math-rm   = #1
    },
  math-sf .meta:n = 
    {
      number-math-sf = #1,
      unit-math-sf   = #1
    },
  math-tt .meta:n = 
    {
      number-math-tt = #1,
      unit-math-tt   = #1
    },
  mode .choice:,
  mode / math .meta:n = 
    {
      number-mode = math,
      unit-mode   = math
    },
  mode / text .meta:n = 
    {
      number-mode = text,
      unit-mode   = text
    },
  text-rm .meta:n = 
    {
      number-text-rm = #1,
      unit-text-rm   = #1
    },
  text-sf .meta:n = 
    {
      number-text-sf = #1,
      unit-text-sf   = #1
    },
  text-tt .meta:n = 
    {
      number-text-tt = #1,
      unit-text-tt   = #1
    }
}
\keys_set:nn { siunitx } {
  math-rm     = \mathrm,
  math-sf     = \mathsf,
  math-tt     = \mathtt,
  number-mode = math,
  text-rm     = \rmfamily,
  text-sf     = \sffamily,
  text-tt     = \ttfamily,
}
%    \end{macrocode}
%    
% Some packages and classes (for example \pkg{beamer}) set the default 
% family to be something other than serif family. A one-off detection 
% will make life easier
% all round.
%    \begin{macrocode}
\AtBeginDocument {
  \tl_set:Nx \l_siunitx_tmpa_tl { \familydefault }
  \tl_if_eq:NNT \l_siunitx_tmpa_tl \c_siunitx_textsf_tl 
    {
      \@ifpackageloaded { cmbright } { }
        { \keys_set:nn { siunitx } { math-rm = \mathsf } }
      \keys_set:nn { siunitx } { text-rm  = \sffamily }
    }
  \tl_if_eq:NNT \l_siunitx_tmpa_tl \c_siunitx_texttt_tl 
    {
      \keys_set:nn { siunitx } 
        {
          math-rm = \mathtt,
          text-rm  = \ttfamily
        }
    }
}
%    \end{macrocode}
%    
%\subsection{Output control}
%
% The \pkg{siunitx} output routine uses all of the font information
% gathered earlier to print the text given in whatever font is required.
% The low-level stuff is done here, with the calling routines expected
% to have taken some steps first (this is to allow line breaks in the
% appropriate places).
% 
%\begin{macro}{\l_siunitx_print_arg_tl}
% The text to print.
%    \begin{macrocode}
\tl_new:N \l_siunitx_print_arg_tl
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_print_type_tl}
% The type of output (\texttt{number} or \texttt{unit}) is always 
% needed.
%    \begin{macrocode}
\tl_new:N \l_siunitx_print_type_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_print:nn}
%\begin{macro}{\siunitx_print:nV}
% The main printing function does everything inside a group, as 
% there are category code and definition changes to make. First, set
% the fonts.  Then move on to printing mode, before moving to actual
% printing.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_print:nn #1#2 {
  \group_begin:
    \tl_set:Nn \l_siunitx_print_type_tl {#1}
    \tl_set:Nn \l_siunitx_print_arg_tl {#2}
    \siunitx_detect_font:
    \bool_if:NF \l_siunitx_detect_mode_bool 
      {
        \bool_if:cTF { l_siunitx_ #1 _math_mode_bool } 
          { \bool_set_true:N \l_siunitx_font_math_mode_bool }
          { \bool_set_false:N \l_siunitx_font_math_mode_bool }
      }
    \siunitx_print_aux:
  \group_end:
}
\cs_generate_variant:Nn \siunitx_print:nn { nV }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}[aux]{\siunitx_print_aux:}
% The various font changes are set up, then the correct printing
% function is called. Everything is inside \cs{text} as this allows 
% proper setting of the various mode settings.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_print_aux: {
  \text 
    {
      \siunitx_print_color:
      \siunitx_font_shape:
      \siunitx_font_weight:
      \use:c 
        { 
          siunitx_ \l_siunitx_print_type_tl _  
          text \l_siunitx_font_family_tl :
        }
      \bool_if:NTF \l_siunitx_font_math_mode_bool 
        { \siunitx_print_math: }
        { \siunitx_print_text: }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_print_color:}
% The colour system checks if \pkg{color} is loaded, and only does
% anything if it is.  This will change when \LaTeX3 proper is available:
% there will be colour out of the box!
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_print_color: {
  \tl_if_empty:cF { l_siunitx_ \l_siunitx_print_type_tl _color_tl } 
    {
      \color 
        {
          \tl_use:c { l_siunitx_ \l_siunitx_print_type_tl _color_tl }
        }
    }
}
\AtBeginDocument {
  \@ifpackageloaded { color } { } 
    { \cs_set_eq:NN \siunitx_print_color: \scan_stop: }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_print_math:}
%\begin{macro}{\siunitx_print_text:}
% Printing the text means replacing any awkward characters, which is
% dependent on the output mode. The rest of the package uses "_" and
% "^" to represent sub- and superscripts, respectively. In this way, 
% mode decisions can be delayed as long as possible.  The
% \pkg{underscore} package may make "_" active, or more likely
% it will be a superscript character. Both are tested for here.
%    \begin{macrocode}
\group_begin:
  \char_set_lccode:nn { `\@ } { `\_ }
  \char_make_math_subscript:N \@
  \char_set_lccode:nn { `\! } { `\_ }
  \char_make_active:N \!
\tl_to_lowercase:n {
  \group_end:
  \cs_set_protected_nopar:Npn \siunitx_print_math: 
    {
      \ensuremath 
        {
          \use:c 
            {
              siunitx_ \l_siunitx_print_type_tl _ 
              math \l_siunitx_font_family_tl :n
            } 
              { \l_siunitx_print_arg_tl }
        }
    }
  \cs_set_protected_nopar:Npn \siunitx_print_text: 
    {
      \tl_replace_all_in:Nnn \l_siunitx_print_arg_tl { @ } 
        { \siunitx_print_text_sub:n }
      \tl_replace_all_in:Nnn \l_siunitx_print_arg_tl { ! } 
        { \siunitx_print_text_sub:n }
      \tl_replace_all_in:Nnn \l_siunitx_print_arg_tl { ^ } 
        { \siunitx_print_text_super:n }
      \l_siunitx_print_arg_tl
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_print_text_sub:n}
%\begin{macro}[aux]{\siunitx_print_text_sub_super:n}
%\begin{macro}{\siunitx_print_text_super:n}
% The appropriate macros for sub- and superscript in text mode ensure
% the appearance is the same as math mode. As "_" is a letter, there
% is the need to do a category-code juggle. The search and replace 
% code for superscripts deals with the case where a literal number has
% been given with text mode printing.
%    \begin{macrocode}
\group_begin:
  \char_set_lccode:nn { `\@ } { `\_ }
  \char_make_math_subscript:N \@
\tl_to_lowercase:n {
  \group_end:
  \cs_set_protected:Npn \siunitx_print_text_sub:n #1 
    { 
      \cs_set:Npn \siunitx_print_text_sub_super:n ##1
        {
          \ensuremath 
            { 
              @ { \text {#1} } 
              ^ { \text {##1} }
            }
        }
      \peek_meaning_remove:NTF \siunitx_print_text_super:n
        { \siunitx_print_text_sub_super:n }
        { \ensuremath { @ { \text {#1} } } }
    }
}
\cs_new_protected:Npn \siunitx_print_text_sub_super:n { }
\cs_new_protected:Npn \siunitx_print_text_super:n #1 {
  \tl_set:Nn \l_siunitx_tmpa_tl {#1}
  \tl_replace_all_in:Nnn \l_siunitx_tmpa_tl { - } 
    { \c_siunitx_minus_tl }
  \tl_set:Nx \l_siunitx_tmpa_tl
    {
      \exp_not:N \ensuremath
        {
          ^ { \exp_not:N \text { \exp_not:V \l_siunitx_tmpa_tl } }
        }
    }
  \l_siunitx_tmpa_tl
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Pre-processing numbers}
%
% Before the main parsing routine can be called, there is a need to 
% pre-process the input. The possibility that the data in can contain
% more than one number needs to be handled.
% 
%\begin{macro}{\l_siunitx_input_product_tl}
%\begin{macro}{\l_siunitx_input_quotient_tl}
% There are a couple of settings which are created here as they are used
% only for pre-processing.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  input-product  .tl_set:N = \l_siunitx_input_product_tl,
  input-quotient .tl_set:N = \l_siunitx_input_quotient_tl,
}
\keys_set:nn { siunitx } {
  input-product  = x,
  input-quotient = /
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_arg_tl}
%\begin{macro}{\l_siunitx_number_next_tl}
% Storage for the pre-parsed material.  The \texttt{arg} variable 
% contains the current argument, the \texttt{next} variable contains
% anything held-over for the next round.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_arg_tl
\tl_new:N \l_siunitx_number_next_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_multi_tl}
% For products and quotients, a way of feeding information back.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_multi_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_denominator_tl}
%\begin{macro}{\l_siunitx_number_numerator_tl}
% When searching for quotients, some more storage is needed.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_denominator_tl
\tl_new:N \l_siunitx_number_numerator_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_preprocess:n}
%\begin{macro}{\siunitx_number_preprocess:V}
% The pre-processor starts with the obvious: the most likely outcome is
% that all of the argument is passed through unchanged.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_preprocess:n #1 {
  \siunitx_number_preprocess_init:
  \tl_set:Nn \l_siunitx_number_arg_tl {#1}
  \siunitx_number_preprocess_product:
  \tl_if_empty:NT \l_siunitx_number_multi_tl 
    { \siunitx_number_preprocess_quotient: }
}
\cs_generate_variant:Nn \siunitx_number_preprocess:n { V }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_preprocess_init:}
% A little initialisation as normal.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_preprocess_init: {
  \bool_set_false:N \l_siunitx_error_bool
  \tl_clear:N \l_siunitx_number_multi_tl
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_preprocess_product:}
%\begin{macro}[aux]{\siunitx_number_preprocess_product_aux:N}
% Rather than search through the entire argument, we use the 
% delimited-argument trick.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_preprocess_product: {
  \tl_map_function:NN \l_siunitx_input_product_tl
    \siunitx_number_preprocess_product_aux:N
}
\cs_new_protected:Npn \siunitx_number_preprocess_product_aux:N #1 {
  \tl_if_in:NnT \l_siunitx_number_arg_tl {#1} 
    {
      \cs_set:Npn \siunitx_tmp:w ##1 #1 ##2 \q_stop 
        {
          \tl_set:Nn \l_siunitx_number_arg_tl {##1}
          \tl_set:Nn \l_siunitx_number_next_tl {##2}
          \tl_set:Nn \l_siunitx_number_multi_tl { product }      
        }
      \exp_last_unbraced:NV \siunitx_tmp:w \l_siunitx_number_arg_tl 
        \q_stop
      \tl_if_empty:NT \l_siunitx_number_arg_tl
        { \siunitx_error:n { starting-product-token } }
      \tl_if_empty:NT \l_siunitx_number_next_tl 
        { \siunitx_error:n { ending-product-token } }
      \tl_map_break:
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_preprocess_quotient:}
%\begin{macro}[aux]{\siunitx_number_preprocess_quotient_aux:N}
% For the quotient, only one token can appear in each part. So there
% is an additional error check.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_preprocess_quotient: {
  \tl_map_function:NN \l_siunitx_input_quotient_tl
    \siunitx_number_preprocess_quotient_aux:N
}
\cs_new_protected:Npn \siunitx_number_preprocess_quotient_aux:N #1 {
  \tl_if_in:NnT \l_siunitx_number_arg_tl {#1} 
    {
      \cs_set:Npn \siunitx_tmp:w ##1 #1 ##2 \q_stop 
        {
          \tl_set:Nn \l_siunitx_number_numerator_tl {##1}
          \tl_set:Nn \l_siunitx_number_denominator_tl {##2}     
          \tl_set:Nn \l_siunitx_number_multi_tl { quotient } 
        }
      \exp_last_unbraced:NV \siunitx_tmp:w \l_siunitx_number_arg_tl 
        \q_stop
      \tl_if_empty:NT \l_siunitx_number_numerator_tl 
        { \siunitx_error:n { starting-quotient-token } }
      \tl_if_empty:NT \l_siunitx_number_denominator_tl
        { \siunitx_error:n { ending-quotient-token } }
      \tl_if_in:NnT \l_siunitx_number_denominator_tl {#1}
        { \siunitx_error:n { duplicate-quotient-token } }
      \tl_map_break:
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Parsing numbers}
%
% The parser is designed to be relativity fast, which means some code is
% more or less duplicated to gain more speed. It is also loaded so
% that simple numbers (such as \num{-1.23}) are parsed particularly
% quickly. For most documents, this gain more than offsets any slight
% losses with more complicated numbers.
% 
%\begin{macro}{\c_siunitx_number_part_complex_tl}
% A couple of the comparisons needed for checking complex numbers
% are done using stored text. To make them a little quicker, a
% pre-stored version of the text is stored here.
%    \begin{macrocode}
\tl_new:N \c_siunitx_number_part_complex_tl
\tl_set:Nn \c_siunitx_number_part_complex_tl { complex }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_in_complex_bool}
%\begin{macro}{\l_siunitx_number_in_complex_root_bool}
%\begin{macro}{\l_siunitx_number_in_decimal_bool}
%\begin{macro}{\l_siunitx_number_in_exponent_bool}
%\begin{macro}{\l_siunitx_number_in_first_bool}
%\begin{macro}{\l_siunitx_number_in_sign_bool}
%\begin{macro}{\l_siunitx_number_in_uncert_bool}
%\begin{macro}{\l_siunitx_number_in_value_bool}
%    \begin{macrocode}
\bool_new:N \l_siunitx_number_in_complex_bool
\bool_new:N \l_siunitx_number_in_complex_root_bool
\bool_new:N \l_siunitx_number_in_decimal_bool
\bool_new:N \l_siunitx_number_in_exponent_bool
\bool_new:N \l_siunitx_number_in_first_bool
\bool_new:N \l_siunitx_number_in_sign_bool
\bool_new:N \l_siunitx_number_in_uncert_bool
\bool_new:N \l_siunitx_number_in_value_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_in_prop}
% The parsed number is stored in a property list as its constituent 
% parts.
%    \begin{macrocode}
\prop_new:N \l_siunitx_number_in_prop
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_parsed_tl}
% Each part of the number parsed has to be built up in a token list.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_parsed_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_part_tl}
%\begin{macro}{\l_siunitx_number_part_decimal_tl}
%\begin{macro}{\l_siunitx_number_part_decimal_marker_tl}
%\begin{macro}{\l_siunitx_number_part_integer_tl}
%\begin{macro}{\l_siunitx_number_part_sign_tl}
%\begin{macro}{\l_siunitx_number_part_uncert_tl}
% The names of various parts of a number are set up as stored values.
% This lets some code be used for different parts of a number, while
% pre-storing everything brings a performance (and clarity) benefit.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_part_tl
\tl_new:N \l_siunitx_number_part_decimal_tl
\tl_new:N \l_siunitx_number_part_decimal_marker_tl
\tl_new:N \l_siunitx_number_part_integer_tl
\tl_new:N \l_siunitx_number_part_sign_tl
\tl_new:N \l_siunitx_number_part_uncert_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_input_uncert_close_tl}
%\begin{macro}{\l_siunitx_input_complex_tl}
%\begin{macro}{\l_siunitx_input_comparator_tl}
%\begin{macro}{\l_siunitx_input_decimal_tl}
%\begin{macro}{\l_siunitx_input_digit_tl}
%\begin{macro}{\l_siunitx_input_exponent_tl}
%\begin{macro}{\l_siunitx_input_ignore_tl}
%\begin{macro}{\l_siunitx_input_uncert_open_tl}
%\begin{macro}{\l_siunitx_input_protect_tl}
%\begin{macro}{\l_siunitx_input_sign_tl}
%\begin{macro}{\l_siunitx_input_symbol_tl}
% The various tokens to check against when parsing are all set up here.
% These are valid inside a single number: the pre-processor has already
% set up the appropriate things for products and quotients.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  input-close-uncertainty .tl_set:N = \l_siunitx_input_uncert_close_tl, 
  input-complex-roots     .tl_set:N = \l_siunitx_input_complex_tl,
  input-comparators       .tl_set:N = \l_siunitx_input_comparator_tl,
  input-decimal-markers   .tl_set:N = \l_siunitx_input_decimal_tl,
  input-digits            .tl_set:N = \l_siunitx_input_digit_tl,
  input-exponent-markers  .tl_set:N = \l_siunitx_input_exponent_tl,
  input-ignore            .tl_set:N = \l_siunitx_input_ignore_tl,
  input-open-uncertainty  .tl_set:N = \l_siunitx_input_uncert_open_tl, 
  input-protect-tokens    .tl_set:N = \l_siunitx_input_protect_tl,
  input-signs             .tl_set:N = \l_siunitx_input_sign_tl,
  input-symbols           .tl_set:N = \l_siunitx_input_symbol_tl,
}
\keys_set:nn { siunitx } { % (
  input-close-uncertainty = ),
  input-complex-roots     = ij,
  input-comparators       = {<=>\approx\ge\geq\gg\le\leq\ll\sim},
  input-decimal-markers   = {.,},
  input-digits            = 0123456789,
  input-exponent-markers  = dDeE,
  input-open-uncertainty  = (, % )
  input-protect-tokens    = \approx\ge\geq\gg\le\leg\ll\mp\pi\pm\sim,
  input-signs             = +-\mp\pm,
  input-symbols           = \pi,
}
%    \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}{\siunitx_number_in_parse:n}
%\begin{macro}{\siunitx_number_in_parse:V}
%\begin{macro}[aux]{\siunitx_number_in_parse_aux:n}
% The parsing routine starts by replacing any formatting in the input
% using \cs{tl_set_rescan:Nnx}. Next, there is a quick routine to
% ensure that all signs are single tokens. The main loop then takes 
% place, which will parse the input into the property list and also
% set up the flags. There are then some checks and possible corrections.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse:n #1 {
  \tl_if_empty:nF {#1} 
    { 
      \siunitx_number_in_init:
      \cs_set_eq:NN \siunitx_number_in_parse_more:N
        \siunitx_number_in_parse_mantissa_aux:N
      \siunitx_number_in_parse_aux:n {#1} 
    }
}
\cs_generate_variant:Nn \siunitx_number_in_parse:n { V }
\cs_new_protected:Npn \siunitx_number_in_parse_aux:n #1 {
  \tl_set_rescan:Nnx \l_siunitx_number_arg_tl
    {
      \siunitx_number_in_protect:
      \char_make_ignore:N \~
      \char_make_other:N \,
      \char_make_other:N \.
      \cs_set_eq:NN \, \prg_do_nothing:
    }
    {#1}
  \siunitx_number_in_sign_replace:N \l_siunitx_number_arg_tl
  \siunitx_number_in_parse_relation:N \l_siunitx_number_arg_tl
  \tl_map_function:NN \l_siunitx_number_arg_tl 
    \siunitx_number_in_parse_loop:N
  \tl_if_empty:NF \l_siunitx_number_parsed_tl
    {
      \bool_if:NTF \l_siunitx_number_in_uncert_bool
        { \siunitx_error:nx { invalid-number } {#1} }
        {
          \prop_put:NVn \l_siunitx_number_in_prop 
            \l_siunitx_number_part_tl { true }
          \bool_if:NTF \l_siunitx_number_in_decimal_bool  
            {
              \prop_put:NVV \l_siunitx_number_in_prop 
                \l_siunitx_number_part_decimal_tl 
                \l_siunitx_number_parsed_tl
            }
            {
              \prop_put:NVV \l_siunitx_number_in_prop 
                \l_siunitx_number_part_integer_tl 
                \l_siunitx_number_parsed_tl
            }
       }     
    }
  \siunitx_number_in_check:n {#1}
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_init:}
%\begin{macro}{\siunitx_number_in_init_part:n}
% The set up code is divided into to parts. First, code only needed
% once to start the entire parser. Then a second group, which is 
% carried out at the start of each part of a number, and so is called
% from a few places.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_in_init: {
  \cs_set_eq:NN \siunitx_number_in_parse_loop:N 
    \siunitx_number_in_parse_mantissa:N  
  \cs_set_eq:NN \siunitx_number_in_check:n 
    \siunitx_number_in_check_short:n
  \tl_clear:N \l_siunitx_number_parsed_tl
  \prop_clear:N \l_siunitx_number_in_prop
  \bool_set_false:N \l_siunitx_error_bool
  \bool_set_false:N \l_siunitx_number_in_complex_bool
  \bool_set_false:N \l_siunitx_number_in_complex_root_bool
  \bool_set_false:N \l_siunitx_number_in_exponent_bool
  \bool_set_false:N \l_siunitx_number_in_uncert_bool
  \siunitx_number_in_init_part:n { mantissa }
}
\cs_new_protected_nopar:Npn \siunitx_number_in_init_part:n #1 {  
  \bool_set_false:N \l_siunitx_number_in_decimal_bool
  \bool_set_true:N \l_siunitx_number_in_first_bool
  \bool_set_false:N \l_siunitx_number_in_sign_bool
  \bool_set_false:N \l_siunitx_number_in_value_bool
  \tl_set:Nn \l_siunitx_number_part_tl {#1}
  \tl_set:Nn \l_siunitx_number_part_decimal_tl { #1 -decimal }
  \tl_set:Nn \l_siunitx_number_part_decimal_marker_tl 
    { #1 -decimal-marker }
  \tl_set:Nn \l_siunitx_number_part_integer_tl { #1 -integer }
  \tl_set:Nn \l_siunitx_number_part_sign_tl { #1 -sign }
  \tl_set:Nn \l_siunitx_number_part_uncert_tl { #1 -uncertainty }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_protect:}
%\begin{macro}[aux]{\siunitx_number_in_protect_aux:N}
% Under some circumstances (for example when loading \pkg{breqn}) 
% some tokens do not behave safely under \texttt{x} expansion (at the
% moment). To get round this, they are redefined here.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_in_protect: {
  \tl_map_function:NN \l_siunitx_input_protect_tl
    \siunitx_number_in_protect_aux:N
}
\cs_new_protected:Npn \siunitx_number_in_protect_aux:N #1 {
  \cs_set_eq:NN #1 \scan_stop:
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_sign_replace:N}
% A short spin-out to keep the replacement of tokens clear.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_in_sign_replace:N #1 {
  \tl_replace_all_in:Nnn #1 { -+ } { \mp }
  \tl_replace_all_in:Nnn #1 { +- } { \pm }
  \tl_replace_all_in:Nnn #1 { << } { \ll }
  \tl_replace_all_in:Nnn #1 { <= } { \le }
  \tl_replace_all_in:Nnn #1 { >> } { \gg }
  \tl_replace_all_in:Nnn #1 { >= } { \ge }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_error:nx} 
%\begin{macro}{\siunitx_number_in_parse_error:nV} 
% There are lots of rather similar errors in the parser, all of which
% require a \cs{tl_map_break:}. To keep life simple, this is set up 
% here. 
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_error:nx #1#2 {
  \siunitx_error:nx {#1} { \exp_not:n {#2} }
  \tl_map_break:
}
\cs_generate_variant:Nn \siunitx_number_in_parse_error:nx { nV }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_loop:N}
%\begin{macro}{\siunitx_number_in_parse_more:N}
% The main loop is set up as a place holder, as the definition is
% varied to keep things fast. There is also a place holder for the 
% extended routing for normal mantissas.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_loop:N #1 { }
\cs_new_protected:Npn \siunitx_number_in_parse_more:N #1 { }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_relation:N}
%\begin{macro}[aux]{\siunitx_number_in_parse_relation:w}
% The idea here is that a relation with be the very first token in the
% input, or it is not valid. So the test for a relation can be very
% simple and hopefully efficient.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_relation:N #1 {
  \exp_last_unbraced:NV \siunitx_number_in_parse_relation:w
    #1 \q_stop #1
}
\cs_new_protected:Npn \siunitx_number_in_parse_relation:w 
  #1#2 \q_stop #3 {
  \tl_if_in:NnT \l_siunitx_input_comparator_tl {#1}
    {
      \prop_put:Nnn \l_siunitx_number_in_prop { comparator } {#1}
      \tl_set:Nn #3 {#2}
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_restricted:N}
% When parsing numbers for the \cs{ang} function, no extended input 
% is permitted at all.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_restricted:N #1 {
  \tl_if_in:NnTF \l_siunitx_input_exponent_tl {#1}
    { 
      \siunitx_number_in_parse_error:nx  
        { restricted-number } {#1} 
    }
    { 
      \tl_if_in:NnTF \l_siunitx_input_uncert_open_tl {#1}
        { 
          \siunitx_number_in_parse_error:nV 
            { restricted-number } \l_siunitx_number_arg_tl 
        }
        {
          \tl_if_in:NnTF \l_siunitx_input_uncert_close_tl {#1}
            { 
              \siunitx_number_in_parse_error:nV 
                { restricted-number } \l_siunitx_number_arg_tl
            }
            {
              \tl_if_in:NnTF \l_siunitx_input_complex_tl {#1}
                {
                  \siunitx_number_in_parse_error:nV 
                    { restricted-number } \l_siunitx_number_arg_tl
                }
                {
                  \siunitx_number_in_parse_error:nx 
                    { restricted-number } {#1} 
                }
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_complex:N}
% After a complex root when the root is \emph{after} the number, there
% are a very limited range of legitimate tokens. Thus most cases can be
% trapped with a modified parser.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_complex:N #1 {
  \tl_if_in:NnTF \l_siunitx_input_exponent_tl {#1}
    { 
      \cs_set_eq:NN \siunitx_number_in_parse_loop:N
        \siunitx_number_in_parse_mantissa:N
      \siunitx_number_in_exponent:N #1 
    }
    { 
      \tl_if_in:NnF \l_siunitx_input_ignore_tl {#1}
        {
          \siunitx_number_in_parse_error:nV 
            { misplaced-complex-root-token } 
            \l_siunitx_number_arg_tl
        }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_exponent:N}
% When processing an exponent, the \enquote{extended} part of the
% number which is valid in a mantissa is no longer needed. So the
% auxiliary function is pointed to a series of errors instead.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_exponent:N #1 {
  \tl_if_in:NnTF \l_siunitx_input_exponent_tl {#1}
    { 
      \siunitx_number_in_parse_error:nx  
        { duplicate-exponent-token } { \token_to_str:N #1 } 
    }
    { 
      \tl_if_in:NnTF \l_siunitx_input_uncert_open_tl {#1}
        { 
          \siunitx_number_in_parse_error:nV 
            { invalid-token-in-exponent } \l_siunitx_number_arg_tl 
        }
        {
          \tl_if_in:NnTF \l_siunitx_input_uncert_close_tl {#1}
            { 
              \siunitx_number_in_parse_error:nV 
                { invalid-token-in-exponent } \l_siunitx_number_arg_tl
            }
            {
              \tl_if_in:NnTF \l_siunitx_input_complex_tl {#1}
                {
                  \siunitx_number_in_parse_error:nV 
                    { invalid-token-in-exponent } 
                    \l_siunitx_number_arg_tl
                }
                {
                  \siunitx_number_in_parse_error:nx 
                    { invalid-token-in-number } {#1} 
                }
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_mantissa:N}
%\begin{macro}{\siunitx_number_in_parse_mantissa_aux:N}
% For the mantissa, most things are valid. The procedure is split
% into two parts, with the simple symbols handled here and the more
% complex ones in a second part(which needs to be varied). Essentially
% everything here is a comparison, done so that the code is a fast as
% possible.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_mantissa:N #1 {
  \tl_if_in:NnTF \l_siunitx_input_digit_tl {#1}
    { \siunitx_number_in_digit:n {#1} }
    {
      \tl_if_in:NnTF \l_siunitx_input_decimal_tl {#1}
        { \siunitx_number_in_decimal:N #1 }
        {
          \tl_if_in:NnTF \l_siunitx_input_sign_tl {#1}
            { \siunitx_number_in_sign:N #1 }
            {
              \tl_if_in:NnTF \l_siunitx_input_symbol_tl {#1}
                { 
                  \prop_put:Nnn \l_siunitx_number_in_prop { symbolic } 
                    { true }
                  \siunitx_number_in_digit:n { \ensuremath {#1} }
                }
                { 
                  \tl_if_in:NnF \l_siunitx_input_ignore_tl {#1}
                    { \siunitx_number_in_parse_more:N #1 }
                } 
            }
        }
    }
}
\cs_new_protected:Npn \siunitx_number_in_parse_mantissa_aux:N #1 {
  \tl_if_in:NnTF \l_siunitx_input_exponent_tl {#1}
    { \siunitx_number_in_exponent:N #1 }
    { 
      \tl_if_in:NnTF \l_siunitx_input_uncert_open_tl {#1}
        { \siunitx_number_in_uncert_open:N #1 }
        {
          \tl_if_in:NnTF \l_siunitx_input_uncert_close_tl {#1}
            { 
              \siunitx_number_in_parse_error:nx 
                { misplaced-uncertainty-token } {#1} 
            }
            {
              \tl_if_in:NnTF \l_siunitx_input_complex_tl {#1}
                { \siunitx_number_in_complex:N #1 }
                {
                  \siunitx_number_in_parse_error:nx 
                    { invalid-token-in-number } {#1}
                }  
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_uncert:N}
% Within uncertainties, the range of tokens is limited. An alternative
% parsing system can therefore be used.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_uncert:N #1 {
  \tl_if_in:NnTF \l_siunitx_input_digit_tl {#1}
    { \siunitx_number_in_digit:n {#1} }
    {
      \tl_if_in:NnTF \l_siunitx_input_decimal_tl {#1}
        { 
          \siunitx_number_in_parse_error:nV 
            { invalid-token-in-uncertainty } 
            \l_siunitx_number_arg_tl
        }         
        {
          \tl_if_in:NnTF \l_siunitx_input_sign_tl {#1}
            {
              \siunitx_number_in_parse_error:nV 
                { invalid-token-in-uncertainty } 
                \l_siunitx_number_arg_tl
            }
            {
              \tl_if_in:NnTF \l_siunitx_input_symbol_tl {#1}
                { 
                  \prop_put:Nnn \l_siunitx_number_in_prop { symbolic }
                    { true }
                  \siunitx_number_in_digit:n {#1}
                }
                { 
                  \tl_if_in:NnF \l_siunitx_input_ignore_tl {#1}
                    { 
                      \tl_if_in:NnTF \l_siunitx_input_uncert_close_tl 
                        {#1}
                        { \siunitx_number_in_uncert_close:N #1 }
                        {
                          \siunitx_number_in_parse_error:nV 
                            { invalid-token-in-uncertainty } 
                            \l_siunitx_number_arg_tl
                        }
                    }
                } 
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_parse_uncert_after:N}
% After an uncertainty, there is once again a very limited range of
% tokens that can be present in a valid number.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_parse_uncert_after:N #1 {
  \tl_if_in:NnTF \l_siunitx_input_exponent_tl {#1}
    { 
      \cs_set_eq:NN \siunitx_number_in_parse_loop:N
        \siunitx_number_in_parse_mantissa:N
      \siunitx_number_in_exponent:N #1 
    }
    {
      \tl_if_in:NnTF \l_siunitx_input_sign_tl {#1}
        { 
          \cs_set_eq:NN \siunitx_number_in_parse_loop:N
            \siunitx_number_in_parse_mantissa:N
          \siunitx_number_in_sign:N #1
        }
        {
          \tl_if_in:NnF \l_siunitx_input_ignore_tl {#1}
            { 
              \tl_if_in:NnTF \l_siunitx_input_complex_tl {#1}
                {
                  \cs_set_eq:NN \siunitx_number_in_parse_loop:N
                    \siunitx_number_in_parse_mantissa:N
                  \siunitx_number_in_complex:N #1
                }
                {         
                  \siunitx_number_in_parse_error:nV { invalid-number }
                    \l_siunitx_number_arg_tl 
                }
            }    
        }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_complex:N}
%\begin{macro}[aux]{\siunitx_number_in_complex_aux:nn}
% Only one complex root token can be give, hence the initial test.
% More tests are needed for complex numbers than other systems, so
% the additional ones are turned on, followed by some flag setting.
% The complex root is stored, then there is a check to see if the
% root is at the end of the number: if it is, prevent any more tokens 
% being added.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_complex:N #1 {
  \bool_set_false:N \l_siunitx_number_in_first_bool
  \bool_if:NTF \l_siunitx_number_in_complex_root_bool
    { 
      \siunitx_number_in_parse_error:nx 
        { duplicate-complex-root-token } { \token_to_str:N #1 } 
    }
    {
      \cs_set_eq:NN \siunitx_number_in_check:n 
        \siunitx_number_in_check_full:n 
      \bool_set_true:N \l_siunitx_number_in_complex_root_bool
      \prop_put:Nnn \l_siunitx_number_in_prop { complex-root } {#1}
      \tl_if_empty:NF \l_siunitx_number_parsed_tl
        { 
          \cs_set_eq:NN \siunitx_number_in_parse_loop:N 
            \siunitx_number_in_parse_complex:N   
        } 
      \bool_if:NT \l_siunitx_number_in_decimal_bool
        { 
          \bool_if:NF \l_siunitx_number_in_complex_bool
            {
              \prop_if_in:NnT \l_siunitx_number_in_prop 
                { mantissa-uncertainty }
                {
                  \siunitx_number_in_complex_aux:nn 
                    { mantissa-decimal } { complex-decimal }
                  \siunitx_number_in_complex_aux:nn 
                    { mantissa-uncertainty } { complex-uncertainty }
                }
              \siunitx_number_in_complex_aux:nn { mantissa-integer }
                { complex-integer }
              \siunitx_number_in_complex_aux:nn 
                { mantissa-decimal-marker } { complex-decimal-marker }
              \prop_del:Nn \l_siunitx_number_in_prop { mantissa }
              \prop_put:Nnn \l_siunitx_number_in_prop { complex }
                { true }
            }
        } 
      \prop_if_in:NnF \l_siunitx_number_in_prop { mantissa }
        {
          \prop_if_in:NnT \l_siunitx_number_in_prop { mantissa-sign }
            {                
              \siunitx_number_in_complex_aux:nn { mantissa-sign }
                { complex-sign }
            }
        }  
      \bool_set_true:N \l_siunitx_number_in_complex_bool 
      \bool_set_false:N \l_siunitx_number_in_first_bool 
      \siunitx_number_in_init_part:n { complex } 
      \prop_if_in:NnT \l_siunitx_number_in_prop 
        { complex-decimal-marker }
        { \bool_set_true:N \l_siunitx_number_in_decimal_bool }
      \prop_if_in:NnT \l_siunitx_number_in_prop 
        { complex-sign }
        { \bool_set_true:N \l_siunitx_number_in_sign_bool }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_in_complex_aux:nn #1#2 {
  \prop_get:NnN \l_siunitx_number_in_prop {#1} \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    {
      \prop_del:Nn  \l_siunitx_number_in_prop {#1} 
      \prop_put:NnV \l_siunitx_number_in_prop {#2} \l_siunitx_tmpa_tl
   }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_decimal:N}
% Only one decimal marker allowed, so a test for this. If an integer
% part has been found, it is saved. The flag for the number being
% found is not set unless there is an integer, to watch for the case
% of invalid numbers.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_decimal:N #1 {
  \bool_set_false:N \l_siunitx_number_in_first_bool
  \bool_if:NTF \l_siunitx_number_in_decimal_bool 
    { 
      \siunitx_number_in_parse_error:nx { duplicate-decimal-token } 
        { \token_to_str:N #1 }
    }
    {
      \bool_set_true:N \l_siunitx_number_in_decimal_bool
      \tl_if_empty:NF \l_siunitx_number_parsed_tl
        {
          \prop_put:NVn \l_siunitx_number_in_prop 
            \l_siunitx_number_part_tl { true }
          \prop_put:NVV \l_siunitx_number_in_prop 
            \l_siunitx_number_part_integer_tl 
            \l_siunitx_number_parsed_tl
          \tl_clear:N \l_siunitx_number_parsed_tl 
        }
      \prop_put:NVn \l_siunitx_number_in_prop 
        \l_siunitx_number_part_decimal_marker_tl {#1}
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_digit:n}
% For digits, only in an uncertainty can the value be stored
% directly. Otherwise, there is a need to see if the value is non-zero.
% This is used to drop leading zeros and to validate any sign (as zero
% is unsigned).
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_digit:n #1 {
  \bool_set_false:N \l_siunitx_number_in_first_bool
  \bool_if:NTF \l_siunitx_number_in_uncert_bool
    { \tl_put_right:Nn \l_siunitx_number_parsed_tl {#1} }
    {
      \bool_if:NTF \l_siunitx_number_in_decimal_bool
        {
          \tl_put_right:Nn \l_siunitx_number_parsed_tl {#1}
          \str_if_eq:nnF {#1} { 0 } 
            { \bool_set_true:N \l_siunitx_number_in_value_bool }
        }
        {
          \str_if_eq:nnTF {#1} { 0 } 
            { 
              \prop_put:NVn \l_siunitx_number_in_prop 
                \l_siunitx_number_part_tl { true }
              \prop_put:NVn \l_siunitx_number_in_prop 
                \l_siunitx_number_part_integer_tl { 0 }
            }
            { \bool_set_true:N \l_siunitx_number_in_value_bool }
          \bool_if:NT \l_siunitx_number_in_value_bool  
            { \tl_put_right:Nn \l_siunitx_number_parsed_tl {#1} }
        } 
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_exponent:N}
% A duplicate token test starts off the code, which if passed 
% leads to some simple storage manipulation. As exponents are 
% more simple than the mantissa, the extra processing is swapped for
% some that only raises errors.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_exponent:N #1 {
  \bool_if:NTF \l_siunitx_number_in_exponent_bool
    { 
      \siunitx_number_in_parse_error:nx { duplicate-exponent-token } 
        { \token_to_str:N #1 }
    }
    {
      \cs_set_eq:NN \siunitx_number_in_parse_more:N
        \siunitx_number_in_parse_exponent:N
      \tl_if_empty:NF \l_siunitx_number_parsed_tl 
        { \siunitx_number_in_store: }
      \bool_set_true:N \l_siunitx_number_in_exponent_bool
      \siunitx_number_in_init_part:n { exponent } 
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_sign:N}
% The code for signs is complicated by complex numbers. A sign token
% must be the fist thing in a number, but after the real part of the
% mantissa a second sign token can appear to start a complex number.
% So most of the code here is to detect that case.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_sign:N #1 {
  \bool_if:NTF \l_siunitx_number_in_first_bool
    {
      \bool_set_false:N \l_siunitx_number_in_first_bool
      \bool_set_true:N \l_siunitx_number_in_sign_bool
      \prop_put:NVn \l_siunitx_number_in_prop 
        \l_siunitx_number_part_sign_tl {#1}
    }
    { 
      \bool_if:NTF \l_siunitx_number_in_exponent_bool
        { 
          \siunitx_number_in_parse_error:nx { misplaced-sign-token } 
            {#1}
        }
        {
          \bool_if:NTF \l_siunitx_number_in_complex_bool
            { 
              \siunitx_number_in_parse_error:nx 
                { misplaced-sign-token } {#1} 
            }
            { 
              \tl_if_empty:NF \l_siunitx_number_parsed_tl 
                { \siunitx_number_in_store: }
              \cs_set_eq:NN \siunitx_number_in_check:n 
                \siunitx_number_in_check_full:n  
              \siunitx_number_in_init_part:n { complex }
              \prop_put:Nnn \l_siunitx_number_in_prop 
                { complex-sign } {#1}  
              \bool_set_true:N \l_siunitx_number_in_complex_bool
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_uncert_open:N}
%\begin{macro}{\siunitx_number_in_uncert_close:N}
% Opening and closing uncertainty tokens are handled separately. For
% opening tokens, a check is made that there is something else to the
% number before collecting material up. For the closing token, the
% uncertainty must contain some numbers. A special loop function is then
% set up to prevent any additional digits after the closing token.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_in_uncert_open:N #1 {
  \bool_set_false:N \l_siunitx_number_in_first_bool
  \cs_set_eq:NN \siunitx_number_in_parse_loop:N 
    \siunitx_number_in_parse_uncert:N
  \bool_set_true:N \l_siunitx_number_in_uncert_bool
  \tl_if_empty:NTF \l_siunitx_number_parsed_tl
    {
      \prop_if_in:NVF \l_siunitx_number_in_prop 
        \l_siunitx_number_part_integer_tl
        {  
          \siunitx_number_in_parse_error:nV { invalid-number } 
            \l_siunitx_number_arg_tl 
        }
    }
    { \siunitx_number_in_store: }
}
\cs_new_protected:Npn \siunitx_number_in_uncert_close:N #1 { 
  \bool_set_false:N \l_siunitx_number_in_uncert_bool
  \tl_if_empty:NTF \l_siunitx_number_parsed_tl
    { 
      \siunitx_number_in_parse_error:nV { empty-uncertainty } 
        \l_siunitx_number_arg_tl
    }
    {
      \prop_put:NVV \l_siunitx_number_in_prop 
        \l_siunitx_number_part_uncert_tl \l_siunitx_number_parsed_tl
      \prop_put:Nnn \l_siunitx_number_in_prop 
        { uncertainty } { true }
      \tl_clear:N \l_siunitx_number_parsed_tl
      \cs_set_eq:NN \siunitx_number_in_parse_loop:N 
        \siunitx_number_in_parse_uncert_after:N   
    }  
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_store:}
% A short auxiliary function needed in various places for storing
% either the integer or decimal part of a number, as appropriate.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_in_store: {
  \prop_put:NVn \l_siunitx_number_in_prop \l_siunitx_number_part_tl 
    { true }
  \bool_if:NTF \l_siunitx_number_in_decimal_bool
    {
      \prop_put:NVV \l_siunitx_number_in_prop 
        \l_siunitx_number_part_decimal_tl \l_siunitx_number_parsed_tl
    }
    {
      \prop_put:NVV \l_siunitx_number_in_prop 
        \l_siunitx_number_part_integer_tl \l_siunitx_number_parsed_tl
    }    
  \tl_clear:N \l_siunitx_number_parsed_tl 
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_in_check:n}
%\begin{macro}{\siunitx_number_in_check_short:n}
%\begin{macro}{\siunitx_number_in_check_full:n}
% The checks needed for a number depend on whether there is a complex
% part. In all cases, there must be some digits, as well as a sign or
% decimal marker. There is also a check for a zero-valued input, which
% has any sign deleted. For complex numbers, the check is needed in
% case there was no real part.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_in_check:n #1 { }
\cs_new_protected_nopar:Npn \siunitx_number_in_check_short:n #1 { 
  \prop_if_in:NVF \l_siunitx_number_in_prop 
    \l_siunitx_number_part_integer_tl
    {
      \prop_if_in:NVF \l_siunitx_number_in_prop 
        \l_siunitx_number_part_decimal_tl
        { \siunitx_error:nx { invalid-number } {#1} }
    }
  \bool_if:NF \l_siunitx_number_in_value_bool 
    { 
      \tl_if_eq:NNF \l_siunitx_number_part_tl 
        \c_siunitx_number_part_complex_tl
        { 
          \prop_get:NVN \l_siunitx_number_in_prop
            \l_siunitx_number_part_sign_tl  \l_siunitx_tmpa_tl
          \quark_if_no_value:NF \l_siunitx_tmpa_tl
            {
              \tl_set:Nx \l_siunitx_tmpb_tl
                { \l_siunitx_number_part_sign_tl -deleted }
              \prop_put:NVV \l_siunitx_number_in_prop
                \l_siunitx_tmpb_tl \l_siunitx_tmpa_tl
            } 
          \prop_del:NV \l_siunitx_number_in_prop 
            \l_siunitx_number_part_sign_tl 
        }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_in_check_full:n #1 {
  \tl_if_eq:NNF \l_siunitx_number_part_tl 
    \c_siunitx_number_part_complex_tl 
    { \siunitx_number_in_check_short:n {#1} }
  \bool_if:NF \l_siunitx_number_in_complex_root_bool
    { 
      \prop_get:NnN \l_siunitx_number_in_prop { complex-sign } 
        \l_siunitx_tmpa_tl
      \siunitx_error:nx { misplaced-sign-token } 
        { \exp_not:V \l_siunitx_tmpa_tl }
    }
  \prop_get:NnN \l_siunitx_number_in_prop { mantissa-sign } 
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl 
    {
      \prop_if_in:NnF \l_siunitx_number_in_prop { mantissa }
        {
          \prop_del:Nn \l_siunitx_number_in_prop { mantissa-sign }
          \prop_put:NnV \l_siunitx_number_in_prop { complex-sign } 
            \l_siunitx_tmpa_tl
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Post-processing numbers}
%
% After finding the basic number in the code above, there may be some
% manipulation to do. This covers things such as tidying up excess 
% information and rounding numbers. Nothing is added here that is
% for \enquote{formatting}: this is left for the output part of the 
% system.
% 
%\begin{macro}{\l_siunitx_round_int}
%\begin{macro}{\l_siunitx_round_tl}
%\begin{macro}{\l_siunitx_round_bool}
%\begin{macro}{\l_siunitx_round_decimal_in_tl}
%\begin{macro}{\l_siunitx_round_decimal_out_tl}
%\begin{macro}{\l_siunitx_round_integer_in_tl}
%\begin{macro}{\l_siunitx_round_integer_out_tl}
% The rounding system needs a number of variables.
%    \begin{macrocode}
\int_new:N \l_siunitx_round_int
\tl_new:N \l_siunitx_round_tl
\bool_new:N \l_siunitx_round_bool
\tl_new:N \l_siunitx_round_decimal_in_tl
\tl_new:N \l_siunitx_round_decimal_out_tl
\tl_new:N \l_siunitx_round_integer_in_tl
\tl_new:N \l_siunitx_round_integer_out_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_process_decimal_int}
%\begin{macro}{\l_siunitx_process_uncertainty_int}
%\begin{macro}{\l_siunitx_uncertainty_decimal_tl}
%\begin{macro}{\l_siunitx_uncertainty_integer_tl}
% The code to expand uncertainties needs to know numbers of digits, and
% to store various data.
%    \begin{macrocode}
\int_new:N \l_siunitx_process_decimal_int
\int_new:N \l_siunitx_process_uncertainty_int
\tl_new:N \l_siunitx_uncertainty_decimal_tl
\tl_new:N \l_siunitx_uncertainty_integer_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_process_fixed_bool}
%\begin{macro}{\l_siunitx_process_scientific_bool}
% Settings for the scientific notation system.
%    \begin{macrocode}
\bool_new:N \l_siunitx_process_fixed_bool
\bool_new:N \l_siunitx_process_scientific_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_process_decimal_zero_bool}
%\begin{macro}{\l_siunitx_process_integer_zero_bool}
%\begin{macro}{\l_siunitx_process_sign_tl}
%\begin{macro}{\l_siunitx_process_fixed_int}
%\begin{macro}{\l_siunitx_process_plus_tl}
%\begin{macro}{\l_siunitx_process_unity_mantissa_tl}
%\begin{macro}{\l_siunitx_process_zero_exponent_bool}
%\begin{macro}{\l_siunitx_process_int_to_dec_bool}
%\begin{macro}{\l_siunitx_process_round_min_tl}
%\begin{macro}{\l_siunitx_process_precision_int}
% First, the options are set up.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  add-decimal-zero  .bool_set:N = \l_siunitx_process_decimal_zero_bool,
  add-integer-zero  .bool_set:N = \l_siunitx_process_integer_zero_bool,
  explicit-sign     .tl_set:N   = \l_siunitx_process_sign_tl,
  fixed-exponent    .int_set:N  = \l_siunitx_process_fixed_int,
  retain-explicit-plus  .bool_set:N = \l_siunitx_process_plus_tl,
  retain-unity-mantissa .bool_set:N = 
    \l_siunitx_process_unity_mantissa_bool,
  retain-zero-exponent .bool_set:N =
    \l_siunitx_process_zero_exponent_bool,
  round-integer-to-decimal .bool_set:N = 
    \l_siunitx_process_int_to_dec_bool,
  round-minimum     .tl_set:N  = \l_siunitx_process_round_min_tl,
  round-mode        .choice: ,
  round-mode / figures .code:n = 
    { \tl_set:Nn \l_siunitx_round_tl { figures } },
  round-mode / off     .code:n = { \tl_clear:N \l_siunitx_round_tl },
  round-mode / places  .code:n = 
    { \tl_set:Nn \l_siunitx_round_tl { places } },
  round-precision      .int_set:N = \l_siunitx_process_precision_int,
  scientific-notation .choice: ,
  scientific-notation
    / false           .code:n = 
    {
      \bool_set_false:N \l_siunitx_process_fixed_bool
      \bool_set_false:N \l_siunitx_process_scientific_bool
    },
  scientific-notation
    / fixed           .code:n = 
    {
      \bool_set_true:N  \l_siunitx_process_fixed_bool
      \bool_set_false:N \l_siunitx_process_scientific_bool
    },
  scientific-notation
    / true           .code:n = 
    {
      \bool_set_false:N \l_siunitx_process_fixed_bool
      \bool_set_true:N \l_siunitx_process_scientific_bool
    },
}
\keys_set:nn { siunitx } {
  add-decimal-zero      = true,
  add-integer-zero      = true,
  retain-unity-mantissa = true, 
  round-precision       = 2,
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process:}
% Post-processing is a series of small tasks.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process: {
  \siunitx_number_process_sign:
  \siunitx_number_process_zero_fill:
  \siunitx_number_process_mantissa:
  \prop_if_in:NnF \l_siunitx_number_in_prop { symbolic } 
    {
      \siunitx_number_process_exponent:
      \bool_if:NTF \l_siunitx_process_fixed_bool
        { \siunitx_number_process_fixed: }
        {
          \bool_if:NT \l_siunitx_process_scientific_bool
            { \siunitx_number_process_scientific: }
        }    
      \siunitx_number_process_uncertainty:
      \prop_if_in:NnF \l_siunitx_number_in_prop { uncertainty }
        { \siunitx_number_process_round: }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_exponent:}
%\begin{macro}[aux]{\siunitx_number_process_exponent_aux:n}
% To check for a totally zero exponent, the possibility that one or more
% of the exponent storage areas is zero needs to be considered. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_exponent: {
  \bool_if:NF \l_siunitx_process_zero_exponent_bool 
    {
      \prop_if_in:NnT \l_siunitx_number_in_prop { exponent } 
        {
          \bool_set_false:N \l_siunitx_tmp_bool
          \siunitx_number_process_exponent_aux:n { integer }
          \bool_if:NF \l_siunitx_tmp_bool
            { \siunitx_number_process_exponent_aux:n { decimal } }
          \bool_if:NF \l_siunitx_tmp_bool 
            {
              \prop_del:Nn \l_siunitx_number_in_prop { exponent }
              \prop_del:Nn \l_siunitx_number_in_prop 
                { exponent-integer }
              \prop_del:Nn \l_siunitx_number_in_prop 
                { exponent-decimal }
             }
        }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_process_exponent_aux:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop { exponent- #1 }
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl 
    {
      \int_compare:nNnF { \l_siunitx_tmpa_tl } = { 0 } 
        { \bool_set_true:N \l_siunitx_tmp_bool }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_figures:n}
%\begin{macro}[aux]{\siunitx_number_process_figures_aux:n}
%\begin{macro}[aux]{\siunitx_number_process_figures_init:n}
% The approach here is to find how many digits there are in each part
% of the number, working out which are significant. The next stage is 
% reconstruction of the number.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_figures:n #1 {
  \prop_if_in:NnT \l_siunitx_number_in_prop {#1} 
    { \siunitx_number_process_figures_aux:n {#1} }
}
\cs_new_protected_nopar:Npn \siunitx_number_process_figures_aux:n #1 {
  \siunitx_number_process_figures_init:n {#1}
  \siunitx_number_process_figures_count:n { integer }
  \siunitx_number_process_figures_count:n { decimal }
  \bool_if:NTF \l_siunitx_round_bool 
    {
      \bool_set_false:N \l_siunitx_round_bool
      \int_compare:nNnTF 
        { \l_siunitx_round_int } > 
          { \l_siunitx_process_precision_int }
        { 
          \siunitx_number_process_figures_round:
          \siunitx_number_process_round_tidy:n {#1}
        }
        { \siunitx_number_process_figures_pad:n {#1} }
    }
    {
      \prop_put:Nnn \l_siunitx_number_in_prop { #1 -integer } { 0 }
      \prop_del:Nn \l_siunitx_number_in_prop { #1 -decimal }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_process_figures_init:n #1 {
  \int_zero:N \l_siunitx_round_int
  \bool_set_false:N \l_siunitx_round_bool
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal } 
    \l_siunitx_round_decimal_in_tl
  \quark_if_no_value:NT \l_siunitx_round_decimal_in_tl
    { \tl_clear:N \l_siunitx_round_decimal_in_tl }  
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -integer } 
    \l_siunitx_round_integer_in_tl
  \quark_if_no_value:NT \l_siunitx_round_integer_in_tl
    { \tl_clear:N \l_siunitx_round_integer_in_tl }  
  \tl_clear:N \l_siunitx_round_decimal_out_tl
  \tl_clear:N \l_siunitx_round_integer_out_tl
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_process_figures_count:n}
%\begin{macro}[aux]{\siunitx_number_process_figures_count_aux:n}
% The counting code has to check that characters are actually 
% significant.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_figures_count:n #1 {
  \tl_if_empty:cF { l_siunitx_round_ #1 _in_tl } 
    {
      \prop_if_in:NnF \l_siunitx_number_in_prop { #1 -uncertainty } 
        { \siunitx_number_process_figures_count_aux:n {#1} }
    }
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_figures_count_aux:n #1 {
  \int_set:Nn \l_siunitx_tmp_int 
    { \tl_head:v { l_siunitx_round_ #1 _in_tl } }
  \tl_set:cx { l_siunitx_round_ #1 _in_tl } 
    { \tl_tail:v { l_siunitx_round_ #1 _in_tl } }
  \tl_put_left:cV { l_siunitx_round_ #1 _out_tl } \l_siunitx_tmp_int
  \bool_if:NF \l_siunitx_round_bool 
    {
      \int_compare:nNnF { \l_siunitx_tmp_int } = { 0 }
        { \bool_set_true:N \l_siunitx_round_bool }
    }
  \bool_if:NT \l_siunitx_round_bool 
    { \int_incr:N \l_siunitx_round_int }
  \tl_if_empty:cTF { l_siunitx_round_ #1 _in_tl } 
    {
      \tl_set_eq:cc { l_siunitx_round_ #1 _in_tl } 
        { l_siunitx_round_ #1 _out_tl }
      \tl_clear:c { l_siunitx_round_ #1 _out_tl }
    }
    { \siunitx_number_process_figures_count_aux:n {#1} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_process_figures_round:}
%\begin{macro}[aux]{\siunitx_number_process_figures_round_loop:}
% The control macro for rounding to figures does the decimal part
% then the integer part as loops. There is then some tidying up if a
% digit is carried at the end.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_figures_round: {
  \int_set:Nn \l_siunitx_round_int 
    { \l_siunitx_round_int - \l_siunitx_process_precision_int }
  \tl_if_empty:NF \l_siunitx_round_decimal_in_tl 
    { \siunitx_number_process_figures_round_loop: }
  \tl_if_empty:NF \l_siunitx_round_integer_in_tl 
    { \siunitx_number_process_figures_integer: }
  \bool_if:NT \l_siunitx_round_bool 
    {
      \tl_put_left:Nn \l_siunitx_round_integer_out_tl { 1 }
      \tl_if_empty:NF \l_siunitx_round_decimal_out_tl 
        {
          \tl_reverse:N \l_siunitx_round_decimal_out_tl
          \tl_set:Nx \l_siunitx_round_decimal_out_tl 
            { \tl_tail:n \l_siunitx_round_decimal_out_tl }
          \tl_reverse:N \l_siunitx_round_decimal_out_tl
        }
    }
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_figures_round_loop: {
  \siunitx_number_process_round_decimal:
  \tl_if_empty:NF \l_siunitx_round_decimal_in_tl 
    { \siunitx_number_process_figures_round_loop: }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_process_figures_integer:}
% For figures, the integer part is a little complicated as zeros need
% to be included.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_figures_integer: {
  \int_compare:nNnT { \l_siunitx_round_int } > { 0 } 
    { \tl_put_left:Nn \l_siunitx_round_integer_out_tl { 0 } }
  \int_compare:nNnF { \l_siunitx_round_int } > { 1 } 
    {
      \int_set:Nn \l_siunitx_tmp_int 
        { \tl_head:V \l_siunitx_round_integer_in_tl }
      \bool_if:NT \l_siunitx_round_bool
        { \int_incr:N \l_siunitx_tmp_int }
      \bool_set_false:N \l_siunitx_round_bool
      \int_compare:nNnTF { \l_siunitx_round_int } = { 1 }
        {
          \int_compare:nNnT { \l_siunitx_tmp_int } > { 4 }
            { \bool_set_true:N \l_siunitx_round_bool }
        }
        {
          \int_compare:nNnT { \l_siunitx_tmp_int } > { 10 } 
            {
              \bool_set_true:N \l_siunitx_round_bool
              \int_zero:N \l_siunitx_tmp_int
            }
          \tl_put_left:NV \l_siunitx_round_integer_out_tl 
            \l_siunitx_tmp_int
        }
    }   
  \int_decr:N \l_siunitx_round_int
  \tl_set:Nx \l_siunitx_round_integer_in_tl 
    { \tl_tail:V \l_siunitx_round_integer_in_tl }
  \tl_if_empty:NF \l_siunitx_round_integer_in_tl 
    { \siunitx_number_process_figures_integer: }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_process_figures_pad:n}
% If the number is too short, then the reversal is undone and the 
% padding routine is called.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_figures_pad:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -integer }
    \l_siunitx_round_integer_in_tl
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal }
    \l_siunitx_round_decimal_in_tl
  \int_set:Nn \l_siunitx_round_int 
    { \l_siunitx_process_precision_int - \l_siunitx_round_int }
  \siunitx_number_process_pad:n {#1}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_fixed:}
%\begin{macro}[aux]{\siunitx_number_process_fixed_aux_i:nnn}
%\begin{macro}[aux]{\siunitx_number_process_fixed_aux_ii:nnn}
%\begin{macro}[aux]{\siunitx_number_process_fixed_large:nnn}
%\begin{macro}[aux]{\siunitx_number_process_fixed_large_aux:w}
%\begin{macro}[aux]{\siunitx_number_process_fixed_small:nnn}
%\begin{macro}[aux]{\siunitx_number_process_fixed_small_aux:w}
% When working to a fixed exponent value, the idea is to use the stack
% to do the work. First, there is some set up to do.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_fixed: {
  \prop_if_in:NnF \l_siunitx_number_in_prop { complex } 
    {
      \prop_get:NnN \l_siunitx_number_in_prop { mantissa-integer }
        \l_siunitx_tmpa_tl
      \quark_if_no_value:NT \l_siunitx_tmpa_tl
        { \tl_set:Nn \l_siunitx_tmpa_tl { 0 } }
      \prop_get:NnN \l_siunitx_number_in_prop { mantissa-decimal }
        \l_siunitx_tmpb_tl
      \quark_if_no_value:NT \l_siunitx_tmpb_tl
        { \tl_clear:N \l_siunitx_tmpb_tl }
      \tl_set:Nx \l_siunitx_tmpa_tl
        { { \l_siunitx_tmpa_tl } { \l_siunitx_tmpb_tl } }
      \prop_get:NnN \l_siunitx_number_in_prop { exponent-integer }
        \l_siunitx_tmpb_tl
      \quark_if_no_value:NT \l_siunitx_tmpb_tl
        { \tl_set:Nn \l_siunitx_tmpb_tl { 0 } }
      \tl_set:Nx \l_siunitx_tmpa_tl
        { \l_siunitx_tmpa_tl { \l_siunitx_tmpb_tl } }
      \exp_last_unbraced:NV \siunitx_number_process_fixed_aux_i:nnn 
        \l_siunitx_tmpa_tl
    }
}         
%    \end{macrocode}
% The main loop checks to see which way to adjust the exponent then 
% does the work.
%    \begin{macrocode}        
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_fixed_aux_i:nnn #1#2#3 {
  \prop_put:Nnn \l_siunitx_number_in_prop { exponent } 
    { true }
  \prop_put:NnV \l_siunitx_number_in_prop 
    { exponent-integer } \l_siunitx_process_fixed_int
  \int_compare:nNnF { #1 + 0 #2 } = { 0 }
    { \siunitx_number_process_fixed_aux_ii:nnn {#1} {#2} {#3} }
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_fixed_aux_ii:nnn #1#2#3 {
  \int_compare:nNnTF {#3} > { \l_siunitx_process_fixed_int }
    { \siunitx_number_process_fixed_large:nnn {#1} {#2} {#3} }
    {
      \int_compare:nNnTF {#3} < { \l_siunitx_process_fixed_int }
        { \siunitx_number_process_fixed_small:nnn {#1} {#2} {#3} }
        {
          \prop_put:Nnn \l_siunitx_number_in_prop
            { mantissa-integer } {#1}
          \tl_if_empty:nTF {#2}
            {
              \prop_del:Nn \l_siunitx_number_in_prop 
                { mantissa-decimal }
              \prop_del:Nn \l_siunitx_number_in_prop 
                { mantissa-decimal-marker }
            }
            {
              \prop_put:Nnn \l_siunitx_number_in_prop
                { mantissa-decimal } {#2}
              \prop_if_in:NnF \l_siunitx_number_in_prop 
                { mantissa-decimal-marker }
                {
                  \prop_put:Nnn \l_siunitx_number_in_prop 
                    { mantissa-decimal-marker } { . } 
                }
            } 
        }
    }    
}
%    \end{macrocode}
% Simple stack-based manipulation of the input for number which are 
% either too big or too small. There are a couple of checks needed to
% deal with cases where there is no decimal part and where there are
% leading zeros to dispose of. There is also a check to avoid adding
% an additional zero to the decimal part of the number.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_fixed_large:nnn #1#2#3 {
  \cs_set_protected_nopar:Npn 
    \siunitx_number_process_fixed_large_aux:w ##1##2 \q_stop
      {
        \tl_if_empty:nTF {##2}
          {
            \int_compare:nNnTF 
              { #3 - 1 } = { \l_siunitx_process_fixed_int }
              {
                \siunitx_number_process_fixed_aux_ii:nnn { #1 ##1 }
                  { } { #3 - 1 }
              }
              {
                \siunitx_number_process_fixed_aux_ii:nnn { #1 ##1 }
                  { 0 } { #3 - 1 }
              }
          }  
          {
            \int_compare:nNnTF {#1} = { 0 }
              {
                \siunitx_number_process_fixed_aux_ii:nnn {##1} {##2} 
                  { #3 - 1 }
              }
              {
                \siunitx_number_process_fixed_aux_ii:nnn { #1 ##1 }
                  {##2} { #3 - 1 }
              }
          }
      }
  \tl_if_empty:nTF {#2}    
    { \siunitx_number_process_fixed_aux_ii:nnn { #1 0 } { } { #3 - 1 } }
    { \siunitx_number_process_fixed_large_aux:w #2 \q_stop }
}
\cs_new_protected_nopar:Npn \siunitx_number_process_fixed_large_aux:w 
  { }
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_fixed_small:nnn #1#2#3 {
  \cs_set_protected_nopar:Npn 
    \siunitx_number_process_fixed_small_aux:w ##1##2 \q_stop ##3
      {
        \tl_if_empty:nTF {##2}
          {
            \tl_if_empty:nTF {##3}
              {
                \siunitx_number_process_fixed_aux_ii:nnn { 0 } 
                  { ##1 #2 } { #3 + 1 }
              }
              {
                \siunitx_number_process_fixed_aux_ii:nnn {##3}
                  { ##1 #2 } { #3 + 1 }
              }
          }  
          {
            \siunitx_number_process_fixed_small_aux:w ##2 \q_stop 
              { ##3 ##1 }
          }
      }
  \siunitx_number_process_fixed_small_aux:w #1 \q_stop { }
}
\cs_new_protected_nopar:Npn \siunitx_number_process_fixed_small_aux:w
  { }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\c_siunitx_unity_tl}
%\begin{macro}{\siunitx_number_process_mantissa:}
% A check for the mantissa consisting only of the token \texttt{1}, when
% an exponent is also available.
%    \begin{macrocode}
\tl_new:N \c_siunitx_unity_tl 
\tl_set:Nn \c_siunitx_unity_tl { 1 }
\cs_new_protected_nopar:Npn \siunitx_number_process_mantissa: {
  \bool_if:NF \l_siunitx_process_unity_mantissa_bool 
    {
      \prop_if_in:NnT \l_siunitx_number_in_prop { exponent } 
        {
          \prop_get:NnN \l_siunitx_number_in_prop { mantissa-integer }
            \l_siunitx_tmpa_tl
          \quark_if_no_value:NF \l_siunitx_tmpa_tl
            {
              \tl_if_eq:NNT \c_siunitx_unity_tl \l_siunitx_tmpa_tl 
                { 
                  \prop_if_in:NnF \l_siunitx_number_in_prop 
                    { mantissa-decimal-marker }
                    {
                      \prop_del:Nn \l_siunitx_number_in_prop 
                        { mantissa }
                      \prop_del:Nn \l_siunitx_number_in_prop 
                        { mantissa-integer }
                    }    
                }
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_pad:n}
% For padding a number by adding zero to the end repeatedly. This can
% happen if the input was zero or if the number is too short.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_pad:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal } 
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    {
      \int_while_do:nNnn { \l_siunitx_round_int } > { 0 } 
        {
          \tl_put_right:Nn \l_siunitx_tmpa_tl { 0 }
          \int_decr:N \l_siunitx_round_int
        }
      \prop_put:NnV \l_siunitx_number_in_prop { #1 -decimal } 
        \l_siunitx_tmpa_tl
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_places:n}
%\begin{macro}[aux]{\siunitx_number_process_places_aux_i:n}
% For rounding to a fixed number of places, a check is made to see if
% the decimal part is exactly zero. If it is, just create the
% appropriate number of zeros in the padding routine.  Otherwise, do the
% real work.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_places:n #1 {
  \prop_if_in:NnT \l_siunitx_number_in_prop {#1} 
    {
      \prop_if_in:NnF \l_siunitx_number_in_prop { #1 -uncertainty } 
        { \siunitx_number_process_places_aux_i:n {#1} }
    }
}  
\cs_new_protected_nopar:Npn \siunitx_number_process_places_aux_i:n #1 {
  \int_compare:nNnTF { \l_siunitx_process_precision_int } = { 0 } 
    { 
      \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal } 
        \l_siunitx_tmpa_tl  
      \quark_if_no_value:NF \l_siunitx_tmpa_tl
        {
          \int_compare:nNnTF 
            { \tl_head:V \l_siunitx_tmpa_tl } > { 4 }
            {
              \prop_get:NnN \l_siunitx_number_in_prop { #1 -integer }
                \l_siunitx_tmpa_tl
              \quark_if_no_value:NTF \l_siunitx_tmpa_tl  
                {
                  \prop_put:Nnn \l_siunitx_number_in_prop 
                    { #1 -integer } { 1 }
                }
                {
                  \tl_set:Nx \l_siunitx_tmpa_tl  
                    { \int_eval:n { \l_siunitx_tmpa_tl + 1 } }
                  \prop_put:NnV \l_siunitx_number_in_prop 
                    { #1 -integer } \l_siunitx_tmpa_tl  
                }
            }
            {
              \prop_if_in:NnF \l_siunitx_number_in_prop { #1 -integer }
                { 
                  \prop_put:Nnn \l_siunitx_number_in_prop 
                    { #1 -integer } { 0 }
                }
            }
        } 
      \prop_del:Nn \l_siunitx_number_in_prop { #1 -decimal } 
      \prop_del:Nn \l_siunitx_number_in_prop { #1 -decimal-marker } 
    }
    {
      \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal }
        \l_siunitx_tmpa_tl
      \quark_if_no_value:NF \l_siunitx_tmpa_tl
        {
          \tl_if_empty:NT \l_siunitx_tmpa_tl 
            { \tl_set:Nn \l_siunitx_tmpa_tl { 0 } }
          \int_compare:nNnTF { \l_siunitx_tmpa_tl } = { 0 } 
            {
              \prop_put:Nnn \l_siunitx_number_in_prop { #1 -decimal }
                { }
              \int_set:Nn \l_siunitx_round_int 
                { \l_siunitx_process_precision_int }
              \siunitx_number_process_pad:n {#1}
            }
            {
              \int_set:Nn \l_siunitx_round_int 
                { \tl_elt_count:N \l_siunitx_tmpa_tl }
              \siunitx_number_process_places_aux_ii:n {#1}
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}[aux]{\siunitx_number_process_places_aux_ii:n}
% For rounding to a fixed number of places, the package finds the
% difference in length between what is present and what is required.
% If the number is too short, there is some simple padding to do.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_places_aux_ii:n #1 {
  \int_sub:Nn \l_siunitx_round_int 
    { \l_siunitx_process_precision_int }
  \int_compare:nNnTF { \l_siunitx_round_int } < { 0 } 
    {
      \int_set:Nn \l_siunitx_round_int { - \l_siunitx_round_int }
      \siunitx_number_process_pad:n {#1}
    }
    {
      \siunitx_number_process_places_init:n {#1}
      \siunitx_number_process_places_loop:n {#1}
      \siunitx_number_process_round_tidy:n {#1}
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_process_places_init:n}
% To keep the code a little clearer.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_places_init:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -integer }
    \l_siunitx_round_integer_in_tl    
  \quark_if_no_value:NT \l_siunitx_round_integer_in_tl
    { \tl_clear:N \l_siunitx_round_integer_in_tl }
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal }
    \l_siunitx_round_decimal_in_tl
  \tl_reverse:N \l_siunitx_round_integer_in_tl
  \tl_reverse:N \l_siunitx_round_decimal_in_tl
  \tl_clear:N \l_siunitx_round_integer_out_tl
  \tl_clear:N \l_siunitx_round_decimal_out_tl
  \bool_set_false:N \l_siunitx_round_bool
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_number_process_places_loop:n}
% If there is a decimal, do the decimal processing then come back here.
% If there is an integer, do the same. Only if both are empty does the
% loop stop.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_places_loop:n #1 {
  \tl_if_empty:NTF \l_siunitx_round_decimal_in_tl 
    {
      \tl_if_empty:NF \l_siunitx_round_integer_in_tl 
        {
          \siunitx_number_process_places_integer:n {#1}
          \siunitx_number_process_places_loop:n {#1}
        }
      \bool_if:NT \l_siunitx_round_bool 
        {
          \tl_put_left:Nn \l_siunitx_round_integer_out_tl { 1 }
          \bool_set_false:N \l_siunitx_round_bool
        }
    }
    {
      \siunitx_number_process_round_decimal:
      \siunitx_number_process_places_loop:n {#1}
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_number_process_places_integer:n}
% Rounding for integers is just a case of carrying digits.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_places_integer:n #1 {
  \int_set:Nn \l_siunitx_tmp_int 
    { \tl_head:V \l_siunitx_round_integer_in_tl }
  \tl_set:Nx \l_siunitx_round_integer_in_tl 
    { \tl_tail:V \l_siunitx_round_integer_in_tl }
  \bool_if:NT \l_siunitx_round_bool
    { \int_incr:N \l_siunitx_tmp_int }
  \bool_set_false:N \l_siunitx_round_bool
  \int_compare:nNnT { \l_siunitx_tmp_int } = { 10 } 
    {
      \int_zero:N \l_siunitx_tmp_int
      \bool_set_true:N \l_siunitx_round_bool 
    }
  \tl_put_left:NV \l_siunitx_round_integer_out_tl \l_siunitx_tmp_int
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_round:}
% The lead-off for rounding is the same for decimal places and 
% significant figures.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_round: {
  \tl_if_empty:NF \l_siunitx_round_tl 
    {
      \bool_if:NT \l_siunitx_process_int_to_dec_bool
        {
          \prop_if_in:NnF \l_siunitx_number_in_prop 
            { mantissa-decimal }
            {
              \prop_put:Nnn \l_siunitx_number_in_prop
                { mantissa-decimal } { 0 }
            }
          \prop_if_in:NnF \l_siunitx_number_in_prop 
            { mantissa-decimal-marker }
            {
              \prop_put:Nnn \l_siunitx_number_in_prop
                { mantissa-decimal-marker } { . }
            }
        }
      \cs_set_nopar:Npx \siunitx_tmp:w 
        {
          \exp_not:N \clist_map_function:nN 
            { mantissa , complex }
            \exp_not:c 
              { siunitx_number_process_ \l_siunitx_round_tl :n }
        }
      \siunitx_tmp:w        
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_process_round_decimal:}
%\begin{macro}[aux]{\siunitx_number_process_round_decimal_aux:}
% The rounding routine for decimals is the same for figures and places,
% so there is a generalised function here. Unfortunately, it is also 
% complicated!
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_round_decimal: {
  \int_compare:nNnF { \l_siunitx_round_int } > { 1 } 
    { \siunitx_number_process_round_decimal_aux: }
  \tl_set:Nx \l_siunitx_round_decimal_in_tl 
    { \tl_tail:V \l_siunitx_round_decimal_in_tl }
  \int_decr:N \l_siunitx_round_int
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_round_decimal_aux: {
  \int_set:Nn \l_siunitx_tmp_int 
    { \tl_head:V \l_siunitx_round_decimal_in_tl }
  \bool_if:NT \l_siunitx_round_bool 
    { \int_incr:N \l_siunitx_tmp_int }
  \bool_set_false:N \l_siunitx_round_bool
  \int_compare:nNnTF { \l_siunitx_round_int } = { 1 } 
    {
      \int_compare:nNnT { \l_siunitx_tmp_int } > { 4 } 
        { \bool_set_true:N \l_siunitx_round_bool }
    }
    {
      \int_compare:nNnT { \l_siunitx_tmp_int } = { 10 } 
        {
          \bool_set_true:N \l_siunitx_round_bool
          \int_zero:N \l_siunitx_tmp_int
        }
      \tl_put_left:NV \l_siunitx_round_decimal_out_tl 
        \l_siunitx_tmp_int
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_process_round_tidy:n}
%\begin{macro}[aux]{\siunitx_number_process_round_tidy_aux:w}
% To put data back again: there is a check to see if the number has been
% rounded to zero and a minimal value has been requested.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_round_tidy:n #1 {
  \int_compare:nNnTF
    {
      0 \l_siunitx_round_integer_out_tl +
      0 \l_siunitx_round_decimal_out_tl
    } 
      = { 0 }
    {
      \fp_compare:nNnTF { \l_siunitx_process_round_min_tl } = { 0 }
        {
          \prop_put:Nnn \l_siunitx_number_in_prop { #1 -integer } { 0 }
          \prop_put:NnV \l_siunitx_number_in_prop { #1 -decimal }
            \l_siunitx_round_decimal_out_tl
        }
        {
          \exp_last_unbraced:NV \siunitx_number_process_round_tidy_aux:w
            \l_siunitx_process_round_min_tl . . \q_stop {#1}
        }
    }
    {
      \prop_put:NnV \l_siunitx_number_in_prop { #1 -integer }
        \l_siunitx_round_integer_out_tl
      \tl_if_empty:NTF \l_siunitx_round_decimal_out_tl
        {
          \prop_del:Nn \l_siunitx_number_in_prop { #1 -decimal }
          \prop_del:Nn \l_siunitx_number_in_prop { #1 -decimal-marker }
        }
        {
          \prop_put:NnV \l_siunitx_number_in_prop { #1 -decimal }
            \l_siunitx_round_decimal_out_tl
        }    
     }
}
\cs_new_protected_nopar:Npn
  \siunitx_number_process_round_tidy_aux:w #1 . #2 . #3 \q_stop #4 {
  \prop_put:Nnn \l_siunitx_number_in_prop { comparator } { < }
  \prop_put:Nnn \l_siunitx_number_in_prop { #4 -integer } {#1}
  \tl_if_empty:nTF {#2}
    { \prop_del:Nn \l_siunitx_number_in_prop { #4 -decimal } }
    { \prop_put:Nnn \l_siunitx_number_in_prop { #4 -decimal } {#2} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_scientific:}
%\begin{macro}[aux]{\siunitx_number_process_scientific_aux_i:nnn}
%\begin{macro}[aux]{\siunitx_number_process_scientific_aux_ii:nnn}
%\begin{macro}[aux]{\siunitx_number_process_scientific_large:nnn}
%\begin{macro}[aux]{\siunitx_number_process_scientific_small:wn}
% Converting a number to scientific form is done such that the number
% of places involved is unchanged. The first step is to skip any
% complex-number containing input and to recover the stored data.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_scientific: {
  \prop_if_in:NnF \l_siunitx_number_in_prop { complex } 
    {
      \prop_get:NnN \l_siunitx_number_in_prop { mantissa-integer }
        \l_siunitx_tmpa_tl
      \quark_if_no_value:NT \l_siunitx_tmpa_tl
        { \tl_set:Nn \l_siunitx_tmpa_tl { 0 } }
      \prop_get:NnN \l_siunitx_number_in_prop { mantissa-decimal }
        \l_siunitx_tmpb_tl
      \quark_if_no_value:NT \l_siunitx_tmpb_tl
        { \tl_clear:N \l_siunitx_tmpb_tl }
      \tl_set:Nx \l_siunitx_tmpa_tl
        { { \l_siunitx_tmpa_tl } { \l_siunitx_tmpb_tl } }
      \prop_get:NnN \l_siunitx_number_in_prop { exponent-integer }
        \l_siunitx_tmpb_tl
      \quark_if_no_value:NT \l_siunitx_tmpb_tl
        { \tl_set:Nn \l_siunitx_tmpb_tl { 0 } }
      \tl_set:Nx \l_siunitx_tmpa_tl
        { \l_siunitx_tmpa_tl { \l_siunitx_tmpb_tl } }
      \exp_last_unbraced:NV \siunitx_number_process_scientific_aux_i:nnn
        \l_siunitx_tmpa_tl
    }
}         
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_scientific_aux_i:nnn #1#2#3 {
  \int_compare:nNnF { #1 + 0 #2 } = { 0 }
    { \siunitx_number_process_scientific_aux_ii:nnn {#1} {#2} {#3} }
}
%    \end{macrocode}
% The code here works on a loop, standardising the mantissa into the
% range \( 1 \le x < 10 \). 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_scientific_aux_ii:nnn #1#2#3 {
  \int_compare:nNnTF {#1} > { 9 }
    { \siunitx_number_process_scientific_large:nnn {#1} {#2} {#3} }
    {
      \int_compare:nNnTF {#1} > { 0 }
        {
          \prop_put:Nnn \l_siunitx_number_in_prop
            { mantissa-integer } {#1}

          \tl_if_empty:nTF {#2}
            {
              \prop_del:Nn \l_siunitx_number_in_prop 
                { mantissa-decimal }
              \prop_del:Nn \l_siunitx_number_in_prop 
                { mantissa-decimal-marker }
            }
            {
              \prop_put:Nnn \l_siunitx_number_in_prop
                { mantissa-decimal } {#2}
              \prop_if_in:NnF \l_siunitx_number_in_prop 
                { mantissa-decimal-marker }
                {
                  \prop_put:Nnn \l_siunitx_number_in_prop 
                    { mantissa-decimal-marker } { . } 
                }
            }
          \int_compare:nNnF {#3} = { 0 }
            {
              \int_set:Nn \l_siunitx_tmp_int {#3}
              \prop_put:Nnn \l_siunitx_number_in_prop { exponent } 
                { true }
              \prop_put:NnV \l_siunitx_number_in_prop 
                { exponent-integer } \l_siunitx_tmp_int
            }
        }      
        {
          \siunitx_number_process_scientific_small:wn
            #2 \q_stop {#3}
        }
    }    
}
%    \end{macrocode}
% The fastest way to find the smallest digit of the integer part is
% using some mathematics. This does limit the range of the input, but
% in real cases this should not be an issue.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_scientific_large:nnn #1#2#3 {
  \int_set:Nn \l_siunitx_tmp_int { \int_div_truncate:nn {#1} { 10 } }
  \tl_set:Nx \l_siunitx_tmpa_tl { \int_use:N \l_siunitx_tmp_int }
  \int_set:Nn \l_siunitx_tmp_int { #1 - 10 * \l_siunitx_tmp_int }
  \tl_set:Nx \l_siunitx_tmpa_tl
    { 
      { \l_siunitx_tmpa_tl } { \int_use:N \l_siunitx_tmp_int #2 } 
      { #3 + 1 }
    }
  \exp_last_unbraced:NV \siunitx_number_process_scientific_aux_ii:nnn
    \l_siunitx_tmpa_tl
}
%    \end{macrocode}
% For small numbers, the important digit is easy to find.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_scientific_small:wn #1#2 \q_stop #3 {
   \siunitx_number_process_scientific_aux_ii:nnn {#1} {#2} { #3 - 1 }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_sign:}
% Sorting out signs consists of two parts: retaining a plus if necessary
% and adding an explicit sign.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_sign: {
  \bool_if:NF \l_siunitx_process_plus_tl 
    {
      \prop_if_in:NnTF \l_siunitx_number_in_prop { mantissa-sign }
        { \siunitx_number_process_sign_plus:n { mantissa } }
        {
          \prop_if_in:NnT \l_siunitx_number_in_prop { complex-sign }
            { 
              \prop_if_in:NnF \l_siunitx_number_in_prop { mantissa }
                { \siunitx_number_process_sign_plus:n { complex } }
            } 
        }
      \prop_if_in:NnT \l_siunitx_number_in_prop { exponent-sign }
        { \siunitx_number_process_sign_plus:n { exponent } }
    }
  \tl_if_empty:NF \l_siunitx_process_sign_tl 
    {
      \prop_if_in:NnTF \l_siunitx_number_in_prop { mantissa }
        { \siunitx_number_process_sign_add:n { mantissa } }
        {
          \prop_if_in:NnT \l_siunitx_number_in_prop { complex }
            { \siunitx_number_process_sign_add:n { complex } } 
        }
      \prop_if_in:NnT \l_siunitx_number_in_prop { exponent }
        { \siunitx_number_process_sign_add:n { exponent } }
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_number_process_sign_add:n}
% Adding a sign to an existing number needs a couple of to make sure
% there is a number to add to, and to see if there is a sign already.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_sign_add:n #1 {
  \prop_if_in:NnF \l_siunitx_number_in_prop { #1 -sign } 
    {
      \prop_if_in:NnF \l_siunitx_number_in_prop { #1 -had-sign } 
        {
          \prop_get:NnN \l_siunitx_number_in_prop {#1}
            \l_siunitx_tmpa_tl
          \tl_if_empty:NTF \l_siunitx_tmpa_tl 
            {
              \prop_put:NnV \l_siunitx_number_in_prop { sign } 
                \l_siunitx_process_sign_tl 
            }
            {
              \prop_put:NnV \l_siunitx_number_in_prop { #1 -sign } 
                \l_siunitx_process_sign_tl
            }
        }    
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\c_siunitx_plus_tl}
%\begin{macro}[aux]{\siunitx_number_process_sign_plus:n}
% Holding onto a plus works very much in the same way as adding a sign:
% some quick tests and an assignment. Using a pre-defined token list is
% a speed-related choice: very slightly faster comparison.
%    \begin{macrocode}
\tl_new:N \c_siunitx_plus_tl
\tl_set:Nn \c_siunitx_plus_tl { + }
\cs_new_protected_nopar:Npn \siunitx_number_process_sign_plus:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -sign } 
    \l_siunitx_tmpa_tl
  \tl_if_eq:NNT \c_siunitx_plus_tl \l_siunitx_tmpa_tl 
    { 
      \prop_del:Nn \l_siunitx_number_in_prop { #1 -sign } 
      \prop_put:Nnn \l_siunitx_number_in_prop { #1 -had-sign } { true }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_uncertainty:}
%\begin{macro}[aux]{\siunitx_number_process_uncertainty_aux:n}
% There may be a need to expand uncertainties into a decimal and integer
% part. This is done here so that the core \texttt{in} code is faster.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_uncertainty: {
  \clist_map_function:nN { mantissa , complex }
    \siunitx_number_process_uncertainty_aux:n  
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_uncertainty_aux:n #1 {
  \prop_if_in:NnT \l_siunitx_number_in_prop { #1 -uncertainty } 
    {
      \prop_if_in:NnTF \l_siunitx_number_in_prop { #1 -decimal-marker } 
        { \siunitx_number_process_uncertainty_decimal:n {#1} }
        { \siunitx_number_process_uncertainty_integer:n {#1} }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_process_uncertainty_decimal:n}
%\begin{macro}[aux]{\siunitx_number_process_uncertainty_count:nn}
% To deal with an error in the decimal part, care needs to be taken to
% correctly pad with zeros and also to allow for the possibility that
% the error crosses the decimal--integer boundary.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_uncertainty_decimal:n #1 {
  \siunitx_number_process_uncertainty_count:nn {#1} { decimal }
  \siunitx_number_process_uncertainty_count:nn {#1} { uncertainty }
  \tl_clear:N \l_siunitx_uncertainty_decimal_tl
  \tl_clear:N \l_siunitx_uncertainty_integer_tl
  \int_compare:nNnTF 
    { \l_siunitx_process_uncertainty_int } >
      { \l_siunitx_process_decimal_int } 
    { \siunitx_number_process_uncertainty_separate: }
    { \siunitx_number_process_uncertainty_pad: }
  \tl_if_empty:NF \l_siunitx_uncertainty_integer_tl 
    {
      \prop_put:NnV \l_siunitx_number_in_prop 
        { #1 -uncertainty-integer } 
        \l_siunitx_uncertainty_integer_tl
    } 
  \prop_put:NnV \l_siunitx_number_in_prop { #1 -uncertainty-decimal } 
    \l_siunitx_uncertainty_decimal_tl
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal-marker } 
    \l_siunitx_tmpa_tl
  \prop_put:NnV \l_siunitx_number_in_prop 
    { #1 -uncertainty-decimal-marker } \l_siunitx_tmpa_tl
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_uncertainty_count:nn #1#2 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 - #2 } 
    \l_siunitx_tmpa_tl
  \int_set:cn { l_siunitx_process_ #2 _int } 
    { \tl_elt_count:N \l_siunitx_tmpa_tl }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_process_uncertainty_pad:}
% Uncertainty is short: add zeros.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_uncertainty_pad: {
  \int_while_do:nNnn
    { \l_siunitx_process_uncertainty_int } <
      { \l_siunitx_process_decimal_int }
    {
      \tl_put_right:Nn \l_siunitx_uncertainty_decimal_tl {0} 
      \int_incr:N \l_siunitx_process_uncertainty_int
    }
  \tl_put_right:NV \l_siunitx_uncertainty_decimal_tl 
    \l_siunitx_tmpa_tl
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_process_uncertainty_separate:}
%\begin{macro}{\siunitx_number_process_uncertainty_separate_aux:N}
% Find the integer--decimal boundary and work appropriately.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_uncertainty_separate: {
  \tl_map_function:NN \l_siunitx_tmpa_tl 
    \siunitx_number_process_uncertainty_separate_aux:N
}
\cs_new_protected:Npn 
  \siunitx_number_process_uncertainty_separate_aux:N #1 {
  \int_compare:nNnTF 
    { \l_siunitx_process_uncertainty_int } >
      { \l_siunitx_process_decimal_int } 
    { \tl_put_right:Nn \l_siunitx_uncertainty_integer_tl {#1} }
    { \tl_put_right:Nn \l_siunitx_uncertainty_decimal_tl {#1} }
  \int_decr:N \l_siunitx_process_uncertainty_int
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_process_uncertainty_integer:n}
% Relatively easy: the uncertainty is in the integer part of the number,
% and so there is no need to generate zeros.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_uncertainty_integer:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -uncertainty }
    \l_siunitx_tmpa_tl
  \prop_put:NnV \l_siunitx_number_in_prop { #1 -uncertainty-integer }
    \l_siunitx_tmpa_tl
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_process_zero_fill:}
%\begin{macro}[aux]{\siunitx_number_process_zero_fill_aux:n}
%\begin{macro}[aux]{\siunitx_number_process_zero_fill_aux:nn}
% Checks for adding zeros to each component are carried out. The nesting 
% here makes checking the appropriate flag a little more efficient.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_process_zero_fill: {
  \siunitx_number_process_zero_fill_aux:n { integer }
  \siunitx_number_process_zero_fill_aux:n { decimal }
}
\cs_new_nopar:Npn \siunitx_number_process_zero_fill_aux:n #1 {
  \bool_if:cT { l_siunitx_process_ #1 _zero_bool } 
    {
      \siunitx_number_process_zero_fill_aux:nn { mantissa } {#1}
      \siunitx_number_process_zero_fill_aux:nn { complex }  {#1}
      \siunitx_number_process_zero_fill_aux:nn { exponent } {#1}
    }
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_process_zero_fill_aux:nn #1#2 {
  \prop_if_in:NnT \l_siunitx_number_in_prop { #1 -decimal-marker } 
    {
      \prop_if_in:NnF \l_siunitx_number_in_prop { #1 - #2 } 
        { \prop_put:Nnn \l_siunitx_number_in_prop { #1 - #2 } { 0 } }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Formatting numbers for output}
%
% Getting numbers ready for printing requires the reconstruction of the
% number from the various parts processed earlier. Spaces and brackets
% are added back into the main numbers, as the various parts are also 
% correctly formatted. The difference between the \texttt{in} and
% \texttt{out} store is that the later can include formatting such as 
% hard spaces.
% 
%\begin{macro}{\l_siunitx_number_out_prop}
% Like the \texttt{in} version!
%    \begin{macrocode}
\prop_new:N \l_siunitx_number_out_prop
%    \end{macrocode}
%\end{macro} 
%
%\begin{macro}{\l_siunitx_group_sep_tl}
%\begin{macro}{\l_siunitx_output_decimal_tl}
% A couple of variables are declared here, as they need a little more
% work than just storage.
%    \begin{macrocode}
\tl_new:N \l_siunitx_group_sep_tl
\tl_new:N \l_siunitx_output_decimal_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_complex_after_bool}
% A setting for where complex numbers go.
%    \begin{macrocode}
\bool_new:N \l_siunitx_complex_after_bool
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_brackets_bool}
%\begin{macro}{\l_siunitx_bracket_close_tl}
%\begin{macro}{\l_siunitx_output_complex_copy_bool}
%\begin{macro}{\l_siunitx_output_decimal_copy_bool}
%\begin{macro}{\l_siunitx_exponent_base_tl}
%\begin{macro}{\l_siunitx_exponent_product_tl}
%\begin{macro}{\l_siunitx_group_decimal_bool}
%\begin{macro}{\l_siunitx_group_four_bool}
%\begin{macro}{\l_siunitx_group_integer_bool}
%\begin{macro}{\l_siunitx_negative_color_tl}
%\begin{macro}{\l_siunitx_bracket_open_tl}
%\begin{macro}{\l_siunitx_output_uncert_close_tl}
%\begin{macro}{\l_siunitx_output_complex_tl}
%\begin{macro}{\l_siunitx_output_uncert_open_tl}
%\begin{macro}{\l_siunitx_uncert_sep_bool}
%\begin{macro}{\l_siunitx_tight_bool}
%\begin{macro}{\l_siunitx_uncert_sep_tl}
% Lots of settings, some used only for numbers, some more widely.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  bracket-numbers           .bool_set:N = \l_siunitx_brackets_bool,
  close-bracket             .tl_set:N   = \l_siunitx_bracket_close_tl, 
  complex-root-position     .choice:,
  complex-root-position
    / after-number          .code:n     =
      { \bool_set_true:N \l_siunitx_complex_after_bool } ,
  complex-root-position
    / before-number          .code:n     =
      { \bool_set_false:N \l_siunitx_complex_after_bool } ,
  copy-complex-root         .bool_set:N = 
    \l_siunitx_output_complex_copy_bool,
  copy-decimal-marker       .bool_set:N = 
    \l_siunitx_output_decimal_copy_bool,
  exponent-base             .tl_set:N   = \l_siunitx_exponent_base_tl,
  exponent-product          .tl_set:N   = 
    \l_siunitx_exponent_product_tl,
  group-decimal-digits      .bool_set:N = 
    \l_siunitx_group_decimal_bool,
  group-digits              .meta:n = 
    {
      group-decimal-digits = #1,
      group-integer-digits = #1
    },
  group-four-digits         .bool_set:N = \l_siunitx_group_four_bool,
  group-integer-digits      .bool_set:N = 
    \l_siunitx_group_integer_bool,
  group-separator           .code:n     = 
    {
      \tl_set:Nn \l_siunitx_group_sep_tl { {#1} }
    },
  negative-color            .tl_set:N   = \l_siunitx_negative_color_tl,
  open-bracket              .tl_set:N   = \l_siunitx_bracket_open_tl, 
  output-close-uncertainty  .tl_set:N   = 
    \l_siunitx_output_uncert_close_tl,
  output-complex-root       .tl_set:N   = \l_siunitx_output_complex_tl ,
  output-decimal-marker     .code:n     = 
    {
      \tl_set:Nn \l_siunitx_output_decimal_tl { {#1} }
    },
  output-open-uncertainty   .tl_set:N   = 
    \l_siunitx_output_uncert_open_tl, 
  separate-uncertainty      .bool_set:N = \l_siunitx_uncert_sep_bool,
  tight-spacing             .bool_set:N = \l_siunitx_tight_bool,
  uncertainty-separator     .tl_set:N   = \l_siunitx_uncert_sep_tl,
}
\keys_set:nn { siunitx } { 
  bracket-numbers           = true, % (
  close-bracket             = ),
  complex-root-position     = after-number,
  copy-decimal-marker       = false,
  exponent-base             = 10,
  exponent-product          = \times,
  group-decimal-digits      = true,
  group-integer-digits      = true,
  group-separator           = \,,
  open-bracket              = (, % ) (
  output-close-uncertainty  = ),
  output-complex-root       = \mathrm { i },
  output-decimal-marker     = .,
  output-open-uncertainty   = (, % )
}
%    \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} 
%\end{macro} 
%\end{macro} 
%\end{macro} 
%
%\begin{macro}{\siunitx_number_format:}
% The master control function for formatting output: the usual set up.
% The number is put back together in stages. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format: {
  \prop_if_empty:NF \l_siunitx_number_in_prop 
    {
      \prop_clear:N \l_siunitx_number_out_prop
      \siunitx_number_format_reassemble:
      \siunitx_number_format_complex:
      \siunitx_number_format_sign:n { mantissa }
      \siunitx_number_format_sign:n { exponent }
      \siunitx_number_format_relation:
      \siunitx_number_format_color:
      \siunitx_number_format_final:
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_brackets:n}
%\begin{macro}{\siunitx_number_format_brackets_aux:n}
% There are various points at which brackets might be added to
% avoid ambiguity. The function here adds the appropriate tokens
% around whatever is in the supplied named store.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_brackets:n #1 {
  \bool_if:NT \l_siunitx_brackets_bool 
    {
      \prop_if_in:NnT \l_siunitx_number_out_prop { #1 -bracket } 
        {
          \siunitx_number_format_brackets_aux:n {#1}
          \prop_del:Nn \l_siunitx_number_out_prop { #1 -bracket }
        }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_brackets_aux:n #1 {
  \prop_get:NnN \l_siunitx_number_out_prop { #1 -result } 
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    {
      \prop_get:NnN \l_siunitx_number_out_prop {#1} \l_siunitx_tmpa_tl
    }
  \siunitx_tl_put_left_math:NV \l_siunitx_tmpa_tl 
    \l_siunitx_bracket_open_tl
  \siunitx_tl_put_right_math:NV \l_siunitx_tmpa_tl 
    \l_siunitx_bracket_close_tl
  \str_if_eq:nnTF {#1} { result } 
    { \prop_put:NnV \l_siunitx_number_out_prop {#1} \l_siunitx_tmpa_tl }
    {
      \prop_put:NnV \l_siunitx_number_out_prop { #1 -result } 
        \l_siunitx_tmpa_tl
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_color:}
%\begin{macro}{\siunitx_number_format_color_aux:n}
% If the mantissa is negative, then any colour for output might change.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_color: {
  \tl_if_empty:NF \l_siunitx_negative_color_tl 
    { 
      \siunitx_number_format_color_aux:n { mantissa-sign }
      \siunitx_number_format_color_aux:n { sign }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_color_aux:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop {#1} \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    {
      \str_if_eq:VnT \l_siunitx_tmpa_tl { - }
        {
           \prop_put:NnV \l_siunitx_number_out_prop { color } 
             \l_siunitx_negative_color_tl
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_complex:}
%\begin{macro}[aux]{\siunitx_number_format_complex_aux:n}
%\begin{macro}[aux]{\siunitx_number_format_complex_aux:}
% The real and complex parts of each number are reassembled, with 
% brackets if needed.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_complex: {
  \prop_if_in:NnT \l_siunitx_number_in_prop { complex-root } 
    {
      \prop_if_in:NnTF \l_siunitx_number_out_prop { complex }
        {
          \siunitx_number_format_brackets:n { complex }
          \siunitx_number_format_complex_aux:n { complex }
          \siunitx_number_format_complex_aux:n { complex-result }
          \prop_if_in:NnT \l_siunitx_number_out_prop 
            { complex-uncertainty }
            { 
              \siunitx_number_format_complex_aux:n 
                { complex-uncertainty } 
            }  
        }
        {
          \tl_set:Nx \l_siunitx_tmpa_tl
            { 
              \exp_not:N \siunitx_ensuremath:n 
                { \exp_not:V \l_siunitx_output_complex_tl } 
            }
          \prop_put:NnV \l_siunitx_number_out_prop { complex }
            \l_siunitx_tmpa_tl
        }
        \siunitx_number_format_join_complex:
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_complex_aux:n #1 {
  \siunitx_number_format_complex_aux:
  \prop_get:NnN \l_siunitx_number_out_prop {#1} \l_siunitx_tmpb_tl
  \bool_if:NTF \l_siunitx_complex_after_bool
    {
      \siunitx_tl_put_right_math:NV \l_siunitx_tmpb_tl 
        \l_siunitx_tmpa_tl
    }
    {
      \siunitx_tl_put_left_math:NV \l_siunitx_tmpb_tl 
        \l_siunitx_tmpa_tl
    }
  \prop_put:NnV \l_siunitx_number_out_prop {#1} \l_siunitx_tmpb_tl
}
\cs_new_protected_nopar:Npn \siunitx_number_format_complex_aux: {
  \tl_set:Nn \l_siunitx_tmpa_tl
    {
      \use:c 
        {
          siunitx_ \l_siunitx_print_type_tl _ 
          math \l_siunitx_font_family_tl :n
        }
    }
  \bool_if:NTF \l_siunitx_output_complex_copy_bool
    { 
      \prop_get:NnN \l_siunitx_number_in_prop { complex-root } 
        \l_siunitx_tmpb_tl
      \tl_put_right:Nx \l_siunitx_tmpa_tl 
        { { \exp_not:V \l_siunitx_tmpb_tl } }
    }
    {
      \tl_put_right:Nx \l_siunitx_tmpa_tl 
        { { \exp_not:V \l_siunitx_output_complex_tl } }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_copy:n}
%\begin{macro}{\siunitx_number_format_copy:nn}
% Just copy across.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_copy:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop  {#1} \l_siunitx_tmpa_tl
  \prop_put:NnV \l_siunitx_number_out_prop {#1} \l_siunitx_tmpa_tl
}
\cs_new_protected_nopar:Npn \siunitx_number_format_copy:nn #1#2 {
  \prop_get:NnN \l_siunitx_number_out_prop {#1} \l_siunitx_tmpa_tl
  \prop_put:NnV \l_siunitx_number_out_prop {#2} \l_siunitx_tmpa_tl
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_final:}
% For numbers which do not contain an exponent, the mantissa result is
% simply copied to the final output position. On the other hand, for
% exponents there are further checks, which are handed off to dedicated
% functions. There is also a check for complex numbers with no real
% part, which needs to be \enquote{copied} to the standard result 
% slot.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_final: {
  \prop_if_in:NnT \l_siunitx_number_out_prop { complex }
    {
      \prop_if_in:NnF \l_siunitx_number_out_prop { mantissa-result }
        { 
          \siunitx_number_format_copy:nn { complex } 
            { mantissa-result } 
        }
    }
  \prop_if_in:NnTF \l_siunitx_number_out_prop { exponent }
    {
      \siunitx_number_format_final_exponent:
      \prop_if_in:NnTF \l_siunitx_number_out_prop { mantissa-result } 
        { \siunitx_number_format_final_combined: }
        { \siunitx_number_format_final_exponent_only: }
    }
    { \siunitx_number_format_copy:nn { mantissa-result } { result } }
  \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa-bracket } 
    {
      \prop_put:Nnn \l_siunitx_number_out_prop { result-bracket } 
        { true }
      \prop_del:Nn \l_siunitx_number_out_prop { mantissa-bracket } 
    }
  \prop_if_in:NnT \l_siunitx_number_out_prop { comparator } 
    {
      \siunitx_number_format_brackets:n { result }
      \prop_get:NnN \l_siunitx_number_out_prop { comparator }
        \l_siunitx_tmpa_tl
      \prop_get:NnN \l_siunitx_number_out_prop { result }
        \l_siunitx_tmpb_tl
      \tl_put_right:No \l_siunitx_tmpa_tl { \l_siunitx_tmpb_tl }
      \prop_put:NnV \l_siunitx_number_out_prop { result }
        \l_siunitx_tmpa_tl      
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_format_final_combined:}
% When there is both a mantissa and an exponent, the mantissa is
% combined with the product sign before adding the exponent part on.
% The combined result is then stored. The marker
% \texttt{result-bracket-exponent} indicates that the number needs
% brackets due to the exponent part, but not in other cases.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_final_combined: {
  \siunitx_number_format_brackets:n { mantissa }
  \prop_get:NnN \l_siunitx_number_out_prop { mantissa-result } 
    \l_siunitx_tmpa_tl
  \bool_if:NTF \l_siunitx_tight_bool 
    {  
      \tl_set:Nx \l_siunitx_tmpb_tl 
        { { \exp_not:V \l_siunitx_exponent_product_tl } }
    }
    {  
      \tl_set:Nx \l_siunitx_tmpb_tl 
        { { } \exp_not:V \l_siunitx_exponent_product_tl { } }
    }
  \siunitx_tl_put_right_math:NV \l_siunitx_tmpa_tl
    \l_siunitx_tmpb_tl
  \prop_get:NnN \l_siunitx_number_out_prop { exponent-result } 
    \l_siunitx_tmpb_tl
  \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl
  \prop_put:NnV \l_siunitx_number_out_prop { result } 
    \l_siunitx_tmpa_tl
  \prop_put:Nnn \l_siunitx_number_out_prop 
    { result-bracket-exponent } { true }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_format_final_exponent:}
% When there is an exponent, the base always needs to be added to the
% front of the number itself. The number must be superscripted, of 
% course.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_final_exponent: {
  \prop_get:NnN \l_siunitx_number_out_prop { exponent } 
    \l_siunitx_tmpa_tl
  \tl_set:Nx \l_siunitx_tmpa_tl 
   { ^ { \exp_not:V \l_siunitx_tmpa_tl } }
  \tl_put_left:NV \l_siunitx_tmpa_tl \l_siunitx_exponent_base_tl
  \prop_put:NnV \l_siunitx_number_out_prop { exponent-result } 
    \l_siunitx_tmpa_tl
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_format_final_exponent_only:}
% When there is only an exponent, a check must be made for a 
% sign in the mantissa part. If there is one, it is copied across.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_number_format_final_exponent_only: {
  \prop_get:NnN \l_siunitx_number_in_prop { mantissa-sign }
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl  
    { 
      \bool_if:NT \l_siunitx_tight_bool 
        {  
          \tl_set:Nx \l_siunitx_tmpa_tl 
            { { \exp_not:V \l_siunitx_tmpa_tl } }
        }
      \prop_get:NnN \l_siunitx_number_out_prop { exponent-result }
        \l_siunitx_tmpb_tl
      \siunitx_tl_put_left_math:NV \l_siunitx_tmpb_tl 
        \l_siunitx_tmpa_tl
      \prop_put:NnV \l_siunitx_number_out_prop { exponent-result }
        \l_siunitx_tmpb_tl
    }
  \siunitx_number_format_copy:nn { exponent-result } { result }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_group:n}
%\begin{macro}[aux]{\siunitx_number_format_group_aux:nn}
% Grouping digits only happens if there are no symbols in the input, and
% of course if grouping has been requested.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_group:n #1 {
  \siunitx_number_format_group_aux:nn {#1} { integer }
  \siunitx_number_format_group_aux:nn {#1} { decimal }
  \prop_if_in:NnTF \l_siunitx_number_out_prop { #1 -integer } 
    { \siunitx_number_format_copy:nn { #1 -integer } {#1} }
    { \tl_clear:N \l_siunitx_tmpa_tl }
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -decimal-marker } 
    \l_siunitx_tmpb_tl
  \quark_if_no_value:NF \l_siunitx_tmpb_tl  
    {
      \bool_if:NTF \l_siunitx_output_decimal_copy_bool
        { \tl_set:Nx \l_siunitx_tmpb_tl { { \l_siunitx_tmpb_tl } } }
        {
          \tl_set_eq:NN \l_siunitx_tmpb_tl 
            \l_siunitx_output_decimal_tl
        }
      \tl_set:Nx \l_siunitx_tmpb_tl 
        { 
          \exp_not:N \siunitx_ensuremath:n 
            { \exp_not:V \l_siunitx_tmpb_tl } 
        }
      \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl 
      \prop_put:NnV \l_siunitx_number_out_prop { #1 -decimal-marker }
        \l_siunitx_tmpb_tl
      \prop_get:NnN \l_siunitx_number_out_prop { #1 -decimal } 
        \l_siunitx_tmpb_tl
      \quark_if_no_value:NT \l_siunitx_tmpb_tl   
        { \tl_clear:N \l_siunitx_tmpb_tl }
      \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl
      \prop_put:NnV \l_siunitx_number_out_prop {#1} \l_siunitx_tmpa_tl
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_group_aux:nn #1#2 {
  \prop_if_in:NnT \l_siunitx_number_in_prop { #1 - #2 } 
    {
      \prop_if_in:NnTF \l_siunitx_number_in_prop { symbolic } 
        { \siunitx_number_format_copy:n { #1 - #2 } }
        {
          \bool_if:cTF { l_siunitx_group_ #2 _bool } 
            { \siunitx_number_format_group_four:nn {#1} {#2} }
            { \siunitx_number_format_copy:n { #1 - #2 } }
        } 
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_format_group_four:nn}
%\begin{macro}[aux]{\siunitx_number_format_group_four_aux:NNNNNNw}
%\begin{macro}[aux]{\siunitx_number_format_group_four_aux:nn}
% The idea here is that grouping is only needed for items with at 
% least four tokens in them, and perhaps five if the grouping of 
% four-digit numbers is turned off.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_group_four:nn #1#2 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 - #2 } 
    \l_siunitx_tmpa_tl
  \bool_if:NTF \l_siunitx_group_four_bool 
    { \siunitx_number_format_group_four_aux:nn {#1} {#2} }
    {
      \exp_last_unbraced:NV
        \siunitx_number_format_group_four_aux:NNNNNNw
        \l_siunitx_tmpa_tl \q_no_value \q_no_value \q_no_value
        \q_no_value \q_no_value \q_stop
        { \siunitx_number_format_copy:n {#1 - #2} }
        { \siunitx_number_format_group_four_aux:nn {#1} {#2} }       
    }
}
\cs_new_protected:Npn \siunitx_number_format_group_four_aux:NNNNNNw 
  #1#2#3#4#5#6 \q_stop {
  \quark_if_no_value:NTF #5
}
\cs_new_protected_nopar:Npn \siunitx_number_format_group_four_aux:nn 
  #1#2 {
  \tl_clear:N \l_siunitx_tmpb_tl
  \use:c { siunitx_number_format_group_ #2 : }
  \prop_put:NnV \l_siunitx_number_out_prop { #1 - #2 } 
    \l_siunitx_tmpb_tl
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_format_group_decimal:}
%\begin{macro}[aux]{\siunitx_number_format_group_decimal_aux:}
% Using the \enquote{keep everything on the stack} approach, relatively
% simple recursion is needed. This trick is taken more or less directly
% from \pkg{numprint}.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_group_decimal: {
  \tl_if_empty:NF \l_siunitx_tmpa_tl 
    { 
      \exp_last_unbraced:NV
        \siunitx_number_format_group_decimal_aux:NNNN 
        \l_siunitx_tmpa_tl { } { } { }
    }
}
\cs_new_protected:Npn \siunitx_number_format_group_decimal_aux:NNNN 
  #1#2#3#4 {
  \tl_if_empty:nTF {#2} 
    { \tl_put_right:Nn \l_siunitx_tmpb_tl {#1} }
    {
      \tl_if_empty:nTF {#3} 
        { \tl_put_right:Nn \l_siunitx_tmpb_tl { #1 #2 } }
        {
          \tl_put_right:Nn \l_siunitx_tmpb_tl { #1 #2 #3 }
          \tl_if_empty:nF {#4} 
            {
              \siunitx_tl_put_right_math:NV \l_siunitx_tmpb_tl 
                \l_siunitx_group_sep_tl
              \siunitx_number_format_group_decimal_aux:NNNN #4
            }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_number_format_group_integer:}
%\begin{macro}[aux]{\siunitx_number_format_group_integer_setup:n}
%\begin{macro}[aux]{\siunitx_number_format_group_integer_setup:V}
%\begin{macro}[aux]{\siunitx_number_format_group_integer_setup_aux:NNNN}
%\begin{macro}[aux]{\siunitx_number_format_group_integer_aux:NNNN}
% By keeping everything on the stack, recursion can occur quite 
% efficiently here.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_group_integer: {
  \tl_if_empty:NF \l_siunitx_tmpa_tl 
    { 
      \siunitx_number_format_group_integer_setup:V \l_siunitx_tmpa_tl
    }
}
\cs_new_protected:Npn \siunitx_number_format_group_integer_setup:n #1 {
  \siunitx_number_format_group_integer_setup_aux:NNNN 
    { } #1 { } { } { }
}
\cs_generate_variant:Nn \siunitx_number_format_group_integer_setup:n 
  { V }
\cs_new_protected:Npn 
  \siunitx_number_format_group_integer_setup_aux:NNNN #1#2#3#4 {
  \tl_if_empty:nTF {#2} 
    { \siunitx_number_format_group_integer_aux:NNNN #1 \q_nil }
    {
      \tl_if_empty:nTF {#3} 
        {
          \siunitx_number_format_group_integer_aux:NNNN { } { } #1#2 
            \q_nil
        }
        {
          \tl_if_empty:nTF {#4} 
            {
              \siunitx_number_format_group_integer_aux:NNNN { } #1#2#3
                \q_nil
            }
            {
              \siunitx_number_format_group_integer_setup_aux:NNNN 
                {#1#2#3#4}
            }
        }
    }  
}
\cs_new_protected:Npn 
  \siunitx_number_format_group_integer_aux:NNNN #1#2#3#4 {
  \tl_put_right:Nn \l_siunitx_tmpb_tl {#1#2#3}
  \quark_if_nil:nF {#4} 
    {
      \siunitx_tl_put_right_math:NV \l_siunitx_tmpb_tl 
        \l_siunitx_group_sep_tl
      \siunitx_number_format_group_integer_aux:NNNN #4
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_join_complex:}
% For adding the complex part to the main part of a number.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_join_complex: {
  \siunitx_number_format_sign_complex:
  \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa } 
    {
      \siunitx_number_format_brackets:n { mantissa }
      \prop_get:NnN \l_siunitx_number_out_prop { mantissa-result } 
        \l_siunitx_tmpa_tl 
      \prop_get:NnN \l_siunitx_number_out_prop { complex-result }
        \l_siunitx_tmpb_tl
      \quark_if_no_value:NT \l_siunitx_tmpb_tl
        {
          \prop_get:NnN \l_siunitx_number_out_prop { complex }
            \l_siunitx_tmpb_tl
        }  
      \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl
      \prop_put:NnV \l_siunitx_number_out_prop { mantissa-result } 
        \l_siunitx_tmpa_tl
      \prop_put:Nnn \l_siunitx_number_out_prop { mantissa-bracket } 
        { true }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_join_uncert:}
%\begin{macro}{\siunitx_number_format_join_uncert:n}
%\begin{macro}[aux]{\siunitx_number_format_join_uncert_pm:}
% For adding separated uncertainties to the main part of a number.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_join_uncert: {
  \siunitx_number_format_join_uncert:n { mantissa }
  \siunitx_number_format_join_uncert:n { complex }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_join_uncert:n #1 {
  \prop_get:NnN \l_siunitx_number_out_prop {#1} 
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl  
    {
      \prop_get:NnN \l_siunitx_number_out_prop { #1 -uncertainty }
        \l_siunitx_tmpb_tl
      \quark_if_no_value:NTF \l_siunitx_tmpb_tl 
        { \siunitx_number_format_copy:nn {#1} { #1 -result } } 
        {
          \bool_if:NT \l_siunitx_uncert_sep_bool
            { \siunitx_number_format_join_uncert_pm: }
          \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl
          \prop_put:NnV \l_siunitx_number_out_prop { #1 -result } 
            \l_siunitx_tmpa_tl
          \prop_put:Nnn \l_siunitx_number_out_prop { #1 -bracket } 
            { true }
        }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_join_uncert_pm: {
  \bool_if:NTF \l_siunitx_tight_bool 
    { 
      \tl_put_left:Nn \l_siunitx_tmpb_tl 
        { \siunitx_ensuremath:n { { \pm } } } 
    }
    { 
      \tl_put_left:Nn \l_siunitx_tmpb_tl 
        { \siunitx_ensuremath:n { { } \pm { } } }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_reassemble:}
% The integer, decimal and any non-separated uncertainty parts are 
% put back together. This gives a \enquote{minimal} unit which cannot
% need any brackets or repeated units (if applicable). If the 
% uncertainty is separate, it is stored at this stage pending later 
% re-attachment.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_reassemble: {
  \prop_if_in:NnT \l_siunitx_number_in_prop { mantissa } 
    {
      \siunitx_number_format_group:n { mantissa }
      \siunitx_number_format_uncertainty:n { mantissa }
    }
  \prop_if_in:NnT \l_siunitx_number_in_prop { complex } 
    {
      \siunitx_number_format_group:n { complex }
      \siunitx_number_format_uncertainty:n { complex }
    }
  \prop_if_in:NnT \l_siunitx_number_in_prop { exponent } 
    { \siunitx_number_format_group:n { exponent } }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_relation:}
% A simple check and copy operation for a relation: this will still need
% to be added to the result, of course.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_relation: {
  \prop_get:NnN \l_siunitx_number_in_prop { comparator }
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    {
      \tl_set:Nx \l_siunitx_tmpa_tl
        { 
          \exp_not:N \ensuremath
            { { \exp_not:V \l_siunitx_tmpa_tl } }
        }
      \prop_put:NnV \l_siunitx_number_out_prop { comparator }
        \l_siunitx_tmpa_tl
    }  
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_sign:n}
%\begin{macro}{\siunitx_number_format_sign_complex:}
%\begin{macro}[aux]{\siunitx_number_format_sign_complex:n}
% Some simple sign manipulation: for tight signs, a little shuffling.
% In the complex number case, there is a need for a correction to get
% the right formatting in text mode. For speed reasons, this is done in
% a separate function.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_sign:n #1 {
  \prop_if_in:NnT \l_siunitx_number_out_prop {#1} 
    {
      \prop_get:NnN \l_siunitx_number_in_prop { #1 -sign } 
        \l_siunitx_tmpa_tl
      \quark_if_no_value:NF \l_siunitx_tmpa_tl 
        {
          \bool_if:NT \l_siunitx_tight_bool 
            {
              \tl_set:Nx \l_siunitx_tmpa_tl 
                { { \exp_not:V \l_siunitx_tmpa_tl } }
            }
          \tl_clear:N \l_siunitx_tmpb_tl
          \siunitx_tl_put_left_math:NV \l_siunitx_tmpb_tl 
            \l_siunitx_tmpa_tl
          \prop_put:NnV \l_siunitx_number_out_prop { #1 -sign } 
            \l_siunitx_tmpb_tl        
          \prop_get:NnN \l_siunitx_number_out_prop {#1} 
            \l_siunitx_tmpa_tl   
          \tl_put_left:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl      
          \prop_put:NnV \l_siunitx_number_out_prop {#1} 
            \l_siunitx_tmpa_tl
          \prop_get:NnN \l_siunitx_number_out_prop { #1 -result }
            \l_siunitx_tmpa_tl
          \quark_if_no_value:NF \l_siunitx_tmpa_tl     
            {
              \tl_put_left:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl      
              \prop_put:NnV \l_siunitx_number_out_prop { #1 -result } 
                \l_siunitx_tmpa_tl
            }  
      }
    }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_sign_complex: {
  \siunitx_number_format_sign_complex:n { complex }
  \siunitx_number_format_sign_complex:n { complex-result }
}
\cs_new_protected_nopar:Npn \siunitx_number_format_sign_complex:n #1  {
  \prop_if_in:NnT \l_siunitx_number_out_prop {#1} 
    {
      \prop_get:NnN \l_siunitx_number_in_prop { complex-sign } 
        \l_siunitx_tmpa_tl
      \quark_if_no_value:NF \l_siunitx_tmpa_tl
        {
          \bool_if:NTF \l_siunitx_tight_bool 
            {
              \tl_set:Nx \l_siunitx_tmpa_tl 
                { { \exp_not:V \l_siunitx_tmpa_tl } }
            }
            {
              \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa }
                {
                  \tl_set:Nx \l_siunitx_tmpa_tl
                    { { } \exp_not:V \l_siunitx_tmpa_tl { } }
                }
            }
          \tl_clear:N \l_siunitx_tmpb_tl
          \siunitx_tl_put_left_math:NV \l_siunitx_tmpb_tl 
            \l_siunitx_tmpa_tl
          \prop_put:NnV \l_siunitx_number_out_prop { complex-sign } 
            \l_siunitx_tmpb_tl        
          \prop_get:NnN \l_siunitx_number_out_prop {#1} 
            \l_siunitx_tmpa_tl   
          \tl_put_left:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl      
          \prop_put:NnV \l_siunitx_number_out_prop {#1} 
            \l_siunitx_tmpa_tl 
      }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_format_uncertainty:n}
%\begin{macro}{\siunitx_number_format_uncertainty_joined:n}
%\begin{macro}{\siunitx_number_format_uncertainty_sep:n}
% Uncertainty output varies depending on whether there is a need to 
% separate the error form the number in the output. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_format_uncertainty:n #1 {
  \prop_if_in:NnTF \l_siunitx_number_in_prop { #1 -uncertainty } 
    {
      \bool_if:NTF \l_siunitx_uncert_sep_bool 
        { \siunitx_number_format_uncertainty_sep:n {#1} }
        { \siunitx_number_format_uncertainty_joined:n {#1} }
      \siunitx_number_format_join_uncert:
    }
    { \siunitx_number_format_copy:nn {#1} { #1 -result } }
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_format_uncertainty_joined:n #1 {
  \prop_get:NnN \l_siunitx_number_in_prop { #1 -uncertainty }
    \l_siunitx_tmpa_tl
  \prop_del:Nn \l_siunitx_number_in_prop { #1 -uncertainty }
  \siunitx_tl_put_left_math:NV \l_siunitx_tmpa_tl 
    \l_siunitx_output_uncert_open_tl
  \siunitx_tl_put_left_math:NV \l_siunitx_tmpa_tl
    \l_siunitx_uncert_sep_tl
  \siunitx_tl_put_right_math:NV \l_siunitx_tmpa_tl
    \l_siunitx_output_uncert_close_tl
  \prop_get:NnN \l_siunitx_number_out_prop {#1} \l_siunitx_tmpb_tl
  \tl_put_right:NV \l_siunitx_tmpb_tl \l_siunitx_tmpa_tl
  \prop_put:NnV \l_siunitx_number_out_prop {#1} \l_siunitx_tmpb_tl
}
\cs_new_protected_nopar:Npn 
  \siunitx_number_format_uncertainty_sep:n #1 {
  \prop_if_in:NnT \l_siunitx_number_out_prop { #1 -integer } 
    {
      \prop_if_in:NnF \l_siunitx_number_out_prop 
        { #1 -uncertainty-integer }
        {
          \prop_put:Nnn \l_siunitx_number_out_prop 
            { #1 -uncertainty-integer } { 0 }
        }
    }
    \siunitx_number_format_group:n { #1 -uncertainty }
    \prop_put:NnV \l_siunitx_number_out_prop { #1 -uncertainty }
      \l_siunitx_tmpa_tl
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Numerical output}
%
% The outer level of number processing for actually printing things.
% 
%\begin{macro}{\l_siunitx_number_out_tl}
%\begin{macro}{\l_siunitx_number_out_saved_tl}
% The final result, plus a version for loops.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_out_tl
\tl_new:N \l_siunitx_number_out_saved_tl
%    \end{macrocode}
%\end{macro} 
%\end{macro} 
%
%\begin{macro}{\l_siunitx_number_fraction_tl}
% Fractions need to be build separately, so that there is no problem 
% with stack order.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_fraction_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_compound_bool}
% To help with brackets.
%    \begin{macrocode}
\bool_new:N \l_siunitx_number_compound_bool
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_quotient_mode_tl}
% The action for quotients is stored as a token list variable.
%    \begin{macrocode}
\tl_new:N \l_siunitx_quotient_mode_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_fraction:nn}
% The function used for fractions should be stored here.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_fraction:nn { }
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_output_quotient_tl}
%\begin{macro}{\l_siunix_number_parse_bool}
% Some options related to numbers at the output stage.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  fraction-function  .code:n     = 
     { \cs_set_eq:NN \siunitx_fraction:nn #1 },
  output-product     .tl_set:N   = \l_siunitx_output_product_tl,
  output-quotient    .tl_set:N   = \l_siunitx_output_quotient_tl,
  parse-numbers      .bool_set:N = \l_siunitx_number_parse_bool,
  quotient-mode      .choice:,
  quotient-mode / fraction .code:n = 
    { \tl_set:Nn \l_siunitx_quotient_mode_tl { fraction } },  
  quotient-mode / symbol .code:n = 
    { \tl_set:Nn \l_siunitx_quotient_mode_tl { symbol } },
}
\keys_set:nn { siunitx } {
  fraction-function = \frac,
  output-product    = \times,
  output-quotient   = /,
  parse-numbers     = true,
  quotient-mode     = symbol
}
%    \end{macrocode} 
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\siunitx_number_output:n}
%\begin{macro}{\siunitx_number_output:V}
% The number output system simply sets up for the combined number and
% unit system.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_output:n #1 {
  \tl_clear:N \l_siunitx_unit_tl
  \tl_clear:N \l_siunitx_preunit_tl  
  \siunitx_combined_output:n {#1}
}
\cs_generate_variant:Nn \siunitx_number_output:n { V }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_output_bracket:}
% Compound numbers may need brackets adding.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_bracket: {
  \bool_if:NF \l_siunitx_error_bool 
    {
      \bool_if:NT \l_siunitx_number_compound_bool 
        { \siunitx_number_format_brackets:n { result } }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_output_color:}
% If a colour needs to be set, it is recovered here and put into the
% appropriate place.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_color: {
  \prop_if_in:NnT \l_siunitx_number_out_prop { color }
    { 
      \prop_get:NnN \l_siunitx_number_out_prop { color } 
        \l_siunitx_number_color_tl
    }    
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_output_parse:n}
%\begin{macro}{\siunitx_number_output_parse:V}
%\begin{macro}[aux]{\siunitx_number_output_parse_aux:}
% The parsing system just has to check if there are multiple parts to
% worry about.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_number_output_parse:n #1 {
  \siunitx_number_preprocess:n {#1}
  \bool_if:NF \l_siunitx_error_bool 
    { 
      \tl_if_empty:NTF \l_siunitx_number_multi_tl 
        { \siunitx_number_output_parse_aux: }
        { 
          \use:c 
            { siunitx_number_output_ \l_siunitx_number_multi_tl : } 
        }
    }
}
\cs_generate_variant:Nn \siunitx_number_output_parse:n { V }
%    \end{macrocode}
% There are a few additional tests for printing partwise, as this is
% only needed if there are brackets to add and these are not due to
% an exponent. The test for an exponent is needed as this must force
% the units to come at the end of the number, and there then have to 
% be brackets in the output if there are any separate parts.
%    \begin{macrocode} 
\cs_new_protected_nopar:Npn \siunitx_number_output_parse_aux: {
  \siunitx_number_in_parse:V \l_siunitx_number_arg_tl 
  \bool_if:NF \l_siunitx_error_bool 
    {
      \siunitx_number_process:
      \siunitx_number_format:
      \siunitx_number_output_color:
      \bool_if:NTF \l_siunitx_brackets_bool
        { \siunitx_number_output_single: }
        { 
          \prop_if_in:NnTF \l_siunitx_number_out_prop 
            { result-bracket }
            { \siunitx_number_output_parts: }
            { \siunitx_number_output_single: }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_output_parts:}
%\begin{macro}[aux]{\siunitx_number_output_parts_aux:}
%\begin{macro}[aux]{\siunitx_number_output_parts_aux:n}
%\begin{macro}[aux]{\siunitx_number_output_parts_print:n}
% Printing numbers by parts is necessary when there are units to 
% repeat. That means doing things that have already been done by the
% number formatter again.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_parts: {
  \bool_if:nTF
    {
      \tl_if_empty_p:N \l_siunitx_pre_unit_tl &&
      \tl_if_empty_p:N \l_siunitx_unit_tl 
    }
    { \siunitx_number_output_single: }
    { \siunitx_number_output_parts_aux: }
}
\cs_new_protected_nopar:Npn \siunitx_number_output_parts_aux: {
  \bool_if:NTF \l_siunitx_multi_repeat_bool
    { 
      \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa-result }
        {
          \siunitx_number_output_parts_aux:n { mantissa }
          \siunitx_number_output_parts_aux:n { complex }
        }
      \prop_get:NnN \l_siunitx_number_out_prop { exponent-result }
        \l_siunitx_tmpa_tl  
      \quark_if_no_value:NF \l_siunitx_tmpa_tl
        {
          \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa-result }
            {
              \bool_if:NTF \l_siunitx_tight_bool 
                {  
                  \tl_set:Nx \l_siunitx_tmpb_tl 
                    { { \exp_not:V \l_siunitx_exponent_product_tl } }
                }
                {  
                  \tl_set:Nx \l_siunitx_tmpb_tl 
                    {
                      { } \exp_not:V \l_siunitx_exponent_product_tl { }
                    }
                }
              \siunitx_tl_put_left_math:NV \l_siunitx_tmpa_tl
                \l_siunitx_tmpb_tl
              \prop_put:NnV \l_siunitx_number_out_prop { exponent }
                \l_siunitx_tmpa_tl
            }
          \siunitx_number_output_parts_print:n { exponent }
        }
    }
    { \siunitx_number_output_single: }
}
\cs_new_protected_nopar:Npn \siunitx_number_output_parts_aux:n #1 {
   \prop_if_in:NnT \l_siunitx_number_out_prop {#1} 
     { \siunitx_number_output_parts_print:n {#1} }
   \prop_if_in:NnT \l_siunitx_number_out_prop { #1 -uncertainty } 
     { 
        \bool_if:NTF \l_siunitx_tight_bool 
          { 
            \siunitx_print:nn { number } 
              { \siunitx_ensuremath:n { { \pm } } } 
          }
          { 
            \siunitx_print:nn { number } 
              { \siunitx_ensuremath:n { { } \pm { } } } 
          }
       \siunitx_number_output_parts_print:n { #1 -uncertainty } 
     }
}
\cs_new_protected_nopar:Npn \siunitx_number_output_parts_print:n #1 {
  \siunitx_unit_output_pre_print:
  \prop_get:NnN \l_siunitx_number_out_prop {#1} \l_siunitx_tmpa_tl
  \siunitx_print:nV { number } \l_siunitx_tmpa_tl
  \siunitx_unit_output_print:
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_output_product:}
% For products, there may need to be the addition of brackets if there
% are units about. When not repeating units, some work has to be done to
% print everything correctly. The extra group here is necessary
% otherwise looping will delete the units entirely!
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_product: {
  \bool_if:NTF \l_siunitx_product_brackets_bool
    { 
      \bool_if:nTF
        {
          \tl_if_empty_p:N \l_siunitx_pre_unit_tl &&
          \tl_if_empty_p:N \l_siunitx_unit_tl 
        }
        { \siunitx_number_output_product_aux: }
        { \siunitx_number_output_product_brackets: }
    }
    { 
      \bool_if:NTF \l_siunitx_product_repeat_bool
        { \siunitx_number_output_product_aux: }
        { 
          \siunitx_unit_output_pre_print:
          \tl_set_eq:NN \l_siunitx_unit_saved_tl \l_siunitx_unit_tl
          \tl_clear:N \l_siunitx_pre_unit_tl
          \tl_clear:N \l_siunitx_unit_tl
          \group_begin:  
            \siunitx_number_output_product_aux:
          \group_end:   
          \tl_set_eq:NN \l_siunitx_unit_tl \l_siunitx_unit_saved_tl
          \siunitx_unit_output_print:
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_number_output_product_brackets:}
% When printing products that have to be bracketed, there is a need to
% shuffle the units about a bit.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_product_brackets: {
  \siunitx_unit_output_pre_print:
  \siunitx_print:nn { number } 
    { \siunitx_ensuremath:n { \l_siunitx_bracket_open_tl } }
  \nobreak
  \tl_set_eq:NN \l_siunitx_unit_saved_tl \l_siunitx_unit_tl
  \tl_clear:N \l_siunitx_pre_unit_tl
  \tl_clear:N \l_siunitx_unit_tl
  \siunitx_number_output_product_aux:
  \nobreak
  \tl_set_eq:NN \l_siunitx_unit_tl \l_siunitx_unit_saved_tl
  \siunitx_print:nn { number } 
    { \siunitx_ensuremath:n { \l_siunitx_bracket_close_tl } }
  \siunitx_unit_output_print:
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_number_output_product_aux:}
% Printing the products needs a looping function.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_product_aux: {
  \bool_set_true:N \l_siunitx_number_compound_bool
  \siunitx_number_preprocess:V \l_siunitx_number_arg_tl
  \bool_if:NF \l_siunitx_error_bool
    {
      \tl_if_empty:NTF \l_siunitx_number_multi_tl
        { \siunitx_number_output_parse_aux: }
        { \siunitx_number_output_quotient: }
      \tl_if_empty:NF \l_siunitx_number_next_tl
        {  
          \bool_if:NTF \l_siunitx_tight_bool
            {
              \siunitx_print:nn { number } 
                { 
                  \siunitx_ensuremath:n 
                    { \l_siunitx_output_product_tl } 
                }
            }    
            {
              \siunitx_print:nn  { number } 
                { 
                  \siunitx_ensuremath:n 
                    { { } \l_siunitx_output_product_tl { } }
                }
            } 
          \siunitx_number_output_parse:V \l_siunitx_number_next_tl  
        }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_number_output_quotient:}
% For quotients, there are two options.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_quotient: {
  \use:c 
    { siunitx_number_output_quotient_ \l_siunitx_quotient_mode_tl : }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_output_quotient_fraction:}
% For fraction output, there are quite a lot of braces to construct,
% unfortunately.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_quotient_fraction: {
  \bool_set_false:N \l_siunitx_number_compound_bool
  \siunitx_number_output_quotient_aux_i:
  \tl_set:Nx \l_siunitx_number_out_tl 
    { { \exp_not:V \l_siunitx_number_numerator_tl } }
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { { \exp_not:V \l_siunitx_number_denominator_tl } }
  \tl_put_right:NV \l_siunitx_number_out_tl \l_siunitx_tmpa_tl
  \tl_put_left:Nn \l_siunitx_number_out_tl { \siunitx_fraction:nn } 
  \tl_set:Nx \l_siunitx_number_out_tl 
    {
      \exp_not:N \ensuremath 
        { \exp_not:V \l_siunitx_number_out_tl }
    }
  \siunitx_number_output_single_aux:
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_number_output_quotient_symbol:}
% If a symbol is used for the division, the build process is less 
% complex.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_quotient_symbol: {
  \bool_set_true:N \l_siunitx_number_compound_bool
  \siunitx_number_output_quotient_aux_i:
  \tl_set_eq:NN \l_siunitx_number_out_tl 
    \l_siunitx_number_numerator_tl
  \siunitx_tl_put_right_math:NV \l_siunitx_number_out_tl
    \l_siunitx_output_quotient_tl
  \tl_put_right:NV \l_siunitx_number_out_tl 
    \l_siunitx_number_denominator_tl 
  \siunitx_number_output_single_aux:
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_number_output_quotient_aux_i:}
%\begin{macro}[aux]{\siunitx_number_output_quotient_aux_ii:}
% The two parts of the number are parsed and formatted.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_quotient_aux_i: {
  \siunitx_number_in_parse:V \l_siunitx_number_numerator_tl
  \siunitx_number_output_quotient_aux_ii:
  \siunitx_number_output_color:
  \prop_if_in:NnT \l_siunitx_number_out_prop { complex }
    { 
      \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa }
        {
          \prop_put:Nnn \l_siunitx_number_out_prop 
            { result-bracket } { true } 
          \siunitx_number_format_brackets:n { result }  
        }  
    }
  \prop_get:NnN \l_siunitx_number_out_prop { result }
    \l_siunitx_number_numerator_tl 
  \siunitx_number_in_parse:V \l_siunitx_number_denominator_tl
  \siunitx_number_output_quotient_aux_ii:
  \prop_if_in:NnT \l_siunitx_number_out_prop
    { result-bracket-exponent }
    { 
      \prop_put:Nnn \l_siunitx_number_out_prop { result-bracket } 
        { true }
    }
  \siunitx_number_output_bracket:
  \prop_get:NnN \l_siunitx_number_out_prop { result }
    \l_siunitx_number_denominator_tl    
}
\cs_new_protected_nopar:Npn \siunitx_number_output_quotient_aux_ii: { 
  \siunitx_number_process:
  \siunitx_number_format:
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_number_output_single:}
%\begin{macro}[aux]{\siunitx_number_output_single_aux:}
% Printing a number with no multiple parts is easy. There is a check for
% any units, which if present may force the number to have brackets 
% added. there is then simply a short run to print the units and number.
% The test for bracketing numbers does not happen if there is an 
% exponent: if there is, any other parts will already be bracketed and
% mathematically there is no need for brackets at this point. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_number_output_single: {
  \bool_if:nF
    {
      \tl_if_empty_p:N \l_siunitx_pre_unit_tl &&
      \tl_if_empty_p:N \l_siunitx_unit_tl 
    }
    {
      \prop_if_in:NnF \l_siunitx_number_out_prop { exponent }
        { \siunitx_number_format_brackets:n { result } }
    }
  \siunitx_number_output_bracket:
  \prop_get:NnN \l_siunitx_number_out_prop { result } 
    \l_siunitx_number_out_tl
  \siunitx_number_output_single_aux:
}
\cs_new_protected_nopar:Npn \siunitx_number_output_single_aux: {
  \siunitx_unit_output_pre_print:
  \quark_if_no_value:NTF \l_siunitx_number_out_tl
    { \tl_clear:N \l_siunitx_number_unit_separator_tl }
    { \siunitx_print:nV { number } \l_siunitx_number_out_tl }
  \siunitx_unit_output_print:
}
%    \end{macrocode}
%\end{macro}
%\end{macro} 
%
%\subsection{Angles}
%
% Angles are a special case of numbers for two reasons. First, there
% is always a unit, which is known in advance. Second, there are two
% possible input syntaxes, "\ang{1.23}" and "\ang{1;2;3}". Both need
% to be handled correctly.
% 
%\begin{macro}{\l_siunitx_angle_degree_space_bool}
%\begin{macro}{\l_siunitx_angle_minute_space_bool}
% The need for spaces between parts of an arc needs to be accommodated:
% this is achieved by flagging up the need for such spaces using two
% switches.
%    \begin{macrocode}
\bool_new:N \l_siunitx_angle_degree_space_bool
\bool_new:N \l_siunitx_angle_minute_space_bool
%    \end{macrocode}
%\end{macro}
%\end{macro} 
%
%\begin{macro}{\l_siunitx_angle_marker_box}
%\begin{macro}{\l_siunitx_angle_unit_box}
%\begin{macro}{\l_siunitx_angle_marker_dim}
%\begin{macro}{\l_siunitx_angle_unit_dim}
% When creating astronomy-style angles, the decimal marker and angle 
% symbol have to be boxed up and measured.
%    \begin{macrocode}
\box_new:N \l_siunitx_angle_marker_box
\box_new:N \l_siunitx_angle_unit_box
\dim_new:N \l_siunitx_angle_marker_dim
\dim_new:N \l_siunitx_angle_unit_dim
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_angle_degree_prop}
%\begin{macro}{\l_siunitx_angle_minute_prop}
%\begin{macro}{\l_siunitx_angle_second_prop}
% As there are potentially three numbers to parse, three properly lists
% are made available to hold the results. This allows the code to be
% generalised, with only the name of the storage area varying.
%    \begin{macrocode}
\prop_new:N \l_siunitx_angle_degree_prop
\prop_new:N \l_siunitx_angle_minute_prop
\prop_new:N \l_siunitx_angle_second_prop
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_angle_degree_zero_bool}
%\begin{macro}{\l_siunitx_angle_minute_zero_bool}
%\begin{macro}{\l_siunitx_angle_second_zero_bool}
%\begin{macro}{\l_siunitx_angle_arc_separator_tl}
%\begin{macro}{\l_siunitx_angle_astronomy_bool}
%\begin{macro}{\l_siunitx_angle_unit_separator_tl}
% The angle-specific options are created here.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  add-arc-degree-zero       .bool_set:N = 
    \l_siunitx_angle_degree_zero_bool  , 
  add-arc-minute-zero       .bool_set:N = 
    \l_siunitx_angle_minute_zero_bool  , 
  add-arc-second-zero       .bool_set:N = 
    \l_siunitx_angle_second_zero_bool  ,
  angle-symbol-over-decimal .bool_set:N = 
    \l_siunitx_angle_astronomy_bool    ,
  arc-separator             .tl_set:N   = 
    \l_siunitx_angle_arc_separator_tl  ,
  number-angle-separator    .tl_set:N   = 
    \l_siunitx_angle_unit_separator_tl , 
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_angle_output:nnn}
%\begin{macro}[aux]{\siunitx_angle_output_aux:nnn}
% The input will have been split up by \pkg{xparse}, and so the various
% possible inputs can be picked up. To keep to a minimal route through
% the code, a decimal angle is simply treated like an arc, but with
% any zero-filling disabled.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_angle_output:nnn #1#2#3 {
  \siunitx_angle_init:
  \IfNoValueTF {#2}
    { 
      \bool_set_false:N \l_siunitx_angle_minute_zero_bool
      \bool_set_false:N \l_siunitx_angle_second_zero_bool
      \siunitx_angle_output_aux:nnn {#1} { } { }
    }
    {
      \IfNoValueTF {#3}
        { \siunitx_error:nx { invalid-arc-format } { #1 ; #2 } }
        { \siunitx_angle_output_aux:nnn {#1} {#2} {#3} }
    }
}
\cs_new_protected:Npn \siunitx_angle_output_aux:nnn #1#2#3 {
  \tl_if_empty:nTF { #1#2#3 }
    { \siunitx_error:n { empty-arc } }
    {
      \bool_if:NTF \l_siunitx_number_parse_bool
        { \siunitx_angle_parse:nnn {#1} {#2} {#3} }
        { \siunitx_angle_direct:nnn {#1} {#2} {#3} }
    }
}
%    \end{macrocode}
%\end{macro} 
%\end{macro} 
%
%\begin{macro}{\siunitx_angle_init:}
% The usual separation of initial storage resets.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_angle_init: {
  \bool_set_false:N \l_siunitx_angle_degree_space_bool
  \bool_set_false:N \l_siunitx_angle_minute_space_bool
  \prop_clear:N \l_siunitx_angle_degree_prop
  \prop_clear:N \l_siunitx_angle_minute_prop
  \prop_clear:N \l_siunitx_angle_second_prop
  \tl_clear:N \l_siunitx_preunit_tl 
  \tl_set_eq:NN \l_siunitx_number_unit_separator_tl 
    \l_siunitx_angle_unit_separator_tl
  \cs_set_eq:NN \siunitx_number_in_parse_more:N 
    \siunitx_number_in_parse_restricted:N 
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_angle_direct:nnn}
%\begin{macro}[aux]{\siunitx_angle_direct_aux_i:nnn}
%\begin{macro}[aux]{\siunitx_angle_direct_aux_ii:nnn}
%\begin{macro}[aux]{\siunitx_angle_direct_aux_iii:nnn}
% When printing an arc directly, there is still the need to fill in
% any zero values required and to check the spacing is correct. That
% is done using a chain approach, which is easy to implement and
% reasonably clear.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_angle_direct:nnn #1 {
  \tl_if_empty:nTF {#1}
    {
      \bool_if:NTF \l_siunitx_angle_degree_zero_bool
        { \siunitx_angle_direct_aux_i:nnn { 0 } }
        { \siunitx_angle_direct_aux_i:nnn { } }
    }
    { \siunitx_angle_direct_aux_i:nnn {#1} }
    
}
\cs_new_protected:Npn \siunitx_angle_direct_aux_i:nnn #1#2 {
  \tl_if_empty:nTF {#2}
    {
      \bool_if:NTF \l_siunitx_angle_minte_zero_bool
        { \siunitx_angle_direct_aux_ii:nnn {#1} { 0 } }
        { \siunitx_angle_direct_aux_ii:nnn {#1} { } }
    }
    { \siunitx_angle_direct_aux_ii:nnn {#1} {#2} }
    
}
\cs_new_protected:Npn \siunitx_angle_direct_aux_ii:nnn #1#2#3 {
  \tl_if_empty:nTF {#3}
    {
      \bool_if:NTF \l_siunitx_angle_second_zero_bool
        { \siunitx_angle_direct_aux_iii:nnn {#1} {#2} { 0 } }
        { \siunitx_angle_direct_aux_iii:nnn {#1} {#2} { } }
    }
    { \siunitx_angle_direct_aux_iii:nnn {#1} {#2} {#3} }  
}
\cs_new_protected:Npn \siunitx_angle_direct_aux_iii:nnn #1#2#3 {
  \tl_if_empty:nF {#1}
    {
      \tl_if_empty:nF {#2#3}
        { \bool_set_true:N \l_siunitx_angle_degree_space_bool }
    }
  \tl_if_empty:nF {#2}
    {
      \tl_if_empty:nF {#3}
        { \bool_set_true:N \l_siunitx_angle_minute_space_bool }
    }
  \siunitx_angle_print_direct:nnn {#1} {#2} {#3}
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_angle_parse:nnn}
%\begin{macro}[aux]{\siunitx_angle_parse_aux:nnn}
%\begin{macro}{\siunitx_angle_check_sign:}
%\begin{macro}[aux]{\siunitx_angle_check_sign:n}
%\begin{macro}{\siunitx_angle_zero_fill:}
%\begin{macro}{\siunitx_angle_sign_shuffle:nn}
%\begin{macro}[aux]{\siunitx_angle_sign_shuffle_aux:nnn}
% Parsing an arc requires a number of stages. First, there is the
% basic conversion of the input numbers into three property lists,
% which will contain the data required. There is then a zero-filling
% step, done here so that signs can be shuffled into the correct places.
% After that, a check to make sure there is only one sign for an arc
% before setting up the inter-part spacing and actually printing.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_angle_parse:nnn #1#2#3 {
  \siunitx_angle_parse_aux:nn {#1} { degree }
  \siunitx_angle_parse_aux:nn {#2} { minute }
  \siunitx_angle_parse_aux:nn {#3} { second }
  \siunitx_angle_check_sign:
  \siunitx_angle_zero_fill:
  \prop_if_empty:NF \l_siunitx_angle_degree_prop
    {
      \prop_if_empty:NF \l_siunitx_angle_minute_prop
        { \bool_set_true:N \l_siunitx_angle_degree_space_bool } 
      \prop_if_empty:NF \l_siunitx_angle_second_prop
        { \bool_set_true:N \l_siunitx_angle_degree_space_bool } 
    }
  \prop_if_empty:NF \l_siunitx_angle_minute_prop
    {
      \prop_if_empty:NF \l_siunitx_angle_second_prop
        { \bool_set_true:N \l_siunitx_angle_minute_space_bool } 
    }
  \siunitx_angle_print: 
}
\cs_new_protected:Npn \siunitx_angle_parse_aux:nn #1#2 {
  \prop_clear:N \l_siunitx_number_in_prop
  \tl_if_empty:nF {#1} 
    { 
      \siunitx_number_in_init:
      \siunitx_number_in_parse_aux:n {#1} 
    }
  \prop_get:NnN \l_siunitx_number_in_prop { mantissa-sign-deleted }
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    { 
      \prop_put:NnV \l_siunitx_number_in_prop { mantissa-sign }
        \l_siunitx_tmpa_tl
    }
  \siunitx_number_process:
  \prop_set_eq:cN { l_siunitx_angle_ #2 _prop } 
    \l_siunitx_number_in_prop 
}
%    \end{macrocode}
% Only the highest-order part of an arc can have a sign. This is checked
% now so that the shuffling code is easier to write.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_angle_check_sign: {
  \prop_if_empty:NTF \l_siunitx_angle_degree_prop
    {
      \prop_if_empty:NF \l_siunitx_angle_minute_prop
        { \siunitx_angle_check_sign_aux:n { second } }
    }
    {
      \siunitx_angle_check_sign_aux:n { minute }
      \siunitx_angle_check_sign_aux:n { second } 
    }
}
\cs_new_protected_nopar:Npn \siunitx_angle_check_sign_aux:n #1 {
  \prop_if_in:cnTF { l_siunitx_angle_ #1 _prop }
    { mantissa-sign }
    { \msg_error:nn { siunitx } { bad-arc-sign } }
    {
      \prop_if_in:cnT { l_siunitx_angle_ #1 _prop }
        { mantissa-sign-deleted }
        { \msg_error:nn { siunitx } { bad-arc-sign } }
    }
}
%    \end{macrocode}
% Filling in the zero values is rather awkward as there are signs 
% to worry about. There is therefore a shuffle to move them into the
% correct places.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_angle_zero_fill: {
  \bool_if:nT
    {
      \prop_if_empty_p:N \l_siunitx_angle_second_prop &&
      \l_siunitx_angle_second_zero_bool
    }
    {
      \prop_put:Nnn \l_siunitx_angle_second_prop { mantissa }
        { true }
      \prop_put:Nnn \l_siunitx_angle_second_prop { mantissa-integer }
        { 0 }
    }
  \bool_if:nT
    {
      \prop_if_empty_p:N \l_siunitx_angle_minute_prop &&
      \l_siunitx_angle_minute_zero_bool
    }
    {
      \prop_put:Nnn \l_siunitx_angle_minute_prop { mantissa }
        { true }
      \prop_put:Nnn \l_siunitx_angle_minute_prop { mantissa-integer }
        { 0 }
      \siunitx_angle_sign_shuffle:nn { second } { minute }  
    }
  \bool_if:nT
    {
      \prop_if_empty_p:N \l_siunitx_angle_degree_prop &&
      \l_siunitx_angle_degree_zero_bool
    }
    {
      \prop_put:Nnn \l_siunitx_angle_degree_prop { mantissa }
        { true }
      \prop_put:Nnn \l_siunitx_angle_degree_prop { mantissa-integer }
        { 0 }
      \siunitx_angle_sign_shuffle:nn { second } { degree }
      \siunitx_angle_sign_shuffle:nn { minute } { degree }  
    }
}
\cs_new_protected_nopar:Npn \siunitx_angle_sign_shuffle:nn #1#2 {
  \siunitx_angle_sign_shuffle_aux:nnn {#1} {#2} { }
  \siunitx_angle_sign_shuffle_aux:nnn {#1} {#2} { -deleted }
}
\cs_new_protected_nopar:Npn \siunitx_angle_sign_shuffle_aux:nnn
  #1#2#3 {
  \prop_get:cnN { l_siunitx_angle_ #1 _prop } { mantissa-sign #3 } 
    \l_siunitx_tmpa_tl
  \prop_del:cn { l_siunitx_angle_ #1 _prop } { mantissa-sign #3 } 
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    {
      \prop_put:cnV { l_siunitx_angle_ #2 _prop } { mantissa-sign #3 }
        \l_siunitx_tmpa_tl
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_angle_print:}
%\begin{macro}[aux]{\siunitx_angle_print:nn}
% The standard printing routine examines each part of the arc in turn
% and either does a standard format or calls the special astronomy-style
% routine. There may also be some spaces to add.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_angle_print: {
  \siunitx_angle_print_aux:nn { degree } { \SIUnitSymbolDegree }
  \bool_if:NT \l_siunitx_angle_degree_space_bool
    { 
      \nobreak
      \siunitx_ensuremath:n { \l_siunitx_angle_arc_separator_tl } 
    }
  \siunitx_angle_print_aux:nn { minute } { \SIUnitSymbolArcminute }
  \bool_if:NT \l_siunitx_angle_minute_space_bool
    { 
      \nobreak
      \siunitx_ensuremath:n { \l_siunitx_angle_arc_separator_tl } 
    }
  \siunitx_angle_print_aux:nn { second } { \SIUnitSymbolArcsecond }
}
\cs_new_protected_nopar:Npn \siunitx_angle_print_aux:nn #1#2 {
  \prop_if_empty:cF { l_siunitx_angle_ #1 _prop }
    {
      \prop_set_eq:Nc \l_siunitx_number_in_prop 
        { l_siunitx_angle_ #1 _prop }
      \tl_set:Nn \l_siunitx_unit_tl {#2}  
      \tl_clear:N \l_siunitx_number_out_tl
      \siunitx_number_format:
      \siunitx_number_output_color:
      \bool_if:NTF \l_siunitx_angle_astronomy_bool
        { \siunitx_angle_print_astronomy: }
        { \siunitx_number_output_single: }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_angle_print_astronomy:}
%\begin{macro}[aux]{\siunitx_angle_print_astronomy_aux:}
%\begin{macro}[aux]{\siunitx_angle_print_astronomy_aux:n}
%\begin{macro}[aux]{\siunitx_angle_print_astronomy_marker:}
%\begin{macro}[aux]{\siunitx_angle_print_astronomy_unit:}
% The first check for astronomy-style angles is that there is a decimal
% marker in the current input: if not, the standard method can be used.
% The method for the astronomy-style angle is not straight-forward, so
% needs a little explanation. The integer and decimal parts of the
% number are printed at each end of the function. In the middle is a 
% method to centre the unit symbol on the decimal marker. This is done
% by typesetting the two symbols and measuring their respective widths.
% The two are then put into zero-width boxes, which allows them to be 
% aligned horizontally centred with no vertical change. The larger
% dimension is then used to reconstruct the appropriate width for the
% final output. There is also a need to allow for the \cs{scriptspace}
% added in after superscripts, which otherwise messes up the 
% calculation.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_angle_print_astronomy: {
  \prop_if_in:NnTF \l_siunitx_number_in_prop
    { mantissa-decimal-marker }
    { \siunitx_angle_print_astronomy_aux: }
    { \siunitx_number_output_single: }
}
\cs_new_protected_nopar:Npn \siunitx_angle_print_astronomy_aux: {
  \prop_get:NnN \l_siunitx_number_out_prop { mantissa-integer }
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } 
  \hbox_set:Nn \l_siunitx_angle_marker_box
    {
      \siunitx_print:nn { number } 
        { \siunitx_ensuremath:n { { \l_siunitx_output_decimal_tl } } }
    }
  \hbox_set:Nn \l_siunitx_angle_unit_box
    {
      \siunitx_print:nV { unit } \l_siunitx_unit_tl
      \skip_horizontal:n { -\scriptspace }
    }  
  \siunitx_angle_print_astronomy_aux:n { marker }
  \siunitx_angle_print_astronomy_aux:n { unit }
  \hbox_set:Nn \l_siunitx_angle_marker_box 
    {
      \box_use:N \l_siunitx_angle_marker_box
      \box_use:N \l_siunitx_angle_unit_box
    }
  \dim_compare:nNnTF 
    { \l_siunitx_angle_marker_dim } > { \l_siunitx_angle_unit_dim }
    { \siunitx_angle_print_astronomy_marker: }
    { \siunitx_angle_print_astronomy_unit: }
  \prop_get:NnN \l_siunitx_number_out_prop { mantissa-decimal }
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl  
    { \siunitx_print:nV { number } \l_siunitx_tmpa_tl } 
}
\cs_new_protected_nopar:Npn \siunitx_angle_print_astronomy_aux:n #1 {
  \dim_set:cn { l_siunitx_angle_ #1 _dim  }
    { \box_wd:c { l_siunitx_angle_ #1 _box } }
  \hbox_set_to_wd:cnn { l_siunitx_angle_ #1 _box } { \c_zero_skip }
    {
      \tex_hss:D
      \hbox_unpack:c { l_siunitx_angle_ #1_box }
      \tex_hss:D 
    }
}
\cs_new_protected_nopar:Npn \siunitx_angle_print_astronomy_marker: {
  \hbox_set_to_wd:Nnn \l_siunitx_angle_marker_box 
    { \l_siunitx_angle_marker_dim }
    {
      \tex_hss:D
      \hbox_unpack:N \l_siunitx_angle_marker_box
      \tex_hss:D
    }
  \box_use:N \l_siunitx_angle_marker_box
}
\cs_new_protected_nopar:Npn \siunitx_angle_print_astronomy_unit: {
  \hbox_set_to_wd:Nnn \l_siunitx_angle_marker_box 
    { \l_siunitx_angle_unit_dim } 
    {
      \tex_hss:D
      \hbox_unpack:N \l_siunitx_angle_marker_box
      \tex_hss:D
    }
  \box_use:N \l_siunitx_angle_marker_box
  \skip_horizontal:N \scriptspace
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_angle_print_direct:nnn}
%\begin{macro}[aux]{\siunitx_angle_print_direct_aux:nn}
% The direct printing routine is rather similar to the standard
% one, with just a modified final step.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_angle_print_direct:nnn #1#2#3 {
  \siunitx_angle_print_direct_aux:nn {#1} { \SIUnitSymbolDegree }
  \bool_if:NT \l_siunitx_angle_degree_space_bool
    { 
      \nobreak
      \siunitx_ensuremath:n { \l_siunitx_angle_arc_separator_tl } 
    }
  \siunitx_angle_print_direct_aux:nn {#2} { \SIUnitSymbolArcminute }
  \bool_if:NT \l_siunitx_angle_minute_space_bool
    { 
      \nobreak
      \siunitx_ensuremath:n { \l_siunitx_angle_arc_separator_tl } 
    }
  \siunitx_angle_print_direct_aux:nn {#3} { \SIUnitSymbolArcsecond }
}
\cs_new_protected_nopar:Npn \siunitx_angle_print_direct_aux:nn #1#2 {
  \tl_if_empty:nF {#1}
    {
      \tl_set:Nn \l_siunitx_unit_tl {#2}
      \siunitx_print:nn { number } { \siunitx_ensuremath:n {#1} }
      \siunitx_unit_output_print:
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
% 
%\subsection{Creating unit macros}
%
% Unit macros and related support are created here. To avoid cluttering
% up the user name-space with a lot of short macro names, the standard
% method only makes these available inside the unit-processing functions
% (\cs{SI}, \cs{si} and the \texttt{S} column).
% 
%\begin{macro}{\l_siunitx_declare_list_tl}
% A list of all unit and related functions.
%    \begin{macrocode}
\tl_new:N \l_siunitx_declare_list_tl
\tl_set:Nn \l_siunitx_declare_list_tl { \of \per \raiseto \tothe }
%    \end{macrocode}
%\end{macro} 
%
%\begin{macro}{\siunitx_declare_power_after:Nn}
%\begin{macro}{\siunitx_declare_power_before:Nn}
% Creating powers is all about storing values.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_declare_power_after:Nn #1#2 {
  \tl_put_right:Nn \l_siunitx_declare_list_tl {#1}
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } 
    { \textsuperscript {#2} }
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } 
    { \siunitx_unit_parse_power_after:n {#2} }
}
\cs_new_protected:Npn \siunitx_declare_power_before:Nn #1#2 {
  \tl_put_right:Nn \l_siunitx_declare_list_tl {#1}
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } ##1 
    { ##1 \textsuperscript {#2} }
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } 
    { \siunitx_unit_parse_power_before:n {#2} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_declare_prefix:Nnnn}
% Prefixes need to store both the symbol and the power they represent.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_declare_prefix:Nnnn #1#2#3#4 {
  \tl_put_right:Nn \l_siunitx_declare_list_tl {#1}
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } {#2}
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } 
    {
      \bool_if:NTF \l_siunitx_prefix_symbols_bool 
        { \siunitx_unit_parse_prefix:n {#2} }
        { \siunitx_unit_parse_prefix:nn {#3} {#4} }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_declare_qualifier:Nn}
% Qualifiers just need storing.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_declare_qualifier:Nn #1#2 {
  \tl_put_right:Nn \l_siunitx_declare_list_tl {#1}
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } 
    { \text { ~ } ( #2 ) }
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w }
    { \siunitx_unit_parse_qualifier:n {#2} }
}
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\siunitx_declare_unit:Nnn}
%\begin{macro}[aux]{\siunitx_unit_first_token:n}
% Creating units requires various things to be stored.  This is done
% with several storage bins to keep the code clear.  For the 
% \texttt{macro} definition, the test occurs at use so that there is no
% problem with the creation order for units.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_declare_unit:Nnn #1#2#3 {
  \tl_put_right:Nn \l_siunitx_declare_list_tl {#1}
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } {#2}
  \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } 
    {
      \siunitx_unit_if_literal:nTF {#2}
        { \siunitx_unit_parse_unit:Nn #1 {#2} }
        {#2}
    }
  \tl_if_empty:nTF {#3}
    { 
      \cs_if_free:cF { l_siunitx_ \token_to_str:N #1 _options_tl }
        { 
          \cs_gundefine:c { l_siunitx_ \token_to_str:N #1 _options_tl }
        }
    }
    {
      \cs_if_free:cT { l_siunitx_ \token_to_str:N #1 _options_tl } 
        { \tl_new:c { l_siunitx_ \token_to_str:N #1 _options_tl } }
      \tl_set:cn { l_siunitx_ \token_to_str:N #1 _options_tl } {#3} 
    }
}
\cs_new_protected:Npn \siunitx_unit_first_token:n #1 {
  \exp_last_unbraced:No \token_to_str:N { \tl_head:w #1 \q_stop }
}
%    \end{macrocode}
%\end{macro} 
%\end{macro}
%
%\begin{macro}{\per}
% The \cs{per} function is pretty simple.
%    \begin{macrocode}
\cs_new:cpn { siunitx_ \token_to_str:N \per _literal:w } { / }
\cs_new_protected:cpn { siunitx_ \token_to_str:N \per _function:w } {
  \bool_set_true:N \l_siunitx_per_bool
  \siunitx_unit_parse_per:
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\raiseto}
%\begin{macro}{\tothe}
% Generic versions of the pre-set powers.
%    \begin{macrocode}
\cs_new:cpn { siunitx_ \token_to_str:N \raiseto _literal:w } #1#2 {
  #2
  \textsuperscript {#1}
}
\cs_new_protected:cpn { siunitx_ \token_to_str:N \raiseto _function:w } 
  #1 {
  \siunitx_unit_parse_power_before:n {#1}
}
\cs_new:cpn { siunitx_ \token_to_str:N \tothe _literal:w } #1 {
  \textsuperscript {#1}
}
\cs_new_protected:cpn { siunitx_ \token_to_str:N \tothe _function:w } 
  #1 {
  \siunitx_unit_parse_power_after:n {#1}
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\of}
% A flexible qualifier as well.
%    \begin{macrocode}
\cs_new_protected:cpn { siunitx_ \token_to_str:N \of _literal:w } #1 {
  \text { ~ } ( #1 )
}
\cs_new_protected:cpn { siunitx_ \token_to_str:N \of _function:w } #1 {
  \siunitx_unit_parse_qualifier:n {#1}
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Creating body unit macros}
%
% The user might have asked for the unit macros to be available in the
% document body. If so, then these are created at the start of the 
% document body. 
% 
%\begin{macro}{\l_siunitx_create_free_bool}
%\begin{macro}{\l_siunitx_create_overwrite_bool}
%\begin{macro}{\l_siunitx_create_prespace_bool}
%\begin{macro}{\l_siunitx_create_optional_bool}
%\begin{macro}{\l_siunitx_create_xspace_bool}
% There are a few options which control this behaviour: these are all
% preamble-only.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  free-standing-units    .bool_set:N = \l_siunitx_create_free_bool,
  overwrite-functions    .bool_set:N = 
    \l_siunitx_create_overwrite_bool,
  space-before-unit      .bool_set:N = \l_siunitx_create_prespace_bool,
  unit-optional-argument .bool_set:N = \l_siunitx_create_optional_bool,
  use-xspace             .bool_set:N = \l_siunitx_create_xspace_bool
}
\siunitx_option_deactivate:n {
  free-standing-units, 
  overwrite-functions,
  space-before-unit,
  unit-optional-argument,
  use-xspace
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro} 
%
% The master control macro which occurs at the start of the document.
%    \begin{macrocode}
\AtBeginDocument {
  \bool_if:NTF \l_siunitx_create_free_bool 
    { \siunitx_unit_create_functions: }
    { \siunitx_unit_create_empty_functions: }
}
%    \end{macrocode}
%
%\begin{macro}{\siunitx_unit_create_empty_functions:}
%\begin{macro}[aux]{\siunitx_unit_create_empty_functions_aux:N}
% Without this, horrible things happen with \pkg{memoir} and
% \pkg{hyperref}.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_create_empty_functions: {
  \tl_map_function:NN \l_siunitx_declare_list_tl 
    \siunitx_unit_create_empty_functions_aux:N
}
\cs_new_protected_nopar:Npn 
  \siunitx_unit_create_empty_functions_aux:N #1 {
  \cs_if_free:NT #1 { \cs_set_protected_nopar:Npn #1 { \ERROR } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_create_functions:}
% Creation of macros essentially involves picking up a couple of loops.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_create_functions: {
  \bool_if:NT \l_siunitx_create_overwrite_bool 
    { \tl_map_function:NN \l_siunitx_declare_list_tl \cs_gundefine:N }
  \bool_if:NTF \l_siunitx_create_optional_bool 
    {
      \tl_map_function:NN \l_siunitx_declare_list_tl 
        \siunitx_unit_create_with_arg:N
    }
    {
      \tl_map_function:NN \l_siunitx_declare_list_tl 
        \siunitx_unit_create:N
    }
  \bool_if:NT \l_siunitx_create_xspace_bool 
    { \RequirePackage { xspace } }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_create:N}
%\begin{macro}{\siunitx_unit_create_with_arg:N}
% The creation functions expand everything as far as possible so that
% there is less to do in the document.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_create:N #1 {
  \cs_if_free:NT #1 
    {
      \cs_set:Npx \siunitx_tmp:w 
        {
          \ProvideDocumentCommand \exp_not:N #1 { } 
            {
              \group_begin:
                \exp_not:N \cs_if_free:NF
                  \exp_not:c 
                  { l_siunitx_ \token_to_str:N #1 _options_tl }
                  {
                    \keys_set:nV { siunitx } 
                      \exp_not:c 
                        { l_siunitx_ \token_to_str:N #1 _options_tl }
                  }   
                \bool_if:NT \l_siunitx_create_prespace_bool 
                  {
                    \exp_not:n 
                      { 
                        \siunitx_ensuremath:n 
                          { \l_siunitx_number_unit_separator_tl } 
                      }
                  }
                \exp_not:n { \siunitx_unit_output:nn {#1} { } }
              \group_end:  
              \bool_if:NT \l_siunitx_create_xspace_bool 
                { \exp_not:N \xspace }
            }
        }
      \siunitx_tmp:w
    }
}
\cs_new_protected:Npn \siunitx_unit_create_with_arg:N #1 {
  \cs_if_free:NT #1 
    {
      \cs_set:Npx \siunitx_tmp:w 
        {
          \ProvideDocumentCommand \exp_not:N #1 { o } 
            {
              \group_begin:
                \exp_not:N \cs_if_free:NF
                  \exp_not:c 
                  { l_siunitx_ \token_to_str:N #1 _options_tl }
                  {
                    \keys_set:nV { siunitx } 
                      \exp_not:c 
                        {
                          l_siunitx_ \token_to_str:N #1 _options_tl
                        }
                  }
                \exp_not:N \IfNoValueTF {####1} 
                  { 
                    \bool_if:NT \l_siunitx_create_prespace_bool 
                      {
                        \exp_not:n 
                          { 
                            \siunitx_ensuremath:n 
                              { \l_siunitx_number_unit_separator_tl }
                          }
                      }  
                    \exp_not:n { \siunitx_unit_output:nn {#1} { } } 
                  }
                  { \SI {####1} { \exp_not:N #1 } }
              \group_end:
              \bool_if:NT \l_siunitx_create_xspace_bool
                { \exp_not:N \xspace }
            }
        }
      \siunitx_tmp:w
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_protect_symbols:N}
% There are a few unit names which may be defined by other parts of
% \LaTeX. They need to be unexpandable, as in an \texttt{S} column
% \TeX\ will look for \cs{omit} \emph{before} starting the internal
% version of \cs{si} and doing a redefinition. The same is true 
% for the \cs{color} function, which may well be the first thing in 
% a table cell. The same is true for \cs{array@row@rst}, from REV\TeX,
% which otherwise gives an error.
%    \begin{macrocode}
\AtBeginDocument {
  \cs_if_eq:NNT \color \use_none:n
    { \cs_set_protected:Npn \color #1 { } }
  \cs_set_nopar:Npn \siunitx_tmp:w #1 { }
  \cs_if_eq:NNT \color \siunitx_tmp:w
    { \cs_set_protected:Npn \color #1 { } }  
  \tl_map_function:nN { \bar \color \ng \pm \array@row@rst } 
    \siunitx_protect_symbols:N
}
\tl_put_right:Nn \document { \siunitx_protect_symbols:N \fg }
\cs_new_protected_nopar:Npn \siunitx_protect_symbols:N #1 {
  \cs_if_exist:NT #1 
    {
      \siunitx_cs_if_macro:NT #1 
        { \cs_set_protected_nopar:Npx #1 { \exp_not:V #1 } }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Initial unit processing}
%
% The unit processor has to convert the input (which may be all macros
% or may contain literal input) into formatted text for output.  The 
% input part of the process is used to sort out parsed or literal units.
%
%\begin{macro}{\l_siunitx_unit_forbid_literal_bool}
%\begin{macro}{\l_siunitx_unit_parse_bool}
% One option is related to how units are pre-processed.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  forbid-literal-units .bool_set:N = 
    \l_siunitx_unit_forbid_literal_bool,
  parse-units          .bool_set:N = \l_siunitx_unit_parse_bool
}
\keys_set:nn { siunitx } {
  forbid-literal-units = false,
  parse-units          = true
}
%    \end{macrocode}
%\end{macro} 
%\end{macro}  
% 
%\begin{macro}{\siunitx_unit_in:nn}
%\begin{macro}{\siunitx_unit_in:Vn}
%\begin{macro}{\siunitx_pm:}
% The master function does a very simple checks then hands off. 
% The definition of \cs{pm} needs to be saved here so that it can
% safely be used as an abbreviation for picometre and also in numbers
% for \( \pm \).
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_in:nn #1#2 {
  \bool_if:NTF \l_siunitx_unit_parse_bool 
    {
      \tl_if_empty:nF {#1} 
        {
          \siunitx_unit_if_literal:nTF {#1} 
            {
              \bool_if:NTF \l_siunitx_unit_forbid_literal_bool 
                {
                  \msg_error:nnx { siunitx } { literal-unit }
                    { \exp_not:n {#1} }
                }
                { \siunitx_unit_format_literal:n {#1} }
            }
            {
              \cs_set_eq:NN \siunitx_pm: \pm  
              \siunitx_unit_parse:nn {#1} {#2}
              \siunitx_unit_format:
              \cs_set_eq:NN \pm \siunitx_pm:        
            }
      }
  }
  { \siunitx_unit_format_literal:n {#1} }
}
\cs_generate_variant:Nn \siunitx_unit_in:nn { V }
\cs_new_nopar:Npn \siunitx_pm: { }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_if_literal:nTF}
%\begin{macro}[aux]{\siunitx_unit_if_literal_aux:N}
% A test is needed to see if the input only contains unit macros. This 
% is done by altering setting all of the unit macros to expand to 
% nothing at all. Thus there will only be anything left if there is
% a literal in the unit.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_if_literal:nTF #1#2#3 {
  \group_begin:
    \tl_map_function:NN \l_siunitx_declare_list_tl
      \siunitx_unit_if_literal_aux:N
    \cs_set_eq:NN \of \use_none:n  
    \cs_set_eq:NN \raiseto \use_none:n
    \cs_set_eq:NN \tothe \use_none:n
    \protected@edef \l_siunitx_tmpa_tl {#1}
  \exp_args:NNNV \group_end:
  \tl_set:Nn \l_siunitx_tmpa_tl \l_siunitx_tmpa_tl
  \tl_if_empty:NTF \l_siunitx_tmpa_tl {#3} {#2}
}
\cs_new_protected:Npn \siunitx_unit_if_literal_aux:N #1 {
  \cs_set_eq:NN #1 \prg_do_nothing:
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Parsing macro units}
%
% For macro-based units, the macros are converted into literal text,
% which is then passed on for printing. The code reads through the 
% input to collect up the units, before re-combining everything into
% a single block at the end of the process.
%
%\begin{macro}{\l_siunitx_unit_int}
%\begin{macro}{\l_siunitx_unit_prop}
% Parsed units are stored in a property list, to keep things compact.
% An integer is also needed to count up units.
%    \begin{macrocode}
\int_new:N \l_siunitx_unit_int
\prop_new:N \l_siunitx_unit_prop
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_per_bool}
% To allow \cs{per} to be \enquote{sticky}.
%    \begin{macrocode}
\bool_new:N \l_siunitx_per_bool
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_prefix_symbols_bool}
%\begin{macro}{\l_siunitx_sticky_per_bool}
% Some options are directly related to how units are handled at this
% stage, so need be created before the reconstruction part of the code.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  prefixes-as-symbols .bool_set:N    = \l_siunitx_prefix_symbols_bool,
  sticky-per          .bool_set:N    = \l_siunitx_sticky_per_bool,
}
\keys_set:nn { siunitx } {
  prefixes-as-symbols = true
}
%    \end{macrocode} 
%\end{macro} 
%\end{macro} 
%
%\begin{macro}{\siunitx_unit_parse:nn}
% The unit to be parsed is received here along with any options given.
% The later are needed so that the user can override any saved options
% on a one-off basis.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_parse:nn #1#2 {
  \siunitx_unit_parse_init:
  \siunitx_unit_parse_options:nn {#1} {#2}
  #1
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_parse_init:}
%\begin{macro}[aux]{\siunitx_unit_parse_init_aux:N}
% As always, the initialisation is a separate routine to make life a
% little clearer. The definition of \cs{pm} is saved here as it
% is used by units and numbers.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_parse_init: {
  \prop_clear:N \l_siunitx_unit_prop
  \int_zero:N \l_siunitx_unit_int
  \bool_set_false:N \l_siunitx_per_bool
  \tl_map_function:NN \l_siunitx_declare_list_tl 
    \siunitx_unit_parse_init_aux:N
}
\cs_new_protected:Npn \siunitx_unit_parse_init_aux:N #1 {
  \cs_set_eq:Nc #1 { siunitx_ \token_to_str:N #1 _function:w }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_parse_options:n}
% Any unit-specific options are loaded, followed by re-applying any
% options given for this particular macro. The second call to 
% \cs{keys_set:nn}  is needed to allow the local overriding of settings.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_parse_options:nn #1#2 {
  \tl_if_single:nT {#1}
    {
      \cs_if_free:cF 
        { l_siunitx_ \siunitx_unit_first_token:n {#1} _options_tl }
        {
          \keys_set:nv { siunitx } 
            { l_siunitx_ \siunitx_unit_first_token:n {#1} _options_tl }
          \keys_set:nn { siunitx } {#2}
        }
  }      
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_parse_power_before:n}
%\begin{macro}{\siunitx_unit_parse_power_after:n}
% Storing powers depends on whether they are given before or after
% the unit.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_parse_power_before:n #1 {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { power- \int_eval:n { \l_siunitx_unit_int + 1 } }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl {#1}
}
\cs_new_protected:Npn \siunitx_unit_parse_power_after:n #1 {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { power- \int_use:N \l_siunitx_unit_int }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl {#1}
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_parse_prefix:n}
%\begin{macro}{\siunitx_unit_parse_prefix:nn}
% Saving prefixes always increments the counter. For non-symbolic 
% mode, the base needs to be saved along with the power.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_parse_prefix:n #1 {
  \int_incr:N \l_siunitx_unit_int
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { prefix- \int_use:N \l_siunitx_unit_int }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl {#1}
}
\cs_new_protected:Npn \siunitx_unit_parse_prefix:nn #1#2 {
  \siunitx_unit_parse_prefix:n {#2}
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { prefix-base- \int_use:N \l_siunitx_unit_int }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl {#1}
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_parse_per:}
% The \cs{per} function always applies to the next unit seen, so
% the counter has to be advanced by one.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_parse_per: {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    {  per- \int_eval:n { \l_siunitx_unit_int + 1 } }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl { true }
  \bool_if:NT \l_siunitx_sticky_per_bool
    { \cs_set_eq:NN \per \siunitx_unit_parse_per_error: }
}
\cs_new_protected_nopar:Npn \siunitx_unit_parse_per_error: {
  \msg_error:nn { siunitx } { duplicate-sticky-per }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_parse_qualifier:n}
% Qualifiers never alter the number of units.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_parse_qualifier:n #1 {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { symbol- \int_use:N \l_siunitx_unit_int }
  \prop_if_in:NVF \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
    { \msg_error:nn { siunitx } { qualifier-before-unit } }
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { qualifier- \int_use:N \l_siunitx_unit_int }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl {#1}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_parse_unit:Nn}
%\begin{macro}[aux]{\siunitx_unit_parse_unit_per:}
% For units, there is a check in case a prefix is present (which will 
% have incremented the counter). With the counter correct, simply add
% the literal to the property list. There is also a check to see if
% there is a \enquote{sticky} \cs{per} to think about.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_parse_unit:Nn #1#2 {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { prefix- \int_use:N \l_siunitx_unit_int }
  \prop_if_in:NVTF \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
    {
      \tl_set:Nx \l_siunitx_tmpa_tl 
        { symbol- \int_use:N \l_siunitx_unit_int }
      \prop_if_in:NVT \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
        { \int_incr:N \l_siunitx_unit_int }
    }
    { \int_incr:N \l_siunitx_unit_int }
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { unit- \int_use:N \l_siunitx_unit_int }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl {#1}
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { symbol- \int_use:N \l_siunitx_unit_int }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl {#2}
  \siunitx_unit_parse_unit_per: 
}
\cs_new_protected_nopar:Npn \siunitx_unit_parse_unit_per: {
  \bool_if:NT \l_siunitx_sticky_per_bool 
    {
      \bool_if:NT \l_siunitx_per_bool 
        {
          \tl_set:Nx \l_siunitx_tmpa_tl 
            { per- \int_use:N \l_siunitx_unit_int }
          \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
            { true }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Unit formatting}
%
%\begin{macro}{\l_siunitx_preunit_tl}
%\begin{macro}{\l_siunitx_unit_tl}
%\begin{macro}{\l_siunitx_unit_current_tl}
%\begin{macro}{\l_siunitx_unit_denominator_tl}
%\begin{macro}{\l_siunitx_unit_numerator_tl}
%\begin{macro}{\l_siunitx_unit_saved_tl}
% Storage space for creating unit output.
%    \begin{macrocode}
\tl_new:N \l_siunitx_preunit_tl
\tl_new:N \l_siunitx_unit_tl
\tl_new:N \l_siunitx_unit_current_tl
\tl_new:N \l_siunitx_unit_denominator_tl
\tl_new:N \l_siunitx_unit_numerator_tl
\tl_new:N \l_siunitx_unit_saved_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_unit_denominator_int}
%\begin{macro}{\l_siunitx_unit_numerator_int}
% For tracking in case brackets are needed.
%    \begin{macrocode}
\int_new:N \l_siunitx_unit_denominator_int
\int_new:N \l_siunitx_unit_numerator_int
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_unit_prefix_int}
%\begin{macro}{\l_siunitx_unit_prefix_base_int}
%\begin{macro}{\l_siunitx_unit_prefix_current_tl}
% Used to calculate the overall prefix value.
%    \begin{macrocode}
\int_new:N \l_siunitx_unit_prefix_int
\int_new:N \l_siunitx_unit_prefix_base_int
\tl_new:N \l_siunitx_unit_prefix_current_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_unit_prefix_gram_int}
% Formatting units is complicated by the fact that the kilogram is a 
% base unit, making conversions a little more awkward.
%    \begin{macrocode}
\int_new:N \l_siunitx_unit_prefix_gram_int
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_omit_unit_space_bool}
% Needed to omit the space between a number an a unit when printing
% symbols and when there is no numerator unit.
%    \begin{macrocode}
\bool_new:N \l_siunitx_omit_unit_space_bool
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_per_auto_bool}
%\begin{macro}{\l_siunitx_per_fraction_bool}
%\begin{macro}{\l_siunitx_per_mode_tl}
%\begin{macro}{\l_siunitx_power_number_bool}
%\begin{macro}{\l_siunitx_qualifier_mode_tl}
%\begin{macro}{\l_siunitx_per_two_parts_bool}
% For saving settings.
%    \begin{macrocode}
\bool_new:N \l_siunitx_per_auto_bool
\bool_new:N \l_siunitx_per_fraction_bool
\tl_new:N \l_siunitx_per_mode_tl
\bool_new:N \l_siunitx_power_number_bool
\bool_new:N \l_siunitx_two_parts_bool
\tl_new:N \l_siunitx_qualifier_mode_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_unit_denominator_bracket_bool}
%\begin{macro}{\l_siunitx_unit_separator_tl}
%\begin{macro}{\l_siunitx_per_symbol_tl}
% At this stage, output formatting options are created.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  bracket-unit-denominator .bool_set:N 
    = \l_siunitx_unit_denominator_bracket_bool,
  inter-unit-separator .tl_set:N = \l_siunitx_unit_separator_tl ,
  per-mode             .choice:,
  per-mode / fraction .code:n = 
    {
      \bool_set_false:N \l_siunitx_per_auto_bool
      \bool_set_true:N \l_siunitx_per_fraction_bool
      \bool_set_true:N \l_siunitx_per_two_parts_bool
      \tl_set:Nn \l_siunitx_per_mode_tl { fraction }
    },
  per-mode / power      .meta:n = { per-mode = reciprocal } ,
  per-mode / power-positive-first .meta:n = 
    { per-mode = reciprocal-positive-first } ,
  per-mode / reciprocal .code:n = 
    {
      \bool_set_false:N \l_siunitx_per_auto_bool
      \bool_set_false:N \l_siunitx_per_fraction_bool
      \bool_set_false:N \l_siunitx_per_two_parts_bool
      \tl_clear:N \l_siunitx_per_mode_tl 
    },
  per-mode / reciprocal-positive-first .code:n = 
    {
      \bool_set_false:N \l_siunitx_per_auto_bool
      \bool_set_false:N \l_siunitx_per_fraction_bool
      \bool_set_true:N \l_siunitx_per_two_parts_bool
      \tl_clear:N \l_siunitx_per_mode_tl 
    },
  per-mode / repeated-symbol .code:n = 
    {
      \bool_set_false:N \l_siunitx_per_auto_bool
      \bool_set_false:N \l_siunitx_per_fraction_bool
      \bool_set_false:N \l_siunitx_per_two_parts_bool
      \tl_set:Nn \l_siunitx_per_mode_tl { repeat }
    },
  per-mode / symbol .code:n = 
    {
      \bool_set_false:N \l_siunitx_per_auto_bool
      \bool_set_true:N \l_siunitx_per_fraction_bool
      \bool_set_true:N \l_siunitx_per_two_parts_bool
      \tl_set:Nn \l_siunitx_per_mode_tl { symbol }
    },
  per-mode / symbol-or-fraction .code:n = 
    {
      \bool_set_true:N \l_siunitx_per_auto_bool
      \bool_set_true:N \l_siunitx_per_fraction_bool
      \bool_set_true:N \l_siunitx_per_two_parts_bool
      \tl_set:Nn \l_siunitx_per_mode_tl { symbol }
    },
  per-symbol           .tl_set:N  = \l_siunitx_per_symbol_tl,
  power-font           .choice:,
  power-font / number  .code:n    = 
    { \bool_set_true:N \l_siunitx_power_number_bool },
  power-font / unit    .code:n    = 
    { \bool_set_false:N \l_siunitx_power_number_bool },
  qualifier-mode       .choice:,
  qualifier-mode / brackets .code:n = 
    { \tl_set:Nn \l_siunitx_qualifier_mode_tl { brackets } },
  qualifier-mode / space .code:n = 
    { \tl_set:Nn \l_siunitx_qualifier_mode_tl { space } },
  qualifier-mode / subscript .code:n = 
    { \tl_set:Nn \l_siunitx_qualifier_mode_tl { subscript } },
  qualifier-mode / text      .code:n = 
    { \tl_set:Nn \l_siunitx_qualifier_mode_tl { text } },
}
\keys_set:nn { siunitx } {
  bracket-unit-denominator = true,
  inter-unit-separator     = \,,
  per-mode                 = reciprocal,
  per-symbol               = /,
  power-font               = number,
  qualifier-mode           = subscript
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format:}
% Most of the work is done by the loop, with a little tidying up for
% fraction-like output. Before starting the loop, there is a check for
% the case of a single reciprocal unit when per is set up to create a
% symbol. In that special case, the space between a number and a unit 
% has to be removed.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format: {
  \siunitx_unit_format_init:
  \int_compare:nNnT { \l_siunitx_unit_int } = { 1 } 
    { 
      \str_if_eq:VnT \l_siunitx_per_mode_tl { symbol }
        {
          \prop_if_in:NnT \l_siunitx_unit_prop { per-1 }
            { \bool_set_true:N \l_siunitx_omit_unit_space_bool }
        }
    }
  \int_while_do:nNnn { \l_siunitx_unit_int } > { 0 }
    {
      \siunitx_unit_format_prefix:
      \siunitx_unit_format_symbol:
      \siunitx_unit_format_qualifier:
      \siunitx_unit_format_power:
      \siunitx_unit_format_add:
      \int_decr:N \l_siunitx_unit_int
    }  
  \bool_if:NT \l_siunitx_per_two_parts_bool 
    {
      \bool_if:NTF \l_siunitx_per_fraction_bool
        { \siunitx_unit_format_fraction: }
        { \siunitx_unit_format_sorted: }
    }
} 
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_add:}
%\begin{macro}[aux]{\siunitx_unit_format_add_aux:n}
% Adding the current unit to the output means checking where it goes.
% The odd code when adding a space is to pick up repeated per symbols, 
% which need to suppress the space.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_add: {
  \bool_if:NTF \l_siunitx_per_two_parts_bool 
    {
      \tl_set:Nx \l_siunitx_tmpb_tl 
        { per- \int_use:N \l_siunitx_unit_int }
      \prop_if_in:NVTF \l_siunitx_unit_prop \l_siunitx_tmpb_tl 
        {
          \siunitx_unit_format_add_aux:n { _denominator }
          \int_incr:N \l_siunitx_unit_denominator_int
        }
        {
          \siunitx_unit_format_add_aux:n { _numerator }
          \int_incr:N \l_siunitx_unit_numerator_int
        }
    }
    { \siunitx_unit_format_add_aux:n { } }
  \tl_clear:N \l_siunitx_unit_current_tl
} 
\cs_new_protected_nopar:Npn \siunitx_unit_format_add_aux:n #1 {
  \tl_if_empty:cF { l_siunitx_unit #1 _tl } 
    {
      \str_if_eq:VnTF \l_siunitx_per_mode_tl { repeat }
        {
          \tl_set:Nx \l_siunitx_tmpa_tl 
            { per- \int_eval:n { \l_siunitx_unit_int + 1 } }
          \prop_if_in:NVF \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
            {
              \siunitx_tl_put_right_math:NV \l_siunitx_unit_current_tl
                \l_siunitx_unit_separator_tl
            }
        }
        {  
          \siunitx_tl_put_right_math:NV \l_siunitx_unit_current_tl
            \l_siunitx_unit_separator_tl
        }
    }
  \tl_put_left:cV { l_siunitx_unit #1 _tl } \l_siunitx_unit_current_tl
} 
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_fraction:}
%\begin{macro}[aux]{\siunitx_unit_format_fraction:}
%\begin{macro}[aux]{\siunitx_unit_format_auto:}
%\begin{macro}[aux]{\siunitx_unit_format_symbol:}
%\begin{macro}[aux]{\siunitx_unit_format_symbol_aux:}
%\begin{macro}[aux]{\siunitx_unit_format_symbol_aux_alt:}
% When making (\emph{psuedo}-)fractions there is a check to place a
% \( 1 \) in the numerator is it's blank. For symbol mode, this is
% only done if there is no number. Then some construction work.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_fraction: {
  \int_compare:nNnTF { \l_siunitx_unit_denominator_int } > { 0 } 
    {
      \bool_if:NTF \l_siunitx_per_auto_bool
        { \siunitx_unit_format_fraction_auto: }
        {
          \use:c 
            { siunitx_unit_format_fraction_ \l_siunitx_per_mode_tl : }
        }
    }
    { \tl_set_eq:NN \l_siunitx_unit_tl \l_siunitx_unit_numerator_tl }
} 
\cs_new_protected_nopar:Npn \siunitx_unit_format_fraction_fraction: {
  \tl_if_empty:NT \l_siunitx_unit_numerator_tl 
    { \tl_set:Nn \l_siunitx_unit_numerator_tl { 1 } }
  \tl_set:Nx \l_siunitx_unit_numerator_tl 
    { { \exp_not:V \l_siunitx_unit_numerator_tl } }
  \tl_put_left:Nn \l_siunitx_unit_numerator_tl 
    { \siunitx_print:nn { unit } }   
  \tl_set:Nx \l_siunitx_unit_numerator_tl 
    { { \exp_not:V \l_siunitx_unit_numerator_tl } }
  \tl_set:Nx \l_siunitx_unit_denominator_tl 
    { { \exp_not:V \l_siunitx_unit_denominator_tl } }
  \tl_put_left:Nn \l_siunitx_unit_denominator_tl 
    { \siunitx_print:nn { unit } }   
  \tl_set:Nx \l_siunitx_unit_denominator_tl 
    { { \exp_not:V \l_siunitx_unit_denominator_tl } }
  \tl_set:Nn \l_siunitx_unit_tl { \siunitx_fraction:nn }
  \tl_put_right:NV \l_siunitx_unit_tl \l_siunitx_unit_numerator_tl
  \tl_put_right:NV \l_siunitx_unit_tl \l_siunitx_unit_denominator_tl
  \tl_set:Nx \l_siunitx_unit_tl 
    { \exp_not:N \ensuremath { \exp_not:V \l_siunitx_unit_tl } }
} 
%    \end{macrocode}
% For the \opt{symbol} setting, there is a need to deal with the
% possible \opt{symbol-or-fraction} choice. That is achieved by
% setting up both the \opt{fraction} and \opt{symbol} output.
% In the automatic mode, both cases are combined inside a 
% \cs{tex_mathchoice:D}, with appropriate protection, before sending
% everything through for printing.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_fraction_auto: {
    \mode_if_math:TF
      {
        \group_begin:
          \siunitx_unit_format_fraction_fraction:
        \exp_args:NNNV \group_end:
        \tl_set:Nn \l_siunitx_tmpa_tl \l_siunitx_unit_tl
        \group_begin:
          \siunitx_unit_format_fraction_symbol:
        \exp_args:NNNV \group_end:
        \tl_set:Nn \l_siunitx_tmpb_tl \l_siunitx_unit_tl
        \tl_set:Nx \l_siunitx_tmpb_tl
          {
            \siunitx_print:nn { unit } 
              { \exp_not:V \l_siunitx_tmpb_tl }
          }
        \tl_set:Nx \l_siunitx_unit_tl
          {
            \exp_not:N \ensuremath {
              \tex_mathchoice:D
                { \exp_not:V \l_siunitx_tmpa_tl }
                { \exp_not:V \l_siunitx_tmpb_tl }
                { \exp_not:V \l_siunitx_tmpb_tl }
                { \exp_not:V \l_siunitx_tmpb_tl }
              }
          }
      }
      { \siunitx_unit_format_fraction_symbol: }
}
%    \end{macrocode}
% For a normal symbol, the two parts of the input are arranged either
% side of the symbol itself in math mode.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_fraction_symbol: {
  \siunitx_unit_format_fraction_symbol_aux:
  \int_compare:nNnT { \l_siunitx_unit_denominator_int } > { 1 }
    {
      \bool_if:NT \l_siunitx_unit_denominator_bracket_bool 
        {
          \siunitx_tl_put_left_math:NV \l_siunitx_unit_denominator_tl
            \l_siunitx_bracket_open_tl
          \siunitx_tl_put_right_math:NV \l_siunitx_unit_denominator_tl
            \l_siunitx_bracket_close_tl
        }
    }
  \tl_set_eq:NN \l_siunitx_unit_tl \l_siunitx_unit_numerator_tl
  \siunitx_tl_put_right_math:NV \l_siunitx_unit_tl
    \l_siunitx_per_symbol_tl
  \tl_put_right:NV \l_siunitx_unit_tl \l_siunitx_unit_denominator_tl
}
\cs_new_protected_nopar:Npn 
  \siunitx_unit_format_fraction_symbol_aux: { }
\cs_new_protected_nopar:Npn 
  \siunitx_unit_format_fraction_symbol_aux_alt: {
  \tl_if_empty:NT \l_siunitx_unit_numerator_tl 
    { \tl_set:Nn \l_siunitx_unit_numerator_tl { 1 } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_init:}
% The normal initialisation stuff.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_init: {
  \bool_set_false:N \l_siunitx_omit_unit_space_bool
  \tl_clear:N \l_siunitx_unit_tl
  \tl_clear:N \l_siunitx_unit_current_tl
  \tl_clear:N \l_siunitx_unit_denominator_tl
  \int_zero:N \l_siunitx_unit_prefix_gram_int
  \tl_clear:N \l_siunitx_unit_numerator_tl
  \int_zero:N \l_siunitx_unit_prefix_base_int
  \int_zero:N \l_siunitx_unit_prefix_int
  \int_zero:N \l_siunitx_unit_denominator_int
  \int_zero:N \l_siunitx_unit_numerator_int
  \tl_map_function:NN \l_siunitx_declare_list_tl
    \siunitx_unit_print_literal_aux:N
} 
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_literal:n}
%\begin{macro}{\siunitx_unit_format_literal_aux:N}
% If the unit given contains anything which is not a unit macro, then
% any unit macros that are there simply dump literal meanings. There is 
% then a little work to do sorting out "~" and \texttt{.} characters at 
% the outer level. 
%    \begin{macrocode}
\char_make_active:N \~
\cs_new_protected:Npn \siunitx_unit_format_literal:n #1 {
  \int_zero:N \l_siunitx_unit_prefix_int
  \tl_map_function:NN \l_siunitx_declare_list_tl
    \siunitx_unit_print_literal_aux:N
  \tl_set:Nn \l_siunitx_unit_tl {#1}
  \tl_set:Nx \l_siunitx_tmpa_tl 
    {
      \exp_not:N \siunitx_ensuremath:n
        { \exp_not:V \l_siunitx_unit_separator_tl }
    }
  \tl_replace_all_in:NnV \l_siunitx_unit_tl { . } 
    \l_siunitx_tmpa_tl
  \tl_replace_all_in:NnV \l_siunitx_unit_tl { ~ } 
    \l_siunitx_tmpa_tl
  \siunitx_unit_format_literal_extras: 
}
\cs_new_protected:Npn \siunitx_unit_print_literal_aux:N #1 {
  \cs_set_eq:Nc #1 { siunitx_ \token_to_str:N #1 _literal:w }
}  
\char_make_space:N \~
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_literal_extras:}
%\begin{macro}[aux]{\siunitx_unit_format_literal_extras_aux:nN}
% The code here deals with characters outside the normal range that 
% can appear in units in UTF-8 and related encodings. The idea is to
% do a search and replace, thus avoiding any active characters.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_literal_extras: { 
  \siunitx_unit_format_literal_extras_aux:nN { 176 }
    \SIUnitSymbolDegree
  \siunitx_unit_format_literal_extras_aux:nN { 181 }
    \SIUnitSymbolMicro
  \siunitx_unit_format_literal_extras_aux:nN { 197 }
    \SIUnitSymbolAngstrom 
}
\cs_new_protected_nopar:Npn 
  \siunitx_unit_format_literal_extras_aux:nN #1#2 {
  \char_set_lccode:nn { `\@ } {#1}
  \tl_to_lowercase:n
    { 
      \tl_replace_all_in:NnV \l_siunitx_unit_tl { @ } 
        \l_siunitx_unit_tl
    }
}
\xetex_if_engine:F {
  \luatex_if_engine:F 
    {
      \AtBeginDocument 
        {
          \cs_if_exist:NTF \inputencodingname
            {
              \tl_set:Nn \l_siunitx_tmpa_tl { latin1 , latin5 , latin9 }
              \clist_if_in:NVF \l_siunitx_tmpa_tl \inputencodingname 
                { 
                  \cs_set_eq:NN \siunitx_unit_format_literal_extras: 
                    \scan_stop:
                }
            }
            { 
              \cs_set_eq:NN \siunitx_unit_format_literal_extras:
                \scan_stop: 
            }
        }  
    }  
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_power:}
% To format powers, there are a few issues: are brackets needed, is
% the power reciprocal and is fraction-formatting in operation. Repeated
% per symbols make life a little more complex, as they have to be 
% handled here as well. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_power: {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { power- \int_use:N \l_siunitx_unit_int }
  \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NTF \l_siunitx_tmpa_tl  
    {
      \tl_set:Nx \l_siunitx_tmpa_tl 
        { per- \int_use:N \l_siunitx_unit_int }
      \prop_if_in:NVT \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
        {
          \tl_set:Nn \l_siunitx_tmpa_tl { 1 }
          \siunitx_unit_format_power_aux:
        }
    }
    { \siunitx_unit_format_power_aux: }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_unit_format_power_aux:}
%\begin{macro}[aux]{\siunitx_unit_format_power_aux:n}
%\begin{macro}[aux]{\siunitx_unit_format_power_aux:nn}
% The auxiliary function needs to make sure that the printing routine
% prints the power as a number, not as text: the two modes may be
% different. A search and replace function is needed for superscripts
% in text mode so that negative signs get printed correctly.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_power_aux: {
  \str_if_eq:VnTF \l_siunitx_per_mode_tl { repeat }
    { \siunitx_unit_format_power_repeat: }
    { \siunitx_unit_format_power_per: }
  \str_if_eq:VnF \l_siunitx_tmpa_tl { 1 }
    {
      \siunitx_unit_format_power_brackets:
      \tl_put_right:Nx \l_siunitx_unit_current_tl 
        { 
          ^ 
            { 
              \siunitx_unit_format_power_aux:n 
                { \exp_not:V \l_siunitx_tmpa_tl } 
            } 
        }
    }
}
\cs_new_protected:Npn \siunitx_unit_format_power_aux:n #1 {
  \bool_if:NTF \l_siunitx_power_number_bool
    { \siunitx_unit_format_power_aux:nn { number } {#1} }
    { \siunitx_unit_format_power_aux:nn { unit } {#1} }
}
\cs_new_protected:Npn \siunitx_unit_format_power_aux:nn #1#2 {
  \bool_if:cTF { l_siunitx_ #1 _math_mode_bool }
    { \siunitx_print:nn {#1} {#2} }
    {
      \tl_set:Nn \l_siunitx_tmpa_tl {#2}
      \tl_replace_all_in:Nnn \l_siunitx_tmpa_tl { - } 
        { \text { \c_siunitx_minus_tl } }
      \siunitx_print:nV {#1} \l_siunitx_tmpa_tl
   }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}[aux]{\siunitx_unit_format_power_brackets:}
% A check is made for a qualifier with a space, which needs brackets
% if there is also a power.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_power_brackets: {
  \tl_set:Nx \l_siunitx_tmpb_tl 
    { bracket- \int_use:N \l_siunitx_unit_int }  
  \prop_if_in:NVT \l_siunitx_unit_prop \l_siunitx_tmpb_tl 
    {
      \siunitx_tl_put_left_math:NV \l_siunitx_unit_current_tl 
        \l_siunitx_bracket_open_tl
      \siunitx_tl_put_right_math:NV \l_siunitx_unit_current_tl
        \l_siunitx_bracket_close_tl
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_unit_format_power_per:}
%\begin{macro}[aux]{\siunitx_unit_format_power_repeat:}
% For dealing with \cs{per} and repeated \cs{per} symbols. The sign
% change does not use any numbers, as this makes life easier with 
% non-integer values.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_power_per: {
  \tl_set:Nx \l_siunitx_tmpb_tl 
    { per- \int_use:N \l_siunitx_unit_int }  
  \prop_if_in:NVT \l_siunitx_unit_prop \l_siunitx_tmpb_tl 
    {
      \bool_if:NF \l_siunitx_per_fraction_bool 
        {
          \tl_if_in:NnTF \l_siunitx_tmpa_tl { - } 
            {
              \cs_set:Npn \siunitx_tmp:w ##1 - ##2 \q_stop 
                { \tl_set:Nn \l_siunitx_tmpa_tl {##2} }
              \exp_last_unbraced:NV \siunitx_tmp:w 
                \l_siunitx_tmpa_tl \q_stop
            }
            { \tl_put_left:Nn \l_siunitx_tmpa_tl { - } }
        }
    } 
}
\cs_new_protected_nopar:Npn \siunitx_unit_format_power_repeat: {
  \tl_set:Nx \l_siunitx_tmpb_tl 
    { per- \int_use:N \l_siunitx_unit_int }  
  \prop_if_in:NVT \l_siunitx_unit_prop \l_siunitx_tmpb_tl 
    {
      \siunitx_tl_put_left_math:NV \l_siunitx_unit_current_tl 
        \l_siunitx_per_symbol_tl
    }   
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_prefix:}
%\begin{macro}[aux]{\siunitx_unit_format_prefix_number:}
%\begin{macro}[aux]{\siunitx_unit_format_prefix_number_calc:}
%\begin{macro}[aux]{\siunitx_unit_format_prefix_symbol:}
% If there is a prefix, it is added to the output. When using numerical
% output, some conversion is needed instead.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_prefix: {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { prefix- \int_use:N \l_siunitx_unit_int }
  \prop_if_in:NVT \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
    {
      \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpa_tl
        \l_siunitx_unit_prefix_current_tl
      \bool_if:NTF \l_siunitx_prefix_symbols_bool 
        { \siunitx_unit_format_prefix_symbol: }
        { \siunitx_unit_format_prefix_number: }
    }
} 
\cs_new_protected_nopar:Npn \siunitx_unit_format_prefix_number: {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { prefix-base- \int_use:N \l_siunitx_unit_int }
 \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpa_tl
   \l_siunitx_tmpa_tl
  \int_compare:nNnT { \l_siunitx_unit_prefix_base_int } = { 0 } 
    {
      \int_set:Nn \l_siunitx_unit_prefix_base_int 
        { \l_siunitx_tmpa_tl }
    }
  \int_compare:nNnTF 
    { \l_siunitx_unit_prefix_base_int } = { \l_siunitx_tmpa_tl }
    { \siunitx_unit_format_prefix_number_calc: }
    { \msg_error:nn { siunitx } { prefix-base-mismatch } }
}
%    \end{macrocode}
%  The calculation for converting a unit prefix into a number is 
%  simple unless there are grammes involved. In that case, the base unit
%  is the kilogram and so there is some code to convert the number
%  back correctly.  
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_prefix_number_calc: {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { power- \int_use:N \l_siunitx_unit_int }
  \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpa_tl
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl 
    { \tl_set:Nn \l_siunitx_tmpa_tl { 1 } }
  \tl_set:Nx \l_siunitx_tmpb_tl 
    { unit- \int_use:N \l_siunitx_unit_int }
  \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpb_tl
    \l_siunitx_tmpb_tl
  \str_if_eq:VnT \l_siunitx_tmpb_tl { \gram }
    { 
      \tl_set:Nx \l_siunitx_unit_prefix_current_tl
        { \int_eval:n { \l_siunitx_unit_prefix_current_tl  - 3 } } 
      \tl_set:Nx \l_siunitx_tmpb_tl 
        { symbol- \int_use:N \l_siunitx_unit_int }
      \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpb_tl { kg }
    }
  \tl_set:Nx \l_siunitx_unit_prefix_current_tl 
    {
       \int_eval:n 
         { \l_siunitx_unit_prefix_current_tl * \l_siunitx_tmpa_tl }
    }
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { per- \int_use:N \l_siunitx_unit_int }
  \prop_if_in:NVTF \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
    {
      \int_set:Nn \l_siunitx_unit_prefix_int 
        {
              \l_siunitx_unit_prefix_int 
            - \l_siunitx_unit_prefix_current_tl
        } 
    }
    {
      \int_set:Nn \l_siunitx_unit_prefix_int 
        {
              \l_siunitx_unit_prefix_int 
            + \l_siunitx_unit_prefix_current_tl
        }
    }
}
\cs_new_protected_nopar:Npn \siunitx_unit_format_prefix_symbol: {
  \tl_set_eq:NN \l_siunitx_unit_current_tl 
    \l_siunitx_unit_prefix_current_tl
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_qualifier:}
%\begin{macro}{\siunitx_unit_format_qualifier_brackets:}
%\begin{macro}{\siunitx_unit_format_qualifier_space:}
%\begin{macro}{\siunitx_unit_format_qualifier_subscript:}
%\begin{macro}{\siunitx_unit_format_qualifier_text:}
% Four methods for showing qualifiers, each with its own sub-function.
% For the \texttt{space} methods, a warning is set in the property list
% as if there is a power then some brackets will be needed.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_qualifier: {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { qualifier- \int_use:N \l_siunitx_unit_int }
  \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpa_tl
    \l_siunitx_tmpa_tl
  \quark_if_no_value:NF \l_siunitx_tmpa_tl
    {
      \use:c 
        { 
          siunitx_unit_format_qualifier_ 
          \l_siunitx_qualifier_mode_tl :
        }
    }
} 
\cs_new_protected_nopar:Npn \siunitx_unit_format_qualifier_brackets: {
  \siunitx_tl_put_right_math:NV \l_siunitx_unit_current_tl
    \l_siunitx_bracket_open_tl
  \tl_put_right:NV \l_siunitx_unit_current_tl \l_siunitx_tmpa_tl
  \siunitx_tl_put_right_math:NV \l_siunitx_unit_current_tl
    \l_siunitx_bracket_close_tl
}
\char_make_active:N \~
\cs_new_protected_nopar:Npn \siunitx_unit_format_qualifier_space: {
  \tl_put_right:Nn \l_siunitx_unit_current_tl { \text { ~ } }
  \tl_put_right:NV \l_siunitx_unit_current_tl \l_siunitx_tmpa_tl
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { bracket- \int_use:N \l_siunitx_unit_int }
  \prop_put:NVn \l_siunitx_unit_prop \l_siunitx_tmpa_tl { true }
}
\char_make_space:N \~
\group_begin:
  \char_set_lccode:nn { `\@ } { `\_ }
  \char_make_math_subscript:N \@
\tl_to_lowercase:n {
  \group_end:
  \cs_set_protected_nopar:Npn \siunitx_unit_format_qualifier_subscript: 
    {
      \tl_put_right:Nx \l_siunitx_unit_current_tl 
        { @ { \exp_not:V \l_siunitx_tmpa_tl } }
    }
}
\cs_new_protected_nopar:Npn \siunitx_unit_format_qualifier_text: {
  \tl_put_right:NV \l_siunitx_unit_current_tl \l_siunitx_tmpa_tl
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_sorted:}
% For when the powers are sorted with the positive ones first. The only
% slight issue is making sure that the additional space is included
% between the two units, if needed.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_sorted: {
  \tl_set_eq:NN \l_siunitx_unit_tl \l_siunitx_unit_numerator_tl
  \tl_if_empty:NF \l_siunitx_unit_tl
    {
      \tl_if_empty:NF \l_siunitx_unit_denominator_tl
        { 
          \siunitx_tl_put_right_math:NV \l_siunitx_unit_tl
            \l_siunitx_unit_separator_tl
        }
    }
    \tl_put_right:NV \l_siunitx_unit_tl \l_siunitx_unit_denominator_tl
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_format_symbol:}
%\begin{macro}[aux]{\siunitx_unit_format_symbol_aux:}
%\begin{macro}[aux]{\siunitx_unit_format_symbol_aux_alt:}
% If there is no symbol, something is wrong! The only exception is
% when the code is inside the \cs{si} function (or similar) and there
% is only a prefix with nothing else present at all.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_format_symbol: {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { symbol- \int_use:N \l_siunitx_unit_int }
  \prop_get:NVN \l_siunitx_unit_prop \l_siunitx_tmpa_tl 
    \l_siunitx_tmpa_tl 
  \quark_if_no_value:NTF \l_siunitx_tmpa_tl  
    { \siunitx_unit_format_symbol_aux: }
    {
      \tl_put_right:NV \l_siunitx_unit_current_tl \l_siunitx_tmpa_tl
    }
} 
\cs_new_protected_nopar:Npn \siunitx_unit_format_symbol_aux: {
  \msg_error:nn { siunitx } { prefix-only }
}
\cs_new_protected_nopar:Npn \siunitx_unit_format_symbol_aux_alt: {
  \int_compare:nNnTF { \l_siunitx_unit_int } = { 1 }
    { 
      \prop_del:Nn \l_siunitx_unit_prop { prefix-1 }
      \prop_del:Nn \l_siunitx_unit_prop { prefix-base-1 }
      \prop_if_empty:NF \l_siunitx_unit_prop
        { \msg_error:nn { siunitx } { prefix-only } } 
    }
    { \msg_error:nn { siunitx } { prefix-only } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Unit output}
% 
% A collection of the internal parts of various user functions.
%
%\begin{macro}{\l_siunitx_multi_brackets_bool}
%\begin{macro}{\l_siunitx_multi_repeat_bool}
% Flags for multi-part numbers.
%    \begin{macrocode}
\bool_new:N \l_siunitx_multi_brackets_bool
\bool_new:N \l_siunitx_multi_repeat_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_product_brackets_bool}
%\begin{macro}{\l_siunitx_product_power_bool}
%\begin{macro}{\l_siunitx_number_unit_repeat_bool}
% Flags for product units.
%    \begin{macrocode}
\bool_new:N \l_siunitx_product_brackets_bool
\bool_new:N \l_siunitx_product_power_bool
\bool_new:N \l_siunitx_number_unit_repeat_bool
%    \end{macrocode}
%\end{macro}
%\end{macro} 
%\end{macro} 
% 
%\begin{macro}{\l_siunitx_number_unit_breaks_bool}
%\begin{macro}{\l_siunitx_number_unit_separator_tl}
% Options for printing units or units with numbers.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  allow-number-unit-breaks .bool_set:N = 
    \l_siunitx_number_unit_breaks_bool,
  multi-part-units          .choice:,
  multi-part-units
    / brackets       .code:n =
      {
        \bool_set_true:N  \l_siunitx_multi_brackets_bool
        \bool_set_false:N \l_siunitx_multi_repeat_bool
      },
  multi-part-units
    / repeat         .code:n =
      {
        \bool_set_false:N \l_siunitx_multi_brackets_bool
        \bool_set_true:N  \l_siunitx_multi_repeat_bool
      },
  multi-part-units
    / single         .code:n =
      {
        \bool_set_false:N \l_siunitx_multi_brackets_bool
        \bool_set_false:N \l_siunitx_multi_repeat_bool
      },
  number-unit-separator    .tl_set:N   = 
    \l_siunitx_number_unit_separator_tl,
  product-units            .choice:,
  product-units
    / brackets       .code:n =
      {
        \bool_set_true:N  \l_siunitx_product_brackets_bool
        \bool_set_false:N \l_siunitx_product_power_bool
        \bool_set_false:N \l_siunitx_product_repeat_bool
      },
  product-units
    / brackets-power .code:n =
      {
        \bool_set_true:N  \l_siunitx_product_brackets_bool
        \bool_set_true:N  \l_siunitx_product_power_bool
        \bool_set_false:N \l_siunitx_product_repeat_bool
      },
  product-units
    / power          .code:n =
      {
        \bool_set_false:N \l_siunitx_product_brackets_bool
        \bool_set_true:N  \l_siunitx_product_power_bool
        \bool_set_false:N \l_siunitx_product_repeat_bool
      }, 
  product-units
    / repeat         .code:n =
      {
        \bool_set_false:N \l_siunitx_product_brackets_bool
        \bool_set_false:N \l_siunitx_product_power_bool
        \bool_set_true:N  \l_siunitx_product_repeat_bool
      },
  product-units
    / single         .code:n =
      {
        \bool_set_false:N \l_siunitx_product_brackets_bool
        \bool_set_false:N \l_siunitx_product_power_bool
        \bool_set_false:N \l_siunitx_product_repeat_bool
      },
}
\keys_set:nn { siunitx } {
  multi-part-units      = brackets,
  number-unit-separator = \,,
  product-units         = repeat,
}
%    \end{macrocode}
%\end{macro} 
%\end{macro}
% 
%\begin{macro}{\siunitx_unit_output:nn}
%\begin{macro}{\siunitx_unit_output:Vn}
% For typesetting a unit directly: used by \cs{si} and the \texttt{s}
% column. The second argument is any options to set locally.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_unit_output:nn #1#2 {
  \cs_set_eq:NN \siunitx_unit_format_symbol_aux: 
    \siunitx_unit_format_symbol_aux_alt:
  \cs_set_eq:NN \siunitx_unit_format_fraction_symbol_aux_ii: 
    \siunitx_unit_format_fraction_symbol_aux_alt:
  \siunitx_unit_in:nn {#1} {#2}
  \int_compare:nNnF { \l_siunitx_unit_prefix_int } = { 0 } 
    { 
      \tl_set:Nx \l_siunitx_tmpa_tl 
        {
          \int_use:N \l_siunitx_unit_prefix_base_int
          ^ { \int_use:N \l_siunitx_unit_prefix_int }
        }
      \siunitx_print:nV { number } \l_siunitx_tmpa_tl
      \siunitx_unit_output_number_sep:
    }
  \siunitx_print:nV { unit } \l_siunitx_unit_tl
}
\cs_generate_variant:Nn \siunitx_unit_output:nn { V }
%    \end{macrocode}
%\end{macro} 
%\end{macro} 
%
%\begin{macro}{\siunitx_unit_output_number_sep:}
%\begin{macro}{\siunitx_unit_output_number_sep_aux:}
% For printing the number separator. The \cs{tex_mathchoice:D} code
% deals with the \opt{symbol-or-fraction} setting for \opt{per-mode},
% as in that case omission of the space between a number and unit
% depends on the current math style.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_output_number_sep: {
  \bool_if:NTF \l_siunitx_number_unit_breaks_bool 
    { \penalty \binoppenalty } { \nobreak }
  \bool_if:NTF \l_siunitx_per_auto_bool
    {
      \mode_if_math:TF
        {
          \ensuremath
            {
              \tex_mathchoice:D
                { \l_siunitx_number_unit_separator_tl } 
                { \siunitx_unit_output_number_sep_aux: }
                { \siunitx_unit_output_number_sep_aux: }
                { \siunitx_unit_output_number_sep_aux: }
            }
        }
        { \siunitx_unit_output_number_sep_aux: }
    }
    { \siunitx_unit_output_number_sep_aux: }
}
\cs_new_protected_nopar:Npn \siunitx_unit_output_number_sep_aux: {
  \bool_if:NF \l_siunitx_omit_unit_space_bool
    { \siunitx_ensuremath:n { \l_siunitx_number_unit_separator_tl } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_unit_output_pre_print:}
%\begin{macro}{\siunitx_unit_output_print:}
% The printing functions for units do some simple tests then 
% actually print there output.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_unit_output_pre_print: {
  \tl_if_empty:NF \l_siunitx_pre_unit_tl
    { 
      \nobreak
      \siunitx_print:nV { unit } \l_siunitx_pre_unit_tl 
    }
}
\cs_new_protected_nopar:Npn \siunitx_unit_output_print: {
  \int_compare:nNnF { \l_siunitx_unit_prefix_int } = { 0 } 
    { 
      \tl_set:Nx \l_siunitx_tmpa_tl 
        {
          \bool_if:NTF \l_siunitx_tight_bool 
            {
              \exp_not:N \ensuremath
                { { \exp_not:V \l_siunitx_exponent_product_tl } }
            }    
            { 
              \exp_not:N \ensuremath
                { { } \exp_not:V \l_siunitx_exponent_product_tl { } }
            }        
          \int_use:N \l_siunitx_unit_prefix_base_int
          ^ { \int_use:N \l_siunitx_unit_prefix_int }
        }
      \siunitx_print:nV { number } \l_siunitx_tmpa_tl
    }
  \tl_if_empty:NF \l_siunitx_unit_tl
    {
      \siunitx_unit_output_number_sep:
      \siunitx_print:nV { unit } \l_siunitx_unit_tl 
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Numbers with units}
%
% Numbers with units have to be formatted in a more complex way than
% simply sticking the two together.
% 
%\begin{macro}{\l_siunitx_pre_unit_tl}
% When there is a pre-unit, it gets stored here.
%    \begin{macrocode}
\tl_new:N \l_siunitx_pre_unit_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_product_int}
% Used to count up the number of product tokens in a number.
%    \begin{macrocode}
\int_new:N \l_siunitx_number_product_int
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_combined:nnnn}
% Printing numbers and units means first processing the units, then 
% handing off this information to the combined number and unit 
% processor.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_combined:nnnn #1#2#3#4 {
  \IfNoValueTF {#3} 
    { \tl_clear:N \l_siunitx_pre_unit_tl }
    {
      \siunitx_unit_in:nn {#3} {#1} 
      \cs_set_eq:NN \l_siunitx_pre_unit_tl \l_siunitx_unit_tl
    }
  \cs_set_eq:NN \l_siunitx_brackets_bool 
    \l_siunitx_multi_brackets_bool  
  \siunitx_combined_unit:nnn {#2} {#4} {#1}
  \siunitx_combined_output:n {#2}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_combined_output:n}
% Printing the combination of a number and a unit means checking for
% parsing then parsing the number part.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_combined_output:n #1 {
  \bool_if:NTF \l_siunitx_number_parse_bool
    {
      \tl_clear:N \l_siunitx_number_out_tl
      \bool_set_false:N \l_siunitx_number_compound_bool
      \siunitx_number_output_parse:n {#1}
    }
    {
      \siunitx_unit_output_pre_print:
      \siunitx_print:nn { number } { \siunitx_ensuremath:n {#1} }
      \siunitx_unit_output_print:
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_combined_unit:nnn}
% In most cases, sorting out the main unit is easy: simply set up for
% printing using \cs{siunitx_unit_in:nn}. However, if there are multiple
% parts to the number, and they are to be combined into the unit, then
% there is more work to do. In either case, the result is the 
% correctly-prepared unit stored in \cs{l_siunitx_unit_tl}.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_combined_unit:nnn #1#2#3 {
  \bool_if:NTF \l_siunitx_product_power_bool
    {
      \siunitx_combined_product_count:n {#1}
      \int_compare:nNnTF { \l_siunitx_number_product_int } > { 0 } 
        {
          \int_incr:N \l_siunitx_number_product_int
          \tl_set:Nn \l_siunitx_tmpa_tl {#2}
          \tl_set:Nx \l_siunitx_tmpb_tl 
            { \tothe { \exp_not:V \l_siunitx_number_product_int } }
          \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl
          \siunitx_unit_in:Vn \l_siunitx_tmpa_tl {#3}
        }
        { \siunitx_unit_in:nn {#2} {#3} }
    }
    { \siunitx_unit_in:nn {#2} {#3} }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_combined_product_count:n}
%\begin{macro}[aux]{\siunitx_combined_product_count_aux:n}
% For counting how many products are in a number, so that the unit
% can be adjusted if needed.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_combined_product_count:n #1 {
  \int_zero:N \l_siunitx_number_product_int
  \tl_set:Nn \l_siunitx_tmpa_tl {#1}
  \tl_map_function:NN \l_siunitx_input_product_tl 
    \siunitx_combined_product_count_aux:N
}
\cs_new_protected:Npn \siunitx_combined_product_count_aux:N #1 {
  \tl_if_in:NnT \l_siunitx_tmpa_tl {#1} 
    {
      \int_incr:N \l_siunitx_number_product_int
      \tl_remove_in:Nn \l_siunitx_tmpa_tl {#1}
      \siunitx_combined_product_count_aux:N #1
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Lists of numbers}
%
%\begin{macro}{\l_siunitx_list_brackets_bool}
%\begin{macro}{\l_siunitx_list_repeat_bool}
% For storing the behaviour of list items with respect to units.
%    \begin{macrocode}
\bool_new:N \l_siunitx_list_brackets_bool
\bool_new:N \l_siunitx_list_repeat_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_list_current_tl}
%\begin{macro}{\l_siunitx_list_tl}
% Two token list variables used to store the list for output.
%    \begin{macrocode}
\tl_new:N \l_siunitx_list_current_tl
\tl_new:N \l_siunitx_list_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_list_separator_tl}
%\begin{macro}{\l_siunitx_list_separator_final_tl}
% Settings for lists.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  list-final-separator .tl_set:N = \l_siunitx_list_separator_final_tl,
  list-separator       .tl_set:N = \l_siunitx_list_separator_tl,
  list-units           .choice:,
  list-units
    / brackets .code:n   =
      {
        \bool_set_true:N  \l_siunitx_list_brackets_bool
        \bool_set_false:N \l_siunitx_list_repeat_bool
      },
  list-units  
    / repeat .code:n   =
      {
        \bool_set_false:N \l_siunitx_list_brackets_bool
        \bool_set_true:N  \l_siunitx_list_repeat_bool
      },
  list-units  
    / single .code:n   =
      {
        \bool_set_false:N \l_siunitx_list_brackets_bool
        \bool_set_false:N \l_siunitx_list_repeat_bool
      },
}
\keys_set:nn { siunitx } {
  list-final-separator = { ~ and ~ },
  list-separator       = { , ~ },
  list-units           = repeat,
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_list_numbers:n}
%\begin{macro}{\siunitx_list_numbers_aux_i:n}
%\begin{macro}{\siunitx_list_numbers_aux_ii:n}
% Lists of numbers are handled in a very simple fashion. The input
% list is traversed, and the items are simply placed on a list for
% output. This uses the internal function \cs{siunitx_number_output:n}
% for speed, but does not make any other optimisation. The output list
% also adds the relevant separators.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_list_numbers:n #1 {
  \tl_clear:N \l_siunitx_unit_tl
  \tl_clear:N \l_siunitx_preunit_tl
  \siunitx_list_numbers_aux_i:n {#1}
}
\cs_new_protected:Npn \siunitx_list_numbers_aux_i:n #1 {  
  \tl_clear:N \l_siunitx_list_tl
  \tl_clear:N \l_siunitx_list_current_tl
  \tl_map_function:nN {#1} \siunitx_list_numbers_aux_ii:n   
  \tl_put_right:NV \l_siunitx_list_tl \l_siunitx_list_separator_final_tl
  \tl_put_right:NV \l_siunitx_list_tl \l_siunitx_list_current_tl
  \tl_use:N \l_siunitx_list_tl 
}
\cs_new_protected:Npn \siunitx_list_numbers_aux_ii:n #1 {
  \tl_if_empty:NTF \l_siunitx_list_tl
    { \tl_set_eq:NN \l_siunitx_list_tl \l_siunitx_list_current_tl }
    { 
      \tl_put_right:NV \l_siunitx_list_tl \l_siunitx_list_separator_tl
      \tl_put_right:NV \l_siunitx_list_tl \l_siunitx_list_current_tl
    }
  \tl_set:Nn \l_siunitx_list_current_tl 
    { \siunitx_combined_output:n {#1} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_list_units:nnn}
% For a list of items with units, the method is to first parse the 
% unit when repeating (to save time), then to use the number loop above
% for the actual work. On the other hand, when the unit is only printed
% once life is easier as the normal unit printer can operate.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_list_units:nnn #1#2#3 {
  \bool_if:NTF \l_siunitx_list_repeat_bool
    {
      \siunitx_unit_in:nn {#2} {#3}
      \siunitx_list_numbers_aux_i:n {#1}
    }
    {
      \bool_if:NT \l_siunitx_list_brackets_bool
        {
          \siunitx_print:nn { number } 
            { \siunitx_ensuremath:n { \l_siunitx_bracket_open_tl } }
        }
      \siunitx_list_numbers:n {#1}
      \bool_if:NT \l_siunitx_list_brackets_bool
        {
          \siunitx_print:nn { number } 
            { \siunitx_ensuremath:n { \l_siunitx_bracket_close_tl } }
        }   
      \siunitx_unit_output_number_sep:
      \siunitx_unit_output:nn {#2} {#3}
    }
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Ranges}
%
%\begin{macro}{\l_siunitx_range_brackets_bool}
%\begin{macro}{\l_siunitx_range_repeat_bool}
% Settings for ranges with units.
%    \begin{macrocode}
\bool_new:N \l_siunitx_range_brackets_bool
\bool_new:N \l_siunitx_range_repeat_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_range_phrase_tl}
% Simple settings for ranges.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  range-phrase .tl_set:N = \l_siunitx_range_phrase_tl,
  range-units  .choice:,
  range-units  
    / brackets .code:n   =
      {
        \bool_set_true:N  \l_siunitx_range_brackets_bool
        \bool_set_false:N \l_siunitx_range_repeat_bool
      },
  range-units  
    / repeat .code:n   =
      {
        \bool_set_false:N \l_siunitx_range_brackets_bool
        \bool_set_true:N  \l_siunitx_range_repeat_bool
      },
  range-units  
    / single .code:n   =
      {
        \bool_set_false:N \l_siunitx_range_brackets_bool
        \bool_set_false:N \l_siunitx_range_repeat_bool
      },
}
\keys_set:nn { siunitx } {
  range-phrase = { ~ to ~ },
  range-units  = repeat,
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_range_numbers:nn}
%\begin{macro}{\siunitx_range_numbers_aux:n}
% A range of numbers. This is more restrictive than the \cs{num} 
% function: nothing compound.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_range_numbers:nn #1#2 {
  \siunitx_range_numbers_aux:n {#1}
  \tl_use:N \l_siunitx_range_phrase_tl
  \siunitx_range_numbers_aux:n {#2}
}
\cs_new_protected:Npn \siunitx_range_numbers_aux:n #1 {
  \bool_if:NTF \l_siunitx_number_parse_bool 
    {
      \tl_clear:N \l_siunitx_number_out_tl
      \tl_clear:N \l_siunitx_number_out_saved_tl
      \bool_set_false:N \l_siunitx_number_compound_bool
      \siunitx_number_output_parse:n {#1}
      \bool_if:NT \l_siunitx_number_compound_bool 
        { \msg_error:nnx { siunitx } { multi-part-range } {#1} }
    }
    { 
      \siunitx_unit_output_pre_print:
      \siunitx_print:nn { number } {#1}
      \siunitx_unit_output_print:
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_range_unit:nnnn}
% Unit printing is also simple: basically a past-up job.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_range_unit:nnnn #1#2#3#4 {
  \bool_if:NTF \l_siunitx_range_repeat_bool
    {
      \siunitx_unit_in:nn {#1} {#2}
      \siunitx_range_numbers_aux:n {#3}
      \text { \l_siunitx_range_phrase_tl }
      \siunitx_range_numbers_aux:n {#4}
    }
    {
      \bool_if:NT \l_siunitx_range_brackets_bool
        {
          \siunitx_print:nn { number } 
            { \siunitx_ensuremath:n { \l_siunitx_bracket_open_tl } }
        }
      \siunitx_range_numbers:nn {#3} {#4}
      \bool_if:NT \l_siunitx_range_brackets_bool
        {
          \siunitx_print:nn { number } 
            { \siunitx_ensuremath:n { \l_siunitx_bracket_close_tl } }
        }   
      \siunitx_unit_output_number_sep:
      \siunitx_unit_output:nn {#1} {#2}
    }
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Setting up tables}
% 
% There is a slight problem with the \pkg{cellspace} package: it also
% uses \texttt{S} for a column type  Here, \texttt{S} seems to make
% more sense for \pkg{siunitx}, with \texttt{C} used for 
% \pkg{cellspace}. To enable this to work well, the column
% rewriting code happens \cs{AtBeginDocument}. The \texttt{S} column
% is deleted from \cs{NC@list} so that no warning appears.
%    \begin{macrocode}
\AtBeginDocument {
  \@ifpackageloaded { cellspace } 
      {
        \newcolumntype { C } [1] 
          { > { \bcolumn #1 \@nil } #1 < { \ecolumn } }
        \cs_set:Npn \siunitx_tmp:w #1 \NC@do S #2 \q_stop 
          { \toks_set:Nn \NC@list { #1 #2 } }
        \exp_last_unbraced:NV \siunitx_tmp:w \NC@list \q_stop
        \cs_gundefine:N \NC@find@S
      }
      { }
}
%    \end{macrocode}
%
%\begin{macro}{\siunitx_table_rewrite_create:N}
% The \texttt{s} and \texttt{S} column types are both created using
% the \pkg{array} package, but with the internal macros redefined
% to work with optional argument. First, there is a need to do a 
% quick shuffle with the \cs{NC@list} macro. The \pkg{siunitx} 
% columns have to be listed first, as otherwise the optional 
% arguments do not work correctly. So they are added \enquote{by hand}
% to the appropriate macro.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_rewrite_create:N #1 {
  \tl_set:Nn \l_siunitx_tmpa_tl { \NC@do #1 }
  \tl_put_right:NV \l_siunitx_tmpa_tl \NC@list
  \newcolumntype {#1} { }
  \toks_set:NV \NC@list \l_siunitx_tmpa_tl
  \exp_args:NNc \renewcommand * { NC@rewrite@ #1 } [1] [ ] 
    {
      \toks_put_right:Nn \@temptokena 
        {
          > { \siunitx_table_collect_begin:Nn #1 {##1} } 
          c
          < { \siunitx_table_print: } 
        }
      \NC@find
    }
}
\AtBeginDocument { \siunitx_table_rewrite_create:N s }
\AtBeginDocument { \siunitx_table_rewrite_create:N S }
%    \end{macrocode}
%\end{macro}
%
%\subsection{Collecting tokens in tables}
%
% The table system is in two parts, collecting tokens and typesetting
% the result.  The collection routine tries to ensure that the 
% typesetting part only receives real cell contents.
% 
%\begin{macro}{\l_siunitx_table_collect_tl}
%\begin{macro}{\l_siunitx_table_collect_pre_tl}
%\begin{macro}{\l_siunitx_table_collect_post_tl}
% Three storage areas.
%    \begin{macrocode}
\tl_new:N \l_siunitx_table_collect_tl
\tl_new:N \l_siunitx_table_collect_pre_tl
\tl_new:N \l_siunitx_table_collect_post_tl
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_number_valid_tl}
% As the \texttt{S} column has to make a judgement about tokens which
% can be part of a number, there is a need to have a list of valid
% tokens.
%    \begin{macrocode}
\tl_new:N \l_siunitx_number_valid_tl
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_math_bool}
% A flag used inside the table cell to track math mode: there is
% a need to do things by hand as otherwise the grouping goes 
% wrong.
%    \begin{macrocode}
\bool_new:N \l_siunitx_table_math_bool
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_collect_pre_bool}
%\begin{macro}{\l_siunitx_table_collect_post_bool}
% Flags for having found a number in an \texttt{S} column.
%    \begin{macrocode}
\bool_new:N \l_siunitx_table_collect_pre_bool
\bool_new:N \l_siunitx_table_collect_post_bool
%    \end{macrocode}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\siunitx_table_collect_begin:Nn}
%\begin{macro}[aux]{\siunitx_table_collect_begin_s:}
%\begin{macro}[aux]{\siunitx_table_collect_begin_S:}
% The collector starts by setting up local options, then clears and
% initialises the storage and testing system.  
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_table_collect_begin:Nn #1#2 {
  \keys_set:nn { siunitx } {#2}
  \use:c { siunitx_table_collect_begin_ #1 : }
}
\cs_new_protected_nopar:Npn \siunitx_table_collect_begin_s: {
  \cs_set_eq:NN \siunitx_table_collect_token:N 
    \siunitx_table_collect_token_s:N
  \cs_set_eq:NN \siunitx_table_print: \siunitx_table_print_s:
  \siunitx_table_collect_init_s:
  \siunitx_table_collect_get:
}
\cs_new_protected_nopar:Npn \siunitx_table_collect_begin_S: {
  \cs_set_eq:NN \siunitx_table_collect_token:N 
    \siunitx_table_collect_token_S:N
  \cs_set_eq:NN \siunitx_table_print: \siunitx_table_print_S:
  \siunitx_table_collect_init_S:
  \bool_if:NTF \l_siunitx_number_parse_bool
    { \siunitx_table_collect_get: }
    { \siunitx_table_direct: }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro} 
%
%\begin{macro}{\siunitx_table_collect_braced:n}
% The collection of braced items depends on the column type. So we
% start of with an empty definition.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_table_collect_braced:n #1 { }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_table_collect_expand:N}
%\begin{macro}[aux]{\siunitx_table_collect_expand_math:N}
% The idea here is to expand content if possible.  There are a few 
% things to note. Only macros which are not long or protected are
% expanded. There is the possibility that the macro may need the
% contents of the pre-numeral part to be executed, for example see
% \cref{tab:xmpl:calc} in the user part of the documentation. 
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_table_collect_expand:N #1 {
  \cs_if_eq:NNTF #1 \color
    {
      \bool_if:NTF \l_siunitx_table_collect_pre_bool
        { 
          \tl_clear:N \l_siunitx_number_color_tl
          \tl_clear:N \l_siunitx_unit_color_tl
          \tl_put_right:Nn \l_siunitx_table_collect_pre_tl {#1} 
        }
        {
          \bool_set_true:N \l_siunitx_table_collect_post_bool
          \tl_put_right:Nn \l_siunitx_table_collect_post_tl {#1}
        }
    }
    {
      \siunitx_cs_if_tl:NTF #1 
        {
          \tl_use:N \l_siunitx_table_collect_pre_tl
          \tl_clear:N \l_siunitx_table_collect_pre_tl
          \cs_set_nopar:Npx \siunitx_table_collect_next: 
            { \exp_not:N \siunitx_table_collect_get: \exp_not:V #1 }
        }
        {
          \bool_if:NTF \l_siunitx_table_collect_pre_bool
            { 
              \tl_put_right:Nn \l_siunitx_table_collect_pre_tl {#1} 
              \siunitx_table_collect_expand_math:N #1
            }
            {
              \bool_set_true:N \l_siunitx_table_collect_post_bool
              \tl_put_right:Nn \l_siunitx_table_collect_post_tl {#1}
            }
        }
    }
}
%    \end{macrocode}
% There is a need to keep a track of math mode, so that there are no
% disasters when the tokens are boxed up later. The ideal is to know
% the math state of the collected tokens so that appropriate 
% steps can be taken to insert math shift tokens later.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_table_collect_expand_math:N #1 {
  \token_if_math_shift:NTF #1
    {
      \bool_if:NTF \l_siunitx_table_math_bool
        { \bool_set_false:N \l_siunitx_table_math_bool }
        { \bool_set_true:N \l_siunitx_table_math_bool }
    }
    {
      \cs_if_eq:NNTF #1 \( % \)
        { \bool_set_true:N \l_siunitx_table_math_bool }
        { % \(
          \cs_if_eq:NNT #1 \)
            { \bool_set_false:N \l_siunitx_table_math_bool }
        }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_collect_get:}
%\begin{macro}{\siunitx_table_collect_get_aux:}
% The token collection system first has to check that the next argument
% does not start with an opening-brace character.  If it does, the 
% testing is skipped and the braced token is stored.  Otherwise, a check
% is made against various ignored tokens. At present, things seem to be
% broken with \pkg{expl3}'s \cs{peek_catcode_ignore_spaces:NTF}, so 
% everything is done by hand.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_collect_get: {
  \cs_set_eq:NN \siunitx_table_collect_next: 
    \siunitx_table_collect_get:
  \cs_set_nopar:Npn \peek_execute_branches: 
    {
      \tex_ifcat:D \exp_not:N \l_peek_token \c_group_begin_token
        \exp_after:wN \siunitx_table_collect_braced:n
      \tex_else:D
        \exp_after:wN \siunitx_table_collect_not_braced:N
      \tex_fi:D
    }
  \peek_after:NN \peek_ignore_spaces_execute_branches:
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_collect_init:}
% The usual spin-out of basics.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_collect_init: {
  \tl_clear:N \l_siunitx_table_collect_tl
  \tl_clear:N \l_siunitx_table_collect_pre_tl
  \tl_clear:N \l_siunitx_table_collect_post_tl
  \bool_set_false:N \l_siunitx_table_collect_post_bool
  \bool_set_false:N \l_siunitx_table_math_bool
}
%    \end{macrocode}
%\end{macro} 
%\begin{macro}{\siunitx_table_collect_init_s:}
%\begin{macro}{\siunitx_table_collect_init_S:}
% Some type-specific definitions. In the \texttt{S} case, the 
% initialisation function for numbers is used to set 
% \cs{l_siunitx_number_valid_tl} correctly.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_collect_init_s: {
  \siunitx_table_collect_init:
  \bool_set_false:N \l_siunitx_table_collect_pre_bool
  \cs_set:Npn \siunitx_table_collect_braced:n ##1 
    {
      \tl_put_right:Nn \l_siunitx_table_collect_tl { {##1} }
      \siunitx_table_collect_next:
    }
}
\cs_new_protected_nopar:Npn \siunitx_table_collect_init_S: {
  \siunitx_number_in_init:
  \tl_set:Nx \l_siunitx_number_valid_tl 
    {
      \exp_not:V \l_siunitx_input_complex_tl
      \exp_not:V \l_siunitx_input_decimal_tl
      \exp_not:V \l_siunitx_input_digit_tl
      \exp_not:V \l_siunitx_input_exponent_tl
      \exp_not:V \l_siunitx_input_ignore_tl
      \exp_not:V \l_siunitx_input_comparator_tl
      \exp_not:V \l_siunitx_input_uncert_close_tl
      \exp_not:V \l_siunitx_input_uncert_open_tl
      \exp_not:V \l_siunitx_input_sign_tl
      \exp_not:V \l_siunitx_input_symbol_tl   
    }
  \bool_set_true:N \l_siunitx_table_collect_pre_bool
  \cs_set:Npn \siunitx_table_collect_braced:n ##1 
    {
      \bool_if:NTF \l_siunitx_table_collect_pre_bool
        { \tl_put_right:Nn \l_siunitx_table_collect_pre_tl { {##1} } }
        {
          \bool_set_true:N \l_siunitx_table_collect_post_bool
          \tl_put_right:Nn \l_siunitx_table_collect_post_tl { {##1} }
        }
      \siunitx_table_collect_next:
    }
}
%    \end{macrocode}
%\end{macro} 
%\end{macro}
%
%\begin{macro}{\siunitx_table_collect_next:}
% A holder for the next thing to do.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_collect_next: { }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_table_collect_newline:}
% The end macro needs to come before the new line is called. The 
% print function is redefined so that it only actually does stuff once.
% As each cell is a group anyway, there is no need to save the 
% definition of \cs{siunitx_table_print:}, as it will re-appear on its
% own.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_collect_newline: {
  \siunitx_table_print:
  \cs_set_eq:NN \siunitx_table_print: \prg_do_nothing:
  \tabularnewline
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_table_collect_not_braced:N}
%\begin{macro}[aux]{\siunitx_table_collect_not_braced_aux_i:N}
%\begin{macro}[aux]{\siunitx_table_collect_not_braced_aux_ii:N}
% A few macros are simply passed through to be executed; this is mainly
% so that the table actually works. The newline function needs its own 
% function, which is picked up by hand.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_table_collect_not_braced:N #1 {
  \token_if_eq_meaning:NNF #1 \tex_ignorespaces:D 
    {
      \token_if_eq_meaning:NNF #1 \tex_unskip:D
        { \siunitx_table_collect_not_braced_aux_i:N #1 }
    }
  \siunitx_table_collect_next:
}
\cs_new_protected:Npn \siunitx_table_collect_not_braced_aux_i:N #1 {
  \cs_set:Npn \siunitx_table_collect_not_braced_aux_ii:N ##1 
    {
      \token_if_eq_meaning:NNT #1 ##1 
        { \cs_set_eq:NN \siunitx_table_collect_next: ##1 }
    }
  \tl_map_function:nN 
    { \cs:w \end \endtabular \scan_stop: \siunitx_table_print: }
    \siunitx_table_collect_not_braced_aux_ii:N
  \token_if_eq_meaning:NNT \siunitx_table_collect_next: 
    \siunitx_table_collect_get: 
    {
      \token_if_eq_meaning:NNTF #1 \tabularnewline 
        {
          \cs_set_eq:NN \siunitx_table_collect_next: 
            \siunitx_table_collect_newline:
        }
        { \siunitx_table_collect_token:N #1 }
    }
}
\cs_new_protected:Npn \siunitx_table_collect_not_braced_aux_ii:N #1 { }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_collect_token:N}
%\begin{macro}{\siunitx_table_collect_token_s:N}
% For the \texttt{s} column, every token is added to the same storage
% area, so life is simple.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_table_collect_token:N #1 { }
\cs_new_protected:Npn \siunitx_table_collect_token_s:N #1 { 
  \tl_put_right:Nn \l_siunitx_table_collect_tl {#1}
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_table_collect_token_S:N}
% Not so easy for the \texttt{S} column type. If the content is after
% a number, things are easy.  On the other hand, if the token might be
% a number, then a check is made. It the token is still unmatched, then
% it is passed on to the expansion handler.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_table_collect_token_S:N #1 {
  \bool_if:NTF  \l_siunitx_table_collect_post_bool 
    { \tl_put_right:Nn \l_siunitx_table_collect_post_tl {#1} }
    {
      \tl_if_in:NnTF \l_siunitx_number_valid_tl {#1} 
        {
          \bool_set_false:N \l_siunitx_table_collect_pre_bool
          \tl_put_right:Nn \l_siunitx_table_collect_tl {#1}
        }
        { \siunitx_table_collect_expand:N #1 }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Table printing: general code}
%
%\begin{macro}{\c_siunitx_one_fill_skip}
% A fixed skip of one \texttt{fill}.
%    \begin{macrocode}
\skip_new:N \c_siunitx_one_fill_skip
\skip_set:Nn \c_siunitx_one_fill_skip { \c_zero_skip plus 1 fill }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\c_siunitx_table_correction_skip}
%\begin{macro}{\siunitx_table_colortbl_correction:}
% If the package \pkg{colortbl} is loaded, there is a need to allow
% that it changes how centring is carried out.
%    \begin{macrocode}
\skip_new:N \c_siunitx_table_correction_skip
\AtBeginDocument {
  \@ifpackageloaded { colortbl }
    { 
      \skip_set:Nn \c_siunitx_table_correction_skip 
        { \c_zero_skip plus -0.5 fill } 
    }
    { 
      \skip_set:Nn \c_siunitx_table_correction_skip 
        { \c_zero_skip } 
    }
}
\cs_new_protected_nopar:Npn \siunitx_table_colortbl_correction: {
  \skip_horizontal:n { \c_siunitx_table_correction_skip }
  \tex_kern:D \c_zero_skip
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_align_left:n}
%\begin{macro}{\siunitx_table_align_right:n}
% These are simple shortcuts to keep life clearer in the rest of the 
% code. The idea is that the kern acts as a \enquote{stop} for the 
% horizontal skip. The correction for \pkg{colortbl} is separate as the
% spacing needs to be explicitly deleted.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_align_left:n #1 {
  \siunitx_table_colortbl_correction:
  \skip_horizontal:n {#1}
  \tex_kern:D \c_zero_skip
}
\cs_new_protected_nopar:Npn \siunitx_table_align_right:n #1 {
  \skip_horizontal:n { \c_siunitx_one_fill_skip - #1 }
  \tex_kern:D \c_zero_skip
  \siunitx_table_colortbl_correction:
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Printing units in \texttt{s} columns}
%
% The easiest type of printing is the \texttt{s} column. Here, there is
% no real problem with alignment. All that has to happen is to print the
% collected input as the argument to the internal part of an \cs{si}
% function.
% 
%\begin{macro}{\l_siunitx_table_unit_align_skip}
% The spacing used is stored as a skip, which needs to be set up first.
%    \begin{macrocode}
\skip_new:N \l_siunitx_table_unit_align_skip
%    \end{macrocode}
%\end{macro} 
% 
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  table-unit-alignment .choice:,
  table-unit-alignment / center .code:n =
    { 
      \skip_set:Nn \l_siunitx_table_unit_align_skip 
        { \c_zero_skip plus 0.5 fill } 
    },
  table-unit-alignment / left   .code:n =
    { 
      \skip_set:Nn \l_siunitx_table_unit_align_skip 
        { \c_zero_skip } 
    },
  table-unit-alignment / right  .code:n =
    { 
      \skip_set:Nn \l_siunitx_table_unit_align_skip 
        { \c_zero_skip plus 1 fill } 
    },
}
\keys_set:nn { siunitx } {
  table-unit-alignment = center
}
%    \end{macrocode}
% 
%\begin{macro}{\siunitx_table_print_s:}
% Actually printing an \texttt{s} column is not very complex. There is
% some spacing to do at each side, with the main part of the job being
% to print the material using the internal version of \cs{si}.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_s: { 
  \siunitx_table_align_left:n { \l_siunitx_table_unit_align_skip }
  \siunitx_unit_output:Vn \l_siunitx_table_collect_tl { }
  \siunitx_table_align_right:n { \l_siunitx_table_unit_align_skip }
}
%    \end{macrocode}
%\end{macro} 
%
%\subsection{Formatting and printing in tables}
%
% With the content grabbed, the next stage is to turn it into formatted
% output then print it. Most of the formatting is done elsewhere, so
% most of the work here is in printing.
% 
%\begin{macro}{\l_siunitx_table_center_decimal_bool}
% A switch for the basic \enquote{decimal marker in the middle}
% mode.
%    \begin{macrocode}
\bool_new:N \l_siunitx_table_center_decimal_bool
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_fill_box}
% A box which is only ever filled with \texttt{fil} glue, for padding
% out numbers.
%    \begin{macrocode}
\box_new:N \l_siunitx_table_fill_box
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_fill_dim}
% Calculating the fill needed can be a bit complicated, so is best
% done using a dedicated dimension.
%    \begin{macrocode}
\dim_new:N \l_siunitx_table_fill_dim
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_pre_box}
%\begin{macro}{\l_siunitx_table_post_box}
% Boxes for the content before and after the numerical part.
%    \begin{macrocode}
\box_new:N \l_siunitx_table_pre_box
\box_new:N \l_siunitx_table_post_box
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_result_box}
% The box which is actually needed for printing.
%    \begin{macrocode}
\box_new:N \l_siunitx_table_result_box
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_comparator_dim}
%\begin{macro}{\l_siunitx_table_decimal_dim}
%\begin{macro}{\l_siunitx_table_exponent_dim}
%\begin{macro}{\l_siunitx_table_integer_dim}
%\begin{macro}{\l_siunitx_table_mantissa_dim}
%\begin{macro}{\l_siunitx_table_marker_dim}
%\begin{macro}{\l_siunitx_table_result_dim}
%\begin{macro}{\l_siunitx_table_uncert_dim}
% Dimensions for the various model measurements.
%    \begin{macrocode}
\dim_new:N \l_siunitx_table_comparator_dim
\dim_new:N \l_siunitx_table_decimal_dim
\dim_new:N \l_siunitx_table_exponent_dim
\dim_new:N \l_siunitx_table_integer_dim
\dim_new:N \l_siunitx_table_mantissa_dim
\dim_new:N \l_siunitx_table_marker_dim
\dim_new:N \l_siunitx_table_result_dim
\dim_new:N \l_siunitx_table_uncert_dim
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_gap_dim}
% This is used to work out the potential gap between a number and
% any following material.
%    \begin{macrocode}
\dim_new:N \l_siunitx_table_gap_dim
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_model_prop}
% To store the model version of a number, used when reserving space.
%    \begin{macrocode}
\prop_new:N \l_siunitx_table_model_prop
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_space_dim}
% This dim is used to keep a track of how much space might need to be
% deleted if exponents are not being aligned.
%    \begin{macrocode}
\dim_new:N \l_siunitx_table_space_dim
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\l_siunitx_table_text_align_skip}
%\begin{macro}{\l_siunitx_table_number_align_skip}
% Skips for aligning text and numbers.
%    \begin{macrocode}
\skip_new:N \l_siunitx_table_number_align_skip
\skip_new:N \l_siunitx_table_text_align_skip
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\l_siunitx_table_align_exp_bool}
%\begin{macro}{\l_siunitx_table_align_post_bool}
%\begin{macro}{\l_siunitx_table_align_uncert_bool}
%\begin{macro}{\l_siunitx_table_omit_exp_bool}
%\begin{macro}{\l_siunitx_table_auto_bool}
%\begin{macro}{\l_siunitx_table_comparator_bool}
%\begin{macro}{\l_siunitx_table_decimal_int}
%\begin{macro}{\l_siunitx_table_exponent_int}
%\begin{macro}{\l_siunitx_table_integer_int}
%\begin{macro}{\l_siunitx_table_uncert_int}
%\begin{macro}{\l_siunitx_table_parse_only_bool}
%\begin{macro}{\l_siunitx_table_pre_tl}
%\begin{macro}{\l_siunitx_table_post_tl}
%\begin{macro}{\l_siunitx_table_sign_exponent_bool}
%\begin{macro}{\l_siunitx_table_sign_manitssa_bool}
% As usual, set up the options.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  table-align-exponent        .bool_set:N
    = \l_siunitx_table_align_exp_bool,
  table-align-text-post       .bool_set:N 
    = \l_siunitx_table_align_post_bool,
  table-align-uncertainty     .bool_set:N
    = \l_siunitx_table_align_uncert_bool,
  table-number-alignment      .choice:,
  table-number-alignment / 
    center                  .code:n     = 
      {
        \skip_set:Nn \l_siunitx_table_number_align_skip 
          { \c_zero_skip plus 0.5 fill } 
        \bool_set_false:N \l_siunitx_table_center_decimal_bool
      },
  table-number-alignment / 
    center-decimal-marker   .code:n     = 
      {
        \skip_set:Nn \l_siunitx_table_number_align_skip 
          { \c_zero_skip plus 0.5 fill } 
        \bool_set_true:N \l_siunitx_table_center_decimal_bool
      },
  table-number-alignment / 
    left                    .code:n     = 
      {
        \skip_set:Nn \l_siunitx_table_number_align_skip 
          { \c_zero_skip } 
        \bool_set_false:N \l_siunitx_table_center_decimal_bool
      },
  table-number-alignment / 
    right                   .code:n     = 
      {
        \skip_set:Nn \l_siunitx_table_number_align_skip 
          { \c_zero_skip plus 1 fill } 
        \bool_set_false:N \l_siunitx_table_center_decimal_bool
      },
  table-omit-exponent  .bool_set:N = \l_siunitx_table_omit_exp_bool ,
  table-text-alignment .choice:,
  table-text-alignment / 
    center                  .code:n =
    { 
      \skip_set:Nn \l_siunitx_table_text_align_skip 
        { \c_zero_skip plus 0.5 fill } 
    },
  table-text-alignment / 
    left                    .code:n =
    { 
      \skip_set:Nn \l_siunitx_table_text_align_skip 
        { \c_zero_skip } 
    },
  table-text-alignment / 
    right                   .code:n =
    { 
      \skip_set:Nn \l_siunitx_table_text_align_skip 
        { \c_zero_skip plus 1 fill } 
    },
  table-auto-round          .bool_set:N = \l_siunitx_table_auto_bool,
  table-comparator          .bool_set:N =
    \l_siunitx_table_comparator_bool,  
  table-figures-decimal     .int_set:N  = \l_siunitx_table_decimal_int,
  table-figures-exponent    .int_set:N  = 
    \l_siunitx_table_exponent_int,
  table-figures-integer     .int_set:N  = \l_siunitx_table_integer_int,
  table-figures-uncertainty .int_set:N  = \l_siunitx_table_uncert_int ,
  table-parse-only          .bool_set:N = 
    \l_siunitx_table_parse_only_bool,
  table-space-text-pre      .tl_set:N =
    \l_siunitx_table_pre_tl,  
  table-space-text-post     .tl_set:N =
    \l_siunitx_table_post_tl,  
  table-sign-exponent       .bool_set:N = 
    \l_siunitx_table_sign_exponent_bool,
  table-sign-mantissa       .bool_set:N = 
    \l_siunitx_table_sign_mantissa_bool
}
\keys_set:nn { siunitx } {
  table-align-exponent    = true,
  table-align-text-post   = true,
  table-align-uncertainty = true,
  table-number-alignment  = center-decimal-marker,
  table-text-alignment    = center,
  table-figures-decimal   = 2,
  table-figures-integer   = 3
}
%    \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}
%\end{macro} 
%
% A meta-choice for all table alignment is also provided.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  table-alignment .meta:n = 
    {
      table-number-alignment = #1,
      table-text-alignment   = #1,
      table-unit-alignment   = #1
    }
}
%    \end{macrocode}
%   
%\begin{macro}{\siunitx_table_format_convert:nn} 
% Another special option. This converts a number format in compacted
% form into the various internal settings needed. The function is used
% for the conversion to keep code down.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_format_convert:nn #1#2 {
  \prop_get:NnN \l_siunitx_number_in_prop {#1} \l_siunitx_tmpa_tl
  \quark_if_no_value:NTF \l_siunitx_tmpa_tl
    { \int_set:cn { l_siunitx_table_ #2 _int } { 0 } }
    { 
      \prop_get:NnN \l_siunitx_number_in_prop {#1} \l_siunitx_tmpa_tl
      \int_set:cn  { l_siunitx_table_ #2 _int } { \l_siunitx_tmpa_tl }
    }
}
\keys_define:nn { siunitx } {
  table-format .code:n    = 
    {
      \siunitx_number_in_parse:n {#1}
      \siunitx_table_format_convert:nn { mantissa-integer } { integer }
      \siunitx_table_format_convert:nn { mantissa-decimal } { decimal }
      \siunitx_table_format_convert:nn { mantissa-uncertainty }
        { uncert }
      \siunitx_table_format_convert:nn { exponent-integer } 
        { exponent }
      \prop_if_in:NnTF \l_siunitx_number_in_prop { comparator }
        { \bool_set_true:N \l_siunitx_table_comparator_bool }
        { \bool_set_false:N \l_siunitx_table_comparator_bool }
      \prop_if_in:NnTF \l_siunitx_number_in_prop { mantissa-sign }
        { \bool_set_true:N \l_siunitx_table_sign_mantissa_bool }
        { \bool_set_false:N \l_siunitx_table_sign_mantissa_bool }
      \prop_if_in:NnTF \l_siunitx_number_in_prop { exponent-sign }        
        { \bool_set_true:N \l_siunitx_table_sign_exponent_bool }
        { \bool_set_false:N \l_siunitx_table_sign_exponent_bool }
      \keys_set:nn { siunitx } { table-number-alignment = center }  
    },
}
%    \end{macrocode}
%\end{macro}  
%
%\begin{macro}{\siunitx_table_print_S:}
% The main printing function does a simple test: was there anything
% found that counts as a number. If there was, most of the detail
% is handled elsewhere. If there is only test (such as a heading)
% then it can be printed.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S: {
  \bool_if:NTF \l_siunitx_table_collect_pre_bool
    { 
      \siunitx_table_align_left:n { \l_siunitx_table_text_align_skip }
      \tl_use:N \l_siunitx_table_collect_pre_tl
      \siunitx_table_align_right:n 
        { \l_siunitx_table_text_align_skip }
    }
    { 
      \siunitx_table_align_left:n 
        { \l_siunitx_table_number_align_skip }
      \siunitx_table_print_S_aux: 
      \siunitx_table_align_right:n 
        { \l_siunitx_table_number_align_skip }
    }
}
%    \end{macrocode}
%\end{macro}

%\begin{macro}[aux]{\siunitx_table_print_S_aux:}
% The auxiliary function now splits the path. If the number is only
% being parsed, then it is printed with no more fuss. Otherwise, there
% is a second choice based on the alignment approach.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_aux: {
  \bool_if:NTF \l_siunitx_table_parse_only_bool 
    { 
      \tl_use:N \l_siunitx_table_collect_pre_tl
      \siunitx_number_output:V \l_siunitx_table_collect_tl 
      \tl_use:N \l_siunitx_table_collect_post_tl
    }
    { 
      \bool_if:NTF \l_siunitx_table_center_decimal_bool
        { \siunitx_table_print_S_centered: }
        { \siunitx_table_print_S_reserved: }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}[aux]{\siunitx_table_print_S_parse:}
% A modified version of the number parser for tables.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_parse: {
  \bool_set_false:N \l_siunitx_error_bool
  \siunitx_number_in_parse:V \l_siunitx_table_collect_tl 
  \bool_if:NF \l_siunitx_error_bool 
    {
      \bool_if:NT \l_siunitx_table_omit_exp_bool
        { \bool_set_true:N \l_siunitx_process_fixed_bool }
      \siunitx_number_process:
      \bool_if:NT \l_siunitx_table_omit_exp_bool
        {
          \prop_del:Nn \l_siunitx_number_in_prop { exponent }
          \prop_del:Nn \l_siunitx_number_in_prop { exponent-integer }
        }
      \siunitx_number_format:
      \siunitx_number_output_color:
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\siunitx_table_print_S_centered:}
% When centring the decimal marker, the logic is relatively simple.
% First, box up the integer part of the number, the entire number and
% the decimal marker itself.  There is then a measurement to see
% which part of the number is bigger: before or after the decimal
% marker. Based on that, a path is chosen. The two then come back
% together to print any material after the number: the filling 
% space needed will be equal to the correction required to place notes,
% \emph{etc}.~flush with the number.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered: {
  \siunitx_table_print_S_centered_ends:
  \dim_compare:nNnTF 
    { \box_wd:N \l_siunitx_table_pre_box } = { \c_zero_skip }
    { \tl_use:N \l_siunitx_table_collect_pre_tl }
    { \box_use:N \l_siunitx_table_pre_box }
  \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token }
  \siunitx_table_print_S_parse:
  \siunitx_table_print_S_measure:Nnn \l_siunitx_number_out_prop 
    { integer } { mantissa }
  \siunitx_table_print_S_measure:Nnn \l_siunitx_number_out_prop 
    { marker }  { mantissa }
  \siunitx_table_print_S_measure:Nnn \l_siunitx_number_out_prop 
    { result } { }
  \box_set_eq:NN \l_siunitx_table_result_box \l_siunitx_tmp_box
  \dim_set:Nn \l_siunitx_table_fill_dim
    { \l_siunitx_table_result_dim - \l_siunitx_table_integer_dim }
  \prop_if_in:NnT \l_siunitx_number_out_prop 
    { mantissa-decimal-marker }
    {
      \dim_set:Nn \l_siunitx_table_fill_dim
        { \l_siunitx_table_fill_dim - \l_siunitx_table_marker_dim }
    }
  \dim_compare:nNnTF
    { \l_siunitx_table_integer_dim } > { \l_siunitx_table_fill_dim }
    { \siunitx_table_print_S_centered_integer: }
    { \siunitx_table_print_S_centered_decimal: }
  \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token }  
  \bool_if:NTF \l_siunitx_table_align_post_bool
    { \box_use:N \l_siunitx_table_post_box }
    { 
      \dim_set:Nn \l_siunitx_table_fill_dim
        { - \dim_use:N \l_siunitx_table_fill_dim }
      \skip_horizontal:N \l_siunitx_table_fill_dim
      \box_use:N \l_siunitx_table_post_box
      \box_use:N \l_siunitx_table_fill_box
    }  
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_table_print_S_centered_ends:}
% Here, the material before and after the numerical content is boxed up.
% The shorter one is then re-boxed so that both sides are the same
% length: this stops the alignment going out.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_ends: {
  \hbox_set:Nn \l_siunitx_table_pre_box
    { 
      { 
        \tl_use:N \l_siunitx_table_collect_pre_tl
        \bool_if:NT \l_siunitx_table_math_bool 
          { 
            \scan_stop:
            \c_math_shift_token 
          }
      } 
    }
  \hbox_set:Nn \l_siunitx_table_post_box
    { 
      \bool_if:NT \l_siunitx_table_math_bool 
        { 
          \c_math_shift_token
          \scan_stop:
        }
      \tl_use:N \l_siunitx_table_collect_post_tl 
    }
  \dim_compare:nNnTF 
    { \box_wd:N \l_siunitx_table_pre_box  } > 
    { \box_wd:N \l_siunitx_table_post_box }
    {
      \hbox_set_to_wd:Nnn \l_siunitx_table_post_box
        { \box_wd:N \l_siunitx_table_pre_box }
        { 
          \hbox_unpack:N \l_siunitx_table_post_box
          \tex_hfil:D 
        }
    }
    {
      \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box
        { \box_wd:N \l_siunitx_table_post_box }
        { 
          \tex_hfil:D 
          \hbox_unpack:N \l_siunitx_table_pre_box
        } 
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}[aux]{\siunitx_table_print_S_centered_integer:}
%\begin{macro}[aux]{\siunitx_table_print_S_centered_decimal:}
% Actually printing the content is a case of calculating a suitable
% filler box, then printing it and the content.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_integer: {
  \dim_set:Nn \l_siunitx_table_fill_dim
    { \l_siunitx_table_integer_dim - \l_siunitx_table_fill_dim }
  \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box 
    { \l_siunitx_table_fill_dim } { \tex_hfil:D }
  \box_use:N \l_siunitx_table_result_box
  \box_use:N \l_siunitx_table_fill_box
}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_centered_decimal: {
  \dim_set:Nn \l_siunitx_table_fill_dim
    { \l_siunitx_table_fill_dim - \l_siunitx_table_integer_dim }
  \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box 
    { \l_siunitx_table_fill_dim } { \tex_hfil:D }
  \box_use:N \l_siunitx_table_fill_box
  \box_use:N \l_siunitx_table_result_box
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_print_S_reserved:}
% Sorting out a number with reserved space means checking each part
% in turn. After sorting out the ends, a model number is constructed,
% and this is then used by the various sub-routines to get the spacing
% correct.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved: {
  \dim_zero:N \l_siunitx_table_gap_dim
  \dim_zero:N \l_siunitx_table_space_dim
  \siunitx_table_print_S_reserved_ends:
  \dim_compare:nNnTF 
    { \box_wd:N \l_siunitx_table_pre_box } = { \c_zero_skip }
    { \tl_use:N \l_siunitx_table_collect_pre_tl }
    {
      \box_use:N \l_siunitx_table_pre_box 
      \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token }
    }
  \siunitx_table_print_S_model_create:
  \bool_if:NT \l_siunitx_table_auto_bool
    {
      \int_set:Nn \l_siunitx_process_precision_int 
        { \l_siunitx_table_decimal_int }
      \tl_set:Nn \l_siunitx_round_tl { places }  
    }
  \siunitx_table_print_S_parse:
  \bool_if:NTF \l_siunitx_table_comparator_bool
    { \siunitx_table_print_S_reserved_comparator: }
    {
      \prop_if_in:NnT \l_siunitx_number_out_prop { comparator }
        { 
          \msg_error:nnx { siunitx } { table-partial-number } 
            { a~comparator }
        }
    }
  \int_compare:nNnTF
    { \l_siunitx_table_integer_int + \l_siunitx_table_decimal_int } >
      { 0 }
    { \siunitx_table_print_S_reserved_mantissa: }
    { 
      \prop_if_in:NnT \l_siunitx_number_out_prop { mantissa-result }
        { 
          \msg_error:nnx { siunitx } { table-partial-number } 
            { a~mantissa }
        }
    }
  \prop_if_in:NnT \l_siunitx_number_out_prop { complex-result }
    { 
      \msg_error:nnx { siunitx } { table-partial-number } 
        { a~complex }
    }
  \int_compare:nNnTF { \l_siunitx_table_exponent_int } > { 0 }
    { \siunitx_table_print_S_reserved_exponent: }
    { 
      \prop_if_in:NnT \l_siunitx_number_out_prop { exponent-result }
        { 
          \msg_error:nnx { siunitx } { table-partial-number } 
            { an~exponent }
        }
    }
  \bool_if:NT \l_siunitx_table_math_bool { \c_math_shift_token }  
  \bool_if:NTF \l_siunitx_table_align_post_bool
    { \box_use:N \l_siunitx_table_post_box }
    { 
      \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box
        { \dim_use:N \l_siunitx_table_gap_dim }
        { \tex_hfil:D }
      \dim_set:Nn \l_siunitx_table_gap_dim
        { - \dim_use:N \l_siunitx_table_gap_dim }
      \skip_horizontal:N \l_siunitx_table_gap_dim
      \box_use:N \l_siunitx_table_post_box
      \box_use:N \l_siunitx_table_fill_box
    }  
}  
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_reserved_ends:}
% For the reserved case, the two ends are simply boxed up in correctly
% created spaces.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_ends: {
  \hbox_set:Nn \l_siunitx_tmp_box 
    { 
      \l_siunitx_table_pre_tl
      \bool_if:NT \l_siunitx_table_math_bool 
        { 
          \scan_stop:
          \c_math_shift_token
        }
    }
  \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box
    { \box_wd:N \l_siunitx_tmp_box }
    { 
      \tex_hfil:D
      { \tl_use:N \l_siunitx_table_collect_pre_tl } 
    }
  \hbox_set:Nn \l_siunitx_tmp_box { \l_siunitx_table_post_tl }  
  \hbox_set_to_wd:Nnn \l_siunitx_table_post_box
    { \box_wd:N \l_siunitx_tmp_box }
    { 
      \bool_if:NT \l_siunitx_table_math_bool 
        { 
          \c_math_shift_token
          \scan_stop:
        }
      \tl_use:N \l_siunitx_table_collect_post_tl 
      \tex_hfil:D
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_model_create:}
%\begin{macro}[aux]{\siunitx_table_print_S_model_aux:nn}
% A model value is created from the various numbers set up as
% options. The main formatting routine is used to get everything sorted
% out, so that there is no code copying here.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_model_create: {
  \prop_clear:N \l_siunitx_number_in_prop
  \bool_if:NT \l_siunitx_table_comparator_bool
    { \prop_put:Nnn \l_siunitx_number_in_prop { comparator } { \ll } }
  \siunitx_table_print_S_model_aux:nn { integer } { mantissa-integer }
  \siunitx_table_print_S_model_aux:nn { decimal } { mantissa-decimal }
  \siunitx_table_print_S_model_aux:nn { uncert } 
    { mantissa-uncertainty }
  \siunitx_table_print_S_model_aux:nn { exponent } { exponent-integer }
  \int_compare:nNnF 
    { \l_siunitx_table_integer_int + \l_siunitx_table_decimal_int } =
      { 0 }
    { 
      \prop_put:Nnn \l_siunitx_number_in_prop { mantissa } 
        { true }
    }
  \int_compare:nNnT { \l_siunitx_table_decimal_int } > { 0 }
    { 
      \prop_put:NnV \l_siunitx_number_in_prop 
        { mantissa-decimal-marker }
        \l_siunitx_output_decimal_tl  
    }
  \bool_if:NT \l_siunitx_table_sign_mantissa_bool
    { \prop_put:Nnn \l_siunitx_number_in_prop { mantissa-sign } { - } }
  \int_compare:nNnT { \l_siunitx_table_exponent_int } > { 0 }
    {  
      \bool_if:NT \l_siunitx_table_sign_exponent_bool
        {
          \prop_put:Nnn \l_siunitx_number_in_prop { exponent-sign } 
            { - } 
        } 
    } 
  \siunitx_number_process_sign:
  \siunitx_number_process_zero_fill:
  \siunitx_number_process_mantissa:
  \prop_if_in:NnF \l_siunitx_number_in_prop { symbolic } 
    { \siunitx_number_process_uncertainty: }
  \siunitx_number_format: 
  \prop_set_eq:NN \l_siunitx_table_model_prop 
    \l_siunitx_number_out_prop
}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_model_aux:nn #1#2 {
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { 
      \prg_replicate:nn { \int_use:c { l_siunitx_table_ #1 _int } } 
        { 8 }
    }
  \tl_if_empty:NF \l_siunitx_tmpa_tl
    { 
      \prop_put:NnV \l_siunitx_number_in_prop {#2} \l_siunitx_tmpa_tl 
      \prop_put:Nnn  \l_siunitx_number_in_prop {#1} { true }
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_reserved_reserved_comparator:}
% Space for a comparator is pretty easy: it has to be at the start of
% the output so there is not so much to worry about.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_comparator:
  {  
  \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop 
    { comparator } { }
  \siunitx_table_print_S_get_comparator:Nn 
    \l_siunitx_number_out_prop { }
  \hbox_set_to_wd:Nnn \l_siunitx_table_result_box 
    { \l_siunitx_table_comparator_dim }
    {
      \siunitx_print:nV { number } \l_siunitx_tmpa_tl
      \tex_hfil:D
    }
  \box_use:N \l_siunitx_table_result_box  
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_reserved_mantissa:}
%\begin{macro}[aux]{\siunitx_table_print_S_reserved_mantissa_aux:n}
% Printing the mantissa is done by measuring the integer part of the
% model and the real number, and padding out if necessary. Everything
% else is straight forward. The reason for the two box setting
% operations here is to allow the amount of empty space left after
% the decimal marker to be measured: this is needed if exponents are
% not being aligned.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_mantissa: {
  \siunitx_table_print_S_reserved_mantissa_aux:n { mantissa }
  \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop
    { mantissa } { }
  \siunitx_table_print_S_get_mantissa:Nn 
    \l_siunitx_number_out_prop { }
  \dim_set:Nn \l_siunitx_table_space_dim { \l_siunitx_table_mantissa_dim }
  \hbox_set:Nn \l_siunitx_table_result_box
    {
      \box_use:N \l_siunitx_table_fill_box
      \siunitx_print:nV { number } \l_siunitx_tmpa_tl
    }
  \dim_sub:Nn \l_siunitx_table_space_dim 
    { \box_wd:N \l_siunitx_table_result_box }
  \hbox_set_to_wd:Nnn \l_siunitx_table_result_box
    { \l_siunitx_table_mantissa_dim }
    { 
      \box_use:N \l_siunitx_table_result_box
      \tex_hfil:D
    }
  \box_use:N \l_siunitx_table_result_box
  \siunitx_table_print_S_reserved_uncert:n { mantissa }
}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_reserved_mantissa_aux:n #1 {
  \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop 
    { integer } {#1}
  \siunitx_table_print_S_get_integer:Nn 
    \l_siunitx_number_out_prop {#1}
  \box_clear:N \l_siunitx_tmp_box
  \tl_if_empty:NF \l_siunitx_tmpa_tl
    {
      \hbox_set:Nn \l_siunitx_tmp_box
        { \siunitx_print:nV { number } \l_siunitx_tmpa_tl }
    }
  \hbox_set_to_wd:Nnn \l_siunitx_table_fill_box
    { \l_siunitx_table_integer_dim - \box_wd:N \l_siunitx_tmp_box }
    { \tex_hfil:D }  
  \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop 
    { decimal } {#1}
  \box_clear:N \l_siunitx_tmp_box
  \siunitx_table_print_S_get_decimal:Nn 
    \l_siunitx_number_out_prop {#1}
  \tl_if_empty:NF \l_siunitx_tmpa_tl
    {
      \hbox_set:Nn \l_siunitx_tmp_box
        { \siunitx_print:nV { number } \l_siunitx_tmpa_tl }
    }
  \dim_set:Nn \l_siunitx_table_gap_dim
    { 
      \dim_use:N \l_siunitx_table_decimal_dim - 
      \box_wd:N \l_siunitx_tmp_box 
    }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_print_S_reserved_uncert:n}
%\begin{macro}[aux]{\siunitx_table_print_S_reserved_uncert_aux:n}
% The uncertainty code is generalised for both real and complex parts.
% A lot of the logic is similar to the exponent part (the \cs{pm}
% symbol) or the mantissa (the number measuring). So some of the
% code is shared.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_reserved_uncert:n #1 {
  \bool_if:NT \l_siunitx_uncert_sep_bool
    {
      \int_compare:nNnTF { \l_siunitx_table_uncert_int } > { 0 }
        { \siunitx_table_print_S_reserved_uncert_aux:n {#1} }
        { 
          \prop_if_in:NnT \l_siunitx_number_out_prop 
            { #1 -uncertainty }
            { 
              \msg_error:nn { siunitx } { table-partial-number } 
                { an~uncertainty }
            }
        }
    }        
}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_reserved_uncert_aux:n #1 {
  \siunitx_table_print_S_reserved_uncert_pm:n {#1}     
  \siunitx_table_print_S_reserved_mantissa_aux:n { #1 -uncertainty }
  \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop
    { uncert } {#1}
  \siunitx_table_print_S_get_uncert:Nn \l_siunitx_number_out_prop {#1}
  \hbox_set_to_wd:Nnn \l_siunitx_table_result_box
    { \l_siunitx_table_uncert_dim }
    { 
      \box_use:N \l_siunitx_table_fill_box
      \siunitx_print:nV { number } \l_siunitx_tmpa_tl
      \tex_hfil:D
    }
  \box_use:N \l_siunitx_table_result_box
  \bool_if:NF \l_siunitx_table_align_uncert_bool
    {
      \tex_hskip:D \l_siunitx_table_space_dim
      \dim_zero:N \l_siunitx_table_space_dim
    }  
}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_reserved_uncert_pm:n #1 {
  \tl_clear:N \l_siunitx_tmpb_tl
  \siunitx_number_format_join_uncert_pm:
  \tl_set:Nx \l_siunitx_tmpb_tl
    { { } \exp_not:V \l_siunitx_tmpb_tl { } }
  \hbox_set:Nn \l_siunitx_table_result_box
    { \siunitx_print:nV { number } \l_siunitx_tmpb_tl }
  \prop_if_in:NnF \l_siunitx_number_out_prop { #1 -uncertainty }
    {
      \hbox_set_to_wd:Nnn \l_siunitx_table_result_box
        { \box_wd:N \l_siunitx_table_result_box } { \tex_hfil:D }
    }

  \bool_if:NF \l_siunitx_table_align_uncert_bool
    { \tex_hskip:D -\l_siunitx_table_space_dim }  
 \box_use:N \l_siunitx_table_result_box
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_reserved_exponent:}
%\begin{macro}[aux]{\siunitx_table_print_S_reserved_exponent_product:}
%\begin{macro}[aux]
%  {\siunitx_table_print_S_reserved_exponent_product_aux_i:}
%\begin{macro}[aux]
%  {\siunitx_table_print_S_reserved_exponent_product_aux_ii:}
% Most of the code for the exponent is concerned with getting the
% product sign correct. Other than that, the exponent result is quite
% easy to handle: just print it with some filling.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_reserved_exponent: {
  \dim_zero:N \l_siunitx_table_gap_dim
  \siunitx_table_print_S_reserved_exponent_product:   
  \siunitx_table_print_S_measure:Nnn \l_siunitx_table_model_prop 
    { exponent } { }
  \siunitx_table_print_S_get_exponent:Nn 
    \l_siunitx_number_out_prop { }
  \hbox_set_to_wd:Nnn \l_siunitx_table_result_box 
    { \l_siunitx_table_exponent_dim }
    {
      \siunitx_print:nV { number } \l_siunitx_tmpa_tl
      \tex_hfil:D
    }
  \box_use:N \l_siunitx_table_result_box 
  \bool_if:NF \l_siunitx_table_align_exp_bool
    { \tex_hskip:D \l_siunitx_table_space_dim }  
}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_reserved_exponent_product: {
  \tl_clear:N \l_siunitx_tmpa_tl
  \box_clear:N \l_siunitx_table_result_box
  \prop_if_in:NnTF \l_siunitx_table_model_prop { mantissa-result }
    { \siunitx_table_print_S_reserved_exponent_product_aux_i: }
    { 
      \prop_if_in:NnT \l_siunitx_table_model_prop { complex-result }
        { \siunitx_table_print_S_reserved_exponent_product_aux_i: }
    }
  \bool_if:NF \l_siunitx_table_align_exp_bool
    { \tex_hskip:D -\l_siunitx_table_space_dim }  
  \box_use:N \l_siunitx_table_result_box
}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_reserved_exponent_product_aux_i: {
  \tl_set_eq:NN \l_siunitx_tmpa_tl \l_siunitx_exponent_product_tl
  \bool_if:NT \l_siunitx_tight_bool 
    {  
      \tl_set:Nx \l_siunitx_tmpa_tl 
        { { \exp_not:V \l_siunitx_tmpa_tl } }
    }
  \tl_set:Nx \l_siunitx_tmpa_tl
    { 
      \exp_not:N \siunitx_ensuremath:n 
        { { } \exp_not:V \l_siunitx_tmpa_tl { } }
    }
  \hbox_set:Nn \l_siunitx_table_result_box
    { \siunitx_print:nV { number } \l_siunitx_tmpa_tl }
  \prop_if_in:NnTF \l_siunitx_number_out_prop { exponent-result }
    {
      \prop_if_in:NnF \l_siunitx_number_out_prop { mantissa-result } 
        {
          \prop_if_in:NnF \l_siunitx_number_out_prop { complex-result } 
            { 
              \siunitx_table_print_S_reserved_exponent_product_aux_ii:
            }
        }
    }
    { \siunitx_table_print_S_reserved_exponent_product_aux_ii: }

}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_reserved_exponent_product_aux_ii: {
  \hbox_set_to_wd:Nnn \l_siunitx_table_result_box
    { \box_wd:N \l_siunitx_table_result_box } { \tex_hfil:D }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_print_S_measure:Nnn}
% The measuring code recovers whatever is needed into 
% \cs{l_siunitx_tmpa_tl} (as this is internal code, that is okay).
% The content is then boxed up and measured: if there is nothing to do,
% a bit of time can be saved by not boxing up at all.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_measure:Nnn #1#2#3 {
  \use:c { siunitx_table_print_S_get_ #2 :Nn } #1 {#3}
  \tl_if_empty:NTF \l_siunitx_tmpa_tl
    { \dim_set:cn { l_siunitx_table_ #2 _dim } { \c_zero_skip } }
    {
      \hbox_set:Nn \l_siunitx_tmp_box
        { \siunitx_print:nV { number } \l_siunitx_tmpa_tl }
      \dim_set:cn { l_siunitx_table_ #2 _dim } 
        { \box_wd:N \l_siunitx_tmp_box }
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_comparator:Nn}
% Getting the comparator part is quite easy.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_get_comparator:Nn #1#2 {
  \prop_get:NnN #1 { comparator } \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    { \tl_clear:N \l_siunitx_tmpa_tl }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_decimal:Nn}
% Grabbing the decimal part is a simple operation.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_get_decimal:Nn #1#2 {
  \prop_get:NnN #1 { #2 -decimal } \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    { \tl_clear:N \l_siunitx_tmpa_tl }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_exponent:Nn}
% Getting the exponent part is quite easy.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_get_exponent:Nn #1#2 {
  \prop_get:NnN #1 { exponent-result } \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    { \tl_clear:N \l_siunitx_tmpa_tl }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_integer:Nn}
% Getting the integer part of a number means that the sign also has be
% considered, even if there is no actual integer. This leas to a 
% slightly odd approach here.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_get_integer:Nn #1#2 {
  \prop_get:NnN #1 { #2 -sign } \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    { \tl_clear:N \l_siunitx_tmpa_tl }
  \prop_get:NnN #1 { #2 -integer } \l_siunitx_tmpb_tl
  \quark_if_no_value:NT \l_siunitx_tmpb_tl
    { \tl_clear:N \l_siunitx_tmpb_tl }
  \tl_put_right:NV \l_siunitx_tmpa_tl \l_siunitx_tmpb_tl
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_mantissa:Nn}
% The mantissa without any uncertainty is needed by the reserved
% space routine. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn 
  \siunitx_table_print_S_get_mantissa:Nn #1#2 {
  \prop_get:NnN #1 { mantissa } \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    { \tl_clear:N \l_siunitx_tmpa_tl }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_marker:Nn} 
% The decimal marker is always going to be boxed up using the 
% standard version, not any possible copied value. So the code can be
% kept quite clear.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_get_marker:Nn #1#2 {
  \tl_set:Nx \l_siunitx_tmpa_tl
    { 
      \exp_not:N \siunitx_ensuremath:n 
        { \exp_not:V \l_siunitx_output_decimal_tl }
    }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_result:Nn} 
% Getting the result values is easy. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_get_result:Nn #1#2 {
  \prop_get:NnN #1 { result } \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    { \tl_clear:N \l_siunitx_tmpa_tl }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\siunitx_table_print_S_get_uncert:Nn} 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_print_S_get_uncert:Nn #1#2 {
  \prop_get:NnN #1 { #2 -uncertainty } \l_siunitx_tmpa_tl
  \quark_if_no_value:NT \l_siunitx_tmpa_tl
    { \tl_clear:N \l_siunitx_tmpa_tl }
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Direct printing in \texttt{S} columns}
%
% When number parsing is turned off the usual approach to printing
% tabular material is not suitable. Instead, the strategy used by
% \pkg{dcolumn} can be applied, which requires the decimal marker to
% be made active in math mode.
% 
%\begin{macro}{\siunitx_table_direct:}
% The main part of the system simply makes a choice about the 
% methods to use.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_table_direct: {
  \m@th  
  \bool_if:NTF \l_siunitx_table_center_decimal_bool
    { \siunitx_table_direct_centered: }
    { \siunitx_table_direct_reserved: }
}
%    \end{macrocode}
%\end{macro} 
%
%\begin{macro}{\siunitx_table_direct_centered:}
%\begin{macro}[aux]{\siunitx_table_direct_centered_aux:N}
%\begin{macro}{\siunitx_table_direct_centered_end:}
% When centring the content about a decimal marker, the trick is
% to collect everything into two boxes and then compare the sizes.
% In that sense this is very similar to the normal method, except that
% it will work with non-numerical input.
%    \begin{macrocode}
\char_make_active:N \@
\cs_new_protected_nopar:Npn \siunitx_table_direct_centered: {
  \cs_set_eq:NN \siunitx_table_print: 
    \siunitx_table_direct_centered_end:
  \hbox_set:Nn \l_siunitx_tmp_box 
    { \siunitx_ensuremath:n { \l_siunitx_output_decimal_tl } }
  \hbox_set_to_wd:Nnn \l_siunitx_table_post_box 
    { \box_wd:N \l_siunitx_tmp_box }
    { \tex_hfil:D }  
  \hbox_set:Nn \l_siunitx_table_pre_box 
    \c_group_begin_token 
      \c_math_shift_token
      \tl_map_function:NN \l_siunitx_input_decimal_tl
        \siunitx_table_direct_centered_aux:N
}
\cs_new_protected_nopar:Npn \siunitx_table_direct_centered_aux:N #1 {
  \char_set_lccode:nn { `\@ } { `#1 }
  \char_set_mathcode:nn { `#1 } { 32768 }
  \tl_to_lowercase:n { \cs_set_nopar:Npn @ }
    {
      \c_math_shift_token
      \c_group_end_token
      \hbox_set:Nn \l_siunitx_table_post_box
        \c_group_begin_token
          \c_math_shift_token
          \l_siunitx_output_decimal_tl
    }
}
\char_make_letter:N \@
\cs_new_protected_nopar:Npn \siunitx_table_direct_centered_end: {
    \c_math_shift_token
  \c_group_end_token
  \dim_compare:nNnTF 
    { \box_wd:N \l_siunitx_table_pre_box } > 
    { \box_wd:N \l_siunitx_table_post_box }
    { 
      \hbox_set_to_wd:Nnn \l_siunitx_table_post_box
        { \box_wd:N \l_siunitx_table_pre_box }
        {
          \hbox_unpack:N \l_siunitx_table_post_box
          \tex_hfil:D
        }
    }
    { 
      \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box
        { \box_wd:N \l_siunitx_table_post_box }
        {
          \tex_hfil:D
          \hbox_unpack:N \l_siunitx_table_pre_box
        }
    }
  \box_use:N \l_siunitx_table_pre_box
  \box_use:N \l_siunitx_table_post_box
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_table_direct_reserved:}
%\begin{macro}[aux]{\siunitx_table_direct_reserved_aux:N}
%\begin{macro}{\siunitx_table_direct_reserved_end:}
% The plan here is to box up the entire number using the information
% available about the size of the two parts. Relatively easy,
% but needs a bit of measuring. The first box here does need to use
% \cs{tex_hill:D} as \texttt{fil} glue will not work.
%    \begin{macrocode}
\char_make_active:N \@
\cs_new_protected_nopar:Npn \siunitx_table_direct_reserved: {
  \cs_set_eq:NN \siunitx_table_print: 
    \siunitx_table_direct_reserved_end:
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { \prg_replicate:nn { \l_siunitx_table_integer_int } { 8 } } 
  \hbox_set:Nn \l_siunitx_tmp_box 
    { 
      \siunitx_ensuremath:n 
        { 
          \bool_if:NT \l_siunitx_table_sign_mantissa_bool { - }
          \l_siunitx_tmpa_tl 
        } 
    }
  \dim_set:Nn \l_siunitx_table_integer_dim
    { \box_wd:N \l_siunitx_tmp_box }  
  \tl_set:Nx \l_siunitx_tmpa_tl 
    { \prg_replicate:nn { \l_siunitx_table_decimal_int } { 8 } }
  \hbox_set:Nn \l_siunitx_tmp_box 
    { 
      \siunitx_ensuremath:n 
        { 
          \l_siunitx_output_decimal_tl
          \l_siunitx_tmpa_tl
        } 
    }
  \hbox_set_to_wd:Nnn \l_siunitx_table_post_box 
    { \box_wd:N \l_siunitx_tmp_box }
    { \tex_hfil:D }  
  \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box 
    { \l_siunitx_table_integer_dim }
    \c_group_begin_token 
      \c_math_shift_token
      \tl_map_function:NN \l_siunitx_input_decimal_tl
        \siunitx_table_direct_reserved_aux:N 
      \tex_hfill:D  
}
\cs_new_protected_nopar:Npn \siunitx_table_direct_reserved_aux:N #1 {
  \char_set_lccode:nn { `\@ } { `#1 }
  \char_set_mathcode:nn { `#1 } { 32768 }
  \tl_to_lowercase:n { \cs_set_nopar:Npn @ }
    {
        \c_math_shift_token
      \c_group_end_token
      \hbox_set_to_wd:Nnn \l_siunitx_table_post_box
        { \box_wd:N \l_siunitx_tmp_box }
        \c_group_begin_token
          \c_math_shift_token
          \l_siunitx_output_decimal_tl
    }
}
\char_make_letter:N \@
\cs_new_protected_nopar:Npn \siunitx_table_direct_reserved_end: {
    \c_math_shift_token
    \tex_hfil:D
  \c_group_end_token  
  \siunitx_table_align_left:n { \l_siunitx_table_number_align_skip }
  \box_use:N \l_siunitx_table_pre_box
  \box_use:N \l_siunitx_table_post_box
  \siunitx_table_align_right:n { \l_siunitx_table_number_align_skip }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Symbols}
%
% Not all units use letters alone for their symbol. This raises two 
% problems. First, the symbols need to work in math and in text mode.
% Second, the user needs to be able to adjust each symbol.
% 
%\begin{macro}{\l_siunitx_redefine_symbols_bool}
% Only one setting applies here!
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  redefine-symbols .bool_set:N = \l_siunitx_redefine_symbols_bool,
}
\keys_set:nn { siunitx } {
  redefine-symbols = true
}
%    \end{macrocode}
%\end{macro} 
%
% The redefinition of symbols has to do a number of checks to ensure
% that there are no clashes.
%    \begin{macrocode}
\AtBeginDocument {
  \bool_if:NT \l_siunitx_redefine_symbols_bool 
    {
      \@ifpackageloaded { textcomp } 
        {
          \keys_set:nn { siunitx } 
            {
              math-degree = \text { \textdegree },
              text-degree  = \textdegree,
            }
          \@ifpackageloaded { mathptmx } { } 
            {
              \keys_set:nn { siunitx } { text-micro = \textmu }
              \@ifpackageloaded { fourier } { }
                { \keys_set:nn { siunitx } { text-ohm = \textohm } } 
            }
          \str_if_eq:VnT \encodingdefault { OT1 }
            { 
              \keys_set:nn { siunitx } 
                {
                  math-angstrom = \text { \capitalring { A } },
                  text-angstrom = \capitalring { A }
                }
            }
        } { }
      \@ifpackageloaded { upgreek } 
        {
          \keys_set:nn { siunitx } 
            { math-ohm = \Upomega }
        } { }
    }
}
%    \end{macrocode}
%
%\begin{macro}{\l_siunitx_angstrom_math_tl}
%\begin{macro}{\l_siunitx_arcminute_math_tl}
%\begin{macro}{\l_siunitx_arcsecond_math_tl}
%\begin{macro}{\l_siunitx_celsius_math_tl}
%\begin{macro}{\l_siunitx_degree_math_tl}
%\begin{macro}{\l_siunitx_micro_math_tl}
%\begin{macro}{\l_siunitx_ohm_math_tl}
% The symbol storage macros are created separately for math and text
% mode, although this is all pretty similar. The default definitions use
% what is generally available, except for those for micro, where 
% Computer Modern does not have the appropriate symbol at all. For the 
% math mode omega option, the "\text{\ensuremath{...}}" construction
% deals with the case where \cs{mathnormal} has the wrong symbol.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  math-angstrom   .tl_set:N = \l_siunitx_angstrom_math_tl,
  math-arcminute  .tl_set:N = \l_siunitx_arcminute_math_tl,
  math-arcsecond  .tl_set:N = \l_siunitx_arcsecond_math_tl,
  math-celsius    .tl_set:N = \l_siunitx_celsius_math_tl,
  math-degree     .tl_set:N = \l_siunitx_degree_math_tl,
  math-micro      .tl_set:N = \l_siunitx_micro_math_tl,
  math-ohm        .tl_set:N = \l_siunitx_ohm_math_tl
}
\keys_set:nn { siunitx } {
  math-angstrom  = \text { \AA },
  math-arcminute = { } ^ { \prime },
  math-arcsecond = { } ^ { \prime \prime },
  math-celsius   = { } ^ { \circ } \kern - \scriptspace \mathrm { C },
  math-degree    = { } ^ { \circ },
  math-micro     = \text { \c_siunitx_mu_tl },
  math-ohm       = \text { \ensuremath { \c_siunitx_omega_tl } },
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\l_siunitx_angstrom_text_tl}
%\begin{macro}{\l_siunitx_arcminute_text_tl}
%\begin{macro}{\l_siunitx_arcsecond_text_tl}
%\begin{macro}{\l_siunitx_celsius_text_tl}
%\begin{macro}{\l_siunitx_degree_text_tl}
%\begin{macro}{\l_siunitx_micro_text_tl}
%\begin{macro}{\l_siunitx_ohm_text_tl}
% Text versions are similar.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  text-angstrom  .tl_set:N = \l_siunitx_angstrom_text_tl,
  text-arcminute .tl_set:N = \l_siunitx_arcminute_text_tl,
  text-arcsecond .tl_set:N = \l_siunitx_arcsecond_text_tl,
  text-celsius   .tl_set:N = \l_siunitx_celsius_text_tl,
  text-degree    .tl_set:N = \l_siunitx_degree_text_tl,
  text-micro     .tl_set:N = \l_siunitx_micro_text_tl,
  text-ohm       .tl_set:N = \l_siunitx_ohm_text_tl,
}
\keys_set:nn { siunitx } {
  text-angstrom  = \AA,
  text-arcminute = \ensuremath { { } ^ { \prime } },
  text-arcsecond = \ensuremath { { } ^ { \prime \prime } },
  text-celsius   = 
    \ensuremath { { } ^ { \circ } \kern - \scriptspace \text { C } },
  text-degree    = \ensuremath { { } ^ { \circ } },
  text-micro     = \c_siunitx_mu_tl ,
  text-ohm       = \ensuremath { \c_siunitx_omega_tl },
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\siunitx_symbol_new:n}
% For creating the outer symbol macro.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_symbol_new:n #1 {
  \cs_set_protected_nopar:cpn { SIUnitSymbol #1 } 
    {
      \mode_if_math:TF 
        { \tl_to_lowercase:n { \use:c { l_siunitx_ #1 _math_tl } } }
        { \tl_to_lowercase:n { \use:c { l_siunitx_ #1 _text_tl } } }
    }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SIUnitSymbolAngstrom}
%\begin{macro}{\SIUnitSymbolArcminute}
%\begin{macro}{\SIUnitSymbolArcsecond}
%\begin{macro}{\SIUnitSymbolCelsius}
%\begin{macro}{\SIUnitSymbolDegree}
%\begin{macro}{\SIUnitSymbolMicro}
%\begin{macro}{\SIUnitSymbolOhm}
% The wrapper macros are created.
%    \begin{macrocode}
\siunitx_symbol_new:n { Angstrom }
\siunitx_symbol_new:n { Arcminute }
\siunitx_symbol_new:n { Arcsecond }
\siunitx_symbol_new:n { Celsius }
\siunitx_symbol_new:n { Degree } 
\siunitx_symbol_new:n { Micro }
\siunitx_symbol_new:n { Ohm }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Working with other packages}
%
%\begin{macro}{\l_siunitx_pgf_link_clist}
%\begin{macro}{\siunitx_pgf_link:}
% Here, the settings used by \pkg{siunitx} are translated into those for
% \pkg{pgf}. Things could be done more efficiently, but the logic would 
% be more difficult to follow.
%    \begin{macrocode}
\clist_new:N \l_siunitx_pgf_link_clist
\cs_new_protected_nopar:Npn \siunitx_pgf_link: {
  \clist_clear:N \l_siunitx_pgf_link_clist
  \str_if_eq:VnT \l_siunitx_round_tl { figure }
    {
      \clist_put_right:Nn \l_siunitx_pgf_link_clist { fixed }
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { fixed~zerofill = true }
    }
  \clist_put_right:Nx \l_siunitx_pgf_link_clist
    { precision = \int_use:N \l_siunitx_process_precision_int }
  \clist_put_right:Nx \l_siunitx_pgf_link_clist
    { 
      set~decimal~separator = 
        { { \exp_not:V \l_siunitx_output_decimal_tl } }
    }  
  \clist_put_right:Nx \l_siunitx_pgf_link_clist
    { 
      set~thousands~separator = 
        { \exp_not:V \l_siunitx_group_sep_tl } 
    }  
  \bool_if:NTF \l_siunitx_group_four_bool
    { 
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { min~exponent~for~1000~sep = 3 }
    }
    { 
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { min~exponent~for~1000~sep = 4 }
    }
  \bool_if:nF
    {  
      \l_siunitx_group_decimal_bool ||
      \l_siunitx_group_integer_bool  
    }  
    {
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { min~exponent~for~1000~sep = 999 } 
    }
  \bool_if:NTF \l_siunitx_process_integer_zero_bool
    { 
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { skip~0. = false }
    }
    {
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { skip~0. = true }
    } 
  \str_if_eq:VnTF \l_siunitx_process_sign_tl { + }
    { 
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { showpos = true }
    }
    {
      \clist_put_right:Nn \l_siunitx_pgf_link_clist 
        { showpos = false }
    } 
  \group_begin:  
  \cs_set_nopar:Npx \siunitx_tmp:w
    {
      \group_end:
      \exp_not:N \pgfqkeys 
        { /pgf/number~format }
        { \exp_not:V \l_siunitx_pgf_link_clist }
    } 
  \siunitx_tmp:w   
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\subsection{Messages}
%
% Lots of messages, all of them together in one block to make life
% easier.
%    \begin{macrocode}
\msg_set:nnnn { siunitx } { bad-arc-sign } 
  { Incorrect~use~of~sign~in~degree-minute-second~angle. }
  { Only~the~highest~value~part~of~an~angle~can~have~a~sign. }
\msg_set:nnnn { siunitx } { duplicate-complex-root-token } 
  { Duplicate~complex~root~token~'#1'~in~input. }
  { Only~one~complex~root~token~can~appear~in~a~single~number. }
\msg_set:nnnn { siunitx } { duplicate-decimal-token } 
  { Duplicate~decimal~marker~token~'#1'~in~input. }
  { Only one decimal marker token can appear in a single number. }
\msg_set:nnnn { siunitx } { duplicate-exponent-token } 
  { Duplicate~exponent~marker~token~'#1'~in~input. }
  { Only~one~exponent~marker~token~can~appear~in~a~single~number. }
\msg_set:nnnn { siunitx } { duplicate-quotient-token } 
  { Duplicate~quotient~token. } 
  { Only~one~quotient~token~can~appear~in~a~single~number. }
\msg_set:nnnn { siunitx } { duplicate-sticky-per } 
  { Duplicate~\token_to_str:N \per. } 
  {
    When~the~'sticky-per'~option~is~active,~only~one 
    \token_to_str:N \per \\
    may~appear~in~a~unit.
  }
\msg_set:nnnn { siunitx } { empty-arc } 
  { Empty~degree-minute-second~angle. }
  { The~angle~given~does~not~contain~any~numbers. }
\msg_set:nnnn { siunitx } { empty-uncertainty }
  { Empty~uncertainty~given~in~'#1'. }
  { The~number~given~contains~an~empty~uncertainty. }
\msg_set:nnnn { siunitx } { ending-product-token }
  { Misplaced~product~token. }
  { A~number~cannot~end~with~a~product~token. }
\msg_set:nnnn { siunitx } { ending-quotient-token } 
  { Misplaced~quotient~token. }
  { A~number~cannot~end~with~a~quotient~token. }
\msg_set:nnnn { siunitx } { invalid-arc-format } 
  { Invalid~degree-minute-second angle~'#1'. }
  {
    Angles~given~in~degree-minute-second~format~should~contain~two~';'\\
    symbols~to~divide~up~the~parts~of~the~input.\\
  }
\msg_set:nnnn { siunitx } { invalid-number } 
  { Invalid~numerical~input~'#1'. }
  {
    The~input given~as~a~number~does~not~make~logical~sense.\\
    This~happens,~for example,~if~a~number~only~contains~a~sign.
  }
\msg_set:nnnn { siunitx } { invalid-token-in-exponent }
  { Invalid~exponent~in~numerical~input~'#1'. }
  {
    The~exponent`part~of~a~number~cannot~contain~an~uncertainty~or~
    complex~part.\\
    The~input~given~appears~to~contain~one~of~these~in~the~exponent.
  }
\msg_set:nnnn { siunitx } { invalid-token-in-number }
  { Invalid~token~'#1'~in~numerical~input. }
  {
    Numbers~can~only~contain~tokens~defined~using~the~
    'input-...'~options:\\
    the~token~'#1'~is~not~set~up~as~a~valid~part~of~a~number.
  }
\msg_set:nnnn { siunitx } { invalid-token-in-uncertainty }
  { Invalid~uncertainty~in~numerical~input~'#1'. }
  {
    The~uncertainty~part~of~a~number~may~only~contain~digits~or~
    symbols.
  }
\msg_set:nnnn { siunitx } { literal-unit }
  { Literal~units~disabled. }
  {
    You~gave~the~literal~input~'#1'\\
    but~literal~unit~output~is~disabled.
  }
\msg_set:nnnn { siunitx } { misplaced-sign-token } 
  { Misplaced~sign~token~'#1'. }
  { Sign~tokens~can~only~come~at~the~beginning~of~a~number. }
\msg_set:nnnn { siunitx } { misplaced-complex-root-token } 
  { Misplaced~complex~token~in~numerical~input~'#1'. } 
  {
    The~root~token~must~come~either~before~or~after~the~real~digits\\
    of~the~complex~part.
  }
\msg_set:nnnn { siunitx } { misplaced-uncertainty-token } 
  { Misplaced~uncertainty~token~'#1'. }
  {
    The~uncertainty~in~a~number~must~be~given~between~a~set~of~
    delimiters~as~defined~by~the\\
    \c_space_tl \c_space_tl
    'input-open-uncertainty'~and~'input-close-uncertainty'\\
    options.
  }
\msg_set:nnnn { siunitx } { multi-part-range } 
  { Numerical~range~with~multiple~parts. }
  {
    The~input~'#1'~is~a~number~which~has~more~than~one~part.\\
    Ranges~can~only~contain~one~number~in~each~part.
  }
\msg_set:nnn { siunitx } { option-not-available }
  { Option~'#1'~not~available~in~strict~mode. }
\msg_set:nnn { siunitx } { option-preamble-only }
  { Option~'#1'~only~available~in~the~preamble. }
\msg_set:nnnn { siunitx } { prefix-base-mismatch }
  { Prefix~bases~do~not~match. }
  {
    You~have~asked~for~prefixes~to~be~converted~into~a~power,\\
    but~the~bases~do~not~match.
  }
\msg_set:nnn { siunitx } { prefix-only } 
  { Prefix~with~no~unit. }
\msg_set:nnnn { siunitx } { qualifier-before-unit } 
  { Qualifier~before~unit. }
  { Unit~qualifiers~have~to~follow~after~units,~not~before~them. }
\msg_set:nnnn { siunitx } { restricted-number } 
  { Token~'#1'~forbidden~in~restricted~numerical~input. }
  { 
    The~current~input~must~be~a~real~number~and~cannot~contain: \\
    \c_space_tl -~an~exponent; \\
    \c_space_tl -~an~uncertainty; \\
    \c_space_tl -~a~complex~part.
  }
\msg_set:nnnn { siunitx } { starting-product-token } 
  { Misplaced~product~token. }
  { A~number~cannot~begin~with~a~product~token. }
\msg_set:nnnn { siunitx } { starting-quotient-token } 
  { Misplaced~quotient~token. }
  { A~number~cannot~begin~with~a~quotient~token. }
\msg_set:nnnn { siunitx } { table-partial-number }
  { No~space~reserved~for~#1~\msg_line_context:. }
  { 
    The~number~in~the~current~table~cell~contains~#1~part, \\
    but~you~did~not~reserve~any~space~to~print~it: \\
    it~will~be~missing~in~the~output.
  }
\msg_set:nnnn { siunitx } { unknown-configuration-file } 
  { Unknown~configuration~'#1'. }
  { The~configuration~file~'siunitx-#1.cfg'~was~not~found. }
\msg_set:nnnn { siunitx } { unknown-option } 
  { Unknown~option~'#1'. }
  { 
    The~option~file~'#1'~is~not~known~by~siunitx: \\
    perhaps~it~is~spelled~incorrectly.
  }
\msg_set:nnnn { siunitx } { version-1-option } 
  { Version~1~option~'#1'~detected. }
  { 
    Use: \\
    \c_space_tl \c_space_tl 
    \token_to_str:N \usepackage[load-configurations = version-1]
    \token_to_str:N { siunitx \token_to_str:N } \\
    in~the~preamble~to~load~the~appropriate~code.
  }
%    \end{macrocode}
%    
%\subsection{Design-level macros}
% 
%\begin{macro}{\DeclareBinaryPrefix}
%\begin{macro}{\DeclareSIPostPower}
%\begin{macro}{\DeclareSIPrefix}
%\begin{macro}{\DeclareSIPrePower}
%\begin{macro}{\DeclareSIQualifier}
%\begin{macro}{\DeclareSIUnit}
%\begin{macro}{\DeclareSIUnitWithOptions}
% The macros for creating units and so on are in design name space.
% Basically, a set of shuffles for arguments.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \DeclareBinaryPrefix #1#2#3 {
  \siunitx_declare_prefix:Nnnn #1 {#2} { 2 } {#3}
}
\cs_new_protected_nopar:Npn \DeclareSIPostPower #1#2 {
  \siunitx_declare_power_after:Nn #1 {#2}
}
\cs_new_protected_nopar:Npn \DeclareSIPrefix #1#2#3 {
  \siunitx_declare_prefix:Nnnn #1 {#2} { 10 } {#3}
}
\cs_new_protected_nopar:Npn \DeclareSIPrePower #1#2 {
  \siunitx_declare_power_before:Nn #1 {#2}
}
\cs_new_protected_nopar:Npn \DeclareSIQualifier #1#2 {
  \siunitx_declare_qualifier:Nn #1 {#2}
}
\cs_new_protected_nopar:Npn \DeclareSIUnit #1#2 {
  \siunitx_declare_unit:Nnn #1 {#2} { }
}
\cs_new_protected_nopar:Npn \DeclareSIUnitWithOptions #1#2#3 {
  \siunitx_declare_unit:Nnn #1 {#2} {#3}
}
%    \end{macrocode}
%\end{macro}
%\end{macro} 
%\end{macro} 
%\end{macro} 
%\end{macro}
%\end{macro}
%\end{macro}
% 
% None of this should be done after the preamble.
%    \begin{macrocode}
\@onlypreamble \DeclareBinaryPrefix
\@onlypreamble \DeclareSIPostPower
\@onlypreamble \DeclareSIPrefix
\@onlypreamble \DeclareSIPrePower
\@onlypreamble \DeclareSIQualifier
\@onlypreamble \DeclareSIUnit
\@onlypreamble \DeclareSIUnitWithOptions
%    \end{macrocode}
%    
%\begin{macro}{\SendSettingsToPgf}
% A settings transfer function.
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \SendSettingsToPgf { \siunitx_pgf_link: }
%    \end{macrocode}
%\end{macro}
%
%\subsection{Document macros}
%
% The user document macros are all collected together here for ease.
% 
%\begin{macro}{\ang}
% The \cs{ang} function does very little beyond setting the local
% keys and passing on the input.
%    \begin{macrocode}
\NewDocumentCommand \ang { o > { \SplitArgument { 2 } { ; } } m } {
  \group_begin:
    \IfNoValueF {#1} 
      { \keys_set:nn { siunitx } {#1} }
    \siunitx_angle_output:nnn #2
  \group_end:
}
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\num}
% The \cs{num} macro is quite simple: read the number, check it is 
% correct then print it. 
%    \begin{macrocode}
\NewDocumentCommand \num { o m } {
  \group_begin:
    \IfNoValueF {#1} 
      { \keys_set:nn { siunitx } {#1} }
    \siunitx_number_output:n {#2}
  \group_end:
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\numlist}
% Lists of numbers are trivially easy to work with.
%    \begin{macrocode}
\NewDocumentCommand \numlist { o > { \SplitList { ; } } m } {
  \group_begin:
    \IfNoValueF {#1}
      { \keys_set:nn { siunitx } {#1} }
    \siunitx_list_numbers:n {#2}
  \group_end:
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\numrange}
% A very simple approach is taken here: this is not intended for 
% anything complicated.
%    \begin{macrocode}
\NewDocumentCommand \numrange { o m m } {
  \group_begin:
    \IfNoValueF {#1}
      { \keys_set:nn { siunitx } {#1} }
    \siunitx_range_numbers:nn {#2} {#3}
  \group_end:
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\si}
% The \cs{si} macro needs to pass options through to the internal
% function as well as setting them here. This is used so that options
% set for a unit can be overridden on a one-off basis.
%    \begin{macrocode}
\NewDocumentCommand \si { o m } {
  \group_begin:
    \IfNoValueTF {#1}
      { \siunitx_unit_output:nn {#2} { } }
      {
        \keys_set:nn { siunitx } {#1}
        \siunitx_unit_output:nn {#2} {#1}
      }
  \group_end:
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SIlist}
%\begin{macro}{\SIrange}
% Lists and range of values are handled in a very similar way.
% Everything is kept relatively simple, and so there is not too much
% complexity. In theory the two could be combined together, but 
% the differences between the two make this less desirable.
%    \begin{macrocode}
\NewDocumentCommand \SIlist { o > { \SplitList { ; } } m m } {
  \group_begin:
    \IfNoValueTF {#1}
      { \siunitx_list_units:nnn {#2} {#3} { }  }
      {
        \keys_set:nn { siunitx } {#1}
        \siunitx_list_units:nnn {#2} {#3} {#1} 
      }
  \group_end:
}
\NewDocumentCommand \SIrange { o m m m } {
  \group_begin:
    \IfNoValueTF {#1}
      { \siunitx_range_unit:nnnn {#4} { } {#2} {#3} }
      {
        \keys_set:nn { siunitx } {#1}
        \siunitx_range_unit:nnnn {#4} {#1} {#2} {#3}
      }
  \group_end:
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\SI}
% The main \cs{SI} function follows the same pattern as the previous
% ones.
%    \begin{macrocode}
\NewDocumentCommand \SI { o m o m } {
  \group_begin:
    \IfNoValueTF {#1}
      { \siunitx_combined:nnnn { } {#2} {#3} {#4} }
      {
        \keys_set:nn { siunitx } {#1}
        \siunitx_combined:nnnn {#1} {#2} {#3} {#4}
      }
  \group_end:
}
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\sisetup}
% The set up macro simply moves to the correct path and executes 
% whatever has been passed.
%    \begin{macrocode}
\NewDocumentCommand \sisetup { m } {
  \keys_set:nn { siunitx } {#1}
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Precautions for section headings}
%
% There are two issues to be handled for section headings, \emph{etc}.
% First, within the \cs{addcontentline} macro the various unit functions 
% need to be \cs{protected}. Secondly, there is a need to worry about
% \pkg{hyperref}, and ensure that everything works cleanly and with
% no unnecessary warnings.
% 
%\begin{macro}{\siunitx_contents_add:N}
% An updated version of \cs{addtocontents} which will ensure that
% everything works properly. Using \cs{token_to_str:N} means that
% there is no problem with the asynchronous nature of \TeX's writing
% mechanism.
%    \begin{macrocode}
\AtBeginDocument {
  \cs_set:Npn \addtocontents #1#2
    {
      \protected@write \@auxout
        {
          \cs_set_eq:NN \label \use_none:n 
          \cs_set_eq:NN \index \use_none:n  
          \cs_set_eq:NN \glossary\use_none:n
          \tl_map_function:NN \l_siunitx_declare_list_tl 
            \siunitx_contents_add:N 
        }
        { \token_to_str:N \@writefile {#1} {#2} }
    }
}
\cs_new_protected_nopar:Npn \siunitx_contents_add:N #1 {
  \cs_set_nopar:Npn #1 { \token_to_str:N #1 }
}
%    \end{macrocode}
%\end{macro} 
% 
%\begin{macro}{\siunitx_contents_bookmarks:}
% The idea here is two-fold. First, all of the unit macros are set
% up to simply print their literal interpretation: this is hopefully
% good enough for most bookmark situations. Secondly, the document
% commands are made expandable. This allows a bit of re-arrangement
% of the input, removes any set up options (which are being ignored)
% and stops \pkg{hyperref} issuing a warning. 
%    \begin{macrocode}
\cs_new_protected_nopar:Npn \siunitx_contents_bookmarks: {
  \tl_map_function:NN \l_siunitx_declare_list_tl
    \siunitx_unit_print_literal_aux:N
  \msg_redirect_name:nnn { LaTeX / xparse } { redefine-command } 
    { none }
  \cs_set_eq:NN \num      \siunitx_bookmark_num:w
  \cs_set_eq:NN \numrange \siunitx_bookmark_numrange:w
  \cs_set_eq:NN \si       \siunitx_bookmark_si:w
  \cs_set_eq:NN \SI       \siunitx_bookmark_SI:w
  \cs_set_eq:NN \SIrange  \siunitx_bookmark_SIrange:w
  \cs_set_nopar:Npn \SIUnitSymbolAngstrom  { \AA }
  \cs_set_nopar:Npn \SIUnitSymbolArcminute { ' }
  \cs_set_nopar:Npn \SIUnitSymbolArcsecond { '' }
  \cs_set_nopar:Npn \SIUnitSymbolCelsius   { \textcelsius }
  \cs_set_nopar:Npn \SIUnitSymbolDegree    { \textdegree }
  \cs_set_nopar:Npn \SIUnitSymbolMicro     { \textmu }
  \cs_set_nopar:Npn \SIUnitSymbolOhm       { [ohm] }
}
%    \end{macrocode}
%\end{macro} 
%\begin{macro}{\siunitx_bookmark_num:w}
%\begin{macro}{\siunitx_bookmark_numrange:w}
%\begin{macro}{\siunitx_bookmark_si:w}
%\begin{macro}{\siunitx_bookmark_SI:w}
%\begin{macro}{\siunitx_bookmark_SIrange:w}
% To keep things fast, expandable versions of the document commands
% are created only once. These are then used if necessary to remove
% and re-order arguments in an expandable fashion.
%    \begin{macrocode}
\DeclareExpandableDocumentCommand \siunitx_bookmark_num:w { o m } {#2}
\DeclareExpandableDocumentCommand \siunitx_bookmark_numrange:w { o m m } 
  { #2 \l_siunitx_range_phrase_tl #3 }
\DeclareExpandableDocumentCommand \siunitx_bookmark_si:w { o m } {#2}
\DeclareExpandableDocumentCommand \siunitx_bookmark_SI:w { o m o m } 
  { \IfNoValueF {#3} {#3} #2 ~ #4 }
\DeclareExpandableDocumentCommand \siunitx_bookmark_SIrange:w
  { o m m m } { #2 ~ #4 \l_siunitx_range_phrase_tl #3 ~ #4 }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
% A short check to get things working.
%    \begin{macrocode}
\AtBeginDocument {
  \@ifpackageloaded { hyperref } 
    { \pdfstringdefDisableCommands { \siunitx_contents_bookmarks: } }
    { }
}
%    \end{macrocode}
%
%\subsection{Physical units}
%
%\begin{macro}{\kilogram}
%\begin{macro}{\metre}
%\begin{macro}{\meter}
%\begin{macro}{\mole}
%\begin{macro}{\kelvin}
%\begin{macro}{\candela}
%\begin{macro}{\second}
%\begin{macro}{\ampere}
% The basic SI units are always defined, including both variants for
% metre.
%    \begin{macrocode}
\DeclareSIUnit \kilogram { \kilo \gram }
\DeclareSIUnit \metre    { m }
\DeclareSIUnit \meter    { \metre }
\DeclareSIUnit \mole     { mol }
\DeclareSIUnit \second   { s }
\DeclareSIUnit \ampere   { A }
\DeclareSIUnit \kelvin   { K }
\DeclareSIUnit \candela  { cd }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\gram}
% The gram is an odd unit as it is needed for the base unit kilogram.
%    \begin{macrocode}
\DeclareSIUnit \gram { g }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\yocto}
%\begin{macro}{\zepto}
%\begin{macro}{\atto}
%\begin{macro}{\femto}
%\begin{macro}{\pico}
%\begin{macro}{\nano}
%\begin{macro}{\micro}
%\begin{macro}{\milli}
%\begin{macro}{\centi}
%\begin{macro}{\deci}
% The various SI multiple prefixes are defined here: first the small
% ones. 
%    \begin{macrocode}
\DeclareSIPrefix \yocto { y } { -24 }
\DeclareSIPrefix \zepto { z } { -21 }
\DeclareSIPrefix \atto  { a } { -18 }
\DeclareSIPrefix \femto { f } { -15 }
\DeclareSIPrefix \pico  { p } { -12 }
\DeclareSIPrefix \nano  { n } { -9 }
\DeclareSIPrefix \micro { \SIUnitSymbolMicro } { -6 }
\DeclareSIPrefix \milli { m } { -3 }
\DeclareSIPrefix \centi { c } { -2 }
\DeclareSIPrefix \deci  { d } { -1 }
%    \end{macrocode}
%\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}{\deka}
%\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}
\DeclareSIPrefix \deca  { da } { 1 }
\DeclareSIPrefix \deka  { da } { 1 }
\DeclareSIPrefix \hecto { h }  { 2 }
\DeclareSIPrefix \kilo  { k }  { 3 }
\DeclareSIPrefix \mega  { M }  { 6 }
\DeclareSIPrefix \giga  { G }  { 9 }
\DeclareSIPrefix \tera  { T }  { 12 }
\DeclareSIPrefix \peta  { P }  { 15 }
\DeclareSIPrefix \exa   { E }  { 18 }
\DeclareSIPrefix \zetta { Z }  { 21 }
\DeclareSIPrefix \yotta { Y }  { 24 }
%    \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}{\becquerel}
%\begin{macro}{\celsius}
%\begin{macro}{\degreeCelsius}
%\begin{macro}{\coulomb}
%\begin{macro}{\farad}
%\begin{macro}{\gray}
%\begin{macro}{\hertz}
%\begin{macro}{\henry}
%\begin{macro}{\joule}
%\begin{macro}{\katal}
%\begin{macro}{\lumen}
%\begin{macro}{\lux}
% A number of derived units with defined names and symbols.
%    \begin{macrocode}
\DeclareSIUnit \becquerel     { Bq }
\DeclareSIUnit \celsius       { \SIUnitSymbolCelsius }
\DeclareSIUnit \degreeCelsius { \SIUnitSymbolCelsius }
\DeclareSIUnit \coulomb       { C }
\DeclareSIUnit \farad         { F }
\DeclareSIUnit \gray          { Gy }
\DeclareSIUnit \hertz         { Hz }
\DeclareSIUnit \henry         { H }
\DeclareSIUnit \joule         { J }
\DeclareSIUnit \katal         { kat }
\DeclareSIUnit \lumen         { lm }
\DeclareSIUnit \lux           { lx }
%    \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}{\newton}
%\begin{macro}{\ohm}
%\begin{macro}{\pascal}
%\begin{macro}{\radian}
%\begin{macro}{\siemens}
%\begin{macro}{\sievert}
%\begin{macro}{\steradian}
%\begin{macro}{\tesla}
%\begin{macro}{\volt}
%\begin{macro}{\watt}
%\begin{macro}{\weber}
% More units.
%    \begin{macrocode}
\DeclareSIUnit \newton    { N }
\DeclareSIUnit \ohm       { \SIUnitSymbolOhm }
\DeclareSIUnit \pascal    { Pa }
\DeclareSIUnit \radian    { rad }
\DeclareSIUnit \siemens   { S }
\DeclareSIUnit \sievert   { Sv }
\DeclareSIUnit \steradian { sr }
\DeclareSIUnit \tesla     { T }
\DeclareSIUnit \volt      { V }
\DeclareSIUnit \watt      { W }
\DeclareSIUnit \weber     { Wb }
%    \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}{\arcminute}
%\begin{macro}{\arcsecond}
%\begin{macro}{\day}
%\begin{macro}{\degree}
%\begin{macro}{\hectare}
%\begin{macro}{\hour}
%\begin{macro}{\litre}
%\begin{macro}{\liter}
%\begin{macro}{\minute}
%\begin{macro}{\percent}
%\begin{macro}{\tonne}
% Non-SI, but accepted for general use.
%    \begin{macrocode}
\DeclareSIUnitWithOptions \arcmin { \arcminute } 
  { number-unit-separator = }
\DeclareSIUnitWithOptions \arcminute { \SIUnitSymbolArcminute } 
  { number-unit-separator = }
\DeclareSIUnitWithOptions \arcsecond { \SIUnitSymbolArcsecond } 
  { number-unit-separator = }
\DeclareSIUnit \day { d }
\DeclareSIUnitWithOptions \degree { \SIUnitSymbolDegree } 
  { number-unit-separator = }
\DeclareSIUnit \hectare { ha }
\DeclareSIUnit \hour    { h }
\DeclareSIUnit \litre   { l }
\DeclareSIUnit \liter   { L }
\DeclareSIUnit \minute  { min }
\DeclareSIUnit \percent { \char 37 }
\DeclareSIUnit \tonne   { t }
%    \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}{\astronomicalunit}
%\begin{macro}{\atomicmassunit}
%\begin{macro}{\electronvolt}
%\begin{macro}{\dalton}
% A few units based on physical measurements exist.  
%    \begin{macrocode}
\DeclareSIUnit \astronomicalunit { ua }
\DeclareSIUnit \atomicmassunit   { u }
\DeclareSIUnit \electronvolt     { eV }
\DeclareSIUnit \dalton           { Da }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\clight}
%\begin{macro}{\electronmass}
%\begin{macro}{\planckbar}
% A set of \enquote{natural units}.
%    \begin{macrocode}
\group_begin:
  \char_set_lccode:nn { `\@ } { `\_ }
  \char_make_math_subscript:N \@
\tl_to_lowercase:n {
  \group_end:
  \DeclareSIUnit \clight { \text { \ensuremath { c @ { 0 } } } }
  \DeclareSIUnit \electronmass 
    { \text { \ensuremath { m @ { \text { e } } } } } 
}
\DeclareSIUnit \planckbar { \text { \ensuremath { \hbar } } }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\elementarycharge}
%\begin{macro}{\bohr}
%\begin{macro}{\hartree}
% A set of \enquote{atomic units}.
%    \begin{macrocode}
\DeclareSIUnit \elementarycharge { \text { \ensuremath { e } } }
\group_begin:
  \char_set_lccode:nn { `\@ } { `\_ }
  \char_set_lccode:nn { `\E } { `\E }
  \char_make_math_subscript:N \@
\tl_to_lowercase:n {
  \group_end:
  \DeclareSIUnit \bohr { \text { \ensuremath { a @ { 0 } } } }
  \DeclareSIUnit \hartree 
    { \text { \ensuremath { E @ { \textup { h } } } } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\angstrom}
%\begin{macro}{\bar}
%\begin{macro}{\barn}
%\begin{macro}{\bel}
%\begin{macro}{\decibel}
%\begin{macro}{\knot}
%\begin{macro}{\mmHg}
%\begin{macro}{\nauticalmile}
%\begin{macro}{\neper}
% There are then some day-to-day units which are accepted for use
% with SI, but are not part of the official specification.
%    \begin{macrocode}
\DeclareSIUnit \angstrom     { \SIUnitSymbolAngstrom }
\DeclareSIUnit \bar          { bar }
\DeclareSIUnit \barn         { b }
\DeclareSIUnit \bel          { B }
\DeclareSIUnit \decibel      { \deci \bel }
\DeclareSIUnit \knot         { kn }
\DeclareSIUnit \mmHg         { mmHg }
\DeclareSIUnit \nauticalmile { M }
\DeclareSIUnit \neper        { Np }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro} 
%\end{macro} 
%\end{macro} 
%
%\begin{macro}{\square}
%\begin{macro}{\squared}
%\begin{macro}{\cubic}
%\begin{macro}{\cubed}
% The basic powers are also defined.
%    \begin{macrocode}
\DeclareSIPrePower  \square  { 2 }
\DeclareSIPostPower \squared { 2 }
\DeclareSIPrePower  \cubic   { 3 }
\DeclareSIPostPower \cubed   { 3 }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\subsection{Strict application of the rules}
%
%\begin{macro}{\siunitx_strict_option:n}
%\begin{macro}[aux]{\siunitx_strict_option_aux:n}
% When sticking to the rules closely, a few options are not available.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  strict .code:n = 
    {
      \keys_set:nn { siunitx } 
        {
          bracket-numbers       = true,
          detect-mode           = false,
          detect-shape          = false,
          detect-weight         = false,
          multi-part-units      = bracket,
          parse-numbers         = true,
          parse-units           = true,
          product-units         = repeat,
        }
      \siunitx_strict_option:n  
        { 
          bracket-numbers  ,
          detect-italic    ,
          detect-mode      ,
          detect-shape     ,
          detect-weight    ,
          multi-part-units ,
          parse-numbers    ,
          parse-units      ,
          product-units    ,
        }
      \keys_define:nn { siunitx }
        {
          per-mode / repeated-symbol .code:n =
            { 
              \msg_warning:nnx { siunitx } { option-not-available } 
                {  per-mode~=~repeated-symbol }
            }
        }  
    }
}
\siunitx_option_deactivate:n { strict }
\cs_new_protected_nopar:Npn \siunitx_strict_option:n #1 {
  \clist_map_function:nN {#1} \siunitx_strict_option_aux:n 
}
\cs_new_protected_nopar:Npn \siunitx_strict_option_aux:n #1 {
  \keys_define:nn { siunitx }
    { #1 .code:n = 
      { \msg_warning:nnx { siunitx } { option-not-available } {#1} }
    }  
}
%    \end{macrocode}
%\end{macro}    
%\end{macro} 
%
%\subsection{Locales}
%
% The basics for defining locales are easy: these are just meta keys.
% The US locale is simply an alias for the UK one, which is the default.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  locale .choice:,
  locale /
    DE   .meta:n = 
      {
        exponent-product      = \cdot  ,
        inter-unit-separator  = { \, } ,
        output-decimal-marker = { , }  ,
      },
  locale /
    FR   .meta:n = 
      {
        exponent-product      = \times ,
        inter-unit-separator  = { \, } ,
        output-decimal-marker = { , }  ,
      },
  locale /
    UK   .meta:n = 
      {
        exponent-product      = \times ,
        inter-unit-separator  = \,     ,
        output-decimal-marker = .      ,
      },
  locale /
    US   .meta:n = { locale = UK }, 
  locale /
    USA  .meta:n = { locale = UK }, 
  locale / 
    ZA   .meta:n = 
      {
        exponent-product      = \times ,
        inter-unit-separator  = \cdot  ,
        output-decimal-marker = { , }  ,
      },
}
%    \end{macrocode}	
%
%\subsection{Localisation}
%
% Localisation makes use of the \pkg{translator} package. This only
% happens if it is available, and is transparent to the user.
%    \begin{macrocode}
\file_if_exist:nT { translator.sty } 
  {
    \RequirePackage { translator }
    \usedictionary { translator-basic-dictionary }
    \providetranslation [ to = English ] 
      { to~(numerical~range) } { to }
    \providetranslation [ to = French ]  
      { to~(numerical~range) } { \`a }
    \providetranslation [ to = German ]  
      { to~(numerical~range) } { bis }
    \sisetup 
      {
        list-final-separator = { ~ \translate { and } ~ },
        range-phrase         = 
          { ~ \translate { to~(numerical~range) } ~ },
      }  
  }
%    \end{macrocode}
%
%\subsection{Loading additional configurations}
%
% There is only only option for loading files: keeps things simple.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  load-configurations .code:n =
    { \siunitx_load_configuration:n {#1} }
}
%    \end{macrocode}
%    
%\begin{macro}{\siunitx_load_configuration:n}
%\begin{macro}[aux]{\siunitx_load_configuration_aux:n}
%\begin{macro}{\c_siunitx_configuration_ext_tl}
% Loading configuration files is made slightly complex by the need
% to remove spaces in the file names (none of the files contain any at
% all, so this is easy). Secondly, the \LaTeXe\ \cs{@onefilewithoptions}
% function is used for file loading, as \LaTeX3 currently needs the
% \LaTeXe\ category code stack to keep things sane.
%    \begin{macrocode}
\cs_new_protected:Npn \siunitx_load_configuration:n #1 {
  \tl_set_rescan:Nnn \l_siunitx_tmpa_tl
    { \char_make_ignore:N \ } {#1}
  \clist_map_function:NN \l_siunitx_tmpa_tl 
    \siunitx_load_configuration_aux:n
}
\cs_new_protected:Npn \siunitx_load_configuration_aux:n #1 {
  \tl_if_empty:nF {#1}
    {
      \file_if_exist:nTF 
        { siunitx- #1 . \c_siunitx_configuration_ext_tl }
        { 
          \@onefilewithoptions { siunitx- #1 } [ ] [ ] 
          \c_siunitx_configuration_ext_tl  
        }
        { 
          \msg_error:nnx { siunitx } { unknown-configuration-file } {#1}
        }
    }
}
\tl_new:N \c_siunitx_configuration_ext_tl
\tl_set:Nn \c_siunitx_configuration_ext_tl { cfg }
%    \end{macrocode}
%\end{macro}    
%\end{macro} 
%\end{macro} 
% 
% Load any local configuration file.  
%    \begin{macrocode}
\file_if_exist:nT { siunitx . \c_siunitx_configuration_ext_tl }
  { 
    \@onefilewithoptions { siunitx } [ ] [ ]
      \c_siunitx_configuration_ext_tl  
  }
%    \end{macrocode}
%
% Finally apply the settings given at load time.
%    \begin{macrocode}
\ProcessKeysOptions { siunitx }
%    \end{macrocode}
%    
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
%\subsection{Support for version one}
%
%    \begin{macrocode}
%<*version-1> 
%    \end{macrocode}
%    
%    \begin{macrocode}
\ProvidesExplFile {siunitx-version-1.cfg} {2011/03/20} {2.1m} 
  {siunitx: Version 1 settings}
%    \end{macrocode}
%    
% The abbreviations are loaded by default by version one.   
%    \begin{macrocode}
\keys_set:nn { siunitx } 
  { load-configurations = { abbreviations , binary } }
%    \end{macrocode}
%
% The re-arrangements made to the code in version two, and in particular
% the new option names, mean that support for version one needs to be
% included explicitly. 
% 
%    \begin{macrocode}   
\keys_define:nn { siunitx } {
  addsign        .choice: ,
  addsign /
    all          .meta:n    = { explicit-sign           = +           },
  addsign /
    exp          .meta:n    = { explicit-sign           = +           },
  addsign / 
    false        .meta:n    = { explicit-sign           =             },
  addsign /
    mant         .meta:n    = { explicit-sign           = +           },
  addsign / 
    none         .meta:n    = { explicit-sign           =             },
  addsign /
    true         .meta:n    = { explicit-sign           = +           },
  addsign        .default:n = { true                                  },  
  allowlitunits  .meta:n    = { free-standing-units     = #1          },
  allowlitunits  .default:n = { true                                  },
  allowoptarg    .meta:n    = { unit-optional-argument  = #1          },
  allowoptargs   .default:n = { true                                  },
  allowzeroexp   .meta:n    = { retain-zero-exponent    = #1          },
  allowzeroexp   .default:n = { true                                  },
  alsoload       .code:n    = ,
  angformat      .code:n    = ,
  anglesep       .choice: ,
  anglesep / 
    cdot         .meta:n    = 
      { arc-separator         = { } \cdot { }                         },
  anglesep / 
    comma        .meta:n    = { arc-separator           = { {,} }     },
  anglesep / 
    fullstop     .meta:n    = { arc-separator           = { { . } }   },
  anglesep / 
    med          .meta:n    = { arc-separator           = \:          },
  anglesep / 
    medium       .meta:n    = { arc-separator           = \:          },
  anglesep / 
    none         .meta:n    = { arc-separator           =             },
  anglesep / 
    period       .meta:n    = { arc-separator           = { { . } }   },
  anglesep / 
    space        .meta:n    = { arc-separator           = \text { ~ } },
  anglesep / 
    stop         .meta:n    = { arc-separator           = { { . } }   },
  anglesep / 
    thick        .meta:n    = { arc-separator           = \;          },
  anglesep / 
    thin         .meta:n    = { arc-separator           = \,          },
  anglesep / 
    tightcdot    .meta:n    = 
      { arc-separator           = \bgroup \cdot \egroup               },
  anglesep / 
    tighttimes   .meta:n    =
      { arc-separator           = \bgroup \times \egroup              },
  anglesep / 
    times        .meta:n    = { arc-separator           = \times      },
  anglesep / 
    unknown      .meta:n    = { arc-separator           = #1          },
  astroang       .meta:n    = 
    { angle-symbol-over-decimal = #1                                  },
  astroang       .default:n = { true                                  },     
  closeerr       .meta:n    = { close-bracket           = #1          },
  closefrac      .meta:n    = { close-bracket           = #1          },
  closerange     .meta:n    = { close-bracket           = #1          },
  colour         .code:n    = { color                   = #1          },
  colorall       .code:n    = ,
  colourall      .code:n    = ,
  colorneg       .code:n    = ,
  colourneg      .code:n    = ,
  colorunits     .meta:n    = ,
  colourunits    .meta:n    = ,
  colorvalues    .meta:n    = ,
  colourvalues   .meta:n    = ,
  decimalsymbol  .choice: ,
  decimalsymbol /
    cdot         .meta:n    = 
      { output-decimal-marker   = { } \cdot { }                       }, 
  decimalsymbol /
    comma        .meta:n    = { output-decimal-marker   = { { , } }   }, 
  decimalsymbol /
    fullstop     .meta:n    = { output-decimal-marker   = { { . } }   }, 
  decimalsymbol /
    period       .meta:n    = { output-decimal-marker   = { { . } }   },
  decimalsymbol /
    stop         .meta:n    = { output-decimal-marker   = { { . } }   },
  decimalsymbol /
    tightcdot    .code:n    = 
      { output-decimal-marker   = \bgroup \cdot \egroup               },
  decimalsymbol /
    unknown      .meta:n    = { output-decimal-marker   = #1          },
  debug          .code:n    = ,
  detectdisplay  .meta:n    = { detect-display-math     = #1          },
  detectdisplay  .default:n = { true                                  },
  digitsep       .choice: ,
  digitsep / 
    cdot         .meta:n    = 
      { group-separator       = { } \cdot { }                         },
  digitsep / 
    comma        .meta:n    = { group-separator         = { , }       },
  digitsep / 
    fullstop     .meta:n    = { group-separator         = .           },
  digitsep / 
    med          .meta:n    = { group-separator         = \:          },
  digitsep / 
    medium       .meta:n    = { group-separator         = \:          },
  digitsep / 
    none         .meta:n    = { group-separator         =             },
  digitsep / 
    period       .meta:n    = { group-separator         = .           },
  digitsep / 
    space        .meta:n    = { group-separator         = \text { ~ } },
  digitsep / 
    stop         .meta:n    = { group-separator         = .           },
  digitsep / 
    thick        .meta:n    = { group-separator         = \;          },
  digitsep / 
    thin         .meta:n    = { group-separator         = \,          },
  digitsep / 
    tightcdot    .meta:n    = 
      { group-separator         = \bgroup \cdot \egroup               },
  digitsep / 
    tighttimes  .meta:n     =
      { group-separator         = \bgroup \times \egroup              },
  digitsep / 
    times        .meta:n    = { group-separator         = \times      },
  digitsep / 
    unknown      .meta:n    = { group-separator         = #1          },
  dp             .meta:n    = 
    { 
      round-mode      = places,
      round-precision = #1,
    },
  emulate        .code:n    = ,
  errspace       .choice: ,
  errspace / 
    med          .meta:n    = { uncertainty-separator   = \:          },
  errspace / 
    medium       .meta:n    = { uncertainty-separator   = \:          },
  errspace / 
    none         .meta:n    = { uncertainty-separator   =             },
  errspace / 
    space        .meta:n    = { uncertainty-separator   = \text { ~ } },
  errspace / 
    thick        .meta:n    = { uncertainty-separator   = \;          },
  errspace / 
    thin         .meta:n    = { uncertainty-separator   = \,          },
  errspace / 
    unknown      .meta:n    = { uncertainty-separator   = #1          },
  eVcorra        .code:n    = ,
  eVcorrb        .code:n    = ,
  expbase        .choice: ,
  expbase /
    ten          .meta:n    = { exponent-base           = 10          },
  expbase /
    two          .meta:n    = { exponent-base           = 2           }, 
  expbase /
    unknown      .meta:n    = { exponent-base           = #1          }, 
  expproduct     .choice: ,  
  expproduct / 
    cdot         .meta:n    = 
      { exponent-product        = { } \cdot { }                       },
  expproduct / 
    tightcdot    .meta:n    = 
      { exponent-product        = \bgroup \cdot \egroup                },
  expproduct / 
    tighttimes   .meta:n    =
      { exponent-product        = \bgroup \times \egroup             },
  expproduct / 
    times        .meta:n    = { exponent-product        = \times     },
  expproduct /
    unknown      .meta:n    = { exponent-product        = #1         },   
  fixdp .choice:,
  fixdp / 
    false        .meta:n    = { round-mode              = none        },
  fixdp / 
    true         .meta:n    = { round-mode              = places      },
  fixdp          .default:n = { true                                  },
  fixsf          .choice: ,
  fixsf / 
    false        .meta:n    = { round-mode              = none        },
  fixsf / 
    true         .meta:n    = { round-mode              = figures     },
  fixsf          .default:n = { true                                  },
  fraction       .choice: ,
  fraction /
    frac         .meta:n    = { fraction-function       = \frac       },
  fraction /
    nice         .meta:n    = { fraction-function       = \frac       },
  fraction /
    sfrac        .meta:n    = { fraction-function       = \sfrac      },
  fraction /
    ugly         .meta:n    = 
      { 
        fraction-function       = \frac ,
        per-mode                = symbol-or-fraction
      },
  inlinebold     .meta:n    = { detect-inline-weight    = #1          },
  log            .code:n    = ,
  load           .code:n    = ,
  loctolang      .code:n    = ,
  mathOmega      .meta:n    = { math-ohm                = #1          },
  mathcelsius    .meta:n    = { math-celsius            = #1          },
  mathdegree     .meta:n    = { math-degree             = #1          },
  mathminute     .meta:n    = { math-arcminute          = #1          },
  mathmu         .meta:n    = { math-micro              = #1          },
  mathringA      .meta:n    = { math-angstrom           = #1          },
  mathrm         .meta:x    = 
    { math-rm                 = \exp_not:c {#1}                       },
  mathsOmega     .meta:n    = { math-ohm                = #1          },
  mathscelsius   .meta:n    = { math-celsius            = #1          },
  mathsdegree    .meta:n    = { math-degree             = #1          },
  mathsecond     .meta:n    = { math-arcsecond          = #1          },
  mathsf         .meta:x    = 
    { math-sf                 = \exp_not:c {#1}                       },
  mathsminute    .meta:n    = { math-arcminute          = #1          },
  mathsmu        .meta:n    = { math-micro              = #1          },
  mathsringA     .meta:n    = { math-angstrom           = #1          },
  mathsrm        .meta:x    = 
    { math-rm                 = \exp_not:c {#1}                       },
  mathssecond    .meta:n    = { math-arcsecond          = #1          },
  mathssf        .meta:x    = 
    { math-sf                 = \exp_not:c {#1}                       },
  mathstt        .meta:x    = 
    { math-tt                 = \exp_not:c {#1}                       },
  mathtt         .meta:x    = 
    { math-tt                 = \exp_not:c {#1}                       },
  negcolor       .meta:n    = { negative-color          = #1          },
  negcolour      .meta:n    = { negative-color          = #1          },
  noload         .code:n    = ,
  numaddn        .meta:n    = { input-symbols           = #1          },
  numcloseerr    .meta:n    = { input-close-uncertainty = #1          },
  numdecimal     .meta:n    = { input-decimal-markers   = #1          },
  numdigits      .meta:n    = { input-digits            = #1          },
  numdiv         .meta:n    = { input-quotient          = #1          },
  numexp         .meta:n    = { input-exponent-markers  = #1          },
  numgobble      .meta:n    = { input-ignore            = #1          },
  numopenerr     .meta:n    = { input-open-uncertainty  = #1          },
  numprod        .meta:n    = { input-product           = #1          },
  numsign        .meta:n    = { input-signs             = #1          },
  obeyall        .meta:n    = { detect-all              = #1          },
  obeyall        .default:n = { true                                  },
  obeybold       .meta:n    = { detect-weight           = #1          },
  obeybold       .default:n = { true                                  },
  obeyfamily     .meta:n    = { detect-family           = #1          },
  obeyfamily     .default:n = { true                                  },
  obeyitalic     .meta:n    = { detect-shape            = #1          },
  obeyitalic     .default:n = { true                                  },
  obeymode       .meta:n    = { detect-mode             = #1          },
  obeymode       .default:n = { true                                  },
  openerr        .meta:n    = { open-bracket            = #1          },
  openfrac       .meta:n    = { open-bracket            = #1          },
  openrange      .meta:n    = { open-bracket            = #1          },
  padangle       .choice: ,
  padangle /
    all          .meta:n    =
      {
        add-arc-degree-zero = true,
        add-arc-minute-zero = true,
        add-arc-second-zero = true
      },
  padangle /
    both         .meta:n    =
      {
        add-arc-degree-zero = true,
        add-arc-minute-zero = true,
        add-arc-second-zero = true
      },
  padangle /
    false        .meta:n    =
      {
        add-arc-degree-zero = false,
        add-arc-minute-zero = false,
        add-arc-second-zero = false
      },
  padangle /
    large        .meta:n    =
      {
        add-arc-degree-zero = true,
        add-arc-minute-zero = true,
        add-arc-second-zero = false
      },
  padangle /
    none         .meta:n    =
      {
        add-arc-degree-zero = false,
        add-arc-minute-zero = false,
        add-arc-second-zero = false
      },
  padangle /
    small         .meta:n    =
      {
        add-arc-degree-zero = false,
        add-arc-minute-zero = true,
        add-arc-second-zero = true
      },
    true         .meta:n    =
      {
        add-arc-degree-zero = true,
        add-arc-minute-zero = true,
        add-arc-second-zero = true
      },
  padnumber      .choice: ,
  padnumber /
    all          .meta:n    =
      {
        add-decimal-zero = true,
        add-integer-zero = true
      },
  padnumber /
    both          .meta:n    =
      {
        add-decimal-zero = true,
        add-integer-zero = true
      },
  padnumber /
    false         .meta:n    =
      {
        add-decimal-zero = false,
        add-integer-zero = false
      },
  padnumber /
    leading        .meta:n    =
      {
        add-decimal-zero = true,
        add-integer-zero = false
      },
  padnumber /
    none         .meta:n    =
      {
        add-decimal-zero = false,
        add-integer-zero = false
      },
  padnumber /
    trailing         .meta:n    =
      {
        add-decimal-zero = false,
        add-integer-zero = true
      },
  padnumber /
    true          .meta:n    =
      {
        add-decimal-zero = true,
        add-integer-zero = true
      },
  per            .choice: ,
  per /
    frac         .meta:n    = { per-mode                = fraction    },
  per /
    fraction     .meta:n    = { per-mode                = fraction    },
  per / 
    reciprocal   .meta:n    = { per-mode                = reciprocal  },
  per /
    slash        .meta:n    = { per-mode                = symbol      },
  prefixbase     .code:n    = ,
  prefixproduct  .code:n    = ,
  prefixsymbolic .meta:n    = { prefixes-as-symbols     = #1          },
  prefixsymbolic .default:n = { true                                  },
  prespace       .meta:n    = { space-before-unit       = #1          },
  prespace       .default:n = { true                                  },
  redefsymbols   .meta:n    = { redefine-symbols        = #1          },
  redefsymbols   .default:n = { true                                  },
  repeatunits    .choice: ,
  repeatunits /
    false        .meta:n    = 
      { 
        multi-part-units      = single,
        product-units         = single,                  
      },
  repeatunits /
    power        .meta:n    = 
      { 
        multi-part-units      = repeat,
        product-units         = power,                 
      },
  repeatunits /
    true        .meta:n       =
      { 
        multi-part-units      = repeat,
        product-units         = repeat,                 
      },
  repeatunits    .default:n = { true                                  },
  retainplus     .meta:n    = { retain-explicit-plus    = #1          },
  retainplus     .default:n = { true                                  },
  seperr         .meta:n    = { separate-uncertainty    = #1          },
  seperr         .default:n = { true                                  },
  sepfour        .meta:n    = { group-four-digits       = true        },
  sepfour        .default:n = { true                                  },
  sf             .meta:n    = 
    { 
      round-mode      = figures,
      round-precision = #1,
    },
  sign           .meta:n    = { explicit-sign           = #1          },
  slash          .choice: ,
  slash / 
    slash        .meta:n    = { per-symbol              = /           },
  slash / 
    unknown      .meta:n    = { per-symbol              = #1          },
  stickyper      .meta:n    = { sticky-per              = #1          },
  stickyper      .default:n = { true                                  },
  strictarc      .code:n    = ,
  tabalign       .code:n    = 
    {
      \str_if_eq:nnTF {#1} { centre }
        { \keys_set:nn { siunitx } { table-alignment = center } }
        { \keys_set:nn { siunitx } { table-alignment = #1 } }  
    },
  tabalignexp    .code:n    = { table-align-exponent    = #1          },
  tabautofit     .meta:n    = { table-auto-round        = #1          },
  tabautofit     .default:n = { true                                  },
  tabexpalign    .code:n    = { table-align-exponent    = #1          },
  tabformat      .meta:n    = { table-format            = #1          },
  tabnumalign    .code:n    = 
    {
      \str_if_eq:nnTF {#1} { centre }
        { \keys_set:nn { siunitx } { table-number-alignment = center } }
        { 
          \str_if_eq:nnTF {#1} { centredecimal }
            {
              \keys_set:nn { siunitx } 
                { table-number-alignment = center-decimal-marker } 
            }
            {
              \str_if_eq:nnTF {#1} { centerdecimal }
                {
                  \keys_set:nn { siunitx } 
                    { table-number-alignment = center-decimal-marker } 
                }    
                {
                  \keys_set:nn { siunitx } 
                    { table-number-alignment = #1 } 
                }    
            }
        }
    },
  tabparseonly   .meta:n    = { table-parse-only        = #1          },
  tabparseonly   .default:n = { true                                  },
  tabtextalign   .code:n    = 
    {
      \str_if_eq:nnTF {#1} { centre }
        { \keys_set:nn { siunitx } { table-text-alignment = center } }
        { \keys_set:nn { siunitx } { table-text-alignment = #1 } }
    },
  tabunitalign   .code:n    = 
    {
      \str_if_eq:nnTF {#1} { centre }
        { \keys_set:nn { siunitx } { table-unit-alignment = center } }
        { \keys_set:nn { siunitx } { table-unit-alignment = #1 } }
    },
  textOmega      .meta:n    = { text-ohm                = #1          },
  textcelsius    .meta:n    = { text-celsius            = #1          },
  textdegree     .meta:n    = { text-degree             = #1          },
  textminute     .meta:n    = { text-arcminute          = #1          },
  textmode       .choice: ,
  textmode / 
    true         .meta:n    = { mode                    = text        },
  textmode / 
    false        .meta:n    = { mode                    = math        },
  textmode       .default:n = { true                                  },
  textmu         .meta:n    = { text-micro              = #1          },
  textringA      .meta:n    = { text-angstrom           = #1          },
  textrm         .meta:x    = 
    { text-rm                 = \exp_not:c {#1}                       },
  textsecond     .meta:n    = { text-arcsecond          = #1          },
  textsf         .meta:x    = 
    { text-sf                 = \exp_not:c {#1}                       },
  texttt         .meta:x    = 
    { text-tt                 = \exp_not:c {#1}                       },
  tightpm        .meta:n    = { tight-spacing           = #1          },
  tightpm        .default:n = { true                                  },
  tophrase       .meta:n    = { range-phrase            = #1          },
  trapambigerr   .choice: ,
  trapambigerr   
    / false      .meta:n    = { multi-part-units        = single      },
  trapambigerr   
    / true       .meta:n    = { multi-part-units        = brackets    },
  trapambigerr   .default:n = { true                                  },
  trapambigfrac  .meta:n    = { bracket-numbers         = #1          },
  trapambigfrac  .default:n = { true                                  },
  trapambigrange .choice: ,
  trapambigrange  
    / false      .meta:n    = { range-units             = single      },
  trapambigrange   
    / true       .meta:n    = { range-units             = brackets    },
  trapambigrange .default:n = { true                                  },
  unitcolor      .meta:n    = { unit-color              = #1          },
  unitcolour     .meta:n    = { unit-color              = #1          },
  unitmathrm     .meta:x    = 
    { unit-math-rm            = \exp_not:c {#1}                       },
  unitmathsf     .meta:x    = 
    { unit-math-sf            = \exp_not:c {#1}                       },
  unitmathsrm    .meta:x    = 
    { unit-math-rm            = \exp_not:c {#1}                       },
  unitmathssf    .meta:x    = 
    { unit-math-sf            = \exp_not:c {#1}                       },
  unitmathstt    .meta:x    = 
    { unit-math-tt            = \exp_not:c {#1}                       },
  unitmathtt     .meta:x    = 
    { unit-math-tt            = \exp_not:c {#1}                       },
  unitmode       .meta:n    = { unit-mode               = #1          },
  unitsep        .choice: ,
  unitsep / 
    cdot         .meta:n    = 
      { inter-unit-separator    = { } \cdot { }                       },
  unitsep / 
    comma        .meta:n    = { inter-unit-separator    = { {,} }     },
  unitsep / 
    fullstop     .meta:n    = { inter-unit-separator    = { { . } }   },
  unitsep / 
    med          .meta:n    = { inter-unit-separator    = \:          },
  unitsep / 
    medium       .meta:n    = { inter-unit-separator    = \:          },
  unitsep / 
    none         .meta:n    = { inter-unit-separator    =             },
  unitsep / 
    period       .meta:n    = { inter-unit-separator    = { { . } }   },
  unitsep / 
    space        .meta:n    = { inter-unit-separator    = \text { ~ } },
  unitsep / 
    stop         .meta:n    = { inter-unit-separator    = { { . } }   },
  unitsep / 
    thick        .meta:n    = { inter-unit-separator    = \;          },
  unitsep / 
    thin         .meta:n    = { inter-unit-separator    = \,          },
  unitsep / 
    tightcdot    .meta:n    =
      { inter-unit-separator    = \bgroup \cdot \egroup               },
  unitsep / 
    tighttimes   .meta:n    =
      { inter-unit-separator    = \bgroup \times \egroup              },
  unitsep / 
    times        .meta:n   = { inter-unit-separator     = \times      },
  unitsep / 
    unknown      .meta:n   = { inter-unit-separator     = #1          },
  unitspace      .choice: ,
  unitspace / 
    med          .meta:n   = { inter-unit-separator     = \:          },
  unitspace / 
    medium       .meta:n   = { inter-unit-separator     = \:          },
  unitspace / 
    none         .meta:n   = { inter-unit-separator     =             },
  unitspace / 
    space        .meta:n   = { inter-unit-separator     = \text { ~ } },
  unitspace / 
    thick        .meta:n   = { inter-unit-separator     = \;          },
  unitspace / 
    thin         .meta:n   = { inter-unit-separator     = \,          },
  unitspace / 
    unknown      .meta:n   = { inter-unit-separator     = #1          },
  valuecolor     .meta:n   = { number-color             = #1          },
  valuecolour    .meta:n   = { number-color             = #1          },
  valuemathrm    .meta:x   = 
    { number-math-rm           = \exp_not:c {#1}                      },
  valuemathsf    .meta:x   = 
    { number-math-sf           = \exp_not:c {#1}                      },
  valuemathsrm   .meta:x   = 
    { number-math-rm           = \exp_not:c {#1}                      },
  valuemathssf   .meta:x   = 
    { number-math-sf           = \exp_not:c {#1}                      },
  valuemathstt   .meta:x   = 
    { number-math-tt           = \exp_not:c {#1}                      },
  valuemathtt    .meta:x   = 
    { number-math-tt           = \exp_not:c {#1}                      },
  valuemode      .meta:n   = { number-mode              = #1          },
  valuesep        .choice: ,
  valuesep / 
    cdot         .meta:n    = 
      { number-unit-separator   = { } \cdot { }                       },
  valuesep / 
    comma        .meta:n    = { number-unit-separator   = { {,} }     },
  valuesep / 
    fullstop     .meta:n    = { number-unit-separator   = { { . } }   },
  valuesep / 
    med          .meta:n    = { number-unit-separator   = \:          },
  valuesep / 
    medium       .meta:n    = { number-unit-separator   = \:          },
  valuesep / 
    none         .meta:n    = { number-unit-separator   =             },
  valuesep / 
    period       .meta:n    = { number-unit-separator   = { { . } }   },
  valuesep / 
    space        .meta:n    = { number-unit-separator   = \text { ~ } },
  valuesep / 
    stop         .meta:n    = { number-unit-separator   = { { . } }   },
  valuesep / 
    thick        .meta:n    = { number-unit-separator   = \;          },
  valuesep / 
    thin         .meta:n    = { number-unit-separator   = \,          },
  valuesep / 
    tightcdot    .meta:n    = 
      { number-unit-separator    = \bgroup \cdot \egroup              },
  valuesep / 
    tighttimes   .meta:n    =
      { number-unit-separator    = \bgroup \times \egroup             },
  valuesep / 
    times        .meta:n    = { number-unit-separator    = \times     },
  valuesep / 
    unknown      .meta:n    = { number-unit-separator    = #1         },
  xspace         .meta:n    = { use-xspace               = #1         },
  xspace         .default:n = { true                                  },
} 
%    \end{macrocode}
%  
% The error can be simplified here: if the option is not known, then 
% it really is an error.
%    \begin{macrocode}
\keys_define:nn { siunitx } {
  unknown .code:n = 
    { 
      \msg_error:nnx { siunitx } { unknown-option } 
        { \exp_not:V \l_keys_key_tl } 
    }
}
%    \end{macrocode}
%  
% A couple of settings which are slightly different by default in
% version 1.     
%    \begin{macrocode}
\keys_set:nn { siunitx } {
  free-standing-units = true ,
  mode                = math ,
}
%    \end{macrocode}
%    
%\begin{macro}{\newunit}
%\begin{macro}{\renewunit}
%\begin{macro}{\provideunit}
% The functions for creating units from version one are easy to create.
%    \begin{macrocode}
\NewDocumentCommand \newunit { o m m } {
  \IfNoValueTF {#1}
    { \siunitx_declare_unit:Nnn #2 {#3} { } }
    { \siunitx_declare_unit:Nnn #2 {#3} {#1} }
}
\cs_new_eq:NN \renewunit   \newunit
\cs_new_eq:NN \provideunit \newunit
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}   
%
%\begin{macro}{\newpower}
%\begin{macro}{\renewpower}
%\begin{macro}{\providepower}
% Slightly more complex: an optional argument to check. A simple 
% assumption is made that it will be \texttt{post}: anything else
% would not make sense anyway.
%    \begin{macrocode}
\NewDocumentCommand \newpower     { o m m } {
  \IfNoValueTF {#1} 
    { \DeclareSIPrePower  #2 {#3} }
    { \DeclareSIPostPower #2 {#3} }
}
\NewDocumentCommand \renewpower   { o m m } {
  \IfNoValueTF {#1} 
    { \DeclareSIPrePower  #2 {#3} }
    { \DeclareSIPostPower #2 {#3} }
}
\NewDocumentCommand \providepower { o m m } {
  \IfNoValueTF {#1} 
    { \DeclareSIPrePower  #2 {#3} }
    { \DeclareSIPostPower #2 {#3} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro} 
%
%\begin{macro}{\newprefix}
%\begin{macro}{\renewprefix}
%\begin{macro}{\provideprefix}
% Slightly more complex: an optional argument to check. A simple 
% assumption is made that it will be \texttt{post}: anything else
% would not make sense anyway.
%    \begin{macrocode}
\NewDocumentCommand \newprefix     { o m m m } {
  \IfNoValueTF {#1} 
    { \DeclareSIPrefix     #2 {#3} {#4} }
    { \DeclareBinaryPrefix #2 {#3} {#4} }
}
\NewDocumentCommand \renewprefix   { o m m m } {
  \IfNoValueTF {#1} 
    { \DeclareSIPrefix     #2 {#3} {#4} }
    { \DeclareBinaryPrefix #2 {#3} {#4} }
}
\NewDocumentCommand \provideprefix { o m m m } {
  \IfNoValueTF {#1} 
    { \DeclareSIPrefix     #2 {#3} {#4} }
    { \DeclareBinaryPrefix #2 {#3} {#4} }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}  
%
%\begin{macro}{\newqualifier}
%\begin{macro}{\renewqualifier}
%\begin{macro}{\providequalifier}
% The functions for creating qualifiers are easy to create again.
%    \begin{macrocode}
\NewDocumentCommand \newqualifier { m m } {
  \siunitx_declare_qualifier:Nn #1 {#2}
}
\cs_new_eq:NN \renewqualifier   \newqualifier
\cs_new_eq:NN \providequalifier \newqualifier
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro} 
%
%\begin{macro}{\Square}
%\begin{macro}{\ssquare}
% In version 1, \cs{square} is not used with these two alternatives
% preferred.
%    \begin{macrocode}
\DeclareSIPrePower \Square  { 2 }
\DeclareSIPrePower \ssquare { 2 }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\BAR}
%\begin{macro}{\bbar}
%\begin{macro}{\Day}
%\begin{macro}{\dday}
%\begin{macro}{\Gray}
%\begin{macro}{\ggray}
% Units which are given awkward names in version one.
%    \begin{macrocode}
\DeclareSIUnit \BAR   { \bar }
\DeclareSIUnit \bbar  { \bar }
\DeclareSIUnit \Day   { \day }
\DeclareSIUnit \dday  { \day }
\DeclareSIUnit \Gray  { \gray }
\DeclareSIUnit \ggray { \gray }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\atomicmass}
% Slightly different: given more complete names in version two.
%    \begin{macrocode}
\DeclareSIUnit \atomicmass { \atomicmassunit }
\DeclareSIUnit \arcmin     { \arcminute }
\DeclareSIUnit \arcsec     { \arcsecond }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\are}
%\begin{macro}{\curie}
%\begin{macro}{\gal}
%\begin{macro}{\millibar}
%\begin{macro}{\rad}
%\begin{macro}{\rem}
%\begin{macro}{\roentgen}
% Units which were defined in version one but are no longer listed
% by the \textsc{bipm} as acceptable.
%    \begin{macrocode}
\DeclareSIUnit \are      { a }
\DeclareSIUnit \curie    { Ci }
\DeclareSIUnit \gal      { Gal }
\DeclareSIUnit \millibar { \milli \bar }
\DeclareSIUnit \rad      { rad }
\DeclareSIUnit \rem      { rem }
\DeclareSIUnit \roentgen { R }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\micA}
%\begin{macro}{\micmol}
%\begin{macro}{\micl}
%\begin{macro}{\micL}
%\begin{macro}{\nanog}
%\begin{macro}{\micg}
%\begin{macro}{\picm}
%\begin{macro}{\micm}
%\begin{macro}{\Sec}
%\begin{macro}{\mics}
%\begin{macro}{\cmc}
%\begin{macro}{\dmc}
%\begin{macro}{\cms}
% A few abbreviations which have been renamed.
%    \begin{macrocode}
\DeclareSIUnit \micA   { \micro \ampere }
\DeclareSIUnit \micmol { \micro \mole   }
\DeclareSIUnit \micl   { \micro \litre  }
\DeclareSIUnit \micL   { \micro \liter  }
\DeclareSIUnit \nanog  { \nano  \gram   }
\DeclareSIUnit \micg   { \micro \gram   }
\DeclareSIUnit \picm   { \pico  \metre  }
\DeclareSIUnit \micm   { \micro \metre  }
\DeclareSIUnit \Sec    { \second }
\DeclareSIUnit \mics   { \micro \second }
\DeclareSIUnit \cmc    { \centi \metre \cubed }
\DeclareSIUnit \dmc    { \deci  \metre \cubed }
\DeclareSIUnit \cms    { \centi \metre \squared }
%    \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}
%
%\begin{macro}{\centimetrecubed}
%\begin{macro}{\centimetresquared}
%\begin{macro}{\cubiccentimetre}
%\begin{macro}{\cubicdecimetre}
%\begin{macro}{\squarecentimetre}
%\begin{macro}{\squaremetre}
%\begin{macro}{\squarekilometre}
% Units from version one that did not seem like a good idea to retain.
%    \begin{macrocode}
\DeclareSIUnit \centimetrecubed   { \centi \metre \cubed }
\DeclareSIUnit \centimetresquared { \centi \metre \squared }
\DeclareSIUnit \cubiccentimetre   { \centi \metre \cubed }
\DeclareSIUnit \cubicdecimetre    { \deci \metre \cubed }
\DeclareSIUnit \squarecentimetre  { \centi \metre \squared }
\DeclareSIUnit \squaremetre       { \metre \squared }
\DeclareSIUnit \squarekilometre   { \kilo \metre \squared }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\parsec}
%\begin{macro}{\lightyear}
% A few units for astronomy that version 1 provided.
%    \begin{macrocode}
\DeclareSIUnit \parsec    { pc }
\DeclareSIUnit \lightyear { ly }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%    
%\begin{macro}{\gmol}
%\begin{macro}{\kgmol}
%\begin{macro}{\lbmol}
% Slightly odd chemical engineering units, again provided in version 1.
%    \begin{macrocode}
\DeclareSIUnit \gmol  { g  \text { - } mol }
\DeclareSIUnit \kgmol { kg \text { - } mol }
\DeclareSIUnit \lbmol { lb \text { - } mol }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\molar}
%\begin{macro}{\Molar}
%\begin{macro}{\torr}
% A few common units for chemistry from version 1. \cs{molar} is 
% simply a handy abbreviation: \cs{Molar} is common but rather 
% questionable.
%    \begin{macrocode}
\DeclareSIUnit \molar { \mole \per \cubic \deci \metre }
\DeclareSIUnit \Molar { \textsc { m } }
\DeclareSIUnit \torr  { Torr }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%    
%\begin{macro}{\gon}
% A single unit for geophysics that version 1 included.
%    \begin{macrocode}
\DeclareSIUnit \gon    { gon }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\clight}
% Version one had a different definition for \cs{clight}.
%    \begin{macrocode}
\DeclareSIUnit \clight { \text { \ensuremath { c } } }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\micron}
%\begin{macro}{\mrad}
%\begin{macro}{\gauss}
%\begin{macro}{\eVperc}
%\begin{macro}{\nanobarn}
%\begin{macro}{\picobarn}
%\begin{macro}{\femptobarn}
%\begin{macro}{\attobarn}
%\begin{macro}{\zeptobarn}
%\begin{macro}{\yoctobarn}
%\begin{macro}{\nb}
%\begin{macro}{\pb}
%\begin{macro}{\fb}
%\begin{macro}{\ab}
%\begin{macro}{\zb}
%\begin{macro}{\yb}
% High-energy physics units from version one.
%    \begin{macrocode}
\DeclareSIUnit \micron    { \micro \metre }
\DeclareSIUnit \mrad      { \milli \rad }
\DeclareSIUnit \gauss     { G }
\DeclareSIUnit \eVperc    { \eV \per \clight }
\DeclareSIUnit \nanobarn  { \nano \barn }
\DeclareSIUnit \picobarn  { \pico \barn }
\DeclareSIUnit \femtobarn { \femto \barn }
\DeclareSIUnit \attobarn  { \atto \barn }
\DeclareSIUnit \zeptobarn { \zepto \barn }
\DeclareSIUnit \yoctobarn { \yocto \barn }
\DeclareSIUnit \nb        { \nano \barn }
\DeclareSIUnit \pb        { \pico \barn }
\DeclareSIUnit \fb        { \femto \barn }
\DeclareSIUnit \ab        { \atto \barn }
\DeclareSIUnit \zb        { \zepto \barn }
\DeclareSIUnit \yb        { \yocto \barn }
%    \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}
%\end{macro}
%\end{macro}
%  
%\begin{macro}{\requiresiconfigs}
%\begin{macro}{\siunitx_requireconfig:n}
% Version one provides this, and it might pop up so should not 
% cause errors.
%    \begin{macrocode}
\NewDocumentCommand \requiresiconfigs { m } {
  \keys_set:nn { siunitx } { load-configurations = version-1 }
  \clist_map_function:nN {#1} \siunitx_requireconfig:n
}
\cs_new_protected_nopar:Npn \siunitx_requireconfig:n #1 {
  \str_if_eq:nnT {#1} { synchem }
    { \keys_set:nn { siunitx } { load-configurations = chemistry } }
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%    \begin{macrocode}
%</version-1>
%    \end{macrocode}
%
%\subsection{Abbreviated units}
%
%    \begin{macrocode}
%<*abbreviations>
%    \end{macrocode}
%    
%    \begin{macrocode}
\ProvidesExplFile {siunitx-abbreviations.cfg} {2010/08/12} {2.0s}  
  {siunitx: Abbreviated units}
%    \end{macrocode}
%
% The abbreviation file contains a number of short (mainly two or
% three letter) versions of the usual long names. They are divided up
% into related groups, mainly to avoid an overly long list in one
% place.
%
%\begin{macro}{\A}
%\begin{macro}{\pA}
%\begin{macro}{\nA}
%\begin{macro}{\uA}
%\begin{macro}{\mA}
%\begin{macro}{\kA}
% Currents.
%    \begin{macrocode}
\DeclareSIUnit \A  {        \ampere }
\DeclareSIUnit \pA { \pico  \ampere }
\DeclareSIUnit \nA { \nano  \ampere }
\DeclareSIUnit \uA { \micro \ampere }
\DeclareSIUnit \mA { \milli \ampere }
\DeclareSIUnit \kA { \kilo  \ampere }
%    \end{macrocode}
%\end{macro}
%\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}
\DeclareSIUnit \Hz  {        \hertz }
\DeclareSIUnit \mHz { \milli \hertz }
\DeclareSIUnit \kHz { \kilo  \hertz }
\DeclareSIUnit \MHz { \mega  \hertz }
\DeclareSIUnit \GHz { \giga  \hertz }
\DeclareSIUnit \THz { \tera  \hertz }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\mol}
%\begin{macro}{\fmol}
%\begin{macro}{\pmol}
%\begin{macro}{\nmol}
%\begin{macro}{\umol}
%\begin{macro}{\mmol}
%\begin{macro}{\kmol}
% Amounts of substance (moles).
%    \begin{macrocode}
\DeclareSIUnit \mol  {        \mole }
\DeclareSIUnit \fmol { \femto \mole }
\DeclareSIUnit \pmol { \pico  \mole }
\DeclareSIUnit \nmol { \nano  \mole }
\DeclareSIUnit \umol { \micro \mole }
\DeclareSIUnit \mmol { \milli \mole }
\DeclareSIUnit \kmol { \kilo  \mole }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\V}
%\begin{macro}{\mV}
%\begin{macro}{\kV}
% Potentials.
%    \begin{macrocode}
\DeclareSIUnit \V  {        \volt }
\DeclareSIUnit \mV { \milli \volt }
\DeclareSIUnit \kV { \kilo  \volt }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\l}
%\begin{macro}{\ml}
%\begin{macro}{\ul}
%\begin{macro}{\L}
%\begin{macro}{\mL}
%\begin{macro}{\uL}
% Volumes.
%    \begin{macrocode}
\DeclareSIUnit \l  {        \litre }
\DeclareSIUnit \ml { \milli \litre }
\DeclareSIUnit \ul { \micro \litre }
\DeclareSIUnit \L  {        \liter }
\DeclareSIUnit \mL { \milli \liter }
\DeclareSIUnit \uL { \micro \liter }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\fg}
%\begin{macro}{\pg}
%\begin{macro}{\ng}
%\begin{macro}{\ug}
%\begin{macro}{\mg}
%\begin{macro}{\g}
%\begin{macro}{\kg}
%\begin{macro}{\amu}
% Masses.
%    \begin{macrocode}
\DeclareSIUnit \fg  { \femto \gram }
\DeclareSIUnit \pg  { \pico  \gram }
\DeclareSIUnit \ng  { \nano  \gram }
\DeclareSIUnit \ug  { \micro \gram }
\DeclareSIUnit \mg  { \milli \gram }
\DeclareSIUnit \g   { \gram }
\DeclareSIUnit \kg  { \kilo \gram }
\DeclareSIUnit \amu { \atomicmassunit }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\W}
%\begin{macro}{\mW}
%\begin{macro}{\kW}
%\begin{macro}{\MW}
%\begin{macro}{\GW}
%\begin{macro}{\kJ}
%\begin{macro}{\J}
%\begin{macro}{\eV}
%\begin{macro}{\meV}
%\begin{macro}{\keV}
%\begin{macro}{\MeV}
%\begin{macro}{\GeV}
%\begin{macro}{\TeV}
%\begin{macro}{\kWh}
% Energies.
%    \begin{macrocode}
\DeclareSIUnit \W   {        \watt }
\DeclareSIUnit \mW  { \milli \watt }
\DeclareSIUnit \kW  { \kilo  \watt }
\DeclareSIUnit \MW  { \mega  \watt }
\DeclareSIUnit \GW  { \giga  \watt }
\DeclareSIUnit \J   { \joule }
\DeclareSIUnit \kJ  { \kilo \joule }
\DeclareSIUnit \eV  { \electronvolt }
\DeclareSIUnit \meV { \milli \electronvolt }
\DeclareSIUnit \keV { \kilo  \electronvolt }
\DeclareSIUnit \MeV { \mega  \electronvolt }
\DeclareSIUnit \GeV { \giga  \electronvolt }
\DeclareSIUnit \TeV { \tera  \electronvolt }
\DeclareSIUnitWithOptions \kWh { \kilo \watt \hour }
  { inter-unit-separator = }
%    \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}
%\begin{macro}{\m}
%\begin{macro}{\pm}
%\begin{macro}{\nm}
%\begin{macro}{\um}
%\begin{macro}{\mm}
%\begin{macro}{\cm}
%\begin{macro}{\dm}
%\begin{macro}{\km}
% Lengths.
%    \begin{macrocode}
\DeclareSIUnit \m  {        \metre }
\DeclareSIUnit \pm { \pico  \metre }
\DeclareSIUnit \nm { \nano  \metre }
\DeclareSIUnit \um { \micro \metre }
\DeclareSIUnit \mm { \milli \metre }
\DeclareSIUnit \cm { \centi \metre }
\DeclareSIUnit \dm { \deci  \metre }
\DeclareSIUnit \km { \kilo  \metre }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\K}
% Temperatures.
%    \begin{macrocode}
\DeclareSIUnit \K { \kelvin }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\N}
%\begin{macro}{\mN}
%\begin{macro}{\kN}
%\begin{macro}{\MN}
% Forces.
%    \begin{macrocode}
\DeclareSIUnit \N  {        \newton } 
\DeclareSIUnit \mN { \milli \newton }
\DeclareSIUnit \kN { \kilo  \newton }
\DeclareSIUnit \MN { \mega  \newton }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\Pa}
%\begin{macro}{\kPa}
%\begin{macro}{\MPa}
%\begin{macro}{\GPa}
% Pressures.
%    \begin{macrocode}
\DeclareSIUnit \Pa  {        \pascal }
\DeclareSIUnit \kPa { \kilo  \pascal }
\DeclareSIUnit \MPa { \mega  \pascal }
\DeclareSIUnit \GPa { \giga  \pascal }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\mohm}
%\begin{macro}{\kohm}
%\begin{macro}{\Mohm}
% Resistances.
%    \begin{macrocode}
\DeclareSIUnit \mohm { \milli \ohm }  
\DeclareSIUnit \kohm { \kilo  \ohm }  
\DeclareSIUnit \Mohm { \mega  \ohm }  
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\begin{macro}{\s}
%\begin{macro}{\as}
%\begin{macro}{\fs}
%\begin{macro}{\ps}
%\begin{macro}{\ns}
%\begin{macro}{\us}
%\begin{macro}{\ms}
% Finally, times.
%    \begin{macrocode}
\DeclareSIUnit \s  { \second }
\DeclareSIUnit \as { \atto  \second }
\DeclareSIUnit \fs { \femto \second }
\DeclareSIUnit \ps { \pico  \second }
\DeclareSIUnit \ns { \nano  \second }
\DeclareSIUnit \us { \micro \second }
\DeclareSIUnit \ms { \milli \second }
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%
%    \begin{macrocode}
%</abbreviations>
%    \end{macrocode}   
%    
%\subsection{Binary units}
%
%    \begin{macrocode}
%<*binary>
%    \end{macrocode}  
%    
%    \begin{macrocode}
\ProvidesExplFile {siunitx-binary.cfg} {2011/03/20} {2.1m}
  {siunitx: Binary units}
%    \end{macrocode}
%    
%\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.
%    \begin{macrocode}
\DeclareBinaryPrefix \kibi { Ki } { 10 } 
\DeclareBinaryPrefix \mebi { Mi } { 20 } 
\DeclareBinaryPrefix \gibi { Gi } { 30 } 
\DeclareBinaryPrefix \tebi { Ti } { 40 } 
\DeclareBinaryPrefix \pebi { Pi } { 50 } 
\DeclareBinaryPrefix \exbi { Ei } { 60 } 
\DeclareBinaryPrefix \zebi { Zi } { 70 } 
\DeclareBinaryPrefix \yobi { Yi } { 80 } 
%    \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}
\DeclareSIUnit \bit  { bit }
\DeclareSIUnit \byte { B }
%    \end{macrocode}
%\end{macro}
%\end{macro} 
%
%    \begin{macrocode}
%</binary>
%    \end{macrocode}   
%
%\end{implementation}
% 
%\begin{thebibliography}{1}
%  
%  \bibitem{BIPM}
%    \emph{The International System of Units (SI)},
%    \url{http://www.bipm.org/en/si/}.
%    
%  \bibitem{NIST}
%    \emph{International System of Units from NIST},
%    \url{http://physics.nist.gov/cuu/Units/index.html}.
%    
%  \bibitem{SI:2.1}
%    \emph{SI base units},
%    \url{http://www.bipm.org/en/si/si_brochure/chapter2/2-1/}.
%      
%  \bibitem{SI:2.2.2}
%    \emph{Units with special names and symbols; units that 
%      incorporate special names and symbols},
%    \url{http://www.bipm.org/en/si/si_brochure/chapter2/2-2/2-2-2.html}.
%      
%  \bibitem{SI:3.1}
%    \emph{SI Prefixes},
%    \url{http://www.bipm.org/en/si/si_brochure/chapter3/prefixes.html}.
%      
%  \bibitem{SI:4.1.T6}
%    \emph{Non-SI units accepted for use with the International 
%      System of Units},
%    \url{http://www.bipm.org/en/si/si_brochure/chapter4/table6.html}.
%      
%  \bibitem{SI:4.1.T7}
%    \emph{Non-SI units whose values in SI units must be obtained 
%      experimentally},
%    \url{http://www.bipm.org/en/si/si_brochure/chapter4/table7.html}.
%     
%  \bibitem{SI:4.1.T8}
%    \emph{Other non-SI units},
%    \url{http://www.bipm.org/en/si/si_brochure/chapter4/table8.html}.
%    
%  \bibitem{SI:5.3.3}
%    \emph{Formatting the value of a quantity},
%    \url{http://www.bipm.org/en/si/si_brochure/chapter5/5-3-2.html#5-3-3}.
%      
%\end{thebibliography}
%
%\PrintChanges
%
%\PrintIndex