-
Notifications
You must be signed in to change notification settings - Fork 26
/
siunitx-v2.dtx
17892 lines (17882 loc) · 600 KB
/
siunitx-v2.dtx
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
% \iffalse meta-comment
%<*internal>
\iffalse
%</internal>
%<*readme>
siunitx - A comprehensive (SI) units package
==============================================
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 . 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
`l3kernel` and `l3packages` 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 2015
(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`
- `cancel`
- `caption`
- `cleveref`
- `colortbl`
- `csquotes`
- `datatool`
- `helvet`
- `mathpazo`
- `multirow`
- `listings`
- `pgfplots`
- `xcolor`
%</readme>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
\expandafter\begingroup
\fi
%</internal>
%<*install>
\input l3docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble
---------------------------------------------------------------
The siunitx package --- A comprehensive (SI) units package
Maintained by Joseph Wright
E-mail: [email protected]
Released under the LaTeX Project Public License v1.3c or later
See http://www.latex-project.org/lppl.txt
---------------------------------------------------------------
\endpreamble
\postamble
Copyright (C) 2008-2021 by
Joseph Wright <[email protected]>
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}}
\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.md}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
\expandafter\endbatchfile
\else
\expandafter\endgroup
\fi
%</internal>
%<*driver|package>
\RequirePackage{expl3}[2020/01/12]
\RequirePackage{xparse}
%</driver|package>
%<*driver>
\documentclass{l3doc}
\usepackage[german,french,spanish,UKenglish]{babel}
\usepackage[table]{xcolor}
\usepackage{amsmath,booktabs,cancel,caption,colortbl,csquotes}
\usepackage{datatool,helvet,multirow,pgfplots,siunitx,xfrac,xtab}
\usepackage[capitalise]{cleveref}
\usepackage[final]{listings}
\usepackage[osf]{mathpazo}
\AtBeginDocument{\shorthandoff{<>}}
\crefformat{section}{#2Section~#1#3}
\Crefformat{section}{#2Section~#1#3}
\crefformat{subsection}{#2Section~#1#3}
\Crefformat{subsection}{#2Section~#1#3}
\crefformat{figure}{#2Figure~#1#3}
\Crefformat{figure}{#2Figure~#1#3}
\crefformat{table}{#2Table~#1#3}
\Crefformat{table}{#2Table~#1#3}
\crefrangeformat{table}{#3Tables~#1#4 to~#5#2#6}
\Crefrangeformat{table}{#3Tables~#1#4 to~#5#2#6}
\crefmultiformat{table}{#2Tables~#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
\Crefmultiformat{table}{#2Tables~#1#3}{ and~#2#1#3}{, #2#1#3}{, and~#2#1#3}
% Silence annoying fp package messages
\FPmessagesfalse
\pgfplotsset{compat = newest}
\sisetup{binary-units}
\DeclareSIUnit{\KWH}{kWh}
\DeclareSIPrePower\quartic{4}
\DeclareSIPostPower\tothefourth{4}
\DeclareSIQualifier\catalyst{cat}
\DeclareSIQualifier\isotropic{i}
\DeclareSIQualifier\polymer{pol}
\newlength\mylength
%\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,
% cancel,
% candela,
% centi,
% color,
% coulomb,
% cubed,
% cubic,
% deci,
% decibel,
% degree,
% degreeCelsius,
% DeclareBinaryPrefix,
% DeclareRobustCommand,
% DeclareSIPostPower,
% DeclareSIPrefix,
% DeclareSIPrePower,
% DeclareSIQualifier,
% DeclareSIUnit,
% DTLdisplaydb,
% DTLforeach,
% DTLiffirstrow,
% DTLmul,
% DTLnewdb,
% DTLnewdbentry,
% DTLnewrow,
% farad,
% fontspec,
% gram,
% gray,
% henry,
% highlight,
% hour,
% Hz,
% joule,
% kelvin,
% kibi,
% kilo,
% kilogram,
% kWh,
% litre,
% lumen,
% lux,
% mathnormal,
% metre,
% mebi,
% micro,
% midrule,
% milli,
% mm,
% mole,
% multirow,
% num,
% numlist,
% numrange,
% of,
% pascal,
% per,
% percent,
% protected,
% radian,
% raiseto,
% robustify,
% rowcolor,
% second,
% selectlanguage,
% SendSettingsToPgf,
% si,
% SI,
% SIlist,
% SIrange,
% sievert,
% sisetup,
% SIUnitSymbolDegree,
% square,
% squared,
% tablenum,
% tesla,
% texorpdfstring,
% text,
% textmu,
% toprule,
% tothe,
% translate,
% unit,
% volt,
% watt
% }
% }^^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
% {^^A
% E-mail: \href{mailto:[email protected]}
% {\texttt{[email protected]}}^^A
% }^^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.0c}{2010/06/07}{Mixed literal and macro units now print
% more reliably}
%\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.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.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.0s}{2010/08/08}{Correct errors in rounding code when
% precision requested is zero decimal places}
%\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.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/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.1e}{2010/11/22}{Fix issues with text mode symbols and
% \pkg{fontspec} package}
%\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.1j}{2011/02/01}{Allow for loading of \pkg{inputenc} package
% with no options}
%\changes{v2.1k}{2011/02/09}{Bug fix when printing superscript minus
% signs and using \pkg{fontspec} package}
%\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}}
%\changes{v2.1n}{2011/03/31}{Consistent behaviour for
% \opt{round-integer-to-decimal} when \opt{round-precision} is 0}
%\changes{v2.1o}{2011/04/03}{Fix incorrect font choice when
% \pkg{arev} package is loaded}
%\changes{v2.1o}{2011/04/03}{Account for negative exponents
% when using \opt{fixed-exponent} system}
%\changes{v2.1p}{2011/04/04}{Bad table alignment when some rows
% contain comparators fixed}
%\changes{v2.1p}{2011/04/04}{Poor position of comparators in
% numbers fixed}
%\changes{v2.2a}{2011/04/15}{Fix issue with \texttt{*} tokens in
% tabular preambles}
%\changes{v2.2a}{2011/04/15}{Expand macros with arguments correctly
% in tables}
%\changes{v2.2a}{2011/04/16}{Group digits for input containing symbolic
% entries}
%\changes{v2.2a}{2011/04/16}{Insert tokens correctly when last tabular cell
% does not end \texttt{\textbackslash\textbackslash}}
%\changes{v2.2a}{2011/04/16}{Fix bug with literal units and auto-insertion
% of \num{1} when \opt{per-mode} is \opt{symbol}}
%\changes{v2.2b}{2011/04/17}{Make \cs{of} work in hyper-linked sections}
%\changes{v2.2b}{2011/04/17}{Fix bug with \cs{highlight} macro when
% no colour support is loaded}
%\changes{v2.2b}{2011/04/19}{Fix bad formatting of negative exponents when
% using the \opt{output-exponent-marker} option}
%\changes{v2.2c}{2011/04/20}{Fix bad interaction with \pkg{cellspace} package}
%\changes{v2.2d}{2011/04/28}{Fix the \opt{strict} option}
%\changes{v2.2e}{2011/05/23}{Fix incorrect interpretation of complex numbers
% with no real part}
%\changes{v2.2g}{2011/06/02}{Correctly space \cs{degree} and similar units
% in lists and ranges when only a single unit is given}
%\changes{v2.2h}{2011/06/03}{Fix bug in significant figures rounding code
% for some integer part values}
%\changes{v2.2i}{2011/06/15}{Fix \opt{detect-mode} option inside
% table cells}
%\changes{v2.2j}{2011/06/26}{Fix incorrect line breaking in \cs{SIrange}}
%\changes{v2.2k}{2011/06/27}{Fix behaviour of subscripts inside alignments
% when printing in text mode}
%\changes{v2.2l}{2011/06/30}{Fix loss of main unit when \opt{per-mode} is set
% to \opt{symbol} and a pre-unit is used}
%\changes{v2.3}{2011/06/19}{New implementation for alignment in \texttt{S}
% column}
%\changes{v2.3a}{2011/07/09}{Restore fix in v2.2l missing in v2.3}
%\changes{v2.3b}{2011/08/08}{Adjust internal load order so that
% \opt{free-standing-units} works correctly for abbreviations}
%\changes{v2.3c}{2011/07/12}{Fix display of \( \pm \) in numbers when
% \opt{separate-uncertainty} is \opt{true} and literal units are used}
%\changes{v2.3d}{2011/08/18}{Fix broken superscript display in literal unit
% mode}
%\changes{v2.3e}{2011/09/09}{Internal changes to work with \LaTeX3
% updates}
%\changes{v2.3f}{2011/09/03}{Fix processing of numbers in tables when entire
% number is invalid}
%\changes{v2.3g}{2011/10/06}{Deal with erroneous leading zero in some
% fixed exponent cases}
%\changes{v2.3h}{2011/10/14}{Ensure math mode for exponent products in all
% circumstances}
%\changes{v2.3h}{2011/10/14}{Improvements to output when using \pkg{tex4ht}}
%\changes{v2.4}{2011/11/03}{Reduce number of math mode options, improving
% consistency of output}
%\changes{v2.4a}{2011/11/28}{Extend search-and-replace code for UTF-8
% characters}
%\changes{v2.4a}{2011/12/04}{Use a more cautious approach to changing
% settings at the start of the document}
%\changes{v2.4b}{2011/12/06}{Erroneous doubled \texttt{\#} corrected}
%\changes{v2.4c}{2011/12/09}{Erroneous check for text mode sanserif font fixed}
%\changes{v2.4d}{2011/12/09}{Fix for edge-case user commands in captions
% where the command clashes with a unit name}
%\changes{v2.4e}{2011/12/11}{Fix issue with \pkg{inputenc} package and
% some of the recent special symbol changes}
%\changes{v2.4f}{2011/12/21}{Allow easier use of headings when not parsing
% numbers in tables}
%\changes{v2.4f}{2011/12/23}{Fix bug with detection of bold font in table
% cells}
%\changes{v2.4g}{2012/01/06}{Update internals to match changes in \pkg{expl3}
% which caused issues with some tokens in numerical arguments}
%\changes{v2.4h}{2012/01/15}{Bug fix for implementation of
% \opt{reciprocal-positive-first}}
%\changes{v2.4i}{2012/01/19}{Bug fix for rounding with large numbers of
% decimal places}
%\changes{v2.4j}{2012/01/26}{Leave vertical mode before any document-level
% commands}
%\changes{v2.4k}{2012/03/22}{Internal changes to allow for \pkg{breqn}
% package tricks}
%\changes{v2.4l}{2012/03/23}{Fix a load-order issue with \pkg{soulpos}
% package}
%\changes{v2.4m}{2012/04/03}{Correct bug in \cs{SIlist} when only a single
% number is given}
%\changes{v2.4n}{2012/04/04}{Allow conversion of numbers with more than
% nine digits to scientific notation}
% \changes{v2.5}{2012/04/07}{Fixed table code to give fewer underfull
% boxes when comparators are used}
% \changes{v2.5}{2015/04/07}{Added \opt{zero-decimal-to-integer} option}
% \changes{v2.5}{2012/04/07}{Added \opt{omit-uncertainty} option}
% \changes{v2.5}{2012/04/08}{Modified \opt{fixed-exponent} such that it can
% remove an exponent part}
% \changes{v2.5}{2012/04/08}{Modified number of intrinsically-mathematical
% options}
% \changes{v2.5a}{2012/04/19}{Fixed support for \enquote{dynamic} nature of spacing
% in free standing units (bug introduced in v2.5)}
% \changes{v2.5b}{2012/04/20}{Fixed treatement \texttt{\^} and \texttt{\_}
% in literal units when \pkg{breqn} package is loaded}
% \changes{v2.5b}{2012/04/20}{Added support for \pkg{eulervm} package}
% \changes{v2.5c}{2012/04/03}{Fixed conversion of numbers with more than
% nine digits when using fixed exponents}
% \changes{v2.5c}{2012/05/03}{Modified treatment entirely empty cells in
% \texttt{s} columns}
% \changes{v2.5d}{2012/06/11}{Extend range of settings automatically altered
% to use UTF-8 values is appropriate}
% \changes{v2.5d}{2012/06/11}{Added \opt{qualifier-phrase} option}
% \changes{v2.5d}{2012/06/11}{Added \opt{phrase} choice for \opt{qualifier-mode}
% option}
% \changes{v2.5e}{2012/06/13}{Fixed an internal error in unit expansion
% introduced in v2.4f}
% \changes{v2.5f}{2012/07/16}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.5g}{2012/07/22}{Fixed \opt{binary-units} option}
% \changes{v2.5h}{2012/08/28}{Modified literal unit test to allow spaces in
% units to be ignored}
% \changes{v2.5i}{2012/09/11}{Fixed alignment of values without uncertainties in
% columns where space is reserved for uncertainties}
% \changes{v2.5j}{2012/09/18}{Fixed rounding when uncertainties are present}
% \changes{v2.5k}{2012/09/20}{Fixed a warning with \pkg{amsmath} related to fraction
% functions}
% \changes{v2.5k}{2012/11/13}{Fixed handling spaces correctly after start of document}
% \changes{v2.5l}{2012/11/21}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.5m}{2012/11/27}{Fixed bug with UTF-8 engines and literal units}
% \changes{v2.5m}{2012/11/27}{Fixed \cs{highlight} behavior in bookmarks}
% \changes{v2.5m}{2012/11/27}{Modified loading of \opt{binary-units}}
% \changes{v2.5m}{2012/11/27}{Fixed right-to-left mode with \pkg{bidi}
% package}
% \changes{v2.5n}{2012/12/29}{Fixed transmission of grouping information by
% \cs{SendSettingsToPgf}}
% \changes{v2.5o}{2013/01/09}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.5p}{2013/02/01}{Fixed printing of \cs{pm} and \cs{mp} when used
% as signs in text mode}
% \changes{v2.5q}{2013/03/10}{Fixed use active \texttt{-} in numbersn}
% \changes{v2.5q}{2013/03/10}{Fixed binary units in tables}
% \changes{v2.5r}{2013/07/11}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.5s}{2013/07/31}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.6}{2013/11/19}{Fixed loading when \pkg{mdwtab} is in use}
% \changes{v2.6}{2014/09/03}{Fixed minus sign when \pkg{tex4ht} is in use}
% \changes{v2.6}{2014/09/03}{Fixed spacing when printing comparators}
% \changes{v2.6}{2014/09/03}{Modified treatment of hard spaces (\texttt{\~}) in
% argument of \cs{num}}
% \changes{v2.6}{2014/09/03}{Modified standard setting for \opt{mode} option
% to \opt{math}}
% \changes{v2.6}{2014/09/04}{Fixed printing of uncertainties when the
% input is an integer and the uncertainty is given as a separate part}
% \changes{v2.6}{2014/09/04}{Fixed definition \cs{fg} in
% bookmarks when \pkg{babel} is loaded with the \opt{french} option}
% \changes{v2.6}{2014/09/05}{Fixed printing exponent in tables when
% \opt{output-exponent-marker} is active}
% \changes{v2.6a}{2014/09/15}{Modified glyph selection when \pkg{fontspec}
% is detected}
% \changes{v2.6b}{2014/09/27}{Modified range of font shapes which can be
% detected}
% \changes{v2.6c}{2014/10/01}{Fixed use of \cs{micro} when \pkg{fontspec}
% is loaded but \pkg{unicode-math} is not}
% \changes{v2.6d}{2014/10/07}{Fixed conversion of \enquote{long} to
% \enquote{short} uncertainty values with integer mantissas}
% \changes{v2.6e}{2015/01/21}{Modified symbol selection where \pkg{fontspec}
% and certain other packages are in use}
% \changes{v2.6f}{2015/04/01}{Fixed \opt{table-sign-exponent} and
% \opt{table-sign-mantissa} options when set \opt{false}}
% \changes{v2.6f}{2015/04/04}{Modified detection of \pkg{mathspec}}
% \changes{v2.6g}{2015/06/24}{Fixed issue with empty table cells}
% \changes{v2.6h}{2015/07/17}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.6i}{2015/08/18}{Fixed rounding of numbers with large numbers of
% digits}
% \changes{v2.6i}{2015/08/18}{Fixed behaviour of \cs{cancel} when printing
% in math mode}
% \changes{v2.6j}{2015/09/01}{Fixed printing of all units when
% \opt{exponent-to-prefix} is set}
% \changes{v2.6j}{2015/09/01}{Fixed appearance of $\pm$ when
% \opt{exponent-to-prefix} is set}
% \changes{v2.6k}{2015/09/12}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.6l}{2015/09/14}{Fixed an internal error}
% \changes{v2.6m}{2015/10/15}{Fixed an issue with \pkg{mwtab}}
% \changes{v2.6n}{2015/12/31}{Modified definition for degree Celsius}
% \changes{v2.6n}{2015/12/31}{Fixed {\aa}ngstr{\"o}m symbol with \LuaTeX{}}
% \changes{v2.6o}{2016/01/05}{Added support for unit powers when converting exponents
% to prefixes}
% \changes{v2.6p}{2016/01/13}{Added support for reciprocal powers when converting
% exponents to prefixes}
% \changes{v2.6p}{2016/01/19}{Modified definition for degree Celsius}
% \changes{v2.6q}{2016/03/01}{Fixed font selection when document commands are
% used inside table cells in \texttt{S} columns}
% \changes{v2.6r}{2016/06/06}{Fixed color safety issue}
% \changes{v2.6r}{2016/08/14}{Fixed internal \pkg{expl3} usage issues}
% \changes{v2.6r}{2016/08/21}{Fixed handling \texttt{e0}}
% \changes{v2.6r}{2016/08/21}{Added a warning when color support is not available}
% \changes{v2.6s}{2016/09/02}{Removed one excess warning}
% \changes{v2.7}{2016/11/11}{Added first documented code level interfaces}
% \changes{v2.7}{2016/11/23}{Fixed behavior when \pkg{cellspace} is applied to
% math mode material}
% \changes{v2.7b}{2017/01/28}{Fixed large numbers in scientific mode}
% \changes{v2.7c}{2017/02/01}{Fixed spacing of integers in tables when
% aligning decimal marker to center}
% \changes{v2.7d}{2017/02/19}{Fixed doubled pre-number tokens in tables}
% \changes{v2.7e}{2017/03/06}{Modified treatment of \texttt{+} }
% \changes{v2.7f}{2017/03/23}{Fixed spacing with \opt{reciprocal-positive-first}
% setting}
% \changes{v2.7g}{2017/05/19}{Fixed an issue with recent \pkg{expl3} update}
% \changes{v2.7h}{2017/06/12}{Modified code internals}
% \changes{v2.7i}{2017/07/23}{Fixed an incorrect variable name}
% \changes{v2.7k}{2017/11/01}{Fixed formatting of units when not parsed}
% \changes{v2.7l}{2018/03/11}{Modified \pkg{unicode-math} support}
% \changes{v2.7m}{2018/03/20}{Modified definition of \cs{astronomicalunit} unit}
% \changes{v2.7n}{2018/04/27}{Fixed symbolic input and digit grouping}
% \changes{v2.7q}{2018/05/11}{Fixed patching of \pkg{cellspace} columns}
% \changes{v2.7r}{2018/05/16}{Fixed issue in tabulars when REV\TeX{} is in use}
% \changes{v2.7s}{2018/05/17}{Modified package date format}
% \changes{v2.7t}{2018/06/08}{Fix inclusion of sign in astronomy-style
% angles}
% \changes{v2.7t}{2019/10/10}{Fix \opt{round-half} when \opt{even} at zero precision}
% \changes{v2.7u}{2020/01/15}{Modified internals to track \pkg{expl3} changes}
% \changes{v2.7v}{2020/02/17}{Fix appearance of superscript decimals with
% comma decimal marker}
% \changes{v2.8}{2020/02/20}{Use companion font symbols (now always loaded by
% the kernel)}
% \changes{v2.8}{2020/02/20}{Allow \cs{ohm} to appear correctly in PDF
% bookmarks}
% \changes{v2.8a}{2020/02/23}{Correct appearance of ohm when
% \pkg{unicode-math} is loaded}
% \changes{v2.8b}{2020/02/25}{Correct appearance of ohm when
% \pkg{newtxmath} is loaded}
%
%\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{l3kernel} and \pkg{l3packages} 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 2015 (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{cancel}
% \item \pkg{caption}
% \item \pkg{cleveref}
% \item \pkg{colortbl}
% \item \pkg{csquotes}
% \item \pkg{helvet}
% \item \pkg{mathpazo}
% \item \pkg{multirow}
% \item \pkg{listings}
% \item \pkg{pgfplots}
% \item \pkg{xcolor}
%\end{itemize}
%
%\section{\pkg{siunitx} for the impatient}
%
% The package provides the user macros:
%\begin{itemize}
% \item \cs{ang}\oarg{options}\marg{angle}
% \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{sisetup}\marg{options}
% \item \cs{tablenum}\oarg{options}\marg{number}
%\end{itemize}
% plus the \texttt{S} and \texttt{s} column types for decimal
% alignments and units in tabular environments. These user macros and
% column types 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 latter 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 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[version-1-compatibility]{siunitx}
%\end{LaTeXdemo}
% to use options from version 1 of the package.
%
%\subsection{Numbers}
%
%\begin{function}{\num}
% \begin{syntax}
% \cs{num}\oarg{options}\marg{number}
% \end{syntax}
%\end{function}
% 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 both \enquote{soft} (\verb*" ") and
% \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.
%
%\begin{function}{\numlist}
% \begin{syntax}
% \cs{numlist}\oarg{options}\marg{numbers}
% \end{syntax}
%\end{function}
%\changes{v2.0}{2010/05/23}{Introduced \cs{numlist} and \cs{SIlist}
% functions}
% 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}
%
%\begin{function}{\numrange}
% \begin{syntax}
% \cs{numrange}\oarg{options}\marg{number1}\marg{number2}
% \end{syntax}
%\end{function}
% 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}
%
%\begin{function}{\ang}
% \begin{syntax}
% \cs{ang}\oarg{options}\marg{angle}
% \end{syntax}
%\end{function}
% 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}
%
%\begin{function}{\si}
% \begin{syntax}
% \cs{si}\oarg{options}\marg{unit}
% \end{syntax}
%\end{function}
% 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{si} contains literal items (for example letters or
% numbers) then \pkg{siunitx} converts \texttt{.} and "~" into
% inter-unit product 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.
%
%\begin{function}{\SI}
% \begin{syntax}
% \cs{SI}\oarg{options}\marg{number}\oarg{preunit}\marg{unit}
% \end{syntax}
%\end{function}
% 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{si} 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}
%