summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-05-23 23:51:56 +0000
committerKarl Berry <karl@freefriends.org>2010-05-23 23:51:56 +0000
commit120f7e4c07269238a49d6bf82cdd01e0be96f2a7 (patch)
tree39447369aa5139982e3323a38cf4a5b4ef0c81ba /Master/texmf-dist
parentad61437dbc77ced3998eeb1fbc47f07382a9740b (diff)
siunitx 2 (23may10)
git-svn-id: svn://tug.org/texlive/trunk@18439 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/siunitx/README43
-rw-r--r--Master/texmf-dist/doc/latex/siunitx/siunitx-bug.tex13
-rw-r--r--Master/texmf-dist/doc/latex/siunitx/siunitx.pdfbin434944 -> 466026 bytes
-rw-r--r--Master/texmf-dist/source/latex/siunitx/siunitx.dtx24885
-rw-r--r--Master/texmf-dist/source/latex/siunitx/siunitx.ins46
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-DE.cfg49
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-SIunits.cfg346
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-UK.cfg49
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-ZA.cfg49
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-abbr.cfg98
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-accepted.cfg64
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-addn.cfg59
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-astro.cfg43
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-binary.cfg51
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-chemeng.cfg44
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-fancynum.cfg69
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-fancyunits.cfg127
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-geophys.cfg42
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-hep.cfg59
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-hepunits.cfg92
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-named.cfg77
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-physical.cfg47
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-prefix.cfg70
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-prefixed.cfg126
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-sistyle.cfg108
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-synchem.cfg47
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-units.cfg74
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/si-unitsdef.cfg254
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/siunitx-abbreviations.cfg92
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/siunitx-binary.cfg (renamed from Master/texmf-dist/tex/latex/siunitx/config/si-USA.cfg)35
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/config/siunitx-version-1.cfg661
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/siunitx.sty9691
32 files changed, 18958 insertions, 18552 deletions
diff --git a/Master/texmf-dist/doc/latex/siunitx/README b/Master/texmf-dist/doc/latex/siunitx/README
index 927521fd0ce..a924ef805d7 100644
--- a/Master/texmf-dist/doc/latex/siunitx/README
+++ b/Master/texmf-dist/doc/latex/siunitx/README
@@ -21,9 +21,40 @@ syntax. The package includes automated processing of numbers
and units, and the ability to control tabular alignment of
numbers.
-A number of LaTeX packages have been developed in the past for
-formatting units: SIunits, sistyle, unitsdef, units, fancyunits
-and fancynum. Support for users of all of these packages is
-available as emulation modules in siunitx. In addition, siunitx
-can carry out many of the functions of the dcolumn, rccol and
-numprint packages
+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.8 and TeX Live 2009
+(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.
diff --git a/Master/texmf-dist/doc/latex/siunitx/siunitx-bug.tex b/Master/texmf-dist/doc/latex/siunitx/siunitx-bug.tex
deleted file mode 100644
index 5dc24b321b4..00000000000
--- a/Master/texmf-dist/doc/latex/siunitx/siunitx-bug.tex
+++ /dev/null
@@ -1,13 +0,0 @@
-\listfiles
-\documentclass{article}
-\usepackage{siunitx}
-\sisetup{debug}
-\begin{document}
-This is the bug test-case document for the \textsf{siunitx}
-package.\\
-Please put your demonstration here, and e-mail to the package
-author.
-\begin{center}
- \texttt{joseph.wright@morningstar2.co.uk}
-\end{center}
-\end{document}
diff --git a/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf b/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf
index d4361d5c920..d5ceb91d94c 100644
--- a/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf
+++ b/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx
index 96b2cfd1d9b..7d26d6aa9b3 100644
--- a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx
+++ b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx
@@ -1,6 +1,5 @@
% \iffalse meta-comment
-% !TEX program = pdflatex
-% !TEX encoding = iso-8859-1
+% !TeX program = pdfLaTeX
%<*internal>
\iffalse
%</internal>
@@ -28,12 +27,43 @@ syntax. The package includes automated processing of numbers
and units, and the ability to control tabular alignment of
numbers.
-A number of LaTeX packages have been developed in the past for
-formatting units: SIunits, sistyle, unitsdef, units, fancyunits
-and fancynum. Support for users of all of these packages is
-available as emulation modules in siunitx. In addition, siunitx
-can carry out many of the functions of the dcolumn, rccol and
-numprint packages
+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.8 and TeX Live 2009
+(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
@@ -73,11 +103,8 @@ This work is "maintained" (as per LPPL maintenance status) by
This work consists of the file siunitx.dtx
and the derived files siunitx.pdf,
- siunitx.sty
- siunitx.bib,
- siunitx.ins,
- siunitx-bug.tex and
- various .cfg files.
+ siunitx.sty and
+ siunitx.ins.
\endpostamble
\usedir{tex/latex/siunitx}
@@ -85,40 +112,15 @@ This work consists of the file siunitx.dtx
\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\usedir{tex/latex/siunitx/config}
-\generate{\file{si-SIunits.cfg}{\from{\jobname.dtx}{SIunits}}
- \file{si-sistyle.cfg}{\from{\jobname.dtx}{sistyle}}
- \file{si-unitsdef.cfg}{\from{\jobname.dtx}{unitsdef}}
- \file{si-units.cfg}{\from{\jobname.dtx}{units}}
- \file{si-hepunits.cfg}{\from{\jobname.dtx}{hepunits}}
- \file{si-fancynum.cfg}{\from{\jobname.dtx}{fancynum}}
- \file{si-fancyunits.cfg}{\from{\jobname.dtx}{fancyunits}}
-}
-\generate{\file{si-prefix.cfg}{\from{\jobname.dtx}{prefix}}
- \file{si-named.cfg}{\from{\jobname.dtx}{named}}
- \file{si-prefixed.cfg}{\from{\jobname.dtx}{prefixed}}
- \file{si-addn.cfg}{\from{\jobname.dtx}{addn}}
- \file{si-accepted.cfg}{\from{\jobname.dtx}{accepted}}
- \file{si-physical.cfg}{\from{\jobname.dtx}{physical}}
- \file{si-abbr.cfg}{\from{\jobname.dtx}{abbr}}
-}
-\generate{\file{si-synchem.cfg}{\from{\jobname.dtx}{synchem}}
- \file{si-hep.cfg}{\from{\jobname.dtx}{hep}}
- \file{si-astro.cfg}{\from{\jobname.dtx}{astro}}
- \file{si-geophys.cfg}{\from{\jobname.dtx}{geophys}}
- \file{si-chemeng.cfg}{\from{\jobname.dtx}{chemeng}}
- \file{si-binary.cfg}{\from{\jobname.dtx}{binary}}
-}
-\generate{\file{si-UK.cfg}{\from{\jobname.dtx}{UK}}
- \file{si-USA.cfg}{\from{\jobname.dtx}{USA}}
- \file{si-DE.cfg}{\from{\jobname.dtx}{DE}}
- \file{si-ZA.cfg}{\from{\jobname.dtx}{ZA}}
+\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>
-\generate{
- \file{jawltxdoc.sty}{\from{\jobname.dtx}{jawltxdoc}}
-}
\usedir{source/latex/siunitx}
\generate{
\file{\jobname.ins}{\from{\jobname.dtx}{install}}
@@ -126,8 +128,6 @@ This work consists of the file siunitx.dtx
\nopreamble\nopostamble
\usedir{doc/latex/siunitx}
\generate{
- \file{\jobname-bug.tex}{\from{\jobname.dtx}{bug}}
- \file{\jobname.bib}{\from{\jobname.dtx}{refs}}
\file{README.txt}{\from{\jobname.dtx}{readme}}
}
\ifx\fmtname\nameofplainTeX
@@ -136,60 +136,274 @@ This work consists of the file siunitx.dtx
\expandafter\endgroup
\fi
%</internal>
+%<*driver|package>
+\RequirePackage{expl3}
+%</driver|package>
%<*driver>
-%\fi
-%\iffalse
-\PassOptionsToClass{a4paper}{article}
-\documentclass[german,english,UKenglish]{ltxdoc}
-\EnableCrossrefs
-\CodelineIndex
-\RecordChanges
-\usepackage[final]{graphicx}
-\IfFileExists{xfrac.sty}{\usepackage{xfrac}}{}
-\usepackage{jawltxdoc}
-\usepackage{textcomp,tikz,pgfplots,tocloft,datatool}
-\usepackage[latin1]{inputenc}
+\documentclass[full]{l3doc}
+
+\usepackage{amsmath,booktabs,caption,csquotes,datatool,helvet,pgfplots}
+\usepackage{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{
- eVcorra=0.1ex,
- unitsep=cdot,
- alsoload={synchem,hep,binary,astro,geophys,chemeng},
- loctolang={UK:UKenglish,DE:german}}
-\setlength{\cftsubsecnumwidth}{2.5em}
+ load-configurations =
+ {
+ abbreviations,
+ binary,
+ }
+}
+\DeclareSIPrePower\quartic{4}
+\DeclareSIPostPower\tothefourth{4}
+\DeclareSIQualifier\polymer{pol}
+\DeclareSIQualifier\catalyst{cat}
+%\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 =
+% {
+% ampere,
+% ang,
+% angstrom,
+% becquerel,
+% 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,
+% mole,
+% num,
+% numlist,
+% numrange,
+% of,
+% pascal,
+% per,
+% percent,
+% protected,
+% radian,
+% raiseto,
+% robustify,
+% second,
+% SendSettingsToPgf,
+% si,
+% SI,
+% sievert,
+% SIlist,
+% SIrange,
+% sisetup,
+% SIUnitSymbolDegree,
+% square,
+% squared,
+% tesla,
+% texorpdfstring,
+% text,
+% toprule,
+% tothe,
+% volt
+% }
+% }^^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}
-%
-%\changes{v1.0}{2008/06/12}{First official release}
-%
-%\setkeys{lst}{language=[LaTeX]{TeX},moretexcs={sisetup,num,ang,SI,
-% si,newunit,newpower,newprefix,metre,candela,kelvin,ampere,eV,
-% second,mole,per,kilogram,Square,squared,cubed,cubic,kilo,centi,
-% gram,tothe,toprule,midrule,bottomrule,newton,micro,joule,mega,
-% raiseto,deci,mathnormal,numprint,electronvolt,selectlanguage,
-% kibi,byte,molar,Molar,mmHg,mebi,torr,parsec,lightyear,clight,
-% eVperc,addplot,color,milli,cm,Hz,kg,DeclareRobustCommand,
-% pascal,dalton,addtolocale,DTLnewdb,DTLnewrow,DTLnewdbentry,
-% DTLforeach,DTLiffirstrow,DTLmul,newqualifier,hour,renewunit,
-% degree,numrange,SIrange}}
-%
-%\title{\currpkg\ --- A comprehensive (SI) units package^^A
-% \thanks{This file describes version \fileversion, last revised
-% \filedate.}}
-%\author{Joseph Wright^^A
-% \thanks{E-mail: joseph.wright@morningstar2.co.uk}}
+%
+%\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
%
-%\newcommand*{\SIunits}{\pkg{SIunits}\xspace}
-%\newcommand*{\SIstyle}{\pkg{SIstyle}\xspace}
-%\newcommand*{\unitsdef}{\pkg{unitsdef}\xspace}
-%\newcommand*{\units}{\pkg{units}\xspace}
-%\newcommand*{\numprint}{\pkg{numprint}\xspace}
+%\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}
+%
%\begin{abstract}
% Typesetting values with units requires care to ensure that the
% combined mathematical meaning of the value plus unit combination is
@@ -198,2778 +412,2906 @@ This work consists of the file siunitx.dtx
% different countries and publishers have differing conventions on
% the exact appearance of numbers (and units).
%
-% The \currpkg provides a set of tools for authors to typeset numbers
-% and units in a consistent way. The package has an extended set of
-% configuration options which make it possible to follow varying
-% typographic conventions with the same input syntax. The package
-% includes automated processing of numbers and units, and the ability
-% to control tabular alignment of numbers.
-%
-% A number of \LaTeX\ packages have been developed in the past for
-% formatting units: \SIunits, \SIstyle, \unitsdef, \units,
-% \pkg{fancyunits} and \pkg{fancynum}. Support for users of all of
-% these packages is available as emulation modules in \currpkg.
-% In addition, \currpkg can carry out many of the functions of the
-% \pkg{dcolumn}, \pkg{rccol} and \numprint packages.
+% The \pkg{siunitx} package provides a set of tools for authors
+% to typeset numbers and units in a consistent way. The package has an
+% extended set of configuration options which make it possible to
+% follow varying typographic conventions with the same input syntax.
+% The package includes automated processing of numbers and units, and
+% the ability to control tabular alignment of numbers.
%\end{abstract}
%
-%\begin{multicols}{2}
-% \tableofcontents
-%\end{multicols}
+%\tableofcontents
+%
+%\begin{documentation}
+%
+%\section{Introduction}
%
-%\clearpage
-%\part{Introduction}
% The correct application of units of measurement is very important
% in technical applications. For this reason, carefully-crafted
% definitions of a coherent units system have been laid down by the
-% \latin{Conf\'erence G\'en\'erale des Poids et
-% Mesures}\footnote{General Conference on Weights and Measures.}
-% (CGPM): this has resulted in the \latin{Syst\`eme International
-% d'Unit\'es}\footnote{International System of Units.} (SI). At the
-% same time, typographic conventions for correctly displaying both
-% numbers and units exist to ensure that no loss of meaning occurs in
-% printed matter.
-%
-% \currpkg aims to provide a unified method for \LaTeX\ users to
+% \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 units and values correctly and easily. The design
-% philosophy of \currpkg is to follow the agreed rules by default,
-% but to allow variation through option settings. In this way,
-% users can use \currpkg to follow the requirements of publishers,
-% co-authors, universities, \etc without needing to alter the input
-% at all.
-%
-% \currpkg is intended as a complete replacement for \SIunits,
-% \SIstyle, \unitsdef, \units, \pkg{fancyunits} and
-% \pkg{fancynum}. As such, emulation modes are provided for all of
-% these packages. Where possible, conventions from the existing
-% solutions have been used here. For example, the macros \cs{num},
-% \cs{ang} and \cs{SI} act in a very similar fashion to those in
-% existing packages.
-%
-%\clearpage
-%\part{Using the \currpkg package}
-%
-%\section{For the impatient}
-% \currpkg provides the user macros:
+% 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 MiKTeX 2.8 and
+% TeX Live 2009 (updating the relevant packages online may be
+% necessary). LaTeX3, and so \pkg{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:
+%\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{SI}\oarg{options}\marg{value}\oarg{pre-unit}\marg{unit}
-% \item \cs{si}\oarg{options}\marg{unit}
% \item \cs{num}\oarg{options}\marg{number}
+% \item \cs{si}\oarg{options}\marg{unit}
+% \item \cs{SI}\oarg{options}\marg{value}\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 |S| and |s| column types for decimal alignments and units
-% in tables. These macros are designed for typesetting units and
-% values with control of appearance and with intelligent processing.
-%
-% By default, all text is typeset in the current upright, serif maths
-% font. This can be changed by setting the appropriate package
-% options: \opt{obeyall} will use the current font for typesetting.
-%
-% The package includes a ``unit processor'', which allows the use of
-% named units or literal values. Named units are processed to
-% correctly include powers.
-%\begin{LaTeXexample}
-% \SI{10}{\gram}\\
-% \SI{23.4}{g.cm^3}\\
-% \num{1e34}\\
-% \ang{1;2;3}\\
-% \emph{\SI{16,7}{\metre\per\second}}\\
-% \textbf{\SI{30e3}{\Hz}}\\
-% \SI{1.2 x 3.56 x 9.2}{\milli\metre}\\
-% \sisetup{obeyall}
-% \textbf{\SI{-4.5}{\cm}}\\
-% \si{\joule\per\mole\per\kelvin}\\
-% \si[per=frac]{\joule\per\mole\per\kelvin}\\
-% \num[dp=4]{1.23456}\\
-% \num[dp=4]{9.8}\\
-% \begin{tabular}{S[tabformat=3.2]}
+% plus the \texttt{S} and \texttt{s} column types for decimal
+% alignments and units in tables. These macros are designed for
+% typesetting units and values with control of appearance and with
+% intelligent processing.
+%
+% 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 LaTeX2e 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-configuration = 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.
+%\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.
+%\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 values, 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 values are given together. Mathematically,
+% these form a single entity, and should be separated by a non-breaking
+% space. 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.
+%\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.
+%\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
-% {Heading}\\
+% Unit & Macro & Symbol \\
% \midrule
-% 1.3 \\
-% 134.2 \\
-% 3.56 \\
-% 74,7 \\
+% \DescribeUnit{ampere} \\
+% \DescribeUnit{candela} \\
+% \DescribeUnit{kelvin} \\
+% \DescribeUnit{kilogram} \\
+% \DescribeUnit{metre} \\
+% \DescribeUnit{mole} \\
+% \DescribeUnit{second} \\
% \bottomrule
% \end{tabular}
-%\end{LaTeXexample}
-%
-%\section{Requirements}
-% \currpkg requires a reasonably up to date \TeX\ system. The
-% package requires \eTeX-extensions, which should be available on
-% most systems.\footnote{If you have an old \LaTeX\, try
-% ``\texttt{elatex}'' rather than ``\texttt{latex}''.} The following
-% packages are also needed:
-%\begin{itemize}
-% \item \pkg{array} and \pkg{xspace}: from the \pkg{tools} bundle,
-% which should be available to everyone;
-% \item \pkg{xkeyval}: this processes the option handling, and needs
-% to be at least v2.5;
-% \item \pkg{amstext}: from the \AMS\TeX\ support bundle (the
-% \AMS\ fonts are also needed to provide the default upright
-% \si{\micro}).
-%\end{itemize}
-% Hopefully most people using the package will have access to all of
-% those items.
-%
-% To use the \opt{fraction=sfrac} option, the \pkg{xfrac} package is
-% needed. This needs various experimental \LaTeX3 packages. As a
-% result, \currpkg does not load \pkg{xfrac}. If you want to use
-% \opt{fraction=sfrac}, \emph{you} need to load \pkg{xfrac} in your
-% preamble before \currpkg.\footnote{This document has been compiled
-% in this way. You have to load \pkg{xfrac} first as otherwise very
-% nasty things happen with \pkg{xkeyval}. MiK\TeX\ users should note
-% that the packaged versions of \pkg{expl3}, \pkg{template} and
-% \pkg{xparse} will not work with \pkg{xfrac}: download copies from
-% \textsc{ctan}!} If the package is not loaded, \opt{fraction=sfrac}
-% falls back on a \pkg{nicefrac}-like method. The interested user
-% should look at the \pkg{xfrac} documentation for reasons this might
-% not be ideal.\footnote{On the other hand, some fractional units
-% will look really bad with \cs{sfrac}. Use this option with
-% caution.}
-%
-%\section{Loading the package}
-% \currpkg is loaded by the usual \LaTeX\ method.
-%\begin{LaTeXexample}[noexample]
-% \usepackage[<options>]{siunitx}
-%\end{LaTeXexample}
-% As is shown in the example, the package can be loaded with one or
-% more options, using the key--value system. The full range of
-% package options are described in Section~\ref{sec:options}; some
-% options are described in the along with the appropriate user
-% macros. Most of the user macros accept the same key--value
-% settings as an optional argument.
-%
-%\section{Numbers}
-%\DescribeMacro{\num}
-% Numbers are automatically formatted by the \cs{num} macro. This
-% takes one optional and one mandatory argument:
-% \cs{num}\oarg{options}\marg{number}. The contents of \meta{number}
-% are automatically formatted, in a similar method to that used by
-% \numprint. The formatter removes ``hard'' spaces (\cs{,} and |~|),
-% automatically identifies exponents (by default marked using |e| or
-% |d|) and adds the appropriate spacing of large numbers. A leading
-% zero is added before a decimal marker, if needed: both ``|.|'' and
-% ``|,|'' are recognised as decimal marker.
-%\begin{LaTeXexample}
-% \num{1} \num{123} \num{1234} \num{12345}\\
-% \num{0.1} \num{0.123} \num{0,1234} \num{.12345}\\
-% \num{1e10} \num{3.45d-4} \num{-e10}
-%\end{LaTeXexample}
-% Various error-checking systems are built into the package, so that
-% if \meta{number} does not contain any numeric characters, a warning
-% is issued. Isolated signs are also detected. The package
-% recognises |(| and |)| as ``extra'' characters, which can be used
-% to indicate the error in a number.\footnote{This is common in
-% chemical crystallography, for example.} The \opt{seperr} causes
-% this data to be given as a separate error value. If the number
-% also contains an exponent, then brackets are re-added after the
-% separation to ensure that meaning is not lost.
-%\begin{LaTeXexample}
-% $\num{1.234(5)} = \num[seperr]{1.234(5)}$\\
-% $\num{1.234(5)e6} = \num[seperr]{1.234(5)e6}$
-%\end{LaTeXexample}
-% The same applies to the unit and value macro \cs{SI}, described
-% later, for example the rest mass of an electron \cite{IUPAC}:
-%\begin{LaTeXexample}
-% $ m_{\mathrm{e}}
-% = \SI{9.1093897(54)e-31}{\kg} $\\
-% $ m_{\mathrm{e}}
-% = \SI[seperr]{9.1093897(54)e-31}{\kg} $
-%\end{LaTeXexample}
-%
-% A number of effects are available as options. These are fully
-% explained in Section~\ref{sec:options}. Some of the more useful
-% options are illustrated here. By default, the output of the
-% package is typeset in maths mode. However, the use of the current
-% text font can be forced.\footnote{This document is typeset using
-% lowercase numbers in text mode, which emphasises the effect here.}
-%\begin{LaTeXexample}
-% \num{1234567890} \num[mode=text]{1234567890}
-%\end{LaTeXexample}
-% \currpkg can automatically add zeros and signs to numbers. This
-% can be altered as desired.
-%\begin{LaTeXexample}
-% \num{1.} \num[padnumber=all]{1.}\\
-% \num{2} \num[addsign=all]{2}\\
-% \num{3e4} \num[addsign=mant]{3e4} \num[addsign=all]{3e4}\\
-% \num{.5} \num[padnumber=none]{.5}
-%\end{LaTeXexample}
-% The separation of digits can be turned on and off, and the output
-% changed.
-%\begin{LaTeXexample}
-% \num{1234} \num[sepfour=true]{1234}\\
-% \num{12345} \num[digitsep=comma]{12345}\\
-% \num[digitsep=none]{12345}
-%\end{LaTeXexample}
-% The formatting of exponents is also customisable.
-%\begin{LaTeXexample}
-% \num{1e10} \num[expproduct=cdot]{1e10}\\
-% \num{2e20} \num[expbase=5]{2e20}\\
-% \num{3e30} \num[expproduct=tighttimes]{3e30}
-%\end{LaTeXexample}
-%
-% \currpkg can automatically add colour to negative numbers, which is
-% often useful for highlighting purposes. This is turned on with the
-% \opt{colourneg} option; the colour used is set by \opt{negcolour}.
-% Both of these are available with the US spellings: \opt{colorneg}
-% and \opt{negcolor}.
-%\begin{LaTeXexample}
-% \num{-1}\\
-% \sisetup{colourneg} \num{-2}\\
-% \num{3e-3}\\
-% \num[negcolour=blue]{-4}
-%\end{LaTeXexample}
-%
-% \currpkg can automatically zero-fill and round to a fixed number of
-% decimal places. This is controlled by two options \opt{fixdp} and
-% \opt{dp}. The later is an integer which specifies how many places
-% to fix to; setting this option automatically sets \opt{fixdp} to
-% \opt{true}. The place-fixing system will only alter pure numbers: for
-% example, any error component will result in the input being left
-% unchanged.
-%\begin{LaTeXexample}
-% \num{1.23456}\\
-% \sisetup{dp=2}
-% \num{1.23456}\\
-% \num{9.8}\\
-% \num{-10.432}\\
-% \num{44.3221(2)}
-%\end{LaTeXexample}
-%
-%\section{Tabular material}
-%\subsection{Aligning numbers}
-% Centring numbers in tabular content is handled by a new column
-% type, the |S| column. This is based closely on the \pkg{dcolumn}
-% method for centring numbers in columns, but adds the functionality
-% of the \cs{num} macro.\footnote{The approach used is actually a
-% combination of \pkg{dcolumn} for centring the material and
-% \numprint for processing it. It will therefore give rather
-% different results than the \texttt{n} and \texttt{N} column types
-% in \numprint.}
-%
-% By default, the decimal marker of the number is placed at the
-% centre of the column, which then resizes to accommodate the width
-% of the contents (\ref{tab:default}). This behaviour is set by the
-% \opt{tabnumalign=centredecimal} option. By setting the
-% \opt{tabnumalign} option to \opt{centre}, the centre of the space
-% reserved for the number is placed at the centre of the column. The
-% space reserved is stored in \opt{tabformat}, which is of the form
-% \texttt{\meta{before}\meta{dec}\meta{after}}, where \meta{before}
-% is the number of characters before the decimal marker and
-% \meta{after} is the number after. Thus in the example,
-% \opt{tabformat=2.4} provides space for two digits before the
-% decimal marker and four after. \opt{tabnumalign} can also be set
-% to \opt{left} and \opt{right}, with the expected results.
-%\begin{LaTeXexample}[float]
+%\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}
+%\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 values, 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{Behaviour of \texttt{S} column type}
-% \label{tab:default}
+% \caption{Standard behaviour of the \texttt{S} column type.}
+% \label{tab:S:standard}
% \centering
-% \begin{tabular}{%
-% S%
-% S[tabnumalign=centre,tabformat=2.4]%
-% S[tabnumalign=right,tabformat=2.4]%
-% S[tabnumalign=centre,tabformat=2.4,decimalsymbol=comma]}
+% \begin{tabular}{S}
% \toprule
-% {Some Values} & {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 \\
+% 2.3456 \\
+% 34.2345 \\
+% -6.7835 \\
+% 90.473 \\
+% 5642.5 \\
+% 1.2e3 \\
+% e4 \\
% \bottomrule
% \end{tabular}
% \end{table}
-%\end{LaTeXexample}
-% The \opt{tabformat} setting can also be used to reserve space for
-% numbers containing exponents. This is given in the same format as
-% above, but with a mantissa and exponent part (\ref{tab:exptab}).
-% Notice that this is designed to expect that numbers will contain a
-% mantissa. Exponents can either be aligned so that the ``$\times$''
-% symbols match up vertically, or the exponent part can be allowed to
-% move across as needed. Space for signs is added by using any sign
-% in the \opt{tabformat}, so for example \opt{tabformat=+2.2} and
-% \opt{tabformat=-2.2} have exactly the same effect. Setting
-% \opt{tabformat} will automatically switch \opt{tabnumalign} from
-% \opt{centredecimal} to \opt{centre}, if the former is
-% currently set. In other cases, the current alignment option is
-% retained.
-%\begin{LaTeXexample}[float]
+%\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{Exponents in tables}
-% \label{tab:exptab}
+% \caption{Detection of surrounding material in an \texttt{S}
+% column.}
+% \label{tab:S:extras}
% \centering
-% \begin{tabular}{%
-% S[tabnumalign=right,tabformat=2.2e2]%
-% S[tabnumalign=centre,tabformat=2.2e1.1]%
-% S[tabnumalign=centre,tabformat=2.2e1.1,tabalignexp=false]%
-% S[tabnumalign=centre,tabformat=+2.2]}
+% \begin{tabular}{S[color=orange]}
% \toprule
-% {Longer values}
-% & {Longer values}
-% & {Longer values}
-% & {Values} \\
+% {Some Values} \\
% \midrule
-% 2.3e1 & 2.34e1 & 2.34e1 & +2.31 \\
-% 34.23e45 & 34.23e45 & 34.23e45 & 34.23 \\
-% 56.78 & 56.78 & 56.78 & -56.78 \\
-% 1.0e34 & 1.0e34 & 1.0e34 & +-1.0 \\
+% 12.34 \\
+% \color{purple} 975,31 \\
+% 44.268 \textsuperscript{\emph{a}} \\
% \bottomrule
% \end{tabular}
% \end{table}
-%\end{LaTeXexample}
-%
-% Data not to be processed as a number should be protected by
-% wrapping it in braces: this is most likely to be true for column
-% headers (again as illustrated). By default, the contents of
-% non-numeric cells are centred. This can be altered by setting
-% \opt{tabtextalign}, which can be set to \opt{left}, \opt{right} or
-% \opt{centre}. The use of digit separators in table columns is
-% accounted for: extra space is reserved if digit separators will be
-% added.
-%
-%\subsection{Columns of units}
-% As a complement to the |S| column, \currpkg also provides a second
-% column type, |s|. This is intended for producing columns of units.
-% The letters chosen are intended to be similar to \cs{SI} and
-% \cs{si}, respectively. The alignment of material in |s| columns is
-% governed by the \opt{tabunitalign} option.
-%\begin{LaTeXexample}[float]
+%\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{Number and units in tables}
-% \label{tab:num-unit}
-% \begin{tabular}{%
-% S[tabformat=1.2e-1,tabnumalign=centre]%
-% s[tabunitalign=left]}
-% \toprule
-% {Value} & \multicolumn{1}{c}{Unit} \\
-% \midrule
-% 2.16e-5 & \metre\squared\per\second \\
-% 2.83e-6 & \metre\squared\per\second \\
-% 7.39e3 & \pascal\cubic\metre\per\mole \\
-% 1.0e5 & \pascal \\
-% \bottomrule
+% \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{LaTeXexample}
+%\end{LaTeXdemo}
%
-% As the \cs{si} macro can take literal or macro input, the |s|
-% column cannot validate the input. \emph{Everything} in an |s|
+% 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
-% \ref{tab:s-limits}. Notice that the braces do not prevent
+% \cref{tab:s:processing}. Notice that the braces do not prevent
% processing and colouring of the cell contents.
-%\begin{LaTeXexample}[float]
+%\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{The \texttt{s} column processes everything}
-% \label{tab:s-limits}
-% \begin{tabular}{%
-% s[colourall,colour=orange]%
-% s[colourall,colour=orange]}
+% \caption{Font detection options.}
+% \label{tab:opt:font:det}
+% \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
% \toprule
-% {Unit} & \multicolumn{1}{c}{Unit}\\
+% \multicolumn{1}{l}{Option name} &
+% Type &
+% \multicolumn{1}{l}{Default} \\
% \midrule
-% {m^3} & \multicolumn{1}{c}{\si{m^3}} \\
-% \kilogram & \kilogram \\
+% detect-all & Meta & \meta{none} \\
+% detect-display-math & Switch & false \\
+% detect-family & Switch & false \\
+% detect-inline-weight & Choice & text \\
+% detect-italic & Switch & false \\
+% detect-mode & Switch & false \\
+% detect-none & Meta & \meta{none} \\
+% detect-weight & Switch & false \\
% \bottomrule
-% \end{tabular}
-% \end{table}
-%\end{LaTeXexample}
+% \end{tabular}
+%\end{table}
%
-%\section{Angles}
-%\DescribeMacro{\ang}
-% Angles can be typeset using the \cs{ang} command. This takes two
-% arguments, \cs{ang}\oarg{options}\marg{angle}, where \meta{options}
-% can be any of the package options to apply only to this value.
-% \meta{angle} can be given either as a decimal number or as a
-% semi-colon separated list of degrees, minutes and seconds, \ie\
-% \cs{ang}\marg{decimal angle} or
-% \cs{ang}|{|\meta{degrees}|;|\meta{minutes}|;|\meta{seconds}|}|. By
-% default, no space is introduced between angles and the degrees,
-% minutes and seconds markers.
-%\begin{LaTeXexample}
-% \ang{10} \ang{12.3} \ang{4,5}\\
-% \ang{1;2;3} \ang{;;1}\\
-% \ang{+10;;} \ang{-0;1;}
-%\end{LaTeXexample}
-%
-% By default, angles with no degrees (or minutes) are zero-filled;
-% angles with degrees but no minutes or seconds are not filled. This
-% behaviour can be altered using the package options.
-%\begin{LaTeXexample}
-% \ang{;;1} \ang[padangle=none]{;;1}\\
-% \ang{2;;} \ang[padangle=all]{2;;}\\
-% \sisetup{padangle=all} \ang{;3;} \ang{4;;} \ang{;;5}
-%\end{LaTeXexample}
-% The \cs{num} macro is used to typeset each number of the angle, so
-% the options for \cs{num} also apply here. The \opt{anglesep} value
-% can be used to separate degrees, minutes and seconds.
-%\begin{LaTeXexample}
-% \ang{1.05} \ang[decimalsymbol=comma]{1.05}\\
-% \ang{3.67890} \ang[digitsep=comma]{3.67890}\\
-% \ang{9;8;7} \ang[anglesep=thin]{9;8;7}
-%\end{LaTeXexample}
-% The degrees, minutes and seconds signs can be placed over the
-% decimal sign using the \opt{astroang} option. This is designed on
-% the assumption that only the last number given has a decimal
-% part.
-%\begin{LaTeXexample}
-% \ang{1.2} \ang[astroang]{1.2}\\
-% \ang{1;2.3;} \ang[astroang]{1;2.3;}\\
-% \ang{1;2;3.4} \ang[astroang]{1;2;3.4}
-%\end{LaTeXexample}
-%
-%\section{Units and values}
-%\DescribeMacro{\SI}
-% The core aim of \currpkg is correctly typesetting values which have
-% units. The main output macro here is \cs{SI}, which has the same
-% syntax as the macros with the same name in \SIstyle and \unitsdef
-% packages. The \cs{SI} macro takes two mandatory arguments, in
-% addition to the optional set up argument, and a second optional
-% argument:
-% \cs{SI}\oarg{options}\marg{number}\oarg{preunit}\marg{unit}. The
-% \meta{number} argument operates in exactly the same manner as the
-% equivalent argument of the \cs{num} macro. \meta{unit} will be
-% typeset with a non-breakable space between it and the preceding
-% number, with font control as outlined earlier. Finally,
-% \meta{preunit} is a unit to be typeset \emph{before} the numerical
-% value (most likely to be a currency). Some examples illustrate the
-% general power of the macro.
-%\begin{LaTeXexample}
-% \SI[mode=text]{1.23}{J.mol^{-1}.K^{-1}}\\
-% \SI{.23e7}{\candela}\\
-% \SI[per=slash]{1.99}[\pounds]{\per\kilogram}\\
-% \SI{70}{\metre\per\second}\\
-% \SI[per=frac,fraction=nice]{1,345}{\ampere\per\mole}
-%\end{LaTeXexample}
-% The use of unit macros outside of the \cs{SI} macro is described
-% later.
-%
-%\subsection{Literal units}
-%\changes{v1.1}{2008/07/23}{Unit processor extended to interpret
-% \texttt{\textunderscore} correctly}
-% Units can be input in two ways, inspired by \SIstyle and \SIunits.
-% The \SIstyle-like method uses literal input. Five characters have
-% a special meaning:
-%\begin{itemize}
-% \item ``|^|'' and ``|_|'' The superscript and subscript
-% characters can be used without the usual
-% need for surrounding maths characters (|$|);^^A$
-% \item ``|.|'' and ``|,|'': the full stop (point) symbol and comma
-% are made active, and produce the current contents of the
-% \opt{unitsep} option;
-% \item ``|~|'' The contents of the \opt{unitspace} option are typeset
-% by a tilde.
-%\end{itemize}
-% This allows ready input of units.
-%\begin{LaTeXexample}
-% \SI{10}{kg.m.s^{-2}}\\
-% \SI{1.453}{g/cm^3}\\
-% \SI{6.345}{kg_{pol}.mmol_{cat}^{-1}}\\
-% \SI{33.562}{cd~s}\\
-% \SI[unitsep=medium]{100}{m.s^{-2}}
-%\end{LaTeXexample}
-% The literal unit system will correctly typeset input containing the
-% symbols \si{\micro} (micro), \si{\degree} (degree) and
-% \si{\angstrom} (ring-A).\footnote{Currently this works with \XeTeX\
-% and \pkg{inputenc} using the \texttt{latin1}, \texttt{latin5} and
-% \texttt{latin9} encodings.}
-% \begingroup\makeatletter\si@unt@nonlatin
-%\begin{LaTeXexample}
-% \SI{10}{µm}\\
-% \SI{20}{°C}\\
-% \SI{30}{Å}
-%\end{LaTeXexample}
-%\endgroup
-%
-%\DescribeOption{allowlitunits}
-%\changes{v1.2f}{2009/02/20}{New \opt{allowlitunits} option}
-% 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{allowlitunits} option to
-% \opt{false}: the standard setting is \defaultopt{true}.
-%
-%\subsection{The unit interpreter}
-% The second operation mode for the \cs{SI} macro is based on the
-% behaviour of \SIunits. Here, each unit, SI multiple prefix and
-% power is given a macro name. These are entered in a method very
-% similar to the reading of the unit name in English.
-%\begin{LaTeXexample}
-% \SI{10}{\kilo\gram\metre\per\second\squared}\\
-% \SI{1.453}{\gram\per\cubic\centi\metre}\\
-% \SI{33.562}{\candela\second}\\
-% \SI[unitsep=medium]{100}{\metre\per\Square\second}\\
-% \SI[prefixsymbolic=false]{4.56}{\kilo\metre\per\second}
-%\end{LaTeXexample}
-% On its own, this is very similar to \SIunits, and is less
-% convenient than the direct input method.\footnote{Users of \SIunits
-% should note the lack of need for a \cs{usk}-type macro.} However,
-% the package allows you to define new unit macros; a large number of
-% pre-defined abbreviations are also supplied. More importantly, by
-% defining macros for units, instead of literal values, new
-% functionality is made available. Units may be re-defined to give
-% different output, and handling of reciprocal values can be altered.
-%\begin{LaTeXexample}
-% \SI[per=frac,fraction=frac]{10}{\gram\metre\per\second\squared}\\
-% \SI[per=slash]{1.453}{\gram\per\cubic\centi\metre}\\
-% \SI{33.562}{\candela\second}\\
-% \SI[per=frac,fraction=nice]{100}{\metre\per\Square\second}
-%\end{LaTeXexample}
-% The unit processor will trap \emph{some} errors in the input and
-% give the ``best guess'' result. However, it is down to the user to
-% check the output.
-%
-%\subsection{Powers of units}
-%\DescribeMacro{\Square}
-%\DescribeMacro{\ssquare}
-%\DescribeMacro{\squared}
-%\DescribeMacro{\cubic}
-%\DescribeMacro{\cubed}
-% Including powers in units is handled using a ``natural language''
-% method. Thus preceding a unit by \cs{Square} or \cs{cubic} which
-% raise the unit to the appropriate power, while \cs{squared} or
-% \cs{cubed} follow the unit they apply to. The \cs{Square} macro is
-% capitalised to avoid a name clash with \pkg{pstricks}; the
-% alternative \cs{ssquare} is also provided.
-%\begin{LaTeXexample}
-% \SI{10}{\metre\squared}\\
-% \SI{20}{\Square\metre}\\
-% \SI{30}{\metre\cubed}\\
-% \SI{40}{\cubic\metre}
-%\end{LaTeXexample}
+%\DescribeOption{detect-weight}
+%\DescribeOption{detect-family}
+%\DescribeOption{detect-italic}
+%\DescribeOption{detect-mode}
+% The options \opt{detect-weight} and \opt{detect-italic} set detection
+% of the prevailing font weight and italic states, respectively. The
+% italic state is only checked if the surrounding material is not in
+% math mode (as math text is always italic). 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-italic}
+% and \opt{detect-mode} to \texttt{true}, while \opt{detect-none}
+% sets all of them to \texttt{false}.
+%
+%\DescribeOption{detect-inline-weight}
+% Font weight detection is influenced by the value of
+% \opt{detect-inline-weight}, which takes values \opt{text}, \opt{math}
+% and \opt{combined}. The package can detect the local value of font
+% weight for either the surrounding text, or the surrounding inline
+% ("$" \ldots "$") math. The \opt{combined} option checks both and uses
+% the prevailing weight if either test is true.
+%\begin{LaTeXdemo}
+% \sisetup{
+% detect-weight = true,
+% detect-inline-weight = math
+% }%
+% $\num{1234}$ \\
+% { \boldmath $\num{1234}$ } \\
+% { \bfseries $\num{1234}$ } \\
+% \sisetup{detect-inline-weight = text}
+% { \boldmath $\num{1234}$ } \\
+% { \bfseries $\num{1234}$ }
+%\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.
+%\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}
%
-%\DescribeMacro{\per}
-% The \cs{per} macro intelligently creates reciprocal powers, and
-% also adds the power $-1$ when appropriate.
-%\begin{LaTeXexample}
-% \SI{10}{\per\second\squared}\\
-% \SI{20}{\per\Square\second}\\
-% \SI[per=frac,fraction=nice]{30}{\per\second\cubed}\\
-% \SI[per=slash]{40}{\per\cubic\second}\\
-% \SI{50}{\per\second}\\
-% \SI{60}{\per\metre\Square\candela}
-%\end{LaTeXexample}
+%\subsection{Output font families}
%
-%\DescribeMacro{\tothe}
-%\DescribeMacro{\raiseto}
-% For powers not defined above or with \cs{newpower}, the \cs{tothe}
-% macro can be used ``in line'' to produce a power. As follows from
-% standard English usage, this comes after the unit. \cs{raiseto}
-% achieves the same, but is used \emph{before} a unit to add a power
-% \emph{after}.\footnote{\cs{raiseto} acts in the same way as
-% \cs{tothe} when used in a literal context: the power will be
-% produced where the macro is, rather than moving after the next
-% item.}
-%\begin{LaTeXexample}
-% \SI{16.86}{\metre\tothe{4}}\\
-% \SI{7.895}{\raiseto{-6}\newton}\\
-% \SI{1.34}{\per\kelvin\tothe{7}}
-%\end{LaTeXexample}
-%
-%\subsection{Units with no values}
-%\DescribeMacro{\si}
-% For typesetting the symbol for a unit on its own, with the full
-% font control and without extra spaces, the \cs{si} macro is
-% provided.\footnote{The same effect can be achieved using the
-% \cs{SI} macro with an empty numerical argument.} The macro name
-% avoids a clash with the functionality of the earlier packages, but
-% is similar to \cs{ilu} from the \unitsdef package.
-%\begin{LaTeXexample}
-% \SI{}{kg.m/s^2}\\
-% \si{kg.m/s^2}\\
-% \si[mode=text,unitsep=thin]{\mole\per\cubic\deci\metre}
-%\end{LaTeXexample}
-%
-%\subsection{Free-standing units}
-% Users of the \unitsdef package will be accustomed to using unit
-% macros on their own (following a value) or with an optional
-% argument containing a number. In both cases, only a single unit
-% macro could be used. \currpkg supports both operation modes, with
-% the limitation that units trailing values loose font control of the
-% value. When used in this way, the units \emph{do not} take an
-% optional \pkg{keyval} argument.
-%\begin{LaTeXexample}
-% \sisetup{prespace,allowoptarg}
-% 123\metre\\
-% \kelvin[123]\\
-% \sisetup{mode=text} \ampere[234]\\
-% 6\second
-%\end{LaTeXexample}
-%
-%\subsection{Pre-defined units, prefixes and powers}
-%\newcommand*{\csindex}[1]{^^A
-% \cs{#1}^^A
-% \expandafter\SpecialUsageIndex\csname#1\endcsname}
-%\newcommand*{\unitinfo}[1]{^^A
-% #1 & \csindex{#1} &
-% \expandafter\si\expandafter{\csname#1\endcsname}}
+% 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}
-% \caption{The seven base SI units}
-% \label{tab:baseunits}
% \centering
-% \begin{tabular}{lll}
+% \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}{c}{Unit} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Symbol} \\
+% \multicolumn{1}{l}{Option name} &
+% Type &
+% \multicolumn{1}{l}{Default} \\
% \midrule
-% \unitinfo{kilogram}\\
-% \unitinfo{metre}\\
-% \unitinfo{second}\\
-% \unitinfo{mole}\\
-% \unitinfo{kelvin}\\
-% \unitinfo{ampere}\\
-% \unitinfo{candela}\\
+% 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}
-%\DescribeMacro{\metre}
-%\DescribeMacro{\meter}
-% The package always defines the seven base SI units, irrespective of
-% any package options given (\ref{tab:baseunits}). The kilogram is
-% notable as by default it is a \emph{base} unit with a prefix. Thus,
-% when the package is loaded with the option \opt{load=\{\}},
-% \cs{kilo} and \cs{gram} \emph{are not defined}. As metre is often
-% spelled as ``meter'' in the US, the macro \cs{meter} is provided in
-% addition to the \cs{metre} macro.\footnote{The official SI spelling
-% for the unit is ``metre''.}
-%
-% By default, a number of additional definitions are created by the
-% package. These are controlled by the \opt{load} and \opt{noload}
-% options. Unless specifically requested with the option
-% \opt{noload=prefix}, \currpkg defines the standard prefixes for
-% powers of ten (\ref{tab:prefix}). This leads to the redefinition
-% of \cs{kilogram} as \cs{kilo}\cs{gram}. The macro \cs{deka} is
-% provided, as this is used as an alias for \cs{deca} in some places.
-% The package also defines a number of derived SI units which have
-% assigned names and symbols (\ref{tab:derived}). Note that \cs{Gray}
-% is capitalised to avoid a name clash with the \pkg{pstricks}
-% package.\footnote{The macros \cs{ohm} and \cs{celsius} are not
-% defined by \currpkg if the \pkg{gensymb} package is loaded.}
-%\newcommand*{\prefixunitsym}[1]{\si[prefixsymbolic=false]{#1}}
-%\newcommand*{\prefixinfo}[1]{^^A
-% #1 & \csindex{#1} &
-% \expandafter\prefixunitsym\expandafter{\csname#1\endcsname} &
-% \expandafter\si\expandafter{\csname#1\endcsname}}
+%
+%\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}
-% \caption{The SI prefixes (\opt{load=prefix})}
-% \label{tab:prefix}
% \centering
-% \begin{tabular}{lllclllc}
+% \caption{Options for number parsing.}
+% \label{tab:opt:num:in}
+% \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
% \toprule
-% \multicolumn{1}{c}{Prefix} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Power} &
-% Symbol &
-% \multicolumn{1}{c}{Prefix} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Power} &
-% Symbol \\
-% \midrule
-% \prefixinfo{yocto} &
-% \prefixinfo{deca} \\
-% \prefixinfo{zepto} &
-% \prefixinfo{hecto} \\
-% \prefixinfo{atto} &
-% \prefixinfo{kilo} \\
-% \prefixinfo{femto} &
-% \prefixinfo{mega} \\
-% \prefixinfo{pico} &
-% \prefixinfo{giga} \\
-% \prefixinfo{nano} &
-% \prefixinfo{tera} \\
-% \prefixinfo{micro} &
-% \prefixinfo{peta} \\
-% \prefixinfo{milli} &
-% \prefixinfo{exa} \\
-% \prefixinfo{centi} &
-% \prefixinfo{zetta} \\
-% \prefixinfo{deci} &
-% \prefixinfo{yotta} \\
+% \multicolumn{1}{l}{Option name} &
+% Type &
+% \multicolumn{1}{l}{Default} \\
+% \midrule ^^A (
+% input-close-uncertainty & Literal & ) \\
+% 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 & \verb=\mp\pi\pm= \\
+% 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{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. 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-open-uncertainty}
+%\DescribeOption{input-close-uncertainty}
+% In some fields, it is common to give the uncertainty in a value
+% 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 LaTeX2e. 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}
-% \changes{v1.2n}{2009/09/16}{New \cs{degreeCelsius} unit}
-% \caption{The derived SI units with defined names
-% (\opt{load=named})}
-% \label{tab:derived}
% \centering
-% \begin{tabular}{llllll}
+% \caption{Number post-processing options.}
+% \label{tab:opt:num:post}
+% \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
% \toprule
-% \multicolumn{1}{c}{Unit} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Symbol} &
-% \multicolumn{1}{c}{Unit} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Symbol} \\
+% \multicolumn{1}{l}{Option name} &
+% Type &
+% \multicolumn{1}{l}{Default} \\
% \midrule
-% \unitinfo{becquerel} &
-% \unitinfo{lux} \\
-% \unitinfo{celsius} &
-% \unitinfo{newton} \\
-% & \csindex{degreeCelsius} & \degreeCelsius &
-% \unitinfo{ohm} \\
-% \unitinfo{coulomb} &
-% \unitinfo{pascal} \\
-% \unitinfo{farad} &
-% \unitinfo{radian} \\
-% \unitinfo{Gray} &
-% \unitinfo{siemens} \\
-% & \csindex{ggray} & \ggray &
-% \unitinfo{sievert} \\
-% \unitinfo{hertz} &
-% \unitinfo{steradian} \\
-% \unitinfo{henry} &
-% \unitinfo{tesla} \\
-% \unitinfo{joule} &
-% \unitinfo{volt} \\
-% \unitinfo{katal} &
-% \unitinfo{watt} \\
-% \unitinfo{lumen} &
-% \unitinfo{weber} \\
+% 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-mode & Choice & off \\
+% round-precision & Integer & 2 \\
% \bottomrule
% \end{tabular}
%\end{table}
%
-% In addition to these units, there are three other groups of units
-% for use with the SI system which do not fit into the above. These
-% are those derived from physical measurements
-% (\ref{tab:experimental}), those considered ``accepted''
-% (\ref{tab:accepted}), and those accepted temporarily
-% (\ref{tab:addn}).\footnote{These are supposed to be replaced over
-% time by SI units.}
-%\DescribeMacro{\litre}
-%\DescribeMacro{\liter}
-% The unit ``litre'' is often spelled ``liter'' in the US; both
-% spellings are provided by \currpkg, with \cs{liter} giving
-% \si{\liter} and \cs{litre} producing \si{\litre}.
+%\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{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}
+%
+%\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}
-% \caption{Units derived from experiments
-% (\opt{load=physical})}
-% \label{tab:experimental}
% \centering
-% \begin{tabular}{lll}
+% \caption{Output options for numbers.}
+% \label{tab:opt:num:out}
+% \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
% \toprule
-% \multicolumn{1}{c}{Unit} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Symbol} \\
-% \midrule
-% electron volt & \csindex{electronvolt} & \electronvolt \\
-% unified atomic mass unit
-% & \csindex{atomicmassunit} & \atomicmassunit \\
-% & \csindex{atomicmass} & \atomicmass \\
+% \multicolumn{1}{l}{Option name} &
+% Type &
+% \multicolumn{1}{l}{Default} \\
+% \midrule
+% brackets-numbers & Switch & true \\ ^^A (
+% close-bracket & Literal & ) \\
+% complex-root-position & Choice & after-number \\
+% 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 )
+% range-phrase & Literal & \verb*= to = \\
+% 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-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 decimal marker from
+% the input can be used in the output by setting the
+% \opt{copy-decimal-marker} option.
+%\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-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 value, 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 value 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}
-% \caption{Units accepted for use with SI
-% (\opt{load=accepted})}
-% \label{tab:accepted}
% \centering
-% \begin{tabular}{lll}
+% \caption{Output options for lists and ranges of numbers.}
+% \label{tab:opt:num:list}
+% \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
% \toprule
-% \multicolumn{1}{c}{Unit} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Symbol} \\
-% \midrule
-% \unitinfo{bel} \\
-% day & \csindex{Day} & \Day \\
-% & \csindex{dday} & \dday \\
-% \unitinfo{degree} \\
-% \unitinfo{hour} \\
-% \unitinfo{litre} \\
-% & \csindex{liter} & \liter \\
-% \unitinfo{minute} \\
-% minute (arc) & \csindex{arcmin} & \arcmin \\
-% \unitinfo{neper} \\
-% \unitinfo{percent} \\
-% second (arc) & \csindex{arcsec} & \arcsec \\
-% \unitinfo{tonne} \\
+% \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.
+%\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{Additional (temporary) SI units
-% (\opt{load=addn})}
-% \label{tab:addn}
-% \begin{tabular}{lll}
+% \caption{Multi-part number options.}
+% \label{tab:opt:num:multi}
+% \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
% \toprule
-% \multicolumn{1}{c}{Unit} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Symbol} \\
+% \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{slash} 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
-% {\aa}ngstr{\"o}m & \csindex{angstrom} & \angstrom \\
-% \unitinfo{are} \\
-% \unitinfo{curie} \\
-% bar & \csindex{BAR} & \BAR \\
-% & \csindex{bbar} & \bbar \\
-% \unitinfo{barn} \\
-% \unitinfo{gal} \\
-% \unitinfo{hectare} \\
-% \unitinfo{millibar} \\
-% \unitinfo{rad} \\
-% \unitinfo{rem} \\
-% \unitinfo{roentgen} \\
+% 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}
%
-%\subsection{Prefixed and abbreviated units}
-% Many basic units have prefixes which are commonly used with the
-% unit, such as centimetre or megahertz. The package therefore
-% defines a number of common prefixed units (\opt{load=prefixed}).
-% Several of these also have obvious abbreviations (such as \cs{MHz}
-% for \cs{megahertz}), which are made available by \opt{load=abbr}.
-% In common with the units discussed above, the prefixed and
-% abbreviated unit definitions are loaded by default.
-%\newcommand*{\tablesubhead}[1]{^^A
-% \addlinespace \emph{#1} \\*}
-%\begin{longtable}{llll}
-% \caption{Prefixed (\opt{load=prefixed}) and abbreviated
-% (\opt{load=abbr}) units\label{tab:abbr}}\\
+%\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
-% Unit & Macro & Symbol & Abbreviation \\
+% \multicolumn{1}{l}{Unit} &
+% \multicolumn{1}{l}{Abbreviation} &
+% \multicolumn{1}{l}{Symbol} \\
% \midrule
-% \endfirsthead
+% }
+% \tablehead{^^A
+% \multicolumn{3}{l}{\emph{Continued from previous page}} \\
% \toprule
-% Unit & Macro & Symbol & Abbreviation \\
+% \multicolumn{1}{l}{Unit} &
+% \multicolumn{1}{l}{Abbreviation} &
+% \multicolumn{1}{l}{Symbol} \\
% \midrule
-% \endhead
-% \bottomrule
-% \multicolumn{4}{r}{\emph{Continued on next page}}
-% \endfoot
+% }
+% \tabletail{^^A
% \bottomrule
-% \endlastfoot
-%
-% \tablesubhead{Masses}
-% \unitinfo{kilogram} & \csindex{kg} \\
-% \unitinfo{femtogram} & \csindex{fg} \\
-% \unitinfo{picogram} & \csindex{pg} \\
-% \unitinfo{nanogram} & \csindex{nanog} \\
-% \unitinfo{microgram} & \csindex{micg} \\
-% \unitinfo{milligram} & \csindex{mg} \\
-% atomic mass & \csindex{atomicmass} & \amu & \csindex{amu} \\
-%
-% \tablesubhead{Lengths}
-% \unitinfo{picometre} & \csindex{picom} \\
-% \unitinfo{nanometre} & \csindex{nm} \\
-% \unitinfo{micrometre} & \csindex{micm} \\
-% \unitinfo{millimetre} & \csindex{mm} \\
-% \unitinfo{centimetre} & \csindex{cm} \\
-% \unitinfo{decimetre} & \csindex{dm} \\
-% \unitinfo{kilometre} & \csindex{km} \\
-%
-% \tablesubhead{Times}
-% \unitinfo{second} & \csindex{Sec} \\
-% \unitinfo{attosecond} & \csindex{as} \\
-% \unitinfo{femtosecond} & \csindex{fs} \\
-% \unitinfo{picosecond} & \csindex{ps} \\
-% \unitinfo{nanosecond} & \csindex{ns} \\
-% \unitinfo{microsecond} & \csindex{mics} \\
-% \unitinfo{millisecond} & \csindex{ms} \\
-%
-% \tablesubhead{Moles}
-% \unitinfo{femtomole} & \csindex{fmol} \\
-% \unitinfo{picomole} & \csindex{pmol} \\
-% \unitinfo{nanomole} & \csindex{nmol} \\
-% \unitinfo{micromole} & \csindex{micmol} \\
-% \unitinfo{millimole} & \csindex{mmol} \\
-% \unitinfo{kilomole} & \csindex{kmol} \\
-%
-% \tablesubhead{Currents}
-% \unitinfo{picoampere} & \csindex{pA} \\
-% \unitinfo{nanoampere} & \csindex{nA} \\
-% \unitinfo{microampere} & \csindex{micA} \\
-% \unitinfo{milliampere} & \csindex{mA} \\
-% \unitinfo{kiloampere} & \csindex{kA} \\
-%
-% \tablesubhead{Areas}
-% square centimetre & \csindex{squarecentimetre} &
-% \squarecentimetre & \csindex{cms} \\*
-% & \csindex{centimetresquared} & \centimetresquared \\
-% square metre & \csindex{squaremetre} & \squaremetre \\
-% square kilometre & \csindex{squarekilometre} & \squarekilometre \\
-%
-% \tablesubhead{Volumes}
-%\changes{v1.1d}{2008/10/29}{New units \cs{microliter}, \cs{milliliter},
-% \cs{micL} and \cs{mL}}
-% \unitinfo{microlitre} & \csindex{micl} \\
-% \unitinfo{millilitre} & \csindex{ml} \\
-% \unitinfo{microliter} & \csindex{micL} \\
-% \unitinfo{milliliter} & \csindex{mL} \\
-% cubic centimetre & \csindex{cubiccentimetre} &
-% \cubiccentimetre & \csindex{cmc} \\*
-% & \csindex{centimetrecubed} & \centimetrecubed \\
-% cubic decimetre & \csindex{cubicdecimetre} &
-% \cubicdecimetre & \csindex{dmc} \\
-%
-% \tablesubhead{Frequencies}
-% \unitinfo{hertz} & \csindex{Hz} \\
-% \unitinfo{millihertz} & \csindex{mHz} \\
-% \unitinfo{kilohertz} & \csindex{kHz} \\
-% \unitinfo{megahertz} & \csindex{MHz} \\
-% \unitinfo{gigahertz} & \csindex{GHz} \\
-% \unitinfo{terahertz} & \csindex{THz} \\
-%
-% \tablesubhead{Potentials}
-% \unitinfo{millivolt} & \csindex{mV} \\
-% \unitinfo{kilovolt} & \csindex{kV} \\
-%
-% \tablesubhead{Energies}
-% \unitinfo{kilojoule} & \csindex{kJ}\\
-% \unitinfo{electronvolt} & \csindex{eV} \\
-% \unitinfo{millielectronvolt} & \csindex{meV} \\
-% \unitinfo{kiloelectronvolt} & \csindex{keV} \\
-% \unitinfo{megaelectronvolt} & \csindex{MeV} \\
-% \unitinfo{gigaelectronvolt} & \csindex{GeV} \\
-% \unitinfo{teraelectronvolt} & \csindex{TeV} \\
-% \unitinfo{kilowatthour} & \cs{kWh} \\
-%
-% \tablesubhead{Powers}
-% \unitinfo{milliwatt} \\
-% \unitinfo{kilowatt} \\
-% \unitinfo{megawatt} \\
-%
-% \tablesubhead{Capacitances}
-% \unitinfo{femtofarad} \\
-% \unitinfo{picofarad} \\
-% \unitinfo{nanofarad} \\
-% \unitinfo{microfarad} \\
-% \unitinfo{millifarad} \\
-%
-% \tablesubhead{Resistances}
-% \unitinfo{kilohm} \\
-% \unitinfo{megohm} \\
-% \unitinfo{gigaohm} \\
-% \unitinfo{millisiemens} \\
-%
-% \tablesubhead{Forces}
-% \unitinfo{millinewton} \\
-% \unitinfo{kilonewton} \\
-%
-% \tablesubhead{Other units}
-% \unitinfo{hectopascal} \\
-% \unitinfo{megabecquerel} \\
-% \unitinfo{millisievert} \\
-%\end{longtable}
-%
-%\subsection{Defining new units}
-%\DescribeMacro{\newunit}
-%\DescribeMacro{\renewunit}
-%\DescribeMacro{\provideunit}
-% New units are produced using the \cs{newunit} macro. This works as
-% might be expected:
-% \cs{newunit}\oarg{options}\marg{unit}\marg{symbol}, where
-% \meta{symbol} can contain literal values, other units, multiple
-% prefixes, powers and \cs{per}. The \meta{options} argument can be
-% any suitable options, and applies the specific unit macro only. The
-% most obvious example for using this macro is the \cs{degree}
-% unit.\footnote{Although the \cs{ang} macro is preferred for this
-% job.} The (first) optional argument to \cs{SI} and \cs{si} can be
-% used to override the settings for the unit. The \cs{renewunit} and
-% \cs{provideunit} macros take the same arguments.
-%\begin{LaTeXexample}
-% \SI{3.1415}{\degree}\\
-% \newunit[valuesep=none]{\oddunit}{XXX}
-% \SI{12345}{\oddunit}
-% \SI[valuesep=thick]{67890}{\oddunit}
-%\end{LaTeXexample}
-%
-% As with the \LaTeX\ commands \cs{newcommand}, \etc, the choice of
-% \cs{newunit}, \cs{renewunit} or \cs{provideunit} depends on the
-% presence of an existing definition. While \cs{newunit} should be
-% used when a unit has not been previously defined, \cs{renewunit}
-% will issue a warning if the named unit does not already exist.
-% \cs{provideunit} defines the unit if it does not exist, and
-% otherwise does nothing at all. The same behaviour is seen with
-% \cs{providepower} and \cs{provideprefix} (\latin{vide infra}).
-%
-% Output that is only valid in maths mode requires \cs{ensuremath},
-% text-only input requires \cs{text}. In the example below,
-% \cs{mathnormal} is used to force the font choice only for the
-% single character.\footnote{The \cs{mathrm} font used for this
-% document has an ``\ss'' at the $\pi$ position.}
-%\begin{LaTeXexample}
-% \newunit{\SIpi}{\ensuremath{\mathnormal{\pi}}}
-% \SI{10}{\metre\per\SIpi\squared}
-%\end{LaTeXexample}
-%
-%\DescribeMacro{\newpower}
-%\DescribeMacro{\renewpower}
-%\DescribeMacro{\providepower}
-% Powers are defined:
-% \cs{newpower}\ofixarg{post}\marg{power}\marg{num}. Here,
-% \meta{power} is the name of the power macro and \meta{num} is the
-% (positive) number it represents. The later argument is always
-% processed internally by \cs{num}, but \emph{must} be a number.
-% Giving the optional argument \opt{post} indicates to the package
-% that the power will come after the unit it applies to; by default
-% it is assumed that it will come before.
-%\begin{LaTeXexample}
-% \newpower{\quartic}{4}
-% \newpower[post]{\totheforth}{4}\\
-% \si{\kilogram\totheforth}\\
-% \si{\quartic\metre}
-%\end{LaTeXexample}
+% \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{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{kilomole}{kmol} \\
+%
+% \midrule
+%
+% \DescribeNamedUnit{picoampere}{pA} \\
+% \DescribeNamedUnit{nanoampere}{nA} \\
+% \DescribeNamedUnit{microampere}{uA} \\
+% \DescribeNamedUnit{milliampere}{mA} \\
+% \DescribeNamedUnit{kiloampere}{kA} \\
+%
+% \midrule
+%
+% \DescribeNamedUnit{microlitre}{ul} \\
+% \DescribeNamedUnit{millilitre}{ml} \\
+% \DescribeNamedUnit{microliter}{uL} \\
+% \DescribeNamedUnit{milliliter}{mL} \\
+%
+% \midrule
+%
+% \DescribeNamedUnit{millihertz}{mHz} \\
+% \DescribeNamedUnit{hertz}{Hz} \\
+% \DescribeNamedUnit{kilohertz}{kHz} \\
+% \DescribeNamedUnit{megahertz}{MHz} \\
+% \DescribeNamedUnit{gigahertz}{GHz} \\
+% \DescribeNamedUnit{terahertz}{THz} \\
+%
+% \midrule
+%
+% \DescribeNamedUnit{millivolt}{mV} \\
+% \DescribeNamedUnit{kilovolt}{kV} \\
+%
+% \midrule
+%
+% \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} \\
+%
+% \end{xtabular}
+%\end{center}
%
-%\DescribeMacro{\newprefix}
-%\DescribeMacro{\renewprefix}
-%\DescribeMacro{\provideprefix}
-% The standard SI powers of ten are defined by the package, and are
-% described above. However, the user can define new prefixes with
-% \cs{newprefix}. This has syntax
-% \cs{newunit}\ofixarg{binary}\marg{prefix}\marg{symbol}\marg{powers-ten},
-% where \meta{powers-ten} is the number of powers of ten the prefix
-% represents. When the \opt{binary} option is given, the prefix is a
-% power of two. For example, \cs{kilo} and \cs{kibi} are defined:
-%\begin{LaTeXexample}[noexample]
-% \newprefix{\kilo}{k}{3}
-% \newprefix[binary]{\kibi}{Ki}{10}
-%\end{LaTeXexample}
-%
-%\changes{v1.1}{2008/09/22}{Qualifiers introduced}
-%\DescribeMacro{\newqualifier}
-%\DescribeMacro{\renewqualifier}
-%\DescribeMacro{\providequalifier}
-% It is possible to create unit ``qualifiers'', which add subscript
-% descriptions to units. Although not encouraged, this is sometimes
-% necessary to make the meaning clear. No qualifiers are pre-defined
-% by \currpkg, and so the user needs to declare them using
-% \cs{newqualifier}. Currently, only subscript qualifiers can be
-% created; a more extended set of options is planned for the next
-% release of \currpkg.
-%\begin{LaTeXexample}
-% \newqualifier{\polymer}{pol}
-% \newqualifier{\catalyst}{cat}
-% \si{\kg\polymer\per\mole\catalyst\per\hour}
-%\end{LaTeXexample}
-%
-%\section{Ranges of numbers}
-%
-%\changes{v1.2}{2009/01/22}{Added \cs{numrange} and \cs{SIrange} for
-% handling ranges}
-%\DescribeMacro{\numrange}
-%\DescribeMacro{\SIrange}
-% To aid the input of ranges of numbers, the macros \cs{numrange} and
-% \cs{SIrange} are available. These both take an optional settings
-% argument, then two numbers. The \cs{SIrange} macro then needs a
-% unit. Depending on package settings, the phrase for the range and
-% the repetition of units can be altered.
-%\begin{LaTeXexample}
-% \numrange{1}{10}\\
-% \numrange[tophrase=dash]{0.4}{0.6}\\
-% \SIrange{1.0}{1.4}{\metre}\\
-% \SIrange[tophrase=dots]{12}{15}{\pascal}\\
-% \SIrange[repeatunits=false]
-% {44}{45}{\kilo\gram}\\
-%\end{LaTeXexample}
-%
-%\section{Specialist units}
-% In some subject area, there are units which are in common use even
-% though they are outside of the SI system. Unlike the units
-% discussed earlier, these specialist units are not loaded by
-% default. In each case, they should be requested with the option
-% \opt{alsoload=\meta{name}}.
-%
-%\subsection{Binary units (\opt{binary})\label{sec:binary}}
%\DescribeMacro{\bit}
%\DescribeMacro{\byte}
-% The binary prefixes, \cs{bit}, \cs{byte} (\ref{tab:binary}) are not
-% formally part of the SI system. They are available by giving the
-% \opt{alsoload=binary} option.
-%\begin{LaTeXexample}
-% \SI{100}{\mebi\byte}
-%\end{LaTeXexample}
+% 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
-% (\opt{alsoload=binary})}
-% \label{tab:binary}
+% \caption{Binary prefixes \protect \\
+% (\opt{load-configurations=binary}).}
+% \label{tab:unit:binary}
% \centering
-% \begin{tabular}{lllc}
+% \begin{tabular}{llc>{$}l<{$}}
% \toprule
-% \multicolumn{1}{c}{Prefix} &
-% \multicolumn{1}{c}{Macro} &
-% \multicolumn{1}{c}{Power} &
-% Symbol \\
+% Prefix & Macro & Symbol & \multicolumn{1}{l}{Power} \\
% \midrule
-% \prefixinfo{kibi} \\
-% \prefixinfo{mebi} \\
-% \prefixinfo{gibi} \\
-% \prefixinfo{tebi} \\
-% \prefixinfo{pebi} \\
-% \prefixinfo{exbi} \\
+% \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}
%
-%\subsection{Synthetic chemistry (\opt{synchem})}
-%\DescribeMacro{\mmHg}
-%\DescribeMacro{\molar}
-%\DescribeMacro{\Molar}
-%\DescribeMacro{\torr}
-%\DescribeMacro{\dalton}
-% The \opt{synchem} file adds the common chemistry units \cs{mmHg},
-% \cs{molar}, \cs{Molar}, \cs{torr} and \cs{dalton} to \currpkg. The
-% \cs{Molar} macro is somewhat awkward, as it can be given as either
-% ``\textsc{m}'' or ``M''. The later is obviously easily confused
-% with the sign for the prefix mega. By default, \currpkg uses the
-% UK default of a small-caps symbol. The \cs{dalton} unit is defined
-% here as this name is not recognised by the various international
-% bodies: the symbol \si{\amu} is preferred.
-%\begin{LaTeXexample}
-% \SI{1}{\Molar} HCl\\
-% \SI{760}{\torr}\\
-% \SI{0.01}{\mmHg}\\
-% \SI{3.0}{\molar}\\
-% \SI{106.42}{\dalton}
-%\end{LaTeXexample}
-%
-%\subsection{High-energy physics (\opt{h})}
-% In contrast to \pkg{hepunits}, \currpkg does not define a long list
-% of compound units for high-energy physics.\footnote{Using the
-% \opt{emulate=hepunits} option will load a file defining those.}
-% Instead, a small selection of new units are defined
-% (\ref{tab:hep}). The mechanisms provided by \currpkg should avoid
-% the need for large numbers of abbreviations. For example, the
-% \pkg{hepunits} \cs{MinveV} can be given as |\per\MeV| in \currpkg,
-% which requires only one more character.
+% 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}
+%\end{LaTeXdemo}
+%
+%\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}
+%\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}
-% \caption{High-energy physics units (\opt{alsoload=hep})}
-% \label{tab:hep}
% \centering
-% \begin{tabular}{lllc}
+% \caption{Unit output options.}
+% \label{tab:opt:units:out}
+% \begin{tabular}{>{\ttfamily}ll>{\ttfamily}l}
% \toprule
-% Unit & Macro & Symbol & Abbreviation \\
-% \midrule
-% \addlinespace \emph{Areas} \\
-% \unitinfo{yoctobarn} & \csindex{yb} \\
-% \unitinfo{zeptobarn} & \csindex{zb} \\
-% \unitinfo{attobarn} & \csindex{ab} \\
-% \unitinfo{femtobarn} & \csindex{fb} \\
-% \unitinfo{picobarn} & \csindex{pb} \\
-% \unitinfo{nanobarn} & \csindex{nb} \\
-% \addlinespace \emph{Other units} \\
-% \unitinfo{micron} \\
-% millirad & \csindex{mrad} & \mrad \\
-% \unitinfo{gauss} \\
+% \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 & / \\
+% prefixes-as-symbols & Switch & true \\
+% qualifier-mode & Choice & subscript \\
+% sticky-per & Switch & false \\
% \bottomrule
% \end{tabular}
%\end{table}
%
-%\DescribeMacro{\clight}
-%\DescribeMacro{\eVperc}
-% The \opt{hep} option defines two units which are slightly unusual.
-% \cs{clight} gives \clight, which is recognised as a unit when used
-% in the appropriate circumstances. The second unit provided is
-% \cs{eVperc}, which is commonly-used and clear enough for a compound
-% definition. Notice that the value of \opt{eVcorrb} will need to be
-% adjusted when using this unit.
-%\begin{LaTeXexample}
-% \SI[per=slash,eVcorrb=0.4ex]{4.657}{\mega\eVperc\squared}
-%\end{LaTeXexample}
-%
-%\subsection{Astronomy (\opt{astro})}
-%\DescribeMacro{\parsec}
-%\DescribeMacro{\lightyear}
-% For astronomers, the \cs{parsec} and \cs{lightyear} units are
-% available, and give the obvious results.
-%\begin{LaTeXexample}
-% \SI{12}{\parsec}\\
-% \SI{1}{\lightyear}
-%\end{LaTeXexample}
-%
-%
-%\subsection{Geophysics (\opt{geophys})}
-%\changes{v1.1j}{2008/12/22}{New module \opt{geophys} containing \cs{gon}
-% unit}
-%\DescribeMacro{\gon}
-% For geophysics, the unit \cs{gon} is available.
-%\begin{LaTeXexample}
-% \SI{12}{\gon}
-%\end{LaTeXexample}
-%
-%\subsection{Chemical engineering (\opt{chemeng})}
-%\changes{v1.2f}{2009/02/20}{New module \opt{chemeng}}
-%\changes{v1.2f}{2009/02/20}{New unit \cs{gmol}}
-%\changes{v1.2f}{2009/02/20}{New unit \cs{kgmol}}
-%\changes{v1.2f}{2009/02/20}{New unit \cs{lbmol}}
-%\DescribeMacro{\gmol}
-%\DescribeMacro{\kgmol}
-%\DescribeMacro{\lbmol}
-% For chemical engineers, the units \cs{gmol}, \cs{kgmol} and \cs{lbmol}
-% can be loaded.
-%\begin{LaTeXexample}
-% \SI{1}{\gmol} \\
-% \SI{5}{\kgmol} \\
-% \SI{10}{\lbmol} \\
-%\end{LaTeXexample}
-%
-%\section{Font control}
-% Following the lead of \SIstyle, \currpkg provides control over the
-% font used to typeset output. By default, all text is typeset using
-% the current upright serif maths font, whether the macros are given
-% in text or maths mode. Some examples will show the effect.
-%\begin{LaTeXexample}
-% \num{10} $\num{10}$\\
-% \sffamily \ang{20} $\ang{20}$\\
-% \textbf{\SI{30}{\kilo\gram}}\\
-% \boldmath $\SI{40}{\kilo\gram}$
-% \[ \num{50} \]
-%\end{LaTeXexample}
-%
-% In contrast, by setting \opt{obeyall}, the current font is used:
-% this may be maths or text, depending on the context.
-%\begin{LaTeXexample}
-% \sisetup{obeyall}\\
-% \ang{1;1;1} $\ang{1;1;1}$\\
-% \sffamily \ang{2;2;2} $\ang{2;2;2}$\\
-% \textbf{\ang{3;3;3}} \boldmath $\ang{3;3;3}$\\
-% \emph{\ang{4;4;4}} \emph{$\ang{4;4;4}$}
-% \[ \ang{5;5;5} \]
-%\end{LaTeXexample}
-%
-% Fine control of which elements of the local font are used is
-% available with the \opt{obeyfamily}, \opt{obeybold},
-% \opt{obeyitalic} and \opt{obeymode} options.
-%\begin{LaTeXexample}
-% \sisetup{obeyfamily}\\
-% \ang{1;1;1} $\ang{1;1;1}$\\
-% \sffamily \ang{2;2;2} $\ang{2;2;2}$\\
-% \sisetup{obeybold}
-% \textbf{\ang{3;3;3}} \boldmath $\ang{3;3;3}$\\
-% \emph{\ang{4;4;4}} \emph{$\ang{4;4;4}$}
-% \[ \ang{5;5;5} \]
-%\end{LaTeXexample}
-%
-%\section{Package options\label{sec:options}}
-%\DescribeMacro{\sisetup}
-% The ``native'' options for the package are all given using the
-% key--value method. Most of the package options can be given both
-% when loading the package and at any point in the document. This is
-% achieved using the \cs{sisetup} macro.
-%
-% The package options take a number of different forms.
-%\begin{itemize}
-% \item \opt{option=\meta{bool}} Simple true/false values. These
-% macros all default to \opt{option=true}, meaning that giving the
-% option name along will set the appropriate flag.
-% \item \opt{option=\meta{choice}} Take a single item from a
-% pre-determined list. Depending on the value, one or more
-% internal states will be altered. Values not on the list are
-% ignored (with a warning).
-% \item \opt{option=\meta{choice,literal}} If the given value is a
-% \meta{choice}, then the internal settings for that choice are
-% used. Any other value is used directly.
-% \item \opt{option=\meta{literal}} The given value is used as a
-% literal by the package.
-% \item \opt{option=\meta{csname}} These options expect a command
-% sequence as a value.
-% \item \opt{option=\meta{length}} Requires a \TeX\ length, for
-% example \opt{0.5ex}.
-% \item \opt{option=\meta{list}} Takes a list of one or more items,
-% which are not determined in advance.
-% \item \opt{option=\meta{number}} Takes a number (possibly
-% including an exponent part).
-%\end{itemize}
+%\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 surrounding environment. Setting the option to
+% \opt{symbol-or-fraction}, causes the same behaviour as
+% \opt{symbol} when the surroundings are in line, and the same
+% behaviour as \opt{fraction} when in a display context.
+%\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}
+%\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{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} and \opt{space} 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=space]
+% {\kilogram\polymer\squared\per\mole\catalyst\per\hour}
+%\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}
%
-% The package has a large range of options, to allow full control of
-% the various features of the package. These control differing
-% aspects of the package, and are given below in groups based on
-% function. Where the key has a default value, it is given in bold.
+%\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 values 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{Font family and style}
-% The font used when typesetting material can be tightly controlled
-% using \currpkg. A number of options affect how the package matches
-% the surrounding font, and the font families used to achieve this.
-% The default is to use the current upright maths serif font with no
-% variation.
+%\subsection{Tabular material}
%
-%\DescribeOption{mode}
-%\DescribeOption{textmode}
-%\DescribeOption{valuemode}
-%\DescribeOption{unitmode}
-%\DescribeOption{obeymode}
-% The output of \currpkg can occur using either text or maths mode.
-% The package option \opt{mode} determines which is used: valid
-% options are \defaultopt{maths} and \opt{text}.\footnote{Here and in
-% all other cases, either UK or US spelling may be used. Thus
-% \opt{mode=maths} or \opt{mode=math} have exactly the same effect.}
-% The shortcut \opt{textmode} is provided for setting \opt{mode=text}
-% quickly. Further refinement is possible using the \opt{valuemode}
-% and \opt{unitmode} options. These apply to numbers (the output of
-% \cs{num} and the first mandatory argument of \cs{SI}) and units
-% (all other output), respectively. By setting the \opt{obeymode}
-% flag, the package will use the local typesetting mode (maths or
-% text).
-%
-%\DescribeOption{obeyall}
-%\DescribeOption{obeyfamily}
-%\DescribeOption{obeybold}
-%\DescribeOption{obeyitalic}
-% The detection and matching of surrounding text can be controlled
-% using a number of Boolean package options. \opt{obeyall} turns on
-% all of the detection. Thus output with \opt{obeyall} in force will
-% always match the local text appearance. \opt{obeyfamily} instructs
-% the package on detecting the surrounding font family (Roman, sans
-% serif, fixed width), but does not detect bold or italic.
-% \opt{obeybold} detects the local bold setting, whilst
-% \opt{obeyitalic} picks up italic fonts.
-%
-% Bold detection is influenced by the value of \opt{inlinebold},
-% which takes values \defaultopt{text} and \opt{maths}. The package
-% can detect the local value of bold for either the surrounding text,
-% or the surrounding inline (|$|\ldots|$|) maths. The
-% \opt{obeyitalic} option does \emph{not} have the same facility
-% (maths is italic anyway).
-%
-%\DescribeOption{mathsrm}
-%\DescribeOption{mathssf}
-%\DescribeOption{mathstt}
-%\SpecialOptionIndex{mathrm}
-%\SpecialOptionIndex{mathsf}
-%\SpecialOptionIndex{mathtt}
-%\DescribeOption{textrm}
-%\DescribeOption{textsf}
-%\DescribeOption{texttt}
-% The font commands used by the package to achieve the above are all
-% available for user modification. The options \opt{mathsrm},
-% \opt{mathssf} and \opt{mathstt} hold the command sequences used in
-% maths mode,\footnote{These can also be set using \opt{mathrm},
-% \opt{mathsf} and \opt{mathtt}} while \opt{textrm}, \opt{textsf} and
-% \opt{texttt} do the same for text mode. By default, these contain
-% the obvious command names, for example \opt{mathsrm=mathrm} and
-% \opt{texttt=ttfamily}. However, they can be set at will: the macro
-% names indicate the nature of the surrounding text detected. For
-% example, the value of \opt{mathssf} is used in maths mode when the
-% surrounding text is sans serif.
-%
-%\SpecialOptionIndex{valuemathsrm}
-%\SpecialOptionIndex{valuemathssf}
-%\SpecialOptionIndex{valuemathstt}
-%\SpecialOptionIndex{valuemathrm}
-%\SpecialOptionIndex{valuemathsf}
-%\SpecialOptionIndex{valuemathtt}
-%\SpecialOptionIndex{unitmathsrm}
-%\SpecialOptionIndex{unitmathssf}
-%\SpecialOptionIndex{unitmathstt}
-%\SpecialOptionIndex{valuetextrm}
-%\SpecialOptionIndex{valuetextsf}
-%\SpecialOptionIndex{valuetexttt}
-%\SpecialOptionIndex{valuetextrm}
-%\SpecialOptionIndex{valuetextsf}
-%\SpecialOptionIndex{valuetexttt}
-%\SpecialOptionIndex{unittextrm}
-%\SpecialOptionIndex{unittextsf}
-%\SpecialOptionIndex{unittexttt}
-% Each of the font options can be given separately for the contents
-% of numbers and units. The option names include \opt{value} or
-% \opt{unit} before the mode name. For example, the \opt{mathsrm}
-% option may be split into \opt{valuemathsrm} and \opt{unitmathsrm}.
-%
-%\DescribeOption{detectdisplay}
-% The font detection system can treat displayed mathematical content
-% in two ways. This is controlled by the \opt{detectdisplay} option.
-% When set to \defaultopt{true}, display mathematics is treated
-% independently from the body of the document. Thus the local
-% \emph{maths} font is checked for matching. In contrast, when set
-% to \opt{false}, display material is treated with the current
-% running text font.
-%\begin{LaTeXexample}
-% \sffamily
-% Some text
-% \sisetup{obeyall}
-% \[ x = \SI{1.2e3}{\kg\kelvin\candela} \]
-% More text
-% \sisetup{detectdisplay=false}
-% \[ y = \SI{3}{\metre\second\mole} \]
-%\end{LaTeXexample}
-%
-%\subsection{Spacing and separators}
-%\DescribeOption{unitsep}
-%\DescribeOption{valuesep}
-%\DescribeOption{digitsep}
-%\DescribeOption{anglesep}
-% The separators between items can all be set using options taking a
-% list of pre-defined items or a literal value. The ``\opt{sep}''
-% options (\opt{unitsep}, \opt{valuesep}, \opt{digitsep} and
-% \opt{anglesep}) all recognise \opt{thin}, \opt{medium}, \opt{med},
-% \opt{thick}, \opt{space}, \opt{cdot}, \opt{times}, \opt{tightcdot},
-% \opt{tighttimes}, \opt{fullstop}, \opt{stop}, \opt{period} and
-% \opt{none}. The named spaces are the normal maths separations,
-% with \opt{space} representing a full (non-breakable text) space,
-% and with the obvious meanings for \opt{cdot} and \opt{times}. The
-% \opt{tight} variants reduce the spacing available. Three possible
-% values are provided for ``|.|'', and \opt{none} yields no space at
-% all. In all cases, other values are treated literally and are
-% typeset in maths mode. The default value is \defaultopt{thin} for
-% all separations except \opt{anglesep}, which is set to
-% \defaultopt{none}.
-%
-%\DescribeOption{unitspace}
-%\DescribeOption{errspace}
-% The \opt{unitspace} and \opt{errspace} options again take a list
-% or literal value, but only the ``real'' spaces \opt{thin},
-% \opt{medium}, \opt{med}, \opt{thick}, \opt{space} and \opt{none}
-% are recognised in the list. The \opt{unitspace} option controls the
-% output generated by an explicit space (|~|) inside a unit macro,
-% while \opt{errspace} is used to separate a bracketed error from the
-% main number.
-%
-%\subsection{Number formatting}
-%\DescribeOption{numdigits}
-%\DescribeOption{numdecimal}
-%\DescribeOption{numdiv}
-%\DescribeOption{numexp}
-%\DescribeOption{numsign}
-%\DescribeOption{numaddn}
-%\DescribeOption{numgobble}
-% There are two groups of options for formatting numbers. The first
-% group all begin with ``\opt{num}'', and take literal values used by
-% the package to parse numbers. \opt{numdigits} contains the valid
-% number symbols (\defaultopt{0123456789}), with \opt{numdecimal}
-% containing the decimal markers (\defaultopt{.,}). As in the
-% \numprint package, \opt{numexp} (the list of exponent markers)
-% recognises \defaultopt{deDE} as valid by default. \opt{numsign}
-% contains the sign markers for numbers
-% (\defaultopt{+-\cs{pm}\cs{mp}}). \opt{numdiv} holds the division
-% marker in numbers (\defaultopt{/}). \opt{numaddn} and \opt{numgobble}
-% both control which other characters do not give an error when present
-% in a number. \opt{numaddn} contains valid characters which should be
-% included in the final output ``as is'', whereas \opt{numgobble} lists
-% the characters that are completely ignored. In all cases, the
-% content of the options is a simple string, for example
-% \opt{numdigits=1234567890}.
-%
-%\DescribeOption{decimalsymbol}
-%\DescribeOption{digitsep}
-%\DescribeOption{sepfour}
-% The second group of number options control the output of numbers
-% after parsing. The symbol used by \currpkg as a decimal marker is
-% set by the \opt{decimalsymbol} option, which can take a list of
-% choices or a literal. The valid choices here are
-% \defaultopt{fullstop}, \opt{comma}, \opt{cdot} and
-% \opt{tightcdot}.\footnote{\opt{fullstop} also has aliases
-% \opt{stop} and \opt{period}.} Notice that this does not have to
-% agree with the input marker. The other separator for numerical
-% output is the division of digits into groups of three. The result
-% is dependent on two options. The previously-described
-% \opt{digitsep} option controls the spacing added between groups of
-% three numbers. For numbers consisting of exactly four digits, the
-% \opt{sepfour} Boolean option controls whether separation occurs in
-% these cases. The default is \defaultopt{false}.
-%\begin{LaTeXexample}
-% \num{1234}\\
-% \num[sepfour]{1234}
-%\end{LaTeXexample}
-%
-%\DescribeOption{seperr}
-%\DescribeOption{numopenerr}
-%\DescribeOption{numcloseerr}
-% For numbers given with an error [\eg \num{1.23(4)}], the package
-% can separate out the error part, to give for example
-% \num[seperr]{1.23(4)}. This behaviour is activated by the
-% \opt{seperr} option, and requires that \opt{numopenerr} and
-% \opt{numcloseerr} contain the left- and right-hand delimiters for
-% the error [defaults \opt{numopenerr=(} and \opt{numcloseerr=)}].
-%\begin{LaTeXexample}
-% \sisetup{seperr}\\
-% \num{1.234(5)}\\
-% \num{1.234(5)e6}
-%\end{LaTeXexample}
-%\DescribeOption{trapambigerr}
-%\DescribeOption{openerr}
-%\DescribeOption{closeerr}
-%\DescribeOption{tightpm}
-% If the number has an exponent, or if units are not repeated, then
-% the result can be considered ambiguous. By default, the package
-% adds the markers stored in \opt{openerr} and \opt{closeerr} to
-% remove the ambiguity; the options have the same default values as
-% the input error markers. Detection of a potentially-ambiguous
-% error is controlled by the \opt{trapambigerr} option, although for
-% numbers with units the \opt{repeatunits} option is also important.
-% The spacing around the $\pm$ sign is normally set by \TeX. However,
-% using the \opt{tightpm} option will cause this to be reduced to a
-% minimum.
-%\begin{LaTeXexample}
-% \sisetup{seperr}\\
-% \num[trapambigerr=false]{1.234(5)e6}\\
-% \SI{1.234(5)}{\metre}\\
-% \sisetup{repeatunits=false}
-% \SI{1.234(5)}{\metre}\\
-% \SI[trapambigerr=false]{1.234(5)}{\metre}\\
-% \num[tightpm]{1.234(5)}
-%\end{LaTeXexample}
-%
-%\DescribeOption{numprod}
-%\DescribeOption{repeatunits}
-% The number processor can recognise products in the numerical input;
-% the symbols used for products are stored in \opt{numprod}, with the
-% default value of ``\opt{x}''. By default, the \cs{SI} macro will
-% repeat the units for a number given in this way. This behaviour is
-% altered by the \opt{repeatunits} option, which takes the values
-% \defaultopt{true}, \opt{false} and \opt{power}. The later applies
-% only when providing multiplied numbers with units, and converts the
-% unit to the appropriate power rather than repeating the
-% units.\footnote{This is a very simply option: do not expect it to
-% work with anything except areas and volumes.} Notice that when
-% applied to errors, \opt{repeatunits} takes priority over
-% \opt{trapambigerr}.\footnote{\opt{repeatunits} also applies to the
-% range macro \cs{SIrange}.}
-%\begin{LaTeXexample}
-% \num{1 x 2 x 3}\\
-% \SI{4 x 5 x 6}{\metre}\\
-% \sisetup{repeatunits=false}
-% \SI{1.2 x 3.4 x 5.6}{\milli\metre\cubed}\\
-% \SI[seperr]{1.234(5)}{\metre}\\
-% \SI[seperr,
-% trapambigerr=false]
-% {9.1093897(54)e-31}{\kilo\gram}\\
-% \SI[seperr,repeatunits,
-% trapambigerr=false]
-% {9.1093897(54)e-31}{\kilo\gram}\\
-% \SI[repeatunits=power]{1 x 2 x 3}{\metre}
-%\end{LaTeXexample}
-%
-%\DescribeOption{expproduct}
-%\DescribeOption{expbase}
-%\DescribeOption{allowzeroexp}
-% The formatting of exponents is controlled by \opt{expproduct} and
-% \opt{expbase}. \opt{expproduct} sets the symbol used to indicate a
-% product for exponents (\eg the $\times$ in \num{2e2}), while the
-% value of \opt{expbase} sets the power used (the \num{10} in the
-% example). Both options accept a very short list of options:
-% \defaultopt{times}, \opt{tighttimes}, \opt{cdot} and
-% \opt{tightcdot} for the product, and \defaultopt{ten} and \opt{two}
-% for the power.\footnote{The \opt{tighttimes} and \opt{tightcdot}
-% options give the rather questionable results:
-% \num[expproduct=tighttimes]{1e2} and
-% \num[expproduct=tightcdot]{1e2}, as opposed to \num{1e2} and
-% \num[expproduct=cdot]{1e2}.} Other choices are used literally. Also
-% relevant to exponent processing is the \opt{allowzeroexp} option.
-% By default, the package will suppress a zero exponent, but setting
-% the flag will allow the output of \num[allowzeroexp]{e0}.
-%
-%\DescribeOption{addsign}
-%\DescribeOption{sign}
-%\DescribeOption{retainplus}
-% Additions to the input can take the form of implicit signs and
-% padded zeros. The \opt{addsign} option takes a list of potential
-% sites to add a sign: \defaultopt{none}, \opt{mantissa},
-% \opt{exponent} and \opt{both}.\footnote{Aliases are provided:
-% \opt{mant} = \opt{mantissa}, \opt{exp} = \opt{exponent}, \opt{all}
-% = \opt{true} = \opt{both}, \opt{false} = \opt{none}.} If no sign
-% is given in the input, the setting here determines if one is added.
-% The sign to add is stored in \opt{sign}, which takes the list of
-% choices \defaultopt{plus}, \opt{minus}, \opt{pm} and \opt{mp}, or
-% uses the input literally (in maths mode). For positive numbers,
-% the \opt{retainplus} option causes a $+$ sign explicitly in the
-% input to be retained. By default, the package will remove such
-% signs.
-%
-%\DescribeOption{padnumber}
-% The \opt{padnumber} option controls the addition of zeros to the
-% input, to ``pad'' the result. The option takes a list of choices:
-% \defaultopt{leading}, \opt{trailing}, \opt{both} and
-% \opt{none}.\footnote{Aliases: \opt{all} = \opt{true} = \opt{both},
-% \opt{false} = \opt{none}.} No additional precision is added by
-% this option; integer input will not add a decimal point.
-%\begin{LaTeXexample}
-% \num[padnumber=leading]{.1}\\
-% \num[padnumber=leading]{2.}\\
-% \num[padnumber=trailing]{3.}\\
-% \num[padnumber=both]{4.}\\
-% \num[padnumber=both]{.5}\\
-% \num[padnumber=both]{6}\\
-% \num[padnumber=none]{7.}\\
-% \num[padnumber=none]{.8}
-%\end{LaTeXexample}
-%
-%\DescribeOption{fixdp}
-%\DescribeOption{dp}
-% In contrast to the \opt{padnumber} option, the package can alter
-% the precision of the input number if the \opt{fixdp} option is set.
-% The \opt{fixdp} option will fix the decimal places of the output to
-% the number stored in the \opt{dp} option. The later should be a
-% positive integer or zero.
-%\begin{LaTeXexample}
-% \sisetup{fixdp,dp=3}
-% \num{1}\\
-% \num{53.9}\\
-% \num{4.56783}\\
-% \num{-1.2942}\\
-% \num{-1.2959}\\
-% \num{9.9999}\\
-% \num{2.1264e90}\\
-% \num[dp=0]{12.345}
-%\end{LaTeXexample}
-%
-%\DescribeOption{fixsf}
-%\changes{v1.1}{2008/08/22}{New \opt{fixsf} option}
-%\DescribeOption{sf}
-%\changes{v1.1}{2008/08/22}{New \opt{sf} option}
-% In contrast to the \opt{dp} option, the \opt{fixsf} and \opt{sf}
-% options control the number of significant figures in the output.
-% This never adds extra digits to the output, as significant figures
-% are concerned with accuracy.
-%\begin{LaTeXexample}
-% \sisetup{fixsf,sf=3}
-% \num{1}\\
-% \num{53.9}\\
-% \num{4.56783}\\
-% \num{-1.2942}\\
-% \num{-1.2959}\\
-% \num{9.9999}\\
-% \num{2.1264e90}\\
-% \num{773322}
-%\end{LaTeXexample}
-%
-%\DescribeOption{tophrase}
-% When using the range macros \cs{numrange} and \cs{SIrange}, the phrase
-% used for ``to'' is set using the option \opt{tophrase}. This can take
-% three pre-defined choices \defaultopt{to}, \opt{dots} and \opt{dash},
-% or arbitrary input in text mode.
-%\begin{LaTeXexample}
-% \numrange{1}{10}\\
-% \numrange[tophrase=dots]{1}{10}\\
-% \numrange[tophrase=dash]{1}{10}\\
-% \numrange[tophrase={{ bis }}]{1}{10}\\
-%\end{LaTeXexample}
-% Notice that any space required must be included in the phrase itself,
-% and that this may require a second set of braces.
+% 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}).
%
-%\DescribeOption{trapambigrange}
-%\changes{v1.2i}{2009/04/01}{Added \opt{trapambigrange} option}
-%\DescribeOption{openrange}
-%\DescribeOption{closerange}
-% When \opt{repeatunits} is false, the \opt{trapambigrange} option
-% controls whether brackets are added to keep unit--value agreement.
-% As with other options for trapping ambiguous output, the bracket
-% symbols used here are stored as \opt{openrange} and \opt{closerange}.
-%\begin{LaTeXexample}
-% \SIrange{1}{10}{\kg}\\
-% \SIrange[repeatunits=false]{1}{10}{\kg}\\
-% \SIrange[repeatunits=false,trapambigrange=false]
-% {1}{10}{\kg}
-%\end{LaTeXexample}
-% Notice that any space required must be included in the phrase itself,
-% and that this may require a second set of braces.
-%
-%\subsection{Angle formatting}
-%\DescribeOption{padangle}
-%\DescribeOption{strictarc}
-% The angle formatter uses \cs{num} to format numbers: any options
-% for numbers are therefore applicable here. The \opt{padangle}
-% option takes choices \defaultopt{small}, \opt{large}, \opt{all} and
-% \opt{none}, and controls how angles are padded when given in
-% degrees, minutes and seconds.\footnote{Aliases: \opt{all} =
-% \opt{true} = \opt{both}, \opt{false} = \opt{none}.} When giving
-% angles as arcs (in degrees, minutes and seconds), the package can
-% detect if the correct number of semi-colons have been given. This
-% is controlled by the \opt{strictarc} option, which is a Boolean
-% switch with a \defaultopt{true} default. With \opt{strictarc} set
-% to \opt{false}, an incomplete arc is interpreted as degrees and
-% minute, while an over-complete one will drop excess input.
-%\begin{LaTeXexample}
-% \ang[padangle=none]{1;;}\\
-% \ang[padangle=large]{2;;}\\
-% \ang[padangle=small]{3;;}\\
-% \ang[padangle=both]{;4;}\\
-% \ang[padangle=none]{;5;5}\\
-% \ang[strictarc=false]{1;2}\\
-% \ang[strictarc=false]{1;2;3;4;}
-%\end{LaTeXexample}
-%
-%\DescribeOption{angformat}
-% The angle formatting system can convert between decimal angles and
-% those given as degrees, minutes and seconds. This is controlled by
-% the \opt{angformat} option, which takes choices
-% \defaultopt{unchanged}, \opt{decimal} and
-% \opt{arc}.\footnote{Aliases: \opt{decimal} = \opt{dec}, \opt{arc} =
-% \opt{dms}, \opt{unchanged} = \opt{none}.} When set to
-% \opt{unchanged}, nothing is done to the input. The conversion is
-% based on \TeX\ dimensions, and is therefore limited in accuracy.
-% For this reason, the output is automatically rounded: output as a
-% decimal angle is limited to three places, and that as an arc is
-% given to a single decimal place for the seconds component.
-%\begin{LaTeXexample}
-% $\ang{1;2;3} = \ang[angformat=dec]{1;2;3}$\\
-% $\ang{4.56} = \ang[angformat=arc]{4.56}$
-%\end{LaTeXexample}
-%
-%\DescribeOption{astroang}
-% For astronomers, the \opt{astroang} option is provided. This
-% moves the degrees, minutes or seconds symbol (as appropriate)
-% over the decimal marker rather than after the number.
-%\begin{LaTeXexample}
-% \ang{1;2;3.4}\\
-% \ang[astroang]{5;6;7.8}
-%\end{LaTeXexample}
+%\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-text-post & Switch & true \\
+% table-alignment & Choice & \m{none} \\
+% table-auto-round & 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-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}
%
-%\subsection{Tabular material}
-%\DescribeOption{tabnumalign}
-% Material typeset in |S| columns is processed internally by the
-% \cs{num} macro. Thus, as with angles, the number options also
-% apply here. The positioning of tabular material is controlled by
-% the two options \opt{tabnumalign} and \opt{tabformat}.
-% \opt{tabnumalign} takes values \defaultopt{centredecimal},
-% \opt{centre}, \opt{left} and \opt{right}.\footnote{Aliases
-% \opt{centerdecimal} = \opt{centredecimal}; \opt{center} =
-% \opt{centre}.} When using \opt{centredecimal}, the package places
-% the decimal marker of the mantissa at the centre of the column,
-% which then grows to accommodate the widest number given. For equal
-% numbers of digits before and after the decimal sign, this is the
-% easiest option. The other choices use a fixed-width box to store
-% the number; the box is then aligned with the edges of the column.
-%
-%\DescribeOption{tabformat}
-% The \opt{tabformat} option sets the amount of space reserved by
-% \currpkg for the alignment box when not using the
-% \opt{centredecimal} setting of \opt{tabnumalign}. The numerical
-% parts of \opt{tabformat} are interpreted as
-% \texttt{\meta{pre}\meta{dec}\meta{post}}; \meta{pre} and
-% \meta{post} are the number of digits before and after the decimal
-% sign, respectively. Both signs and exponents can be included in
-% \opt{tabformat}, resulting in appropriate space being reserved. The
-% entire \opt{tabformat} input is processed using the \cs{num} macro
-% internally. Thus the decimal and exponent signs used in
-% \opt{tabformat} are checked against \opt{numdecimal} and
-% \opt{numexp}, respectively.
-%
-%\DescribeOption{tabalignexp}
-%\DescribeOption{tabexpalign}
-%\changes{v1.1d}{2008/10/29}{Added \opt{tabexpalign} as an alias for
-% \opt{tabalignexp}}
-% When \opt{tabformat} contains exponents, two possibilities are
-% available for alignment. The first method is to place the exponent
-% parts so that the ``$\times 10$'' parts form a column, with
-% whitespace after shorter mantissa components. In the second
-% method, no additional space is added after the mantissa, and the
-% exponents do no line up (\ref{tab:alignexp}). This is controlled
-% by the \opt{tabalignexp} option, which can be set to
-% \defaultopt{true} or \opt{false}. The alias \opt{tabexpalign} is
-% available for this option.
-%\begin{LaTeXexample}[float]
+%\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{The \opt{tabalignexp} option}
-% \label{tab:alignexp}
-% \sisetup{tabformat=1.3e2,tabnumalign=centre}
-% \begin{tabular}{SS[tabalignexp=false]}
+% \caption{Parsing without aligning in an \texttt{S} column.}
+% \label{tab:S:parse}
+% \begin{tabular}
+% {
+% S
+% S[table-parse-only]
+% }
% \toprule
-% {Header} & {Header} \\
+% {Decimal-centred} &
+% {Simple centring} \\
% \midrule
-% 1.2e3 & 1.2e3 \\
-% 1.234e56 & 1.234e56 \\
+% 12.345 & 12.345 \\
+% 6,78 & 6,78 \\
+% -88.8(9) & -88.8(9) \\
+% 4.5e3 & 4.5e3 \\
% \bottomrule
% \end{tabular}
% \end{table}
-%\end{LaTeXexample}
-%
-%\DescribeOption{tabtextalign}
-%\DescribeOption{tabunitalign}
-%\DescribeOption{tabalign}
-% Cells containing no numbers are handled by \currpkg in a manner
-% similar to \cs{multicolumn}. The setting of \opt{tabtextalign} is
-% taken from the list \defaultopt{centre}, \opt{right} and
-% \opt{left}.\footnote{Alias \opt{centre} = \opt{center}.} As would
-% be expected, these settings centre, right- or left-align the cell
-% contents. In |s| columns, all content is treated as input to the
-% \cs{si} macro. The alignment of the contents relative to the cell
-% is controlled by the \opt{tabunitalign} option, which takes options
-% \defaultopt{left}, \opt{right} and \opt{centre}. The settings for
-% \opt{tabnumalign}, \opt{tabtextalign} and \opt{tabunitalign} can be
-% set to the same value in one go with the \opt{tabalign} option.
-%
-%\DescribeOption{tabautofit}
-% The contents of table cells can automatically be rounded or
-% zero-filled to the number of decimal places given in
-% \opt{tabformat}. This is activated by the \opt{tabautofit} Boolean
-% option. As \opt{tabformat} does not apply to columns with alignment
-% \opt{centredecimal}, \opt{tabautofit} is also inactive for these
-% columns (\ref{tab:autofit}).
-%\begin{LaTeXexample}[float]
+%\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
-% \caption{The \opt{tabautofit} option}
-% \label{tab:autofit}
-% \sisetup{tabformat=1.3,tabnumalign=centre}
-% % Notice the overfull hbox which results with
-% % the first column
-% \begin{tabular}{%
-% S%
-% S[tabautofit]%
-% S[tabautofit,tabnumalign=centredecimal]}
-% \toprule
-% {Header} & {Header} & {Header} \\
-% \midrule
-% 1.2 & 1.2 & 1.2 \\
-% 1.2345 & 1.2345 & 1.2345 \\
-% \bottomrule
+% \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{LaTeXexample}
-%
-%\DescribeOption{tabparseonly}
-% It is possible to turn off the automatic alignment of numbers
-% while retaining the ability to parse the |S| column input.
-% Setting \opt{tabparseonly} to \opt{true} will still parse the
-% column contents, but will not align the decimal markers. The
-% alignment of the cell is governed by \opt{tabnumalign}
-% (\ref{tab:parse}).
-%\begin{LaTeXexample}[float]
+%\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
-% \caption{The \opt{tabparseonly} option}
-% \label{tab:parse}
-% \begin{tabular}{%
-% S[tabparseonly]%
-% S[tabparseonly,tabnumalign=left]%
-% S[tabparseonly,tabnumalign=right]}
-% \toprule
-% {Header} & {Header} & {Header} \\
-% \midrule
-% 14.2 & 14.2 & 14.2 \\
-% 1.23456 & 1.23456 & 1.23456 \\
-% 1.2e3 & 1.2e3 & 1.2e3 \\
-% \bottomrule
+% \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{LaTeXexample}
-%
-%\subsection{Units}
-%\DescribeOption{per}
-% Most of the unit options are concerned with the processing of named
-% units. The processor for units given as macro names can be
-% influenced to give a variety of output formats. The \opt{per}
-% option defines how the keyword macro \cs{per} is handled. This
-% option takes a choice from the list \defaultopt{reciprocal},
-% \opt{slash} and \opt{fraction}.\footnote{Aliases \opt{reciprocal} =
-% \opt{rp} = \opt{power}, \opt{fraction} = \opt{frac}.} The default
-% option uses \cs{per} to indicate reciprocal powers, whereas
-% \opt{slash} causes the package to use ``$/$'' to show division.
-%
-%\DescribeOption{fraction}
-%\DescribeOption{slash}
-% The \opt{fraction} option defines how \opt{per=fraction} is
-% interpreted. The list of applicable values here is
-% \defaultopt{frac}, \opt{nice}, \opt{ugly} and \opt{sfrac}. In each
-% case, the unit is typeset as a fraction, but the macro use to
-% achieve this varies. \opt{frac} uses the \TeX\ \cs{frac}, macro,
-% while \opt{nice} makes use of a \cs{nicefrac}-like method. The
-% \opt{ugly} option uses a slash in text mode and \cs{frac} in maths
-% mode.\footnote{Similar to the \pkg{ugly} option of the
-% \pkg{nicefrac} package.} Finally, the setting \opt{fraction=sfrac}
-% uses the \cs{sfrac} macro from the \pkg{xfrac} package, when
-% available.\footnote{\pkg{xfrac} is part of the experimental system
-% for \LaTeX3. As it requires a number of additional packages to
-% work, \currpkg does not load \pkg{xfrac}. If it is unavailable, the
-% \opt{sfrac} setting will fall back to using \cs{nicefrac}. See the
-% \pkg{xfrac} documentation for reasons to prefer \cs{sfrac} to
-% \cs{nicefrac}.} The \opt{slash} option sets the symbol used when
-% \opt{per=slash} is in force. This recognises the single keyword
-% \opt{slash}; anything else is used literally.
-%\begin{LaTeXexample}
-% \sisetup{per=fraction}
-% \si[fraction=frac]{\metre\per\second}\\
-% \si[fraction=nice]{\metre\per\second}\\
-% \si[fraction=sfrac]{\metre\per\second}\\
-% \si[per=slash]{\metre\per\second}
-%\end{LaTeXexample}
-%
-%\DescribeOption{stickyper}
-% By default, \cs{per} applies only to the next unit
-% given.\footnote{This is the standard method of reading units in
-% English: for example, \si{\joule\per\mole\per\kelvin} is pronounced
-% ``joules per mole per kelvin''.} By setting the \opt{stickyper}
-% flag, this behaviour is changed so that \cs{per} applies to all
-% subsequent units.\footnote{This is the behaviour in \SIunits.}
-%\begin{LaTeXexample}
-% \si{\kilogram\per\metre\ampere}\\
-% \si[stickyper]{\kilogram\per\metre\ampere}
-%\end{LaTeXexample}
-%
-%\DescribeOption{trapambigfrac}
-%\DescribeOption{openfrac}
-%\DescribeOption{closefrac}
-% When using \opt{per=slash}, multiple units in the denominator will
-% yield a potentially ambiguous result. The \opt{trapambigfrac}
-% determines whether the package checks for this: this takes
-% \defaultopt{true} and \opt{false}. When set, the contents of
-% \opt{openfrac} are inserted before the denominator, and
-% \opt{closefrac} is inserted after.
-%\begin{LaTeXexample}
-% \sisetup{trapambigfrac,openfrac=(,closefrac=),per=slash}\\
-% \si{\metre\per\second\per\kilogram}\\
-% \si[trapambigfrac=false]{\metre\per\second\per\kilogram}
-%\end{LaTeXexample}
-%
-%\DescribeOption{prefixsymbolic}
-%\DescribeOption{prefixbase}
-%\DescribeOption{prefixproduct}
-% The unit prefixes (\cs{kilo}, \etc) are normally given as letters.
-% However, the package can convert these into numerical
-% powers.\footnote{Provided things are not too complex!} This is
-% controlled by the \opt{prefixsymbolic} Boolean option, which by
-% default is \defaultopt{true}. If \opt{prefixsymbolic} is set to
-% \opt{false}, the format of the prefix is controlled by
-% \opt{prefixbase} and \opt{prefixproduct}, which work in the same
-% way as \opt{expbase} and \opt{expproduct}.
-%
-%\DescribeOption{prespace}
-%\DescribeOption{xspace}
-%\DescribeOption{allowoptarg}
-% By default, the single unit macros (\eg \cs{metre}) add no space
-% either before or after the unit. Setting the \opt{xspace} flag to
-% true means that the single macros are followed by the \cs{xspace}
-% command (when used outside of \cs{SI}/\cs{si}). For users of
-% \unitsdef, the \opt{prespace} macro changes the behaviour of the
-% unit macros, so that they can immediately follow a number. As a
-% result, the unit macros will \emph{always} be preceded by a fixed
-% space when the \opt{prespace} flag is true: this will be in
-% addition to any other space. Also relevant to users moving from
-% \unitsdef is the \opt{allowoptarg} option. This allows single unit
-% macros to take an optional numerical argument, in the same way that
-% occurs in that package.
-%\begin{LaTeXexample}
-% \metre is the symbol for metres\\
-% \sisetup{xspace}
-% No, \metre is the correct symbol\\
-% \sisetup{prespace}
-% 30\metre\\
-% Do not use \metre in running text\\
-% \sisetup{allowoptarg}
-% \metre[40]
-%\end{LaTeXexample}
-%
-%\subsection{Symbols}
-% User access to control the symbols used for \si{\ohm}, \si{\micro},
-% \si{\degree}, \si{\arcmin}, \si{\arcsec}, \si{\angstrom} and
-% \si{\celsius} is provided here. These are all literal options,
-% which are available in text and maths mode variants. For example,
-% \opt{textmicro} is the code used for the \si{\micro} symbol in text
-% mode. The text mode macros should be safe when forced into text,
-% and the maths ones when forced into maths. The symbols defined in
-% this way are:
-%\newcommand*{\listsymbopt}[1]{\item \opt{#1}\SpecialOptionIndex{#1}}
-%\begin{itemize}
-% \listsymbopt{textOmega};
-% \listsymbopt{mathsOmega};
-% \listsymbopt{textmu};
-% \listsymbopt{mathsmu};
-% \listsymbopt{textdegree};
-% \listsymbopt{mathsdegree};
-% \listsymbopt{textminute};
-% \listsymbopt{mathsminute};
-% \listsymbopt{textsecond};
-% \listsymbopt{mathssecond};
-% \listsymbopt{textringA};
-% \listsymbopt{mathsringA};
-% \listsymbopt{textcelsius};
-% \listsymbopt{mathscelsius}.
-%\end{itemize}
-%
-%\DescribeOption{redefsymbols}
-% When \currpkg is loaded, it can check for the presence of the
-% \pkg{textcomp} and \pkg{upgreek} packages, to provide better
-% symbols for certain items. To prevent this, set the
-% \opt{redefsymbols} option \opt{false} (the default is
-% \defaultopt{true}).
-%
-%\DescribeOption{eVcorra}
-%\DescribeOption{eVcorrb}
-% The \si{\electronvolt} symbol requires some fine-tuning, and so has
-% two options of its own, both \TeX\ lengths. \opt{eVcorra} is the
-% correction applied to the gap between ``e'' and ``V'' of the unit:
-% the default is \defaultopt{0.3ex}. \opt{eVcorrb} is the correction
-% applied to the gap between ``V'' of the unit and whatever follows;
-% the default is \defaultopt{0ex}. The optimal value for these
-% options will depend on the current font settings.\footnote{This
-% document uses \opt{eVcorra=0.1ex}.}
-%\begin{LaTeXexample}
-% \si[per=slash]{\electronvolt\per\metre}\\
-% \si[per=slash,eVcorrb=0.7ex]{\electronvolt\per\metre}
-%\end{LaTeXexample}
-%
-%\subsection{Colour}
-%\DescribeOption{colourall}
-%\DescribeOption{colourunits}
-%\DescribeOption{colourvalues}
-%\SpecialOptionIndex{colorall}
-%\SpecialOptionIndex{colorunit}
-%\SpecialOptionIndex{colorvalue}
-% The package provides internal hooks for applying colour to part or
-% all of the output. This requires the user to load the \pkg{color}
-% or \pkg{xcolor} package to support colour in the output; \currpkg
-% will ignore a colour request if support is unavailable. The Boolean
-% options \opt{colourall}, \opt{colourunits} and \opt{colourvalues}
-% are used to turn application of a given colour on or off for all
-% output, only units and only values, respectively. All three
-% switches are available with US spelling, \eg \opt{colorall} and
-% \opt{colourall} behave in the same way. With colour turned off, no
-% \cs{color} command is issued internally, and output follows the
-% surrounding text.
-%
-%\DescribeOption{colour}
-%\DescribeOption{unitcolour}
-%\DescribeOption{valuecolour}
-%\SpecialOptionIndex{color}
-%\SpecialOptionIndex{unitcolor}
-%\SpecialOptionIndex{valuecolor}
-% The colour names to use for colouring output are set by the
-% \opt{colour}, \opt{unitcolour} and \opt{valuecolour} options (all
-% also available with US spelling). The \opt{colour} option
-% internally sets both \opt{unitcolour} and \opt{valuecolour}.
-%\begin{LaTeXexample}
-% {\color{brown} Text \num{50}}\\
-% \sisetup{colourall,colour=green}
-% \SI{10}{\metre}\\
-% {\color{purple} Text \num{70}}\\
-% \sisetup{colourunits=true,colourvalues=false}
-% \SI{40}{\second}
-%\end{LaTeXexample}
-%
-%\DescribeOption{colourneg}
-%\DescribeOption{negcolour}
-%\SpecialOptionIndex{colorneg}
-%\SpecialOptionIndex{negcolor}
-% \currpkg can automatically add a colour to negative numbers. This
-% is turned on using the \opt{colourneg} switch. The colour used is
-% set by the \opt{negcolour} option; both options are available using
-% US spellings.
-%
-%\subsection{International support}
-%\DescribeOption{locale}
-% \currpkg allows the user to switch between the typographic
-% conventions of different (geographical) areas by using
-% \latin{locales}. Currently, the package is supplied with
-% configurations for locales \opt{UK}, \opt{USA}, \opt{DE} (Germany)
-% and \opt{ZA} (South Africa). The \opt{locale} option is used to
-% switch to a particular locale.
-%\begin{LaTeXexample}
-% \SI{1.234}{\metre}\\
-% \SI[locale=DE]{6.789}{\metre}
-%\end{LaTeXexample}
-%
-%\DescribeOption{loctolang}
-% Locales are distinct from \pkg{babel} languages, as typographic
-% conventions are not tightly integrated with language. However, it
-% is useful to be able to associate a particular locale with a
-% \pkg{babel} language. The option \opt{loctolang} handles this, and
-% expects pairs of values:
-% \opt{loctolang=\meta{locale}:\meta{language}}.
-%\begin{LaTeXexample}
-% \sisetup{loctolang={UK:UKenglish,DE:german}}\\
-% \SI{6.022e23}{\per\mole}\\
-% \selectlanguage{german}\\
-% \SI{6.022e23}{\per\mole}
-%\end{LaTeXexample}
-%
-%\subsection{Package control}
-%\DescribeOption{load}
-%\DescribeOption{noload}
-%\DescribeOption{alsoload}
-% The package keeps most of the unit and abbreviations definitions in
-% files separate from \file{siunitx.sty}. To control what is loaded,
-% three complementary options are provided, all of which take a list
-% of one or more choices. \opt{load} and \opt{alsoload} define which
-% support configuration files are loaded. The list in \opt{load}
-% recognises the value \opt{default}, which is expanded to the normal
-% list before loading. The difference between \opt{load} and
-% \opt{alsoload} is that \opt{load} specifies the \emph{complete}
-% list of files to load, whereas \opt{alsoload} adds to the existing
-% list. To use the \opt{load} option successfully requires knowing
-% everything that is needed. The \opt{noload} option can be used to
-% delete one or more items from the \opt{load} list, without needing
-% to know what is on it.\footnote{\opt{noload} does not prevent the
-% loading of a file needed by one which is loaded. Thus the package
-% may internally override a \opt{noload} value if needed.}
-%
-%\DescribeOption{log}
-%\DescribeOption{debug}
-% To control data written to the \ext{log} file, the \opt{log} option
-% is provided. This takes a value from the list \defaultopt{normal},
-% \opt{none}, \opt{minimal}, \opt{errors} and \opt{debug}. As would
-% be expected, these indicate the amount of detail written to the log
-% file. As a shortcut to \opt{log=debug}, the package also recognises
-% the \opt{debug} option directly.
-%
-%\DescribeOption{strict}
-% Some users will want to stick closely to the official rules for
-% typesetting units. This could be made complicated if the options
-% for non-standards behaviour could not be turned off. The load-time
-% option \opt{strict} resets package behaviour to follow the rules
-% closely, and disables options which deviate from this. If the
-% package is loaded with the \opt{strict} option, all output is made
-% in maths mode using the upright serif font.
-%
-%\subsection{Back-compatibility options}
-%\DescribeOption{emulate}
-% The package can emulate \SIunits, \SIstyle, \unitsdef, \units,
-% \pkg{hepunits}, \pkg{fancyunits} and \pkg{fancynum}. Giving the
-% \opt{emulate=\meta{package}} option will give the desired
-% emulation, and combinations which would be possible with the real
-% packages will also work here. The package will recognise the
-% options of the emulated packages. This will automatically cause
-% emulation to be switched on.
-%
-%\subsection{Summary of all options}
-% \ref{tab:allopt} lists a summary of the package options (excluding
-% those for backward-compatibility). A reminder or the input format
-% is also provided.
-%\begin{longtable}{>{\ttfamily}lll}
-% \caption{All package options\label{tab:allopt}}\\
+%\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
-% Option & Type & Description \\
+% {Values}
+% & {Values}
+% & {Values}
+% & {Values}
+% & {Values} \\
% \midrule
-% \endfirsthead
+% 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 = $ > $,
+% table-space-text-post =
+% \textsuperscript{\emph{a}}
+% }
+% \begin{tabular}{S}
% \toprule
-% Option & Type & Description \\
+% {Values} \\
% \midrule
-% \endhead
+% 2.3456 \\
+% 34.2345 \textsuperscript{\emph{a}}\\
+% 56.7835 \\
+% $ > $ 90.473 \\
% \bottomrule
-% \multicolumn{3}{r}{\emph{Continued on next page}}
-% \endfoot
+% \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}).\footnote{Currently, closing up material
+% to numbers is only supported for simple real numbers. A more
+% extended method, including a second option for text before numbers,
+% is planned for \pkg{siunitx} v2.1.}
+%\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
-% \endlastfoot
-% addsign & List & Add sign to number \\
-% allowlitunits & Boolean & Allow literal input of units \\
-% allowoptarg & Boolean & Allow optional argument to unit macros \\
-% allowzeroexp & Boolean & Allow \num[allowzeroexp]{e0} \\
-% angformat & List & Conversion of angle format \\
-% anglesep & List or literal & Space between angle components \\
-% astroang & Boolean & Astronomy-style angles \\
-% closeerr & Literal & Closes potential-ambiguous error \\
-% closefrac & Literal & Closes potential-ambiguous fraction \\
-% closerange & Literal & Closes potential-ambiguous range \\
-% color & Literal & Colour used for units and values \\
-% colour & Literal & Colour used for units and values \\
-% colorall & Boolean & Switch for colouring all output \\
-% colourall & Boolean & Switch for colouring all output \\
-% colorneg & Boolean & Colour negative numbers \\
-% colourneg & Boolean & Colour negative numbers \\
-% colorunits & Boolean & Switch for colouring units \\
-% colourunits & Boolean & Switch for colouring units \\
-% colorvalues & Boolean & Switch for colouring values \\
-% colourvalues & Boolean & Switch for colouring values \\
-% decimalsymbol & List or literal & Decimal symbol \\
-% debug & Boolean & Write debugging data to log \\
-% detectdisplay & Boolean & Treat display maths separately \\
-% digitsep & List & Separation of digits in large numbers \\
-% dp & Integer & Number of decimal places to \\
-% & & output numbers to \\
-% emulate & Modules & Emulation modules to load \\
-% errspace & List & Spacing of bracketed error \\
-% eVcorra & Length & Spacing correction in \eV \\
-% eVcorrb & Length & Spacing correction after \eV \\
-% expbase & List or literal & Base used for exponents \\
-% expproduct & List or literal & Product sign for exponents \\
-% fixdp & Boolean & Switch for fixing decimal \\
-% & & places of numbers \\
-% fixsf & Boolean & Switch for fixing significant \\
-% & & figures of numbers \\
-% fraction & List & Method used when setting \opt{per=frac} \\
-% inlinebold & List & Select how inline bold is tested \\
-% load & Modules & Modules to load \\
-% locale & Modules & Locale to follow \\
-% loctolang & Special & Associate locale with \pkg{babel}
-% language \\
-% log & List & Amount of data added to log \\
-% mathOmega & Literal & ``$\makeatletter\si@mathsOmega\makeatother$''
-% symbol in maths mode \\
-% mathcelsius & Literal & ``$\makeatletter\si@mathscelsius\makeatother$''
-% symbol in maths mode \\
-% mathdegree & Literal & ``$\makeatletter\si@mathsdegree\makeatother$''
-% symbol in maths mode \\
-% mathminute & Literal & ``$\makeatletter\si@mathsminute\makeatother$''
-% symbol in maths mode \\
-% mathmu & Literal & ``$\makeatletter\si@mathsmu\makeatother$''
-% symbol in maths mode \\
-% mathringA & Literal & ``$\makeatletter\si@mathsringA\makeatother$''
-% symbol in maths mode \\
-% mathrm & Csname & Roman maths font \\
-% mathsOmega & Literal & ``$\makeatletter\si@mathsOmega\makeatother$''
-% symbol in maths mode \\
-% mathscelsius & Literal & ``$\makeatletter\si@mathscelsius\makeatother$''
-% symbol in maths mode \\
-% mathsdegree & Literal & ``$\makeatletter\si@mathsdegree\makeatother$''
-% symbol in maths mode \\
-% mathsecond & Literal & ``$\makeatletter\si@mathssecond\makeatother$''
-% symbol in maths mode \\
-% mathsf & Csname & Sans serif maths font \\
-% mathsminute & Literal & ``$\makeatletter\si@mathsminute\makeatother$''
-% symbol in maths mode \\
-% mathsmu & Literal & ``$\makeatletter\si@mathsmu\makeatother$''
-% symbol in maths mode \\
-% mathsringA & Literal & ``$\makeatletter\si@mathsringA\makeatother$''
-% symbol in maths mode \\
-% mathsrm & Csname & Roman maths font \\
-% mathssecond & Literal & ``$\makeatletter\si@mathssecond\makeatother$''
-% symbol in maths mode \\
-% mathssf & Csname & Sans serif maths font \\
-% mathstt & Csname & Fixed-width maths font \\
-% mathtt & Csname & Fixed-width maths font \\
-% mode & List & Use text or maths mode for \\
-% & & typesetting \\
-% negcolor & Literal & Colour used for negative numbers \\
-% negcolour & Literal & Colour used for negative numbers \\
-% noload & Modules & Modules not to load \\
-% numaddn & Literal & Additional input allowed in numbers \\
-% numcloseerr & Literal & Character indicating end of \\
-% & & numerical error\\
-% numdecimal & Literal & Decimal symbols in numbers \\
-% numdigits & Literal & Digit characters in numbers \\
-% numdiv & Literal & Division characters in numbers \\
-% numexp & Literal & Exponent characters in numbers \\
-% numgobble & Literal & Characters to ignore in numbers \\
-% numopenerr & Literal & Character indicating start of \\
-% & & numerical error\\
-% numprod & Literal & Characters used for a product \\
-% numsign & Literal & Sign characters in numbers \\
-% obeyall & Boolean & Combination of \opt{obeybold}, \\
-% & & \opt{obeyitalic} and \opt{obeymode} \\
-% obeybold & Boolean & Check local bold setting \\
-% obeyitalic & Boolean & Check local italic setting \\
-% obeymode & Boolean & Check local mode (text/maths) \\
-% openerr & Literal & Opens potentially-ambiguous error \\
-% openfrac & Literal & Opens potentially-ambiguous fraction \\
-% openrange & Literal & Opens potentially-ambiguous range \\
-% padangle & List & Add zeros to blank parts of angles \\
-% padnumber & List & Add zeros to blank parts of numbers \\
-% per & List & Behaviour of \cs{per} \\
-% prefixbase & List or literal & Base used when making prefixes \\
-% & & numerical \\
-% prefixproduct & List or literal & Product sign for prefixes \\
-% prefixsymbolic & Boolean & Behaviour of unit prefixes\\
-% prespace & Boolean & Add space before units \\
-% redefsymbols & Boolean & Use better symbols if available \\
-% repeatunits & List & Repeat units with separated errors, \\
-% & & products and in ranges \\
-% retainplus & Boolean & Retain explicit plus sign\\
-% seperr & Boolean & Separate number and error \\
-% sepfour & Boolean & Separate four-digit numbers \\
-% sf & Integer & Number of significant figures \\
-% & & to output numbers to \\
-% sign & List or literal & Sign to add to numbers \\
-% slash & List or literal & Symbol used for ``/'' \\
-% stickyper & Boolean & Require \cs{per} only once \\
-% strict & Boolean & Obey the rules strictly \\
-% strictarc & Boolean & Require exactly zero or \\
-% & & two semi-colons \\
-% tabalign & List & Positioning of all column data \\
-% tabalignexp & Boolean & Alignment of exponents in tables \\
-% tabautofit & Boolean & Switch for rounding numbers to \\
-% & & length given by \opt{tabformat} \\
-% tabformat & Number & Space reserved in table for numbers \\
-% tabnumalign & List & Alignment of |S| column numbers \\
-% tabparseonly & Boolean & Do not align |S| columns \\
-% & & on decimal marker \\
-% tabtextalign & List & Positioning of text in |S| columns \\
-% tabunitalign & List & Positioning of units in |s| columns \\
-% textcelsius & Literal & ``$^{\circ}$C'' symbol in text mode \\
-% textdegree & Literal & ``${\circ}$'' symbol in text mode \\
-% textminute & Literal & ``$'$'' symbol in text mode \\
-% textmu & Literal & ``$\upmu$'' symbol in text mode \\
-% textomega & Literal & ``$\Omega$'' symbol in text mode \\
-% textringa & Literal & ``\AA'' symbol in maths mode \\
-% textrm & Csname & Roman text font \\
-% textsecond & Literal & ``$''$'' symbol in text mode \\
-% textsf & Csname & Sans serif text font \\
-% texttt & Csname & Fixed-width text font \\
-% tightpm & Boolean & Reduce space around $\pm$ \\
-% tophrase & List or literal & The phrase ``to'' for ranges \\
-% trapambigerr & Boolean & Check for ambiguous errors \\
-% trapambigfrac & Boolean & Check for ambiguous fractions \\
-% trapambigrange & Boolean & Check for ambiguous ranges \\
-% unitcolor & Literal & Switch for colouring units \\
-% unitcolour & Literal & Switch for colouring units \\
-% unitmathrm & Csname & Roman maths font for units \\
-% unitmathsf & Csname & Sans serif maths font for units \\
-% unitmathsrm & Csname & Roman maths font for units \\
-% unitmathssf & Csname & Sans serif maths font for units \\
-% unitmathstt & Csname & Fixed-width maths font for units \\
-% unitmathtt & Csname & Fixed-width maths font for units \\
-% unitmode & List & As \opt{mode}, for units only \\
-% unitsep & List or literal & Separator for units \\
-% unitspace & List or literal & Space used for ``|~|'' in units \\
-% valuecolor & Literal & Switch for colouring value \\
-% valuecolour & Literal & Switch for colouring value \\
-% valuemathrm & Csname & Roman maths font for values \\
-% valuemathsf & Csname & Sans serif maths font for values \\
-% valuemathsrm & Csname & Roman maths font for values \\
-% valuemathssf & Csname & Sans serif maths font for values \\
-% valuemathstt & Csname & Fixed-width maths font for values \\
-% valuemathtt & Csname & Fixed-width maths font for values \\
-% valuemode & List & As \opt{mode}, for values only \\
-% valuesep & List or literal & Separator between value and unit \\
-% xspace & Boolean & Use \pkg{xspace} after units \\
-%\end{longtable}
-%
-%\section{Emulation of other packages}
-% \currpkg has been designed as a replacement for \SIunits, \SIstyle,
-% \unitsdef, \units, \pkg{hepunits}, \pkg{fancyunits} and
-% \pkg{fancynum}. It therefore provides options reproduce the
-% functions of all of these packages. In this way, \currpkg should
-% be usable as a straight replacement for the older
-% packages.\footnote{User macros means that they are described in the
-% package documentation; simply not containing an \texttt{@} does not
-% mean they will have been emulated.} This means for example that
-% the \cs{num} macro takes an optional star when emulating \SIstyle.
-% However, there are some points that should be remembered. In
-% particular, \currpkg validates numerical input, meaning that places
-% where a number is expected in the older packages \emph{require} a
-% number when emulated by \currpkg.
-%
-% The \numprint package has provided many useful ideas for the code
-% used here for number formatting. The basic use of the \cs{numprint}
-% (or \cs{np}) macro can be reproduced using \currpkg. However,
-% \numprint is large and complex, with its own backward-compatibility
-% options. As a result, emulation of \numprint is not provided here.
-% To use a \numprint document with \currpkg, the \cs{numprint} macro
-% could be provided using the following code.
-%^^A Need to deal with \cs{numprint} being defined.
-%\let\numprint\relax
-%\begin{LaTeXexample}
-% \newcommand*{\numprint}[2][]{\SI[obeymode]{#2}{#1}}\\
-% \numprint{-123456} \\
-% \numprint[N/mm^2]{-123456}
-%\end{LaTeXexample}
-%^^A Back to the normal - with \cs{newcommand}
-%\newcommand*{\numprint}{\pkg{numprint}\xspace}
-%
-% \currpkg can be used more-or-less directly to replace both
-% \pkg{dcolumn} and \pkg{rccol}. As is explained in the code
-% section, much of the column-alignment system here is taken from
-% \pkg{dcolumn}, while \pkg{rccol} provided a model for a
-% customisable system. However, neither package has been directly
-% emulated here. The |S| column type can be used to replace both |D|
-% and |R| columns by setting the appropriate package options.
-%
-%\section{Configuration files}
-% \currpkg is a modular package. The unit definitions, abbreviations
-% and locales are all stored in configuration files. These all take
-% names of the form \file{si-\meta{name}.cfg}, where \meta{name} is
-% the part of the filename used as an option in \cs{sisetup} or when
-% loading \currpkg. Producing new configuration files therefore
-% consists of making a suitably-named file and adding it to the path
-% searched by \TeX. The files should normally consist of settings
-% (in \cs{sisetup}) and unit definitions, \etc.
-%
-%\DescribeMacro{\addtolocale}
-% To allow arbitrary macros to be stored in locales, the
-% \cs{addtolocale} macro is provided. This ensures that arbitrary
-% text is only executed when using a locale, not when loading it. The
-% macro takes two arguments, \marg{locale} and \marg{code}.
-%\begin{LaTeXexample}
-% \addtolocale{DE}{TEST}
-% Some text as filler \\
-% \sisetup{locale=DE}
-% This example is rather trivial!
-%\end{LaTeXexample}
-%
-%\DescribeMacro{\requiresiconfigs}
-% To load one or more configuration files from inside another
-% configuration file, the \cs{requiresiconfigs} macro is provided.
-% This accepts a comma-separated list of configuration names, in the
-% same way as \opt{load} or \opt{noload}.
-%
-% In addition to the various configuration files provided with the
-% package, a local file \file{siunitx.cfg} may be provided. This is
-% read at the end of loading \currpkg, and allows the user to include
-% any local definitions or settings easily.
-%
-%\section{Common questions}
-%\subsection{Why do I need \cs{per} more than once?}
-% The unit engine of \currpkg is based around the English method for
-% reading units out loud. Thus \si{\joule\per\mole\per\kelvin} is
-% pronounced ``joules per mole per kelvin''. Hence by default you
-% need to put \cs{per} before each item in the denominator of a unit.
-% The behaviour can be altered by setting the \opt{stickyper} option.
-%
-%\subsection{Why is the order of my units changed?}
-% Then using \opt{per=reciprocal}, the units are typeset as given.
-% However, when using \opt{per=slash} or \opt{per=fraction}, the
-% package needs to find which ones are in the denominator. It then
-% prints the numerator and denominator separately. So if you give a
-% unit in the denominator \emph{before} one in the numerator, they
-% have to be re-ordered.\footnote{``Double division''
-% (\SI{1}{s/m/kg}) is mathematically incorrect.}
-%\begin{LaTeXexample}
-% \SI{88}{\per\kilogram\metre} \\
-% \SI[per=slash]{66}{\per\kilogram\metre}
-%\end{LaTeXexample}
-%
-%\subsection{Why are compound units not recommended outside of
-% \cs{SI}/\cs{si}?}
-% To fully process units made up of several parts, the processor has
-% to know where the end of the unit is. When the unit macros are
-% used outside of \cs{SI}/\cs{si}, this is not the case. The package
-% therefore does its best, but results may be sub-optimal. To get
-% consistent results, either define a new \emph{single} unit, or keep
-% compound units inside \cs{SI} and \cs{si}.
-%\begin{LaTeXexample}
-% \metre\per\micro\second \\
-% \si{\metre\per\micro\second} \\
-% \newunit{\myunit}{\metre\per\micro\second}
-% \myunit
-% \newunit{\myunittwo}{\kilogram\myunit} \\
-% \myunittwo \\
-% \kilogram\myunit
-%\end{LaTeXexample}
-% Notice the difference in behaviour of \cs{per} in the first two
-% lines, and the spacing error on the last line in the example.
-%
-%\subsection{How do I set superscripts to use lining numbers?}
-% Lowercase (``old style'') numbers are favoured by many people for
-% use in running text. However, this does not necessarily look good
-% in superscripts. The mode used to typeset data can be varied, so
-% that maths mode numbers are used for the unit part of the output.
-%\begin{LaTeXexample}
-% \SI[mode=text]{1234}{\metre\per\second}\\
-% \SI[valuemode=text,unitmode=maths]{1234}{\metre\per\second}
-%\end{LaTeXexample}
-%
-%\subsection{Why do most of the examples use
-% \texorpdfstring{\si{\joule\per\mole\per\kelvin}}{J mol-1 K-1}?}
-% The package author is a chemist, and this is the unit of entropy
-% (disorder). It nicely demonstrates the use of the \cs{per} macro,
-% and so it crops up a lot. It is also in the subsection heading
-% here to act as a test with \pkg{hyperref} and moving arguments!
-%
-%\subsection{What can \numprint do that \currpkg cannot?}
-% \currpkg uses a lot of ideas from \numprint: a reasonable amount of
-% the number-processing code here is based on that in \numprint.
-% However, the two packages have somewhat different aims, and as a
-% result there are things that \numprint can do that \currpkg does
-% not implement. The main features of \numprint not available here
-% are:
-%\begin{itemize}
-% \item General support for numbers with base other than $10$ (see
-% \pkg{nbaseprt});
-% \item Alignment of the decimal marker of powers in tables;
-% \item Alignment of numbers in running text;
-% \item Specific formatting commands for \TeX\ counters and lengths.
-%\end{itemize}
+% \end{tabular}
+% \end{table}
+%\end{LaTeXdemo}
%
-%\section{Tricks and known issues}
-%
-%\subsection{Ensuring maths mode}
-% Due to the possibility of output in either maths or text mode, any
-% input which requires a particular mode needs to be protected. You
-% cannot use |$|\ldots|$|, as this can get ``caught out'', but also
-% as it may give hard-to-follow errors. Always use \cs{ensuremath}
-% to force maths processing, and \cs{text} (from the \AMS\TeX\
-% bundle) to ensure text mode.
-%
-%\subsection{Using \texttt{.} and fixed spaces in units}
-% To use a literal |.| in a unit, it has to be within an extra set of
-% braces. This does not need any extra protection, unlike the
-% situation with \SIstyle (for example, no \cs{text} macro is
-% needed). The fixed space (|~|) is more problematic: set
-% \opt{unitspace=space} to get a full space here.
-%\begin{LaTeXexample}
-% \newunit[unitspace=space]{\myunit}{V~vs{.}~NHE}%
-% \SI{10}{\myunit}
-%\end{LaTeXexample}
-%
-%\subsection{Passing unprocessed digits through an \texttt{S}
-% column}
-% The method used to detect numbers in an |S| column will pick up
-% material wrapped inside braces if there is more than a single
-% character inside the braces. If you want to pass a \emph{single}
-% numerical character without processing it, you need two sets of
-% braces (\ref{tab:S-limits}).
-%\begin{LaTeXexample}[float]
+%\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{Passing single digit characters}
-% \label{tab:S-limits}
-% \begin{tabular}{S[colourall,colour=orange]}
+% \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
-% {Heading} \\
+% {Header} & {Header} \\
% \midrule
-% {1-2} \\
-% {1} \\
-% {{1}} \\
-% {{-}} \\ % Using {-} gives an error!
+% 1.2 & 1.2 \\
+% 1.2345 & 1.2345 \\
% \bottomrule
% \end{tabular}
% \end{table}
-%\end{LaTeXexample}
-%
-%\subsection{Limitations of \cs{mathrm}}
-% The package uses the \cs{mathrm} font family by default to typeset
-% output in maths mode. This however has a few side-effects. For
-% example, the Greek alphabet can give odd results.\footnote{This
-% depends on your font setup; this document uses T1 encoding, which
-% shows the issue, whereas using OT1 does not.} The use of the
-% \cs{mathnormal} font \emph{may} get around this issue.
-%\begin{LaTeXexample}
-% \num[numaddn=\pi]{4\pi e-7}\\
-% \num[numaddn=\pi,mathsrm=mathnormal]{4\pi e-7}
-%\end{LaTeXexample}
-% On the other hand, you may want to use text mode, in which case
-% \cs{ensuremath} is needed. Depending on the exact circumstances,
-% the \LaTeX\ protection mechanism (\cs{DeclareRobustCommand}) may be
-% sufficient; in some cases, this will fail and the \eTeX\
-% \cs{protected} system may be required. There are several potential
-% pitfalls in this area; experimentation may well be needed.
-%\begin{LaTeXexample}
-% \DeclareRobustCommand*{\numpi}{\ensuremath{\pi}}
-% \num[numaddn=\numpi,mode=text]{4\numpi e-7}
-%\end{LaTeXexample}
-%
-%\subsection{Effects of emulation}
-% The package has been designed so that almost everything can be set
-% using the options. In the emulation code, some internal macros are
-% redefined. This is because the legacy packages do odd things,
-% which are deliberately not implemented by \currpkg. Using an
-% emulation file will prevent subsequent loading of the real package.
-% This is to prevent errors or, worse, difficult to diagnose changes
-% to output.
-%
-%\subsection{Centring columns on non-decimal input}
-% The \pkg{dcolumn} manual suggests using that package to align a
-% column on a $\pm$ sign. The same type of output is possible using
-% \currpkg, but some care is needed (\ref{tab:dcolumn}). Odd things
-% may happen: use with care!
-%\begin{LaTeXexample}[float]
+%\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
-% \caption{Non-standard \texttt{S} column}
-% \label{tab:dcolumn}
-% \begin{tabular}{%
-% S[digitsep=none,decimalsymbol={\,\pm\,},
-% numdigits={0123456789.},numdecimal=+]}
+% \begin{tabular}{
+% S
+% S[table-number-alignment = center]
+% S[table-number-alignment = right]
+% S[table-number-alignment = left]
+% }
% \toprule
-% {Some Values} \\
+% \multicolumn{1}{c}{Some values}
+% & \multicolumn{1}{c}{Some values}
+% & \multicolumn{1}{c}{Some values}
+% & \multicolumn{1}{c}{Some values} \\
% \midrule
-% 2.3456 + 0.02 \\
-% 34.2345 + 0.001 \\
-% 56.7835 + 0.067 \\
-% 90.473 + 0.021 \\
+% 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{LaTeXexample}
+%\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{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{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{Numbers greater than, less than and so forth}
+%
+% The numerical relationships \( > \), \( < \), \emph{etc}.~are
+% not signs, and so the results obtained by using them as such with
+% \pkg{siunitx} are not predictable. The supported method for including
+% relations is to use them outside of numbers:
+%\begin{LaTeXdemo}
+% \( \num{1e4} > \num{1e-4} \) \\
+% \( {>}\SI{34.5}{\metre} \)
+%\end{LaTeXdemo}
+% Notice the extra braces in the second example line, needed to
+% prevent TeX including more space around the \( > \).
+%
%\subsection{Expanding content in tables}
-% When processing |S| columns, \currpkg works hard to expand any
-% items which may give numbers. So for example you can define values
-% as macros (\ref{tab:vmacros}). To avoid the expansion of single
-% macros, you must either wrap them in two sets of braces or make
-% them robust (using either \cs{DeclareRobustCommand} or
-% \cs{protected}).
-%\begin{LaTeXexample}[float]
+%
+% When processing tables, \pkg{siunitx} will expand anything stored
+% inside a macro, unless it is long or protected. LaTeX2e 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 e-TeX 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
+% LaTeX2e robust commands can lead to unexpected results.)
+%\begin{LaTeXdemo}[code and float]
% \begin{table}
% \centering
-% \caption{Values as macros}
-% \label{tab:vmacros}
-% \newcommand*{\myvala}{1.234}%
-% \newcommand*{\myvalb}{20.345}%
-% \newcommand*{\myvalc}{0.987654}%
-% \DeclareRobustCommand*{\myvald}{88.88}%
-% \begin{tabular}{S[tabtextalign=left]}
+% \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} \\
+% {Some Values} \\
% \midrule
-% \myvala \\
-% \myvalb \\
-% \myvalc \\
-% {{\myvala}} \\
-% \myvald \\
+% \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{LaTeXexample}
+%\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. This means that any calculation code should be wrapped
-% in braces and appear before the use of the number. This is
-% illustrated by using the \pkg{datatool} package to set up a
-% miniature database, and then output the values doubled
-% (\ref{tab:calc}). This example also shows that macros such as
-% \cs{DLTforeach}, which construct a table while \TeX\ is running,
-% cannot be placed inside an |S| column (or an |s| one). Instead, an
-% additional dummy column has been added with no inter-column space.
-% This is used to contain the tale-building macro.
-%\begin{LaTeXexample}[float]
+% the number. An added complication is that TeX itself will
+% expand the first macro in a table cell until it finds
+% something unexpandable. The e-TeX 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:calc}
+% \caption{Calculated values.}
+% \label{tab:xmpl:calc}
% \centering
-% \sisetup{tabformat=2.4}
-% \begin{tabular}{SS@{}l}
+% \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} &
+% {Value} & {Doubled} &
% \DTLforeach{data}{\myvalue=value}{%
% \DTLiffirstrow {\\ \midrule}{\\}%
% \myvalue & % First column
-% {\DTLmul{\myvalue}{\myvalue}{2}} \myvalue % second column
+% \DTLmul{\myvalue}{\myvalue}{2} \myvalue % second column
% & }\\
% \bottomrule
% \end{tabular}
% \end{table}
-%\end{LaTeXexample}
-%
-%\subsection{Adding items after the last column of a tabular}
-% If you use an |S| or |s| column as the last one in a tabular, and
-% you use the \pkg{array} ``|<|'' construction to add items after it,
-% the spacing may be wrong. This will occur if the column contents
-% are of differing widths. Changing the \LaTeX\ |\\| line ending for
-% the plain \TeX\ \cs{cr} will give the correct spacing, but does not
-% allow adjustment of inter-row distance (\ref{tab:cr}).\footnote{For
-% the \TeX\ experts, the issue here is that the system to gather up
-% cell contents is added in using the \texttt{<} construction.
-% Normally, this comes after the cell contents and any other
-% \texttt{<} arguments, so collects the user additions. However, in
-% the last cell the contents include \texttt{\bslash\bslash}, which
-% is converted to \cs{cr} before gathering can occur. By using
-% \cs{cr} directly, the gathering process receives all of the cell
-% contents as normal.} In most cases, this should not be a serious
-% issue. Notice that an extra set of braces is needed here, compared
-% to usual \LaTeX\ use; this is to prevent any expansion of the
-% material by \currpkg.
-%\begin{LaTeXexample}[float]
+%\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{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
+% \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{LaTeXexample}
-%
-%\subsection{Using \currpkg\ with the \pkg{cellspace} package}
-% Both \currpkg\ and \pkg{cellspace} use the letter \texttt{S} for a
+%\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 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 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, \currpkg\ will retain the \texttt{S} column, and moves the
+% 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 \currpkg\ \texttt{S} or \texttt{s}
-% columns.
-%
-%\subsection{Using \currpkg\ with the \pkg{mathabx} package}
-%\changes{v1.1g}{2008/11/26}{Respect loading of \pkg{mathabx}}
-% The \pkg{mathabx} package defines its own \cs{second} and
-% \cs{degree} macros. This is respected by \currpkg: if you want the
-% \currpkg\ definitions instead, put the lines
-%\begin{LaTeXexample}[noexample]
-% \makeatletter
-% \renewunit{\second}{s}
-% \renewunit[valuesep=none]{\degree}{\si@sym@degree}
-% \makeatother
-%\end{LaTeXexample}
-% after |\begin{document}|.
-%
-%\subsection{Numbers with no mantissa in \texttt{S} columns}
-% The \texttt{S} column is design for handling numbers which will
-% contain a decimal symbol. The current code deals unreliably with
-% numbers which consist only of an exponent part. This is on the
-% list for version 2 of \pkg{siunitx}: the current code makes this issue
-% difficult to fix without major changes.
-%
-%\iffalse
-%<*bug>
-%\fi
-%\section{Reporting a problem}
-% \currpkg is quite long and complicated, and works hard to cover all
-% possible eventualities. However, there will be bugs in the code
-% and unexpected interactions with other packages. If you think you
-% have found a bug, please report it. A short test-case
-% demonstrating the problem would be very welcome. The following is
-% a suitable template, and is available as \file{si-bug.ltx} in the
-% \texttt{doc/latex/siunitx} directory or by running the \ext{dtx} or
-% \ext{ins} file through \TeX.
-% \begin{macrocode}
-\listfiles
-\documentclass{article}
-% \end{macrocode}
-% Load other packages needed here.
-% \begin{macrocode}
-\usepackage{siunitx}
-% \end{macrocode}
-% Normally, debugging the load procedure will not be needed; the
-% debug option here means that all run-time information is logged.
-% \begin{macrocode}
-\sisetup{debug}
-\begin{document}
-This is the bug test-case document for the \textsf{siunitx}
-package.\\
-Please put your demonstration here, and e-mail to the package
-author.
-\begin{center}
- \texttt{joseph.wright@morningstar2.co.uk}
-\end{center}
-\end{document}
-% \end{macrocode}
-%\iffalse
-%</bug>
-%\fi
-%
-%\section{Feature requests}
-% Feature requests for \currpkg are welcome. The package maintainer
-% will consider any ideas within the remit of the package (units and
-% values). If suggesting a new feature, an example of how it should
-% work would be appreciated. If new controls are needed, some
-% suggestions for option names would be welcome.
-%
-%\section{Acknowledgements}
-% Many thanks indeed to Stefan Pinnow, who has made a very large
-% number of suggestions and found numerous bugs in the package. His
-% contribution to the package has been vital. The package author has
-% learned \LaTeX\ tricks from far too many people to thank all of
-% them. However, for this package specific thanks must go to the
-% authors of the existing ``unit'' packages: Danie Els (\SIstyle),
-% Marcel Heldoorn (\SIunits), Patrick Happel (\unitsdef), Axel
-% Reichert (\units) and Harald Harders (\numprint). Will Robertson
-% and Heiko Oberdiek deserve much credit for demonstrating \LaTeX\
-% coding best practice. Victor Eijkhout's excellent (and free)
-% \emph{\TeX\ by Topic} has provided some useful coding hints
-% \cite{Eijkhout}. The idea for combining and extending unit
-% provision in \LaTeX\ was heavily inspired by Philip Lehmann's
-% \pkg{biblatex}. Thanks to the various contributors of ideas for the
-% package: Donald Arseneau, Michele Dondi, Paul Gans, Ben Morrow, Lan
-% Thuy Pham, Alan Ristow, Patrick Heinze, Andrea Blomenhofer, Morten
-% H{\o}gholm, Burkhard Moddemann and Patrick Steegstra.
-%
-%\clearpage
-%\part{Correct application of (SI) units}
-%\section{Background}
+% it does \emph{not} work with the \pkg{siunitx} \texttt{S} or
+% \texttt{s} columns.
+%
+%\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 \latin{Conf\'erence G\'en\'erale des Poids et
+% 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.
%
@@ -2985,241 +3327,211 @@ author.
% As befits an agreed international standard, the full rules are
% detailed. It is not appropriate to reproduce these in totality
% here; instead, a useful summary of the key points is provided. The
-% full details are available from the \latin{Bureau International des
-% Poids et Mesures} (BIPM) in French \cite{BIPM:FR} and English
-% \cite{BIPM:EN}. They also publish a very useful and detailed guide
-% to using units, values and so on, available online in a number of
-% different formats \cite{BIPM:PDF}.
-%
-% \currpkg takes account of the information given here, so far as is
-% possible. Thus the package defaults follow the recommendations
+% 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 units and values. Spacing and so forth is
% handled in such a way as to make implementing the rules
% (relatively) easy.
%
-%\section{Units}
-%\subsection{SI base units}
-% There are seven base SI units, listed in \ref{tab:baseunits}. Apart
-% from the kilogram, these are defined in terms of a measurable
+%\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 ``prototype'' held in
-% Paris.\footnote{At the time of writing, this is under review and
-% will be altered.}
+% units as it is still defined in terms of a \enquote{prototype} held in
+% Paris.
%
-%\subsection{SI derived units}
-% All other units within the SI system are regarded as ``derived''
+% 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 \ref{tab:derived}, \ref{tab:experimental} and
-% \ref{tab:accepted}) have a special name and symbol.\footnote{The
-% nautical mile has a given name but no agreed symbol, and although
-% accepted by the SI is not provided by \currpkg as a unit macro.}
-% Most of these units are simple combinations of one or more base
-% units (raised to powers as appropriate). A small number of units
-% derived from experimental data are allowed as SI units
-% (\ref{tab:experimental}).
-%
-% Some of these units (in \ref{tab:accepted}) are regarded as only
-% ``temporarily'' accepted, as the use of only the base and
-% fully-consistent derived units in \ref{tab:derived} is encouraged.
-% They are accepted as they are in common use in one or more
-% disciplines; some are still very widespread in the appropriate
-% areas. These units are mainly multiples of base units (for
-% example, a tonne is \SI{1000}{\kilo\gram}).
-%
-% One point to note is that ``unitless ratios'' are regarded as
-% having base units which cancel out. For example, the radian is
-% regarded as having base unit \si{\metre\per\metre}. The result of
-% this division (``$1$'') is therefore regarded as a derived SI unit
-% in this context.
-%
-%\subsection{SI prefixes}
-% A series of SI prefixes for decimal multiples and submultiples are
+% 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 \ref{tab:prefix}. No space should be used between a
-% prefix and the unit, and only a single prefix should be used. Even
-% the degree Celsius can be given a prefix, for example
-% \SI{1}{\milli\celsius}. The only exception to this rule is for
-% degrees, minutes and seconds of an arc: \ang{1;2;3}.
+% 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 ``gram'' and the prefix symbols are used with
-% the unit symbol \si{\gram}. For example $\SI{1e-6}{\kilogram} =
-% \SI{1}{\milli\gram}$.
-%
-% Three unit-prefix combinations deserve special note. The units
-% hectare, kilohm and megohm elide the additional vowel (these
-% would otherwise be hectoare, kiloohm and megaohm). All other
-% vowel combinations are retained.\footnote{Thanks to Charles
-% Cameron for raising this issue with the package author.}
+% 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} \).
%
-%\subsection{Other units}
% The application of SI units is meant to provide a single set of
% units which ensure consistency and clarity across all areas.
% However, other units are common is many areas, and are not without
-% merit. The units provided by \currpkg by default do not included
+% 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 (Section~\ref{sec:binary} and \ref{tab:binary})
-% are the most obvious example. These are \emph{not} part of the SI
-% specifications, but the prefix names are derived from those in
-% \ref{tab:prefix}.
-%
-% Other units (such as those provided by the modules \opt{synchem},
-% \opt{hep} and \opt{astro}) are normally to be avoided where
-% possible. SI units should, in the main, be preferred due to the
-% advantages of clear definition and self-consistency this brings.
-% However, there will probably always be a place for specialist or
-% non-standard units. This is particulary true of units derived from
-% basic physical constants; for example reason, the \opt{hep} module
-% defines the speed of light, \si{\clight}, as a unit. For work in
-% basic science, a small number of physical constants are recognised
-% as units provided the results for comparison with experiment are
-% given in SI units.
+% 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,
-% \currpkg does define non-SI units.
+% \pkg{siunitx} does define non-SI units.
%
-%\section{Units and values in print}
%\subsection{Mathematical meaning}
-% As explained earlier, a unit--value combination is a single
+%
+% 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{\arcmin} and \si{\arcsec}), it is usual to have
-% a space between the unit and the value. This should therefore be a
-% non-breaking space between the two. Different geographical areas
-% have different conventions on the size of this space; a ``small''
-% space (|\,|) is the \currpkg default.
-%\begin{LaTeXexample}
+% (\si{\degree}, \si{\arcminute} and \si{\arcsecond}), it is usual to
+% have a space between the unit and the value. 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}{\celsius}\\
+% and also for \SI{100}{\degreeCelsius}\\
% but not for \ang{1.23}.
-%\end{LaTeXexample}
+%\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. \currpkg package
-% defaults again follow this convention: any local settings are
-% ignored, and uses the current upright serif maths font. However,
+% 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{LaTeXexample}
+%\begin{LaTeXdemo}
% Units should \textbf{not be bold: \SI{54}{\farad}}\\
% \textbf{But perhaps in a running block,\\
-% it might look better: \SI[obeybold]{54}{\farad}}
-%\end{LaTeXexample}
+% it might look better: \SI[detect-weight]{54}{\farad}}
+%\end{LaTeXdemo}
%
-%\subsection{Unit multiplication and division}
% Symbols for units formed from other units by multiplication are
% indicated by means of either a half-height (that is, centred) dot
-% or a (thin) space. This document uses a half-height dot as
-% (\emph{i}) this is the recommendation of \textsc{nist}, amongst
-% others and (\emph{ii}) it avoids potential confusion between unit
-% prefixes and multiplied units.
-%\begin{LaTeXexample}
-% $\si{\metre\second} = \mbox{metre second}$ \\
-% $\si{\milli\second} = \mbox{millisecond}$ \\
-% \sisetup{unitsep=thin}
-% $\si{\metre\second} = \mbox{metre second}$ \\
-% $\si{\milli\second} = \mbox{millisecond}$
-%\end{LaTeXexample}
-% There are some circumstances under which it is permissable to omit
+% 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
-% ``\si[unitsep=thin]{\kWh}'' does not add any useful information.
-% If using such a unit repeatedly, users of \currpkg are advised to
-% create a custom unit to ensure consistency.\footnote{\cs{kWh} and
-% \cs{kilowatthour} are defined by \currpkg in this way.}
+% \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
+% by means of a virgule (oblique stroke, slash, "/"), a horizontal
% line, or negative exponents.\footnote{Notice that a virgule and a
% solidus are not the same symbol.} However, to avoid ambiguity, the
% virgule must not be repeated on the same line unless parentheses
-% are used. This is ensured when using named unit macros in \currpkg,
-% which will ``trap'' repeated division and format it correctly. In
-% complicated cases, negative exponents are to be preferred over
-% other formats.
-%\begin{LaTeXexample}
+% 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=fraction]{\joule\per\mole\per\kelvin}\\
-% \si[per=slash]{\joule\per\mole\per\kelvin}
-%\end{LaTeXexample}
+% \si[per-mode = fraction]{\joule\per\mole\per\kelvin}\\
+% \si[per-mode = symbol]{\joule\per\mole\per\kelvin}
+%\end{LaTeXdemo}
%
-%\subsection{Repeating units}
% Products and errors should show what unit applies to each value
-% given. Thus \SI{2x3}{\metre} is an ordered set of lengths of a
-% geometric area, whereas \SI[repeatunits=false]{2x3}{\metre} is a
-% length (and equal to \SI{6}{\metre}). Thus, $\times$ is not a
-% product but is a mathematical operator; in the same way, a $2
-% \times 3$ matrix is not a $6$ matrix! In some areas, areas and
-% volumes are given with separated units but a unit raised to the
-% appropriate power: \SI[repeatunits=power]{2 x 3}{\metre}. Although
-% this does display the correct overall units, it is
-% potentially-confusing and is not encouraged.
-%
-%\subsection{Clarity in writing values of quantities}
+% 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 between values, for
-% example ``see pages 1--5''. On the other hand, values with units
-% could be misinterpret as negative values if written in this way. As
-% the unit--value combination is a single mathematic entity, writing
-% the values with an en-dash followed by a single unit is also
-% incorrect. As a result, using the word ``to'' is strongly
+% example \enquote{see pages 1--5}. On the other hand, values with
+% units could be misinterpret as negative values if written in this
+% way. As the unit--value combination is a single 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{LaTeXexample}
-% \SI{1}{\metre} to \SI{5}{\metre} long.
-%\end{LaTeXexample}
+%\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$, \ie length per time squared in this
-% case.} Much better is to show division of all values by the unit,
-% which leaves the entries as unitless ratios. This is illustrated
-% in \ref{tab:label} and \ref{fig:label}.
-%\begin{LaTeXexample}[float]
+% 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
+% values 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:label}
-% \begin{tabular}{cS[tabformat=1.4,tabnumalign=centre]}
+% \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}} \\
+% Entry & {Length/\si{\metre}} \\
% \midrule
-% 1 & 1.1234 \\
-% 2 & 1.1425 \\
-% 3 & 1.7578 \\
-% 4 & 1.9560 \\
+% 1 & 1.1234 \\
+% 2 & 1.1425 \\
+% 3 & 1.7578 \\
+% 4 & 1.9560 \\
% \bottomrule
% \end{tabular}
% \end{table}
-%\end{LaTeXexample}
-%\begin{LaTeXexample}[float]
+%\end{LaTeXdemo}
+%\begin{LaTeXdemo}[code and float]
% \begin{figure}
% \centering
% \begin{tikzpicture}
-% \begin{axis}[xlabel=$t/\si{\second}$,ylabel=$d/\si{\metre}$]
-% \addplot[smooth,mark=x]
+% \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)
@@ -3231,855 +3543,259 @@ author.
% };
% \end{axis}
% \end{tikzpicture}
-% \caption{An example of graph labelling}
-% \label{fig:label}
+% \caption{An example of graph labelling.}
+% \label{fig:xmpl:unitless}
% \end{figure}
-%\end{LaTeXexample}
+%\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 \ref{tab:exp}. The use of \cs{multicolumn} is
-% needed here due to the ``|<|''; without \cs{multicolumn}, the
-% titles are followed by ``\si{\kilo\gram}''!
-%\begin{LaTeXexample}[float]
+% 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:exp}
-% \sisetup{tabnumalign=centre}
+% \caption{Good and bad columns.}
+% \label{tab:good}
+% \sisetup{table-number-alignment = center}
% \begin{tabular}{
% c
-% S[tabformat=1.3e1]<{{\,\si{\kilogram}}}
-% S[tabformat=2.2]}
+% 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}} \\
+% 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 \\
+% 1 & 4.56e3 & 4.56 \\
+% 2 & 2.40e3 & 2.40 \\
+% 3 & 1.345e4 & 13.45 \\
+% 4 & 4.5e2 & 0.45 \\
% \bottomrule
% \end{tabular}
% \end{table}
-%\end{LaTeXexample}
-%
-%\bibliographystyle{unsrt}
-%\StopEventually{%
-% \clearpage
-% \part{Notes}
-% \PrintChanges
-% \PrintIndex
-% \bibliography{siunitx}}
+%\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}
%
-% \iffalse
+% \begin{macrocode}
%<*package>
-% \fi
+% \end{macrocode}
%
-%\clearpage
-%\part{Implementation}
-%\section{Main package}
-% Much of the code here is taken, with little or no modification,
-% from the existing packages. These are all released under the LPPL,
-% and so this use is entirely allowed. Rather than confuse the
-% source here with repeated references, note that code here could be
-% copied from \SIstyle, \SIunits, \numprint, \unitsdef or \units.
-% Some ideas have also been borrowed from \pkg{biblatex}; again these
-% will not be specifically noted. Code from other packages will be
-% marked when used.
-%
-% User-space commands (those not containing |@|) defined here should
-% give the same result as macros with the same name in the older
-% packages.\footnote{Although extra optional arguments may be added.}
-% However, internal package macros will behave differently; if the
-% user has redefined internal macros, then compatibility will be
-% impaired.
-%
-% The code used here uses \LaTeX\ rather than \TeX\ commands where
-% possible.\footnote{This applies to \LaTeX\ kernel commands only;
-% for example, \pkg{ifthenelse} is not used.} For example,
-% \cs{newcommand*} is used in place of \cs{def}, unless custom
-% parameters are needed. Hopefully, this will aid future
-% maintenance. Grouping is used where possible to limit the scope of
-% temporary assignments.
-%
-%\subsection{Setup code}
-% As always, the package starts with identification.
-% \begin{macrocode}
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{siunitx}
- [2010/02/22 v1.4c A comprehensive (SI) units package]
-% \end{macrocode}
-% The package requires \eTeX, so the usual test is made.
-% \begin{macrocode}
-\begingroup
- \@ifundefined{eTeXversion}
- {\PackageError{siunitx}
- {Not running under e-TeX}
- {This package requires e-TeX. Try compiling the document
- with\MessageBreak `elatex' instead of `latex'. When
- using pdfTeX, try `pdfelatex'\MessageBreak instead of
- `pdflatex'}%
- \endgroup\endinput}
- {\endgroup}
-% \end{macrocode}
-%\begin{macro}{\si@catcodes}
-% There are circumstances under which some odd category codes might
-% be in place. The category codes for |{|, |}|, |[|, |]| and |#| are
-% assumed to be okay; if issues arise, this can be altered. \LaTeX\
-% will have set |@| as a letter on loading \currpkg.
-% \begin{macrocode}
-\edef\si@catcodes{%
- \catcode\string`\string ` \the\catcode\string`\`\relax
- \catcode\string`\string = \the\catcode\string`\=\relax
- \catcode\string`\string ^ \the\catcode\string`\^\relax
- \catcode\string`\string _ \the\catcode\string`\_\relax
- \catcode\string`\string ~ \the\catcode\string`\~\relax
- \catcode\string`\string : \the\catcode\string`\:\relax
- \catcode\string`\string - \the\catcode\string`\-\relax
- \catcode\string`\string + \the\catcode\string`\+\relax
- \catcode\string`\string ; \the\catcode\string`\;\relax
- \catcode\string`\string , \the\catcode\string`\,\relax
- \catcode\string`\string . \the\catcode\string`\.\relax}
-\catcode\string`\` 12\relax
-\catcode`\= 12\relax
-\catcode`\^ 7\relax
-\catcode`\_ 8\relax
-\catcode`\~ \active\relax
-\@makeother{\:}
-\@makeother{\-}
-\@makeother{\+}
-\@makeother{\;}
-\@makeother{\,}
-\@makeother{\.}
-% \end{macrocode}
-%\end{macro}
-% Packages needed for functionality are loaded. \pkg{xkeyval}
-% handles the package options, while \pkg{amstext} from the \AMS\
-% bundle is needed for \cs{text}. \pkg{array} is needed for the new
-% column type for tabular material. \pkg{xspace} provides ``magic''
-% spacing after macros, if requested.
-% \begin{macrocode}
-\RequirePackage{xkeyval}[2005/05/07]
-\RequirePackage{amstext,array,xspace}
-% \end{macrocode}
-%\begin{macro}{\si@tempa}
-%\begin{macro}{\si@tempb}
-%\begin{macro}{\si@tempc}
-% Some scratch commands are defined; apart from where a known value
-% is carried through, these could contain anything.
-% \begin{macrocode}
-\newcommand*{\si@tempa}{}
-\newcommand*{\si@tempb}{}
-\newcommand*{\si@tempc}{}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@switch}
-% Various items will need a switch. To avoid name pollution, a
-% single switch is defined here; grouping will keep the definition
-% local.
-% \begin{macrocode}
-\newif\ifsi@switch
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tempboxa}
-%\begin{macro}{\si@tempboxb}
-%\begin{macro}{\si@tempboxc}
-%\begin{macro}{\si@tempboxd}
-% Some boxes are also needed.
-% \begin{macrocode}
-\newbox\si@tempboxa
-\newbox\si@tempboxb
-\newbox\si@tempboxc
-\newbox\si@tempboxd
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@temptoks}
-% A token register is also handy.
-% \begin{macrocode}
-\newtoks{\si@temptoks}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@packagecheck}
-%\begin{macro}{\si@blockpkgs}
-%\begin{macro}{\si@checkpkgs}
-% As \currpkg is intended to replace the other unit-management
-% packages, these are tested for before any further processing. If
-% any are loaded, the package halts compilation; name clashes or
-% unexpected results could occur if this is not tested. Notice that
-% \SIunits and \SIstyle could be loaded with variable capitalisation
-% (at least on Windows); both possibilities are tested.
-% \begin{macrocode}
-\newcommand*{\si@blockpkgs}{SIunits,sistyle,siunits,SIstyle,%
- unitsdef,fancyunits}
-\newcommand*{\si@checkpkgs}{units,hepunits,fancynum}
-\newcommand*{\si@packagecheck}{%
- \begingroup
- \@for\si@tempa:=\si@blockpkgs\do{
- \@ifpackageloaded{\si@tempa}
- {\PackageError{siunitx}
- {Package `\si@tempa' incompatible}
- {The \si@tempa\space package and siunitx are
- incompatible.\MessageBreak Use the
- `emulate=\si@tempa' package option when loading
- siunitx}}
- {}}
-% \end{macrocode}
-% Some packages should not cause a clash, but are emulated and would
-% be better handled that way.
-% \begin{macrocode}
- \@for\si@tempa:=\si@checkpkgs\do{%
- \@ifpackageloaded{\si@tempa}
- {\PackageWarning{siunitx}
- {Consider loading the siunitx package
- with\MessageBreak option `emulate=\si@tempa', rather
- than\MessageBreak loading both \si@tempa\space and
- siunitx}}
- {}}
- \endgroup}
-% \end{macrocode}
-% The check is carried out on loading and at the beginning of the
-% document, so that packages loaded both before and after \currpkg
-% are caught.
-% \begin{macrocode}
-\si@packagecheck
-\AtBeginDocument{\si@packagecheck}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@ifdefinable}
-%\darg{macro}
-% Using \cs{@ifdefinable} to check macro definitions gives a generic
-% error. To give something more helpful, \cs{@ifundefined} is used,
-% but this needs some \cs{expandafter} work. This way it can also be
-% used as a form of \cs{@ifundefined} for macro names.
-% \begin{macrocode}
-\newcommand*{\si@ifdefinable}[1]{%
- \expandafter\expandafter\expandafter\@ifundefined%
- \expandafter\expandafter\expandafter%
- {\expandafter\@gobble\string#1}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@addtolist}
-%\darg{macro}
-%\darg{items}
-% It is quite useful to be able to add to a comma-separated list of
-% expandable items.
-% \begin{macrocode}
-\newcommand*{\si@addtolist}[2]{%
- \ifx\@empty#1\@empty
- \edef#1{#2}%
- \else
- \edef#1{#1,#2}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@addtocsname}
-%\darg{csname}
-%\darg{tokens}
-% A second item to add to a command sequence.
-% \begin{macrocode}
-\newcommand*{\si@addtocsname}[2]{%
- \@ifundefined{#1}
- {\expandafter\gdef\csname #1\endcsname{#2}}
- {\si@temptoks\expandafter\expandafter\expandafter{%
- \csname #1\endcsname#2}%
- \expandafter\xdef\csname #1\endcsname{\the\si@temptoks}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@ifmtarg}
-%\begin{macro}{\si@xifmtarg}
-%\begin{macro}{\si@ifnotmtarg}
-% To keep down dependance on other packages, the very short code
-% block from \pkg{ifmtarg} is copied here with an internal name.
-% \begin{macrocode}
-\begingroup
- \catcode`\Q=3
- \long\gdef\si@ifmtarg#1{%
- \si@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil}
- \long\gdef\si@xifmtarg#1#2Q#3#4#5\@nil{#4}
- \long\gdef\si@ifnotmtarg#1{%
- \si@xifmtarg#1QQ\@firstofone\@gobble\@nil}
-\endgroup
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@newrobustcmd}
-%\begin{macro}{\si@newcommand}
-%\begin{macro}{\si@newcmd}
-%\begin{macro}{\si@xargdef}
-%\darg{macro}
-%\doarg{num-args}
-%\doarg{default}
-%\darg{def}
-% Some more copying, this time from \pkg{etoolbox}. Various macros
-% need to be \emph{really} robust. This is achieved using the \eTeX\
-% \cs{protected} primitive in various places. However, it would be
-% nice to have a \cs{protected} version of \cs{newcommand}.
-% \pkg{etoolbox} has code for that, but to avoid needing to load it,
-% the necessary stuff is copied here. The only changes form the
-% original are names, and the use of \cs{newcommand*} for the
-% \cs{si@newcommand} macro.
-% \begin{macrocode}
-\@ifpackageloaded{etoolbox}
- {\let\si@newrobustcmd\newrobustcmd}
- {\protected\def\si@newrobustcmd{%
- \@ifstar
- {\let\l@ngrel@x\protected\si@newcommand}
- {\def\l@ngrel@x{\protected\long}\si@newcommand}}
- \newcommand*{\si@newcommand}[1]{\@testopt{\si@newcmd#1}0}
- \def\si@newcmd#1[#2]{%
- \@ifnextchar[%]
- {\si@xargdef#1[#2]}
- {\@argdef#1[#2]}}
- \long\def\si@xargdef#1[#2][#3]#4{%
- \@ifdefinable#1{%
- \expandafter\protected
- \expandafter\def
- \expandafter#1%
- \expandafter{%
- \expandafter\@testopt
- \csname\string#1\endcsname{#3}}%
- \expandafter\@yargdef
- \csname\string#1\endcsname\tw@{#2}{#4}}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%
-%\subsection{Logging}
-%\begin{macro}{\ifsi@debug}
-%\begin{macro}{\ifsi@logmin}
-%\begin{macro}{\ifsi@lognone}
-% To control logging, some new switches are declared.
-% \begin{macrocode}
-\newif\ifsi@debug
-\newif\ifsi@logmin
-\newif\ifsi@lognone
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@log@err}
-%\darg{error}
-%\darg{explanation}
-% Some handy re-usable macros are defined here. These all take names
-% beginning These pop up in various places. First errors are
-% handled.
-% \begin{macrocode}
-\newcommand*{\si@log@err}[2]{%
- \ifsi@lognone\else
- \ifsi@logmin
- \PackageWarning{siunitx}{#1}%
- \else
- \PackageError{siunitx}{#1}{#2}%
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@log@warn}
-%\begin{macro}{\si@log@inf}
-%\darg{text}
-% Then warnings and information.
-% \begin{macrocode}
-\newcommand*{\si@log@warn}[1]{%
- \ifsi@lognone\else
- \ifsi@logmin\else
- \PackageWarning{siunitx}{#1}%
- \fi
- \fi}
-\newcommand*{\si@log@inf}[1]{%
- \ifsi@lognone\else
- \ifsi@logmin\else
- \PackageInfo{siunitx}{#1}%
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@log@debug}
-%\darg{debug-info}
-% The debug macro only gives output if the appropriate package option
-% is set.
-% \begin{macrocode}
-\newcommand*{\si@log@debug}[1]{%
- \ifsi@lognone\else
- \ifsi@debug
- \PackageInfo{siunitx}{#1}%
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%
-%\subsection{String comparison}
-%\begin{macro}{\si@str@ifchrstr}
-%\begin{macro}{\si@str@chrstr}
-%\darg{char}
-%\darg{string}
-% At various points, the package needs to compare two strings, to
-% find if one occurs in the other. The first test is if a single
-% character is part of a second string; this is used, for example, to
-% check that a character is valid as input. The first argument is
-% not expanded further, but the second is two allow division into
-% individual units.
-% \begin{macrocode}
-\newcommand*{\si@str@ifchrstr}[2]{%
- \begingroup
- \si@switchfalse
- \renewcommand*{\si@tempa}{#1}%
- \protected@edef\si@tempb{#2}%
- \expandafter\si@str@chrstr\si@tempb\@empty\@empty\@empty
- \ifsi@switch
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@str@chrstr#1#2\@empty{%
- \renewcommand*{\si@tempc}{#1}%
- \ifx\si@tempa\si@tempc
- \expandafter\si@switchtrue
- \else
- \ifx\@empty#2\@empty\else
- \si@str@chrstr#2\@empty\@empty
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@str@ifonlychrs}
-%\begin{macro}{\si@str@onlychrs}
-%\darg{string}
-%\darg{chars}
-% The second test builds on the first. Here, a check is made to see
-% if the first string is made up only of characters from the second
-% string. In this case, the first string is expanded before
-% testing. The second string will be expanded by the internal
-% character by character test.
-% \begin{macrocode}
-\newcommand*{\si@str@ifonlychrs}[2]{%
- \begingroup
- \si@switchtrue
- \protected@edef\si@tempa{#1}%
- \renewcommand*{\si@tempb}{#2}%
- \expandafter\si@str@onlychrs\si@tempa\@empty\@empty\@empty
- \ifsi@switch
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@str@onlychrs#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@tempb}
- {}{\si@switchfalse}%
- \ifx\@empty#2\@empty\else
- \si@str@onlychrs#2\@empty\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%
-%\subsection{Option handling}
-%\begin{macro}{\sisetup}
-%\darg{options}
-% To allow modification of options at run time, a setup macro is
-% provided.
+%\subsection{Preliminaries}
+%
+% The usual preliminaries.
% \begin{macrocode}
-\newcommand*{\sisetup}{\setkeys[si]{key}}
+\ProvidesExplPackage {siunitx} {2010/05/23} {2.0}
+ {A comprehensive (SI) units package}
% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@opt@key}
-%\darg{keyname}
-%\darg{code}
-% To aid maintenance, some shortcuts are defined for generating keys.
-% These also allow the debugging messages to be added automatically
-% to every key. First of all the basic key definition.
+%
+%\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}
-\newcommand*{\si@opt@key}[2]{%
- \define@key[si]{key}{#1}
- {#2\si@log@debug{Option #1 set to ##1}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@opt@cmdkey}
-%\doarg{default}
-%\darg{keyname}
-%\darg{function}
-% For a single command key, a function must be specified.
-% \begin{macrocode}
-\newcommand*{\si@opt@cmdkey}[3][]{%
- \define@cmdkey[si]{key}[si@]{#2}[#1]{#3}}
+\msg_set:nnnn { siunitx } { incompatible-package }
+ { Package~'#1'~incompatible. }
+ { The~#1~package~and~siunitx~are~incompatible. }
+\cs_set_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}
-%\begin{macro}{\si@opt@cmdkeys}
-%\doarg{default}
-%\darg{keyname}
-% Whereas multiple definitions do not take a function.
+%
+% Now load the support packages.
% \begin{macrocode}
-\newcommand*{\si@opt@cmdkeys}[2][]{%
- \define@cmdkeys[si]{key}[si@]{#2}[#1]}
+\RequirePackage{ amstext , array , l3keys2e }
% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@opt@boolkey}
-%\doarg{function}
-%\darg{keyname}
-% Keys which only take switch values; anything other than \opt{true}
-% or \opt{false} will generate a warning from \pkg{xkeyval}.
+%
+%\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}
-\newcommand*{\si@opt@boolkey}[2][]{%
- \define@boolkey[si]{key}[si@]{#2}[true]
- {#1\si@log@debug{Option #2 set to ##1}}}
+\cs_set: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}
-%\begin{macro}{\si@opt@choicekey}
-%\doarg{default}
-%\darg{keyname}
-%\darg{choices}
-%\darg{function}
-% A ``fill in the blanks'' choice key. In all cases, \cs{si@tempa}
-% is used to hold the value given to the key, so that \cs{ifx}
-% testing can occur.
-% \begin{macrocode}
-\newcommand*{\si@opt@choicekey}[4][]{%
- \define@choicekey*+[si]{key}{#2}[\si@tempa]{#3}[#1]
- {#4\si@log@debug{Option #2 set to ##1}}
- {\si@log@warn{Unknown value `##1' for option #2}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@opt@xchoicekey}
-%\darg{keyname}
-%\darg{choices}
-%\darg{initial-value}
-% Several of the package options can take either a choice from a list
-% of known options, or a value to be interpreted literally. To aid
-% maintenance, the necessary code can be set up here. These keys all
-% define a new macro, which must exist. The \cs{si@opt@xchoicekey}
-% macro therefore ensures that this is defined, as well as setting up
-% the \pkg{xkeyval} key.
-% \begin{macrocode}
-\newcommand*{\si@opt@xchoicekey}[3]{%
- \define@choicekey*+[si]{key}{#1}[\si@tempa]{#2}[#1]
-% \end{macrocode}
-% This code will execute if the option is on the list. There will be
-% a ``fixed'' macro with a matching name, which is used for this.
-% \begin{macrocode}
- {\si@log@debug{Option #1 set to ##1}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@#1\endcsname}{\@nameuse{si@fix@##1}}}
-% \end{macrocode}
-% The user has given something that is not on the list as an
-% argument. It is used literally.
-% \begin{macrocode}
- {\si@log@debug{Option #1 set to ##1}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@#1\endcsname}{##1}}
-% \end{macrocode}
-% Finally, the initial value of the macro is set up.
-% \begin{macrocode}
- \expandafter\newcommand\expandafter*\expandafter{%
- \csname si@#1\endcsname}%
- {\@nameuse{si@fix@#3}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@opt@compatkey}
-%\darg{package}
-%\darg{keyname}
-% An all-in-one definition for a back-compatibility key. These
-% should only be used at load time, so are automatically disabled
-% once the package is loaded. Emulation is also automatically turned
-% on.
-% \begin{macrocode}
-\newcommand*{\si@opt@compatkey}[2]{%
- \define@boolkey[si]{key}[si@old@]{#2}[true]
- {\si@log@debug{Emulating #1 package option\MessageBreak #2}%
- \sisetup{emulate=#1}%
- \si@log@debug{Option #2 set to ##1}}
- \AtEndOfPackage{\si@opt@disablekey{#2}
- {Compatibility option #2 only\MessageBreak
- available when loading siunitx package}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@opt@disablekey}
-%\darg{keyname}
-%\darg{text}
-% The ability to disable a key with a meaningful message is a must;
-% the warning will come from \currpkg, and not from \pkg{xkeyval}.
-% \begin{macrocode}
-\newcommand*{\si@opt@disablekey}[2]{%
- \key@ifundefined[si]{key}{#1}
- {}
- {\si@log@debug{Disabling key #1}%
- \si@opt@key{#1}{\si@log@warn{#2}}}}
-% \end{macrocode}
-%\end{macro}
-%
-% The \pkg{xkeyval} package option for logging is declared. This is
-% then processed to set the switches correctly.
-% \begin{macrocode}
-\si@opt@choicekey[normal]{log}{debug,verbose,normal,errors,none}
-% \end{macrocode}
-% A series of comparisons are made to assign the logging mode. The
-% \opt{normal} option is not tested, as executing the option sets the
-% switches appropriately.
-% \begin{macrocode}
- {\si@debugfalse
- \si@logminfalse
- \si@lognonefalse
- \renewcommand*{\si@tempb}{none}%
- \ifx\si@tempa\si@tempb
- \si@lognonetrue
- \fi
- \renewcommand*{\si@tempb}{minimal}%
- \ifx\si@tempa\si@tempb
- \si@logmintrue
- \fi
- \renewcommand*{\si@tempb}{debug}%
- \ifx\si@tempa\si@tempb
- \si@debugtrue
- \fi
- \renewcommand*{\si@tempb}{verbose}%
- \ifx\si@tempa\si@tempb
- \si@debugtrue
- \fi}
-% \end{macrocode}
-% A quick method to set \opt{log=debug}.
-% \begin{macrocode}
-\si@opt@boolkey{debug}
-% \end{macrocode}
-%\begin{macro}{\ifsi@strict}
-% It would be useful to be able to disable some keys, when strict
-% interpretation of the rules is desired. This is a load-time
-% option, and has to disable various options.
-% \begin{macrocode}
-\si@opt@boolkey[%
- \ifsi@strict
- \sisetup{
- obeymode=false,
- obeybold=false,
- obeyitalic=false,
- mode=maths,
- repeatunits=true,
- trapambigerr=true,
- trapambigfrac=true,
- trapambigrange=true}
- \@for\si@tempa:=obeyall,obeymode,obeyitalic,mode,unitmode,%
- valuemode,textmode,obeybold,repeatunits,trapambigerr,%
- trapambigfrac,trapambigrange\do{%
- \begingroup
- \edef\si@tempb{\endgroup
- \noexpand\si@opt@disablekey{\si@tempa}
- {Option `\si@tempa' forbidden in strict mode}}%
- \si@tempb}
- \fi]{strict}
-\AtEndOfPackage{
- \si@opt@disablekey{strict}
- {Option `strict' only available when\MessageBreak
- loading package}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@emulate}
-% The \opt{emulate} option is used for back-compatibility mode; the
-% option is only valid when loading \currpkg.
-% \begin{macrocode}
-\newcommand*{\si@emulate}{}
-\si@opt@key{emulate}{\si@addtolist{\si@emulate}{#1}}
-\AtEndOfPackage{
- \si@opt@disablekey{emulate}
- {Option `emulate' only available when\MessageBreak
- loading package}}
-% \end{macrocode}
-%\end{macro}
-%\changes{2009/03/23}{v1.2g}{Added missing \texttt{space} option
-% for various separators}
-%\begin{macro}{\si@unitsep}
-%\begin{macro}{\si@unitspace}
-%\begin{macro}{\si@errspace}
-%\begin{macro}{\si@valuesep}
-% The two \opt{\dots sep} options control the size of spaces between
-% the number and the unit (\cs{si@valuesep}), and that used to
-% represent a product (\cs{si@unitsep}). Known values here are
-% \opt{thin}, \opt{med}, \opt{medium}, \opt{thick}, \opt{cdot},
-% \opt{tightcdot}\footnote{Both \cs{cdot}-based options only valid
-% for \opt{unitsep}.} and \opt{none};\footnote{Only valid for
-% \opt{valuesep}.} other entries will be treated as custom spaces.
-% \begin{macrocode}
-\si@opt@xchoicekey{unitsep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{thin}
-\si@opt@xchoicekey{unitspace}{space,thin,med,medium,thick,
- none}{thin}
-\si@opt@xchoicekey{errspace}{space,thin,med,medium,thick,
- none}{none}
-\si@opt@xchoicekey{valuesep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{thin}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@digitsep}
-% Separation of digits in large numbers is controlled by the
-% \opt{digitsep} option. As with the other \opt{sep} values, this
-% one has a choice of possible values. The list is quite long, so
-% that a range of options are handled automatically. Notice that
-% \opt{digitsep=none} will be used for no separation at all.
-% \begin{macrocode}
-\si@opt@xchoicekey{digitsep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{thin}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@decimalsymbol}
-% The symbol used for the decimal position is varied here. There are
-% only two real options, but options are given for the name of a full
-% stop.
-% \begin{macrocode}
-\si@opt@xchoicekey{decimalsymbol}{comma,stop,fullstop,period,
- cdot,tightcdot}{fullstop}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@anglesep}
-% The separator between degrees and minutes, and between minutes and
-% seconds, when using \cs{ang}.
-% \begin{macrocode}
-\si@opt@xchoicekey{anglesep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{none}
-% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ifsi@obeymode}
-% The first test for the font control is whether to respect the
-% surrounding maths or text mode.
-% \begin{macrocode}
-\si@opt@boolkey{obeymode}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@numtextmode}
-%\begin{macro}{\ifsi@unittextmode}
-% The output of the package can be typeset using either text or maths
-% mode fonts. Two switches are needed, for numbers and units.
-% \begin{macrocode}
-\newif\ifsi@numtextmode
-\newif\ifsi@unittextmode
-% \end{macrocode}
%\end{macro}
%\end{macro}
-% The \opt{textmode} option has to set both flags.
-% \begin{macrocode}
-\si@opt@choicekey[true]{textmode}{true,false}
- {\si@numtextmodefalse
- \si@unittextmodefalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@numtextmodetrue
- \si@unittextmodetrue
- \fi}
-% \end{macrocode}
-% The \opt{mode} option applies to numbers and units.
-% \begin{macrocode}
-\si@opt@choicekey{mode}{math,maths,text}
- {\si@numtextmodefalse
- \si@unittextmodefalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@numtextmodetrue
- \si@unittextmodetrue
- \fi}
-% \end{macrocode}
-% Now the two options for numbers or units alone.
-% \begin{macrocode}
-\si@opt@choicekey{valuemode}{math,maths,text}
- {\si@numtextmodefalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@numtextmodetrue
- \fi}
-\si@opt@choicekey{unitmode}{math,maths,text}
- {\si@unittextmodefalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@unittextmodetrue
- \fi}
-% \end{macrocode}
-%\begin{macro}{\ifsi@obeyfamily}
-% The package can work to match the font family (serif, sans serif,
-% typewriter) of the surrounding text. This is controlled by a
-% Boolean option.
-% \begin{macrocode}
-\si@opt@boolkey{obeyfamily}
-% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ifsi@obeybold}
-% The package can attempt to respect bold, or may ignore it.
+%\end{macro}
+%
+%\begin{macro}{\_l_siunitx_error_bool}
+%\begin{macro}{\_siunitx_error:nxx}
+%\begin{macro}{\_siunitx_error:nx}
+%\begin{macro}{\_siunitx_error:n}
+%\begin{macro}{\_siunitx_error:nV}
+% General-purpose functions for throwing errors.
% \begin{macrocode}
-\si@opt@boolkey{obeybold}
+\bool_new:N \_l_siunitx_error_bool
+\cs_set_protected:Npn \_siunitx_error:nxx #1#2#3 {
+ \bool_set_true:N \_l_siunitx_error_bool
+ \msg_error:nnxx { siunitx } {#1} {#2} {#3}
+}
+\cs_set_protected:Npn \_siunitx_error:nx #1#2 {
+ \_siunitx_error:nxx {#1} {#2} { }
+}
+\cs_set_protected:Npn \_siunitx_error:n #1 {
+ \_siunitx_error:nxx {#1} { } { }
+}
+\cs_generate_variant:Nn \_siunitx_error:nx { nV }
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ifsi@inlinebtext}
-% For inline maths, two options for checking what is bold are
-% available, the maths environment (\ie \cs{boldmath}) and the
-% surrounding text (\cs{textbf} or \cs{bffamily}).
+%\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}
-\newif\ifsi@inlinebtext
-\si@opt@choicekey{inlinebold}{text,maths,math}
- {\si@inlinebtextfalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@inlinebtexttrue
- \fi}
+\AtBeginDocument {
+ \cs_if_free:cT { T@TS1 }
+ {
+ \DeclareFontEncoding { TS1 } { } { }
+ \DeclareFontSubstitution { TS1 } { cmr } { m } { n }
+ }
+}
% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@obeyitalic}
-% Italic is slightly different to bold, as there is no convenient
-% switch for maths. Thus a choice key is used, with the appropriate
-% check.
+%
+%\begin{macro}{\_c_siunitx_minus_tl}
+% To allow the correct symbol to appear in text mode: this is the same
+% as \cs{textminus} from \pkg{textcomp}.
% \begin{macrocode}
-\si@opt@boolkey{obeyitalic}
+\DeclareTextSymbolDefault \_c_siunitx_minus_tl { TS1 }
+\DeclareTextSymbol \_c_siunitx_minus_tl { TS1 } { 61 }
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ifsi@detectdisplay}
-% For handling display mathematics, a setting is needed for whether to
-% treat it differently from other maths.
+%
+%\begin{macro}{\_c_siunitx_mu_tl}
+% The lack of an upright mu has to be sorted out.
% \begin{macrocode}
-\si@opt@boolkey{detectdisplay}
+\DeclareTextSymbol \_c_siunitx_mu_tl { TS1 } { 181 }
+\DeclareTextSymbolDefault \_c_siunitx_mu_tl { TS1 }
% \end{macrocode}
%\end{macro}
-% The option to obey all font switching commands is Boolean-like but
-% needs alternative setup.
+%
+% Some package redefine \cs{Omega} to be slanted and move the original
+% symbol to \cs{upOmega}. This is handled here.
% \begin{macrocode}
-\si@opt@choicekey[true]{obeyall}{true,false}
- {\si@obeyboldfalse
- \si@obeyitalicfalse
- \si@obeymodefalse
- \si@obeyfamilyfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@obeyboldtrue
- \si@obeyitalictrue
- \si@obeymodetrue
- \si@obeyfamilytrue
- \fi}
+\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}{\si@valuemathsrm}
-%\begin{macro}{\si@valuemathssf}
-%\begin{macro}{\si@valuemathstt}
-%\begin{macro}{\si@unitmathsrm}
-%\begin{macro}{\si@unitmathssf}
-%\begin{macro}{\si@unitmathstt}
-% The fonts used by the package default to the obvious \LaTeX\ ones;
-% however, this needs to be exposed to user modification. First the
-% maths mode fonts are sorted out.
+%
+%\begin{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}
-\si@opt@cmdkeys{valuemathsrm,valuemathssf,valuemathstt}
-\si@opt@cmdkeys{unitmathsrm,unitmathssf,unitmathstt}
+\cs_set_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_set_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}
@@ -4087,1054 +3803,1094 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-% To make life easier for the user, US spellings are provided for the
-% maths keys.
+%
+% Unknown options should raise an \pkg{siunitx}-specific error message.
% \begin{macrocode}
-\si@opt@key{valuemathrm}{\sisetup{valuemathsrm=#1}}
-\si@opt@key{valuemathsf}{\sisetup{valuemathssf=#1}}
-\si@opt@key{valuemathtt}{\sisetup{valuemathstt=#1}}
-\si@opt@key{unitmathrm}{\sisetup{unitmathsrm=#1}}
-\si@opt@key{unitmathsf}{\sisetup{unitmathssf=#1}}
-\si@opt@key{unitmathtt}{\sisetup{unitmathstt=#1}}
+\keys_define:nn { siunitx } {
+ unknown .code:n =
+ {
+ \msg_error:nnx { siunitx } { unknown-option }
+ { \exp_not:V \l_keys_key_tl }
+ }
+}
% \end{macrocode}
-% The combined options are given, for setting numbers and units
-% at the same time.
+%
+%\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}
-\si@opt@key{mathsrm}{\sisetup{valuemathsrm=#1,unitmathsrm=#1}}
-\si@opt@key{mathssf}{\sisetup{valuemathssf=#1,unitmathssf=#1}}
-\si@opt@key{mathstt}{\sisetup{valuemathstt=#1,unitmathstt=#1}}
-\si@opt@key{mathrm}{\sisetup{valuemathsrm=#1,unitmathsrm=#1}}
-\si@opt@key{mathsf}{\sisetup{valuemathssf=#1,unitmathssf=#1}}
-\si@opt@key{mathtt}{\sisetup{valuemathstt=#1,unitmathstt=#1}}
+\clist_new:N \_l_siunitx_option_deactivate_clist
+\cs_set_protected_nopar:Npn \_siunitx_option_deactivate:n #1 {
+ \clist_put_right:Nn \_l_siunitx_option_deactivate_clist {#1}
+}
+\cs_set_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}
-%\begin{macro}{\si@valuetextrm}
-%\begin{macro}{\si@valuetextsf}
-%\begin{macro}{\si@valuetexttt}
-%\begin{macro}{\si@unittextrm}
-%\begin{macro}{\si@unittextsf}
-%\begin{macro}{\si@unittexttt}
-% The same thing for text mode fonts. Once again the default values
-% are pretty obvious.
+%\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}
-\si@opt@cmdkeys{valuetextrm,valuetextsf,valuetexttt}
-\si@opt@cmdkeys{unittextrm,unittextsf,unittexttt}
-\si@opt@key{textrm}{\sisetup{unittextrm=#1,valuetextrm=#1}}
-\si@opt@key{textsf}{\sisetup{unittextsf=#1,valuetextsf=#1}}
-\si@opt@key{texttt}{\sisetup{unittexttt=#1,valuetexttt=#1}}
+\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:NT}
+%\begin{macro}{\_siunitx_cs_if_tl:NTF}
+%\begin{macro}[aux]{\_siunitx_cs_if_tl_aux:w}
+%\begin{macro}{\_siunitx_cs_if_macro:NT}
+% 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 LaTeX2e 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:Nnn \_siunitx_cs_if_tl:N { T , TF }
+ {
+ \exp_after:wN \_siunitx_cs_if_tl_aux:w
+ \token_to_meaning:N #1 MACRO \q_nil
+ {
+ \cs_if_exist:cTF { \cs_to_str:N #1 ~ }
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+ { \prg_return_false: }
+ }
+ \cs_set_nopar:Npn \_siunitx_cs_if_tl_aux:w #1 MACRO #2 \q_nil
+ { \tl_if_empty:nTF {#1} }
+ \prg_new_conditional:Nnn \_siunitx_cs_if_macro:N { T }
+ {
+ \exp_after:wN \_siunitx_cs_if_tl_aux:w
+ \token_to_meaning:N #1 MACRO \q_nil
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+}
+% \end{macrocode}
+%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
-%\changes{v1.1}{2008/09/22}{Added \opt{numdiv} option}
-%\begin{macro}{\si@numdigits}
-%\begin{macro}{\si@numdiv}
-%\begin{macro}{\si@numdecimal}
-%\begin{macro}{\si@numexp}
-%\begin{macro}{\si@numprod}
-%\begin{macro}{\si@numgobble}
-%\begin{macro}{\si@numsign}
-%\begin{macro}{\si@numcloseerr}
-%\begin{macro}{\si@numopenerr}
-%\begin{macro}{\si@numaddn}
-% The list of possible valid characters for parsing numbers is set
-% up. This is similar to \numprint, but with the \opt{extra} class,
-% and with characters ignored with no output renamed as \opt{gobble}.
+%
+%\begin{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}
-\si@opt@cmdkeys{numdigits,numdecimal,numexp,numgobble,numsign,%
- numcloseerr,numopenerr,numaddn,numprod,numdiv}
+\cs_set_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}
+%
+%\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_set_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_set_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_weight_bool}
+%\begin{macro}{\_l_siunitx_detect_italic_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-italic = false,
+ detect-mode = false,
+ detect-weight = false
+ },
+ detect-all / true .meta:n =
+ {
+ detect-family = true,
+ detect-italic = true,
+ detect-mode = 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-weight .choice:,
+ detect-inline-weight .value_required:,
+ detect-inline-weight /
+ combined .code:n =
+ { \tl_set:Nn \_l_siunitx_detect_inline_weight_tl { combined } },
+ 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_italic_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-italic = true,
+ detect-mode = true,
+ detect-weight = true
+ },
+ detect-none / true .meta:n =
+ {
+ detect-family = false,
+ detect-italic = false,
+ detect-mode = false,
+ detect-weight = false
+ },
+ detect-weight .bool_set:N = \_l_siunitx_detect_weight_bool
+}
+% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\si@numvalid}
-%\begin{macro}{\si@numextra}
-% The various valid characters are collected together in a single
-% macro for later. In common with the above macros, this one starts
-% \cs{si@num\ldots}. The order here is the order the values are
-% tested later on.
+%\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}
-\newcommand*{\si@numextra}{%
- \si@numopenerr\si@numcloseerr\si@numaddn}
-\newcommand*{\si@numvalid}{\si@numgobble\si@numexp\si@numsign
- \si@numdecimal\si@numdigits\si@numextra\si@numprod\si@numdiv}
+\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}{\ifsi@seperr}
-%\begin{macro}{\ifsi@trapambigerr}
-%\begin{macro}{\si@openerr}
-%\begin{macro}{\si@closeerr}
-% An option to control whether numerical error values are printed with
-% or separate from the number.
+%
+%\begin{macro}{\_l_siunitx_font_family_tl}
+% Also some token storage.
% \begin{macrocode}
-\si@opt@boolkey{seperr}
-\si@opt@boolkey{trapambigerr}
-\si@opt@cmdkeys{openerr,closeerr}
+\tl_new:N \_l_siunitx_font_family_tl
% \end{macrocode}
%\end{macro}
+%
+%\begin{macro}{\_siunitx_font_italic:}
+%\begin{macro}{\_siunitx_font_weight:}
+% These could be token lists or functions!
+% \begin{macrocode}
+\cs_set_nopar:Npn \_siunitx_font_italic: { }
+\cs_set_nopar:Npn \_siunitx_font_weight: { }
+% \end{macrocode}
%\end{macro}
%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@sepfour}
-% With four digits in a number, separating may or may not be desired.
-% Note that this option is the same as one for \numprint.
+%
+%\begin{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}
-\si@opt@boolkey{sepfour}
+\cs_set_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_italic_bool
+ { \_siunitx_detect_font_italic: }
+ \bool_if:NT \_l_siunitx_detect_mode_bool
+ { \_siunitx_detect_font_mode: }
+ }
+}
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ifsi@retainplus}
-% An option to keep an explicit positive sign.
+%
+%\begin{macro}{\_siunitx_detect_font_init:}
+% Set up the basic macros on the assumption nothing happens.
% \begin{macrocode}
-\si@opt@boolkey{retainplus}
+\cs_set_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_italic: { \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}{\si@expbase}
-%\begin{macro}{\si@expproduct}
-% The options for exponents are set up.
+%
+%\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_set_protected_nopar:Npn \_siunitx_detect_font_weight: {
+ \mode_if_math:TF
+ {
+ \mode_if_inner:TF
+ {
+ \use:c
+ {
+ _siunitx_detect_font_weight_
+ \_l_siunitx_detect_inline_weight_tl
+ :
+ }
+ }
+ {
+ \bool_if:NTF \_l_siunitx_detect_display_math_bool
+ { \_siunitx_detect_font_weight_math: }
+ { \_siunitx_detect_font_weight_text: }
+ }
+ }
+ { \_siunitx_detect_font_weight_text: }
+}
+% \end{macrocode}
+%\end{macro}
+%\begin{macro}{\_siunitx_detect_font_weight_combined:}
+%\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}
-\si@opt@xchoicekey{expproduct}{times,tighttimes,
- cdot,tightcdot}{times}
-\si@opt@xchoicekey{expbase}{ten}{ten}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_weight_combined: {
+ \_siunitx_detect_font_weight_math:
+ \_siunitx_detect_font_weight_text:
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_weight_math: {
+ \tl_if_eq:nVT { bold } \math@version
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ {
+ \boldmath
+ \bfseries
+ }
+ }
+ \tl_if_eq:nVT { light } \math@version
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ { \lseries }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_weight_text: {
+ \tl_set:Nx \_l_siunitx_tmpa_tl { \exp_args:NV \tl_head_i:n \f@series }
+ \tl_if_eq:nVT { b } \_l_siunitx_tmpa_tl
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ {
+ \boldmath
+ \bfseries
+ }
+ }
+ \tl_if_eq:nVT { l } \_l_siunitx_tmpa_tl
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ { \lseries }
+ }
+}
% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ifsi@allowzeroexp}
-% The package normally prevents \num[allowzeroexp]{e0}.
+%\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}
-\si@opt@boolkey{allowzeroexp}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_family: {
+ \_siunitx_detect_font_family_text:
+ \bool_if:NT \_l_siunitx_detect_display_math_bool
+ {
+ \mode_if_math:T
+ { \mode_if_inner:F { \_siunitx_detect_font_family_math: } }
+ }
+}
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\si@prefixproduct}
-% The marker for multiplication in prefixes.
-% \begin{macrocode}
-\si@opt@xchoicekey{prefixproduct}{times,tighttimes,cdot,
- tightcdot,none}{times}
+%\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_set_protected_nopar:Npn \_siunitx_detect_font_family_math: {
+ \tl_set:Nn \_l_siunitx_font_family_tl { rm }
+ \intexpr_compare:nNnT
+ { \int_use:N \fam } = { \int_use:N \_c_siunitx_mathsf_int }
+ { \tl_set:Nn \_l_siunitx_font_family_tl { sf } }
+ \intexpr_compare:nNnT
+ { \int_use:N \fam } = { \int_use:N \_c_siunitx_mathtt_int }
+ { \tl_set:Nn \_l_siunitx_font_family_tl { tt } }
+}
+\cs_set_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}
-%\begin{macro}{\si@prefixbase}
-% In the same area, the power for prefixes is variable. Here, two
-% choices ar needed.
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_detect_font_italic:}
+% The italic test uses \cs{f@shape} as a handy indicator.
% \begin{macrocode}
-\si@opt@xchoicekey{prefixbase}{ten,two}{ten}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_italic: {
+ \tl_if_eq:nVT { it } \f@shape
+ { \cs_set_nopar:Npn \_siunitx_font_italic: { \itshape } }
+}
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ifsi@prefixsymbolic}
-% Unit prefixes can be given as either symbols or numerically.
+%
+%\begin{macro}{\_siunitx_detect_font_mode:}
+% The mode switch works from the fact that math mode output it the
+% standard.
% \begin{macrocode}
-\si@opt@boolkey{prefixsymbolic}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_mode: {
+ \mode_if_math:F
+ { \bool_set_false:N \_l_siunitx_font_math_mode_bool }
+}
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ifsi@num@padlead}
-%\begin{macro}{\ifsi@num@padtrail}
-% A setting is needed to indicate when to add zeros to decimal
-% numbers, either before the decimal marker (|.1| giving
-% ``\num[padnumber=all]{.1}'') or after (|1.| giving
-% ``\num[padnumber=all]{1.}'').
-% \begin{macrocode}
-\newif\ifsi@num@padlead
-\newif\ifsi@num@padtrail
-\si@opt@choicekey[all]{padnumber}
- {leading,lead,trailing,trail,all,both,true,none,false}
- {\si@num@padleadfalse
- \si@num@padtrailfalse
- \renewcommand*{\si@tempb}{leading}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \fi
- \renewcommand*{\si@tempb}{lead}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \fi
- \renewcommand*{\si@tempb}{trailing}%
- \ifx\si@tempa\si@tempb
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{trail}%
- \ifx\si@tempa\si@tempb
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{all}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{both}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \si@num@padtrailtrue
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@sign}
-%\begin{macro}{\ifsi@num@signmant}
-%\begin{macro}{\ifsi@num@signexp}
-% Some new switches for adding signs to numbers
-% \begin{macrocode}
-\newif\ifsi@num@signmant
-\newif\ifsi@num@signexp
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-% Signs can be added to numbers by default. Two options are needed
-% here; whether to add a sign by default, and what the sign is.
-% \begin{macrocode}
-\si@opt@xchoicekey{sign}{plus,minus,pm,mp}{plus}
-\si@opt@choicekey[all]{addsign}
- {mantissa,exponent,mant,exp,all,both,true,none,false}
-% \end{macrocode}
-%\end{macro}
-% The option is now processed.
-% \begin{macrocode}
- {\si@num@signmantfalse
- \si@num@signexpfalse
- \renewcommand*{\si@tempb}{mantissa}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \fi
- \renewcommand*{\si@tempb}{mant}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \fi
- \renewcommand*{\si@tempb}{exponent}%
- \ifx\si@tempa\si@tempb
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{exp}%
- \ifx\si@tempa\si@tempb
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{all}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{both}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \si@num@signexptrue
- \fi}
-% \end{macrocode}
-%\begin{macro}{\ifsi@tightpm}
-%\begin{macro}{\si@pm}
-% To reduce spacing, it might be necessary to use a ``tight'' $\pm$
-% sign.
-% \begin{macrocode}
-\si@opt@boolkey{tightpm}
-\newcommand*{\si@pm}{%
- \ifsi@tightpm
- \si@fix@tightpm
- \else
- \si@fix@pm
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@ang@padsmall}
-%\begin{macro}{\ifsi@ang@padlarge}
-% A switch for determining whether to typeset |\ang{;;1}| as
-% \ang[padangle=both]{;;1} or \ang[padangle=none]{;;1}. First, two
-% new Boolean switches are needed to indicate padding.
-% \begin{macrocode}
-\newif\ifsi@ang@padsmall
-\newif\ifsi@ang@padlarge
-\si@opt@choicekey[all]{padangle}
- {small,large,all,both,true,none,false}
- {\si@ang@padsmallfalse
- \si@ang@padlargefalse
- \renewcommand*{\si@tempb}{small}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \fi
- \renewcommand*{\si@tempb}{large}%
- \ifx\si@tempa\si@tempb
- \si@ang@padlargetrue
- \fi
- \renewcommand*{\si@tempb}{all}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \si@ang@padlargetrue
- \fi
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \si@ang@padlargetrue
- \fi
- \renewcommand*{\si@tempb}{both}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \si@ang@padlargetrue
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@ang@toarc}
-%\begin{macro}{\ifsi@ang@todec}
-% To control whether angles are formatted as decimals or
-% degrees--minutes--seconds, a package option plus two switches are
-% needed. The later format is referred to as ``\opt{arc}'' most
-% readily. An option to leave the input unchanged is also provided.
-% \begin{macrocode}
-\newif\ifsi@ang@toarc
-\newif\ifsi@ang@todec
-\si@opt@choicekey[all]{angformat}
- {dec,decimal,arc,dms,unchanged,none}
- {\si@ang@toarcfalse
- \si@ang@todecfalse
- \renewcommand*{\si@tempb}{dec}%
- \ifx\si@tempa\si@tempb
- \si@ang@todectrue
- \fi
- \renewcommand*{\si@tempb}{decimal}%
- \ifx\si@tempa\si@tempb
- \si@ang@todectrue
- \fi
- \renewcommand*{\si@tempb}{arc}%
- \ifx\si@tempa\si@tempb
- \si@ang@toarctrue
- \fi
- \renewcommand*{\si@tempb}{dms}%
- \ifx\si@tempa\si@tempb
- \si@ang@toarctrue
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@astroang}
-% A slightly odd option to allow the method used by astronomers for
-% angles.
-% \begin{macrocode}
-\si@opt@boolkey{astroang}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@strictarc}
-% For the \cs{ang} macro, the default is to require two semi-colons
-% in the input for arc angles. This is controlled here.
-% \begin{macrocode}
-\si@opt@boolkey{strictarc}
-% \end{macrocode}
-%\end{macro}
-%\changes{v1.1}{2008/09/03}{Added \opt{tabparseonly} option}
-%\begin{macro}{\ifsi@tab@fixed}
-%\begin{macro}{\ifsi@tabparseonly}
-%\begin{macro}{\si@tabnumalign}
-%\begin{macro}{\si@tab@rfill@S}
-%\begin{macro}{\si@tab@lfill@S}
-% To determine the control of table alignment, two options are
-% provided. The \opt{tabnumalign} option controls which centring method
-% is used, and the fills used for achieving this.
-% \begin{macrocode}
-\newif\ifsi@tab@fixed
-\si@opt@boolkey{tabparseonly}
-\si@opt@choicekey{tabnumalign}
- {centredecimal,centerdecimal,right,left,centre,center}
- {\si@tab@fixedtrue
- \def\si@tab@rfill@S{0.5}%
- \def\si@tab@lfill@S{0.5}%
- \renewcommand*{\si@tempb}{right}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@S{0}%
- \def\si@tab@lfill@S{1}%
- \fi
- \renewcommand*{\si@tempb}{left}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@S{1}%
- \def\si@tab@lfill@S{0}%
- \fi
- \renewcommand*{\si@tempb}{centredecimal}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@tab@fixedfalse
- \fi
- \renewcommand*{\si@tempb}{centerdecimal}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@tab@fixedfalse
- \fi}
-\si@opt@key{tabalign}{\sisetup{tabnumalign=#1,tabtextalign=#1,
- tabunitalign=#1}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@tabalignexp}
-% A switch for aligning exponents.
-% \begin{macrocode}
-\si@opt@boolkey{tabalignexp}
-\si@opt@boolkey[%
- \si@tabalignexpfalse
- \ifsi@tabexpalign
- \expandafter\si@tabalignexptrue
- \fi
- ]{tabexpalign}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@mantprecnt}
-%\begin{macro}{\si@tab@mantpostcnt}
-%\begin{macro}{\si@tab@expprecnt}
-%\begin{macro}{\si@tab@exppostcnt}
-%\begin{macro}{\ifsi@tab@mantsign}
-%\begin{macro}{\ifsi@tab@expsign}
-% To process the format information, various internal
-% number-processing macros are used. First, some
-% storage areas are created.
-% \begin{macrocode}
-\newcount\si@tab@mantprecnt
-\newcount\si@tab@mantpostcnt
-\newcount\si@tab@expprecnt
-\newcount\si@tab@exppostcnt
-\newif\ifsi@tab@mantsign
-\newif\ifsi@tab@expsign
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-% The input is split into a mantissa and exponent, then passed to a
-% re-useable macro for further processing.
-% \begin{macrocode}
-\si@opt@cmdkey{tabformat}
- {\si@num@fixpm
- \renewcommand*{\si@num@arg}{tabformat data}%
- \renewcommand*{\si@num@exp}{}%
- \renewcommand*{\si@num@mant}{}%
- \si@tab@mantsignfalse
- \si@tab@expsignfalse
- \si@switchfalse
- \si@num@sepmantexp{#1}%
-% \end{macrocode}
-% When checking for a sign, the internal flag for finding but
-% deleting a plus sign is used.
-% \begin{macrocode}
- \si@num@sepsign{mant}%
- \ifx\@empty\si@num@mantsign\@empty
- \ifsi@num@delplus
- \expandafter\expandafter\expandafter\si@tab@mantsigntrue
- \fi
- \else
- \expandafter\si@tab@mantsigntrue
- \fi
- \si@num@sepsign{exp}%
- \ifx\@empty\si@num@expsign\@empty
- \ifsi@num@delplus
- \expandafter\expandafter\expandafter\si@tab@expsigntrue
- \fi
- \else
- \expandafter\si@tab@expsigntrue
- \fi
- \si@opt@proctform{mant}%
- \si@opt@proctform{exp}%
-% \end{macrocode}
-%\changes{v1.0h}{2008/08/02}{Simplified warnings for \opt{tabformat}}
-% If both the integer and decimal parts are empty, then something has
-% probably gone wrong.
-% \begin{macrocode}
- \ifnum\si@tab@mantpostcnt=\z@\relax
- \ifnum\si@tab@mantprecnt=\z@\relax
- \si@log@err{Empty mantissa argument for tabformat}
- {The argument `#1' contains no valid entry for
- a mantissa\MessageBreak It should be of the
- form `m.n', where m and n are integers}%
- \fi
- \fi
-% \end{macrocode}
-% If \opt{tabformat} has been given with
-% \opt{tabnumalign=centredecimal} active, then the alignment is
-% changed to centred.
-% \begin{macrocode}
- \ifsi@tab@fixed\else
- \sisetup{tabnumalign=centre}%
- \fi
- \let\pm\si@num@pm
- \let\mp\si@num@mp}
-% \end{macrocode}
-%\begin{macro}{\si@opt@proctform}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% Processing the number further uses the \cs{si@num@digits} macro.
-% The results are stored in the appropriate counter.
-% \begin{macrocode}
-\newcommand*{\si@opt@proctform}[1]{%
- \renewcommand*{\si@num@predec}{}%
- \renewcommand*{\si@num@postdec}{}%
- \si@switchfalse
- \expandafter\si@ifnotmtarg\expandafter{%
- \csname si@num@#1\endcsname}
- {\expandafter\expandafter\expandafter\si@num@digits
- \csname si@num@#1\endcsname\@empty\@empty}%
- \csname si@tab@#1precnt\endcsname\z@\relax
- \csname si@tab@#1postcnt\endcsname\z@\relax
- \ifx\@empty\si@num@predec\@empty\else
- \csname si@tab@#1precnt\endcsname\si@num@predec\relax
- \fi
- \ifx\@empty\si@num@postdec\@empty\else
- \csname si@tab@#1postcnt\endcsname\si@num@postdec\relax
- \fi}
-% \end{macrocode}
-%\end{macro}
-% The alignment of tabular material when not processed by \cs{num}
-% needs to be available.
-% \begin{macrocode}
-\si@opt@choicekey{tabtextalign}{left,right,centre,center}
-% \end{macrocode}
-%\begin{macro}{\si@tab@rfill@t}
-%\begin{macro}{\si@tab@lfill@t}
-% By default, centring happens on both sides of the content of
-% tabular material.
-% \begin{macrocode}
- {\def\si@tab@rfill@t{0.5}%
- \def\si@tab@lfill@t{0.5}%
- \renewcommand*{\si@tempb}{right}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@t{0}%
- \def\si@tab@lfill@t{1}%
- \fi
- \renewcommand*{\si@tempb}{left}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@t{1}%
- \def\si@tab@lfill@t{0}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-% The alignment of unit columns for tabular material has a similar
-% control option.
-% \begin{macrocode}
-\si@opt@choicekey{tabunitalign}{left,right,centre,center}
-% \end{macrocode}
-%\begin{macro}{\si@tab@rfill@s}
-%\begin{macro}{\si@tab@lfill@s}
-% By default, centring happens on both sides of the content of
-% tabular material.
-% \begin{macrocode}
- {\def\si@tab@rfill@s{0.5}%
- \def\si@tab@lfill@s{0.5}%
- \renewcommand*{\si@tempb}{right}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@s{0}%
- \def\si@tab@lfill@s{1}%
- \fi
- \renewcommand*{\si@tempb}{left}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@s{1}%
- \def\si@tab@lfill@s{0}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@fixdp}
-%\changes{v1.1}{2008/08/22}{Modified to work with \opt{fixsf} option}
-%\begin{macro}{\si@num@dp}
-%\changes{v1.1}{2008/08/22}{Modified to work with \opt{fixsf} option}
-% To allow control of rounding, two options are needed. One sets how
-% many fixed digits to use, the second turns this function on and
-% off.
-% \begin{macrocode}
-\si@opt@boolkey[%
- \ifsi@fixdp
- \expandafter\si@fixsffalse
- \fi]{fixdp}
-\newcount\si@num@dp
-\si@opt@key{dp}{%
- \si@str@ifonlychrs{#1}{0123456789}
- {\si@num@dp#1\relax
- \si@fixdptrue
- \si@fixsffalse}
- {\si@log@err{Invalid input for dp option}
- {The dp option must be given a positive integer}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@fixsf}
-%\begin{macro}{\si@num@sf}
-% A similar approach for fixing significant figures.
-% \begin{macrocode}
-\si@opt@boolkey[%
- \ifsi@fixsf
- \expandafter\si@fixdpfalse
- \fi]{fixsf}
-\newcount\si@num@sf
-\si@opt@key{sf}{%
- \si@str@ifonlychrs{#1}{0123456789}
- {\si@num@sf#1\relax
- \ifnum\si@num@sf=\z@\relax
- \si@log@warn{Setting sf=0 disables function}%
- \si@fixsffalse
- \else
- \si@fixsftrue
- \si@fixdpfalse
- \fi}
- {\si@log@err{Invalid input for sf option}
- {The sf option must be given a positive integer}}}
-% \end{macrocode}
+%
+%\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_set:Npn \_siunitx_number_mathrm:n #1 { }
+\cs_set:Npn \_siunitx_number_mathsf:n #1 { }
+\cs_set:Npn \_siunitx_number_mathtt:n #1 { }
+\cs_set_nopar:Npn \_siunitx_number_textrm: { }
+\cs_set_nopar:Npn \_siunitx_number_textsf: { }
+\cs_set_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}
-%\begin{macro}{\ifsi@tabautofit}
-% To apply rounding automatically in a table, a separate option is
-% used.
-% \begin{macrocode}
-\si@opt@boolkey{tabautofit}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@xspace}
-% Unit macros on their own may need \pkg{xpsace}.
-% \begin{macrocode}
-\si@opt@boolkey{xspace}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@prespace}
-% \begin{macrocode}
-\si@opt@boolkey
- [\si@unt@numfalse
- \ifsi@prespace
- \si@unt@numtrue
- \fi]
- {prespace}
+%\end{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_set_nopar:Npn \_siunitx_unit_mathrm: { }
+\cs_set_nopar:Npn \_siunitx_unit_mathsf: { }
+\cs_set_nopar:Npn \_siunitx_unit_mathtt: { }
+\cs_set_nopar:Npn \_siunitx_unit_textrm: { }
+\cs_set_nopar:Npn \_siunitx_unit_textsf: { }
+\cs_set_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}
-%\begin{macro}{\ifsi@allowoptarg}
-% For \unitsdef users, a method to absorb optional arguments is
-% needed.
+%\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}
-\si@opt@boolkey{allowoptarg}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@allowlitunits}
-% To allow literal input in units.
-% \begin{macrocode}
-\si@opt@boolkey{allowlitunits}
-% \end{macrocode}
-%\end{macro}
-%\changes{v1.1d}{2008/10/29}{Minor bug with \opt{per} option fixed}
-%\begin{macro}{\ifsi@frac}
-%\begin{macro}{\ifsi@slash}
-%\begin{macro}{\ifsi@stickyper}
-% The option processing for formatting units with \cs{per} in them
-% needs two switches.
-% \begin{macrocode}
-\newif\ifsi@slash
-\newif\ifsi@frac
-\si@opt@boolkey{stickyper}
-\si@opt@choicekey[reciprocal]{per}
- {reciprocal,rp,power,slash,frac,fraction}
- {\si@slashfalse
- \si@fracfalse
- \let\si@frac\si@frc@frac
- \renewcommand*{\si@tempb}{slash}%
- \ifx\si@tempa\si@tempb
- \si@fractrue
- \si@slashtrue
- \let\si@frac\si@frc@slash
- \fi
- \renewcommand*{\si@tempb}{frac}%
- \ifx\si@tempa\si@tempb
- \si@fractrue
- \fi
- \renewcommand*{\si@tempb}{fraction}%
- \ifx\si@tempa\si@tempb
- \si@fractrue
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@slash}
-% For the \opt{slash} option, the separator can be customised.
-% \begin{macrocode}
-\si@opt@xchoicekey{slash}{slash}{slash}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@repeatunits}
-%\begin{macro}{\ifsi@addunitpower}
-% An option is needed for cases where units should be repeated.
-% \begin{macrocode}
-\newif\ifsi@repeatunits
-\newif\ifsi@addunitpower
-\si@opt@choicekey[true]{repeatunits}{true,false,power}
- {\si@repeatunitsfalse
- \si@addunitpowerfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@repeatunitstrue
- \fi
- \renewcommand*{\si@tempb}{power}%
- \ifx\si@tempa\si@tempb
- \si@addunitpowertrue
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@trapambigfrac}
-%\begin{macro}{\si@closefrac}
-%\begin{macro}{\si@openfrac}
-% Macros for the right and left brackets added to potentially
-% ambiguous denominators.
-% \begin{macrocode}
-\si@opt@boolkey{trapambigfrac}
-\si@opt@cmdkeys{closefrac,openfrac}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-% In the case of fractional handling of the \cs{per} operator,
-% further refinement is available.
-% \begin{macrocode}
-\si@opt@choicekey[frac]{fraction}
- {frac,nicefrac,nice,sfrac,xfrac,uglyfrac,ugly}
- {\let\si@frac\si@frc@frac
- \renewcommand*{\si@tempb}{nicefrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@nice
- \fi
- \renewcommand*{\si@tempb}{uglyfrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@ugly
- \fi
- \renewcommand*{\si@tempb}{nice}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@nice
- \fi
- \renewcommand*{\si@tempb}{sfrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@sfrac
- \fi
- \renewcommand*{\si@tempb}{xfrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@sfrac
- \fi
- \renewcommand*{\si@tempb}{ugly}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@ugly
- \fi}
-% \end{macrocode}
-%\begin{macro}{\si@load}
-%\begin{macro}{\si@noload}
-% Loading of support files is controlled by two keys. The first
-% defines a list of files that may be loaded, the second a list that
-% will not. This makes it easy to exclude a single file from a long
-% list.
-% \begin{macrocode}
-\si@opt@cmdkeys{load,noload}
-\si@opt@key{alsoload}{\si@addtolist{\si@load}{#1}}
-\AtEndOfPackage{
- \si@opt@disablekey{load}
- {Configuration files can only be used\MessageBreak
- when loading package}
- \si@opt@disablekey{noload}
- {Configuration files can only be used\MessageBreak
- when loading package}}
-\AtEndOfPackage{
- \si@opt@key{alsoload}{%
- \@for\si@tempa:=#1\do{\si@loadfile{\si@tempa}}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@colourunits}
-%\begin{macro}{\ifsi@colourvalues}
-%\begin{macro}{\si@unitcolour}
-%\begin{macro}{\si@valuecolour}
-% Colour is turned on and off using two switches and the appropriate
-% options. US spellings are also provided.
-% \begin{macrocode}
-\si@opt@boolkey{colourunits}
-\si@opt@boolkey{colourvalues}
-\si@opt@choicekey[true]{colorunits}
- {true,false}
- {\si@colourunitsfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourunitstrue
- \fi}
-\si@opt@choicekey[true]{colorvalues}
- {true,false}
- {\si@colourvaluesfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourvaluestrue
- \fi}
-\si@opt@choicekey[true]{colorall}
- {true,false}
- {\si@colourvaluesfalse
- \si@colourunitsfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourunitstrue
- \si@colourvaluestrue
- \fi}
-\si@opt@choicekey[true]{colourall}
- {true,false}
- {\si@colourvaluesfalse
- \si@colourunitsfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourunitstrue
- \si@colourvaluestrue
- \fi}
-\si@opt@cmdkeys{unitcolour,valuecolour}
-\si@opt@key{unitcolor}{\sisetup{unitcolour=#1}}
-\si@opt@key{valuecolor}{\sisetup{valuecolour=#1}}
-\si@opt@key{colour}{\sisetup{unitcolour=#1,valuecolour=#1}}
-\si@opt@key{color}{\sisetup{unitcolour=#1,valuecolour=#1}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@colourneg}
-%\begin{macro}{\si@negcolour}
-% The set up for colouring negative numbers is similar.
-% \begin{macrocode}
-\si@opt@boolkey{colourneg}
-\si@opt@choicekey[true]{colorneg}
- {true,false}
- {\si@colournegfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colournegtrue
- \fi}
-\si@opt@cmdkeys{negcolour}
-\si@opt@key{negcolor}{\sisetup{negcolour=#1}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@textOmega}
-%\begin{macro}{\si@mathsOmega}
-%\begin{macro}{\si@upOmega}
-% The various non-Latin symbols need to be handled, and given user interfaces.
-% Some definitions are more complex than others; for \si{\ohm}
-% things are easy.
-% \begin{macrocode}
-\si@opt@cmdkeys{textOmega,mathsOmega}
-\si@opt@key{mathOmega}{\sisetup{mathsOmega=#1}}
-\newcommand*{\si@mathsOmega}{\text{\ensuremath{\si@upOmega}}}
-\newcommand*{\si@textOmega}{\ensuremath{\si@upOmega}}
-\newcommand*\si@upOmega{}
-\AtBeginDocument{
- \ifdefined\upOmega
- \let\si@upOmega\upOmega
- \else
- \let\si@upOmega\Omega
- \fi
-}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\changes{v1.0c}{2008/06/25}{Fixed excess loading of maths fonts}
-%\begin{macro}{\si@textmu}
-%\begin{macro}{\si@mathsmu}
-%\changes{v1.2m}{2009/08/10}{Fixed clash wth \pkg{fourier} package}
-%\changes{v1.3}{2009/09/20}{Better definition for micro symbol}
-% For the \si{\micro} symbol, some direct loading of symbols is
-% needed as the maths mu sign ($\mu$) is wrong.
+\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}
-\si@opt@cmdkeys{textmu,mathsmu}
-\si@opt@key{mathmu}{\sisetup{mathsmu=#1}}
-\DeclareFontEncoding{TS1}{}{}
-\DeclareFontSubstitution{TS1}{cmr}{m}{n}
-\DeclareTextSymbol{\si@textmu}{TS1}{181}
-\DeclareTextSymbolDefault{\si@textmu}{TS1}
-\def\si@mathsmu{\text{\si@textmu}}
+\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}{\si@textdegree}
-%\begin{macro}{\si@mathsdegree}
-%\begin{macro}{\si@textminute}
-%\begin{macro}{\si@mathsminute}
-%\begin{macro}{\si@textsecond}
-%\begin{macro}{\si@mathssecond}
-% The angle signs.
+%
+%\begin{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}
-\si@opt@cmdkeys{textdegree,mathsdegree,textminute,mathsminute,
- textsecond,mathssecond}
-\si@opt@key{mathdegree}{\sisetup{mathsdegree=#1}}
-\si@opt@key{mathminute}{\sisetup{mathsminute=#1}}
-\si@opt@key{mathsecond}{\sisetup{mathssecond=#1}}
-\newcommand*{\si@textdegree}{\ensuremath{{}^{\circ}}}
-\newcommand*{\si@mathsdegree}{{}^{\circ}}
-\newcommand*{\si@textminute}{\ensuremath{{}^{\prime}}}
-\newcommand*{\si@mathsminute}{{}^{\prime}}
-\newcommand*{\si@textsecond}{\ensuremath{{}^{\prime\prime}}}
-\newcommand*{\si@mathssecond}{{}^{\prime\prime}}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_print_aux: {
+ \text
+ {
+ \_siunitx_print_color:
+ \_siunitx_font_weight:
+ \_siunitx_font_italic:
+ \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_set_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_set_protected:Npn \_siunitx_print_text_sub_super:n { }
+\cs_set_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}
-%\begin{macro}{\si@textcelsius}
-%\changes{v1.1e}{2008/11/18}{Bug fix in appearance}
-%\begin{macro}{\si@mathscelsius}
-% Finally, degrees Celsius, which may need the degree symbol.
-% \begin{macrocode}
-\si@opt@cmdkeys{textcelsius,mathscelsius}
-\si@opt@key{mathcelsius}{\sisetup{mathscelsius=#1}}
-\newcommand*{\si@textcelsius}{%
- \si@textdegree\kern-\scriptspace C}
-\newcommand*{\si@mathscelsius}{%
- \si@mathsdegree\kern-\scriptspace C}
+%\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}{\si@textringA}
-%\begin{macro}{\si@mathsringA}
-% The \si{\angstrom} sign.
+%
+%\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}
-\si@opt@cmdkeys{textringA,mathsringA}
-\si@opt@key{mathringA}{\sisetup{mathsringA=#1}}
-\newcommand*{\si@textringA}{\AA}
-\newcommand*{\si@mathsringA}{\text{\AA}}
+\tl_new:N \_l_siunitx_number_arg_tl
+\tl_new:N \_l_siunitx_number_next_tl
% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ifsi@redefsymbols}
-% A flag for using \pkg{textcomp} and \pkg{upgreek} to provide better
-% symbols.
+%
+%\begin{macro}{\_l_siunitx_number_multi_tl}
+% For products and quotients, a way of feeding information back.
% \begin{macrocode}
-\si@opt@boolkey{redefsymbols}
-\AtBeginDocument{
- \si@opt@disablekey{redefsymbols}
- {Symbols can only be redefined\MessageBreak
- when loading siunitx}}
+\tl_new:N \_l_siunitx_number_multi_tl
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\si@eVcorra}
-%\begin{macro}{\si@eVcorrb}
+%
+%\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}
-\newlength\si@eVcorra
-\newlength\si@eVcorrb
-\si@opt@key{eVcorra}{\setlength\si@eVcorra{#1}}
-\si@opt@key{eVcorrb}{\setlength\si@eVcorrb{#1}}
+\tl_new:N \_l_siunitx_number_denominator_tl
+\tl_new:N \_l_siunitx_number_numerator_tl
% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\si@tophrase}
-% The phrase for ``to'' in a range.
+%
+%\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}
-\si@opt@xchoicekey{tophrase}{to,dots,ndash,dash}{to}
+\cs_set_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}
-%\begin{macro}{\ifsi@trapambigrange}
-%\begin{macro}{\si@openrange}
-%\begin{macro}{\si@closerange}
-% Trapping awkward ranges.
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_number_preprocess_init:}
+% A little initialisation as normal.
% \begin{macrocode}
-\si@opt@boolkey{trapambigrange}
-\si@opt@cmdkeys{openrange,closerange}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_number_preprocess_product: {
+ \tl_map_function:NN \_l_siunitx_input_product_tl
+ \_siunitx_number_preprocess_product_aux:N
+}
+\cs_set_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_after:wN \_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}{\si@locale}
-%\begin{macro}{\si@loctolang}
-% Handling typographic conventions needs three keys. \opt{locale} is
-% used to set the locale, \opt{loctolang} to bind to \pkg{babel}.
+%
+%\begin{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}
-\si@opt@key{locale}{%
- \si@loc@load{#1}%
- \si@loc@set{#1}}%
-\si@opt@key{loctolang}{\si@loc@ltol{#1}}
+\cs_set_protected_nopar:Npn \_siunitx_number_preprocess_quotient: {
+ \tl_map_function:NN \_l_siunitx_input_quotient_tl
+ \_siunitx_number_preprocess_quotient_aux:N
+}
+\cs_set_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_after:wN \_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{Compatibility options}
-%\begin{macro}{\ifsi@old@ugly}
-%\begin{macro}{\ifsi@old@nice}
-%\begin{macro}{\ifsi@old@loose}
-%\begin{macro}{\ifsi@old@tight}
-% With the options for the package set up, the next stage is to
-% provide support for users of the older packages. These all set up
-% switches, but do not do anything. That is left to the emulation
-% files, loaded at the end of the package. First of all, the
-% \units options are dealt with; there are not many.
+%\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}
-\si@opt@compatkey{units}{ugly}
-\si@opt@compatkey{units}{nice}
-\si@opt@compatkey{units}{loose}
-\si@opt@compatkey{units}{tight}
+\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}
-%\begin{macro}{\ifsi@old@OHM}
-%\begin{macro}{\ifsi@old@ohm}
-%\begin{macro}{\ifsi@old@redef-gensymb}
-%\begin{macro}{\ifsi@gensymb}
-% The \unitsdef package is unfortunately much more profligate with
-% options. The first set are to do with support for \pkg{gensymb}.
-% \begin{macrocode}
-\si@opt@compatkey{unitsdef}{OHM}
-\si@opt@compatkey{unitsdef}{ohm}
-\si@opt@compatkey{unitsdef}{redef-gensymb}
-\newif\ifsi@gensymb
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ifsi@old@LITER}
-%\begin{macro}{\ifsi@old@liter}
-%\begin{macro}{\ifsi@old@noxspace}
-%\begin{macro}{\ifsi@old@noconfig}
-% The second set are more general functionality.
+%
+%\begin{macro}{\_l_siunitx_number_in_prop}
+% The parsed number is stored in a property list as its constituent
+% parts.
% \begin{macrocode}
-\si@opt@compatkey{unitsdef}{LITER}
-\si@opt@compatkey{unitsdef}{liter}
-\si@opt@compatkey{unitsdef}{noxspace}
-\si@opt@compatkey{unitsdef}{noconfig}
+\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}
-%\begin{macro}{\ifsi@old@noabbr}
-%\begin{macro}{\ifsi@old@noamperageabbr}
-%\begin{macro}{\ifsi@old@nofrequncyabbr}
-%\begin{macro}{\ifsi@old@nomolabbr}
-%\begin{macro}{\ifsi@old@novoltageabbr}
-%\begin{macro}{\ifsi@old@novolumeabbr}
-%\begin{macro}{\ifsi@old@noweightabbr}
-%\begin{macro}{\ifsi@old@noenergyabbr}
-%\begin{macro}{\ifsi@old@nolengthabbr}
-%\begin{macro}{\ifsi@old@notimeabbr}
-% The final set are for control of abbreviations, and are a good
-% demonstration of why to use \pkg{xkeyval}!
-% \begin{macrocode}
-\si@opt@compatkey{unitsdef}{noabbr}
-\si@opt@compatkey{unitsdef}{noampereageabbr}
-\si@opt@compatkey{unitsdef}{nofrequncyabbr}
-\si@opt@compatkey{unitsdef}{nomolabbr}
-\si@opt@compatkey{unitsdef}{novoltageabbr}
-\si@opt@compatkey{unitsdef}{novolumeabbr}
-\si@opt@compatkey{unitsdef}{noweightabbr}
-\si@opt@compatkey{unitsdef}{noenergyabbr}
-\si@opt@compatkey{unitsdef}{nolengthabbr}
-\si@opt@compatkey{unitsdef}{notimeabbr}
+%\end{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_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-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-decimal-markers = {.,},
+ input-digits = 0123456789,
+ input-exponent-markers = dDeE,
+ input-open-uncertainty = (, % )
+ input-protect-tokens = \mp\pi\pm,
+ input-signs = +-\mp\pm,
+ input-symbols = \pi,
+}
% \end{macrocode}
%\end{macro}
%\end{macro}
@@ -5146,5840 +4902,3123 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ifsi@old@cdot}
-%\begin{macro}{\ifsi@old@thickspace}
-%\begin{macro}{\ifsi@old@mediumspace}
-%\begin{macro}{\ifsi@old@thinspace}
-%\begin{macro}{\ifsi@old@thickqspace}
-%\begin{macro}{\ifsi@old@mediumqspace}
-%\begin{macro}{\ifsi@old@thinqspace}
-% The \SIunits package has lots of options. These ones are all
-% related to spacing.
+%
+%\begin{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}
-\si@opt@compatkey{SIunits}{cdot}
-\si@opt@compatkey{SIunits}{thickspace}
-\si@opt@compatkey{SIunits}{mediumspace}
-\si@opt@compatkey{SIunits}{thinspace}
-\si@opt@compatkey{SIunits}{thickqspace}
-\si@opt@compatkey{SIunits}{mediumqspace}
-\si@opt@compatkey{SIunits}{thinqspace}
+\cs_set_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_set_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
+ \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_set_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_set_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_set_protected_nopar:Npn \_siunitx_number_in_protect: {
+ \tl_map_function:NN \_l_siunitx_input_protect_tl
+ \_siunitx_number_in_protect_aux:N
+}
+\cs_set_protected:Npn \_siunitx_number_in_protect_aux:N #1 {
+ \cs_set_eq:NN #1 \scan_stop:
+}
+% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ifsi@old@amssymb}
-%\begin{macro}{\ifsi@old@squaren}
-%\begin{macro}{\ifsi@old@pstricks}
-%\begin{macro}{\ifsi@old@Gray}
-%\begin{macro}{\ifsi@old@italian}
-% These options are used by \SIunits to control clashes with other
-% packages.
+%
+%\begin{macro}{\_siunitx_number_in_sign_replace:N}
+% A short spin-out to keep the replacement of tokens clear.
% \begin{macrocode}
-\si@opt@compatkey{SIunits}{amssymb}
-\si@opt@compatkey{SIunits}{squaren}
-\si@opt@compatkey{SIunits}{pstricks}
-\si@opt@compatkey{SIunits}{Gray}
-\si@opt@compatkey{SIunits}{italian}
+\cs_set_protected_nopar:Npn \_siunitx_number_in_sign_replace:N #1 {
+ \tl_replace_all_in:Nnn #1 { -+ } { \mp }
+ \tl_replace_all_in:Nnn #1 { +- } { \pm }
+}
% \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_set_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_set_protected:Npn \_siunitx_number_in_parse_loop:N #1 { }
+\cs_set_protected:Npn \_siunitx_number_in_parse_more:N #1 { }
+% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ifsi@old@textstyle}
-%\begin{macro}{\ifsi@old@binary}
-%\begin{macro}{\ifsi@old@noams}
-%\begin{macro}{\ifsi@old@derivedinbase}
-%\begin{macro}{\ifsi@old@derived}
-% The miscellaneous options.
+%
+%\begin{macro}{\_siunitx_number_in_parse_restricted:N}
+% When parsing numbers for the \cs{ang} function, no extended input
+% is permitted at all.
% \begin{macrocode}
-\si@opt@compatkey{SIunits}{textstyle}
-\si@opt@compatkey{SIunits}{binary}
-\si@opt@compatkey{SIunits}{noams}
-\si@opt@compatkey{SIunits}{derivedinbase}
-\si@opt@compatkey{SIunits}{derived}
+\cs_set_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_set_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_set_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_set_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 #1
+ }
+ {
+ \tl_if_in:NnF \_l_siunitx_input_ignore_tl {#1}
+ { \_siunitx_number_in_parse_more:N #1 }
+ }
+ }
+ }
+ }
+}
+\cs_set_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_set_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}{\ifsi@old@noprefixcmds}
-% The \pkg{hepunits} package only has one option.
+%
+%\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}
-\si@opt@compatkey{hepunits}{noprefixcmds}
+\cs_set_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}{\ifsi@old@english}
-%\begin{macro}{\ifsi@old@french}
-% \pkg{fancynum} provides a few options. First the rather oddly
-% named \opt{english} and \opt{french} ones.
+%
+%\begin{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}
-\si@opt@compatkey{fancynum}{english}
-\si@opt@compatkey{fancynum}{french}
+\cs_set_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_set_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}{\ifsi@old@tight}
-%\begin{macro}{\ifsi@old@loose}
-% A couple for spacing multiplication.
+%
+%\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}
-\si@opt@compatkey{fancynum}{tight}
-\si@opt@compatkey{fancynum}{loose}
+\cs_set_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_set_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}
+ \tl_if_eq:nnF {#1} { 0 }
+ { \bool_set_true:N \_l_siunitx_number_in_value_bool }
+ }
+ {
+ \tl_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}{\ifsi@old@thinspaces}
-%\begin{macro}{\ifsi@old@commas}
-%\begin{macro}{\ifsi@old@plain}
-% Three for digit separation.
+%
+%\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}
-\si@opt@compatkey{fancynum}{thinspaces}
-\si@opt@compatkey{fancynum}{commas}
-\si@opt@compatkey{fancynum}{plain}
+\cs_set_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_set_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_set_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_set_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}{\ifsi@old@spaceqspace}
-% The \pkg{fancyunits} package provides one option not available with
-% \SIunits.
+%
+%\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}
-\si@opt@compatkey{fancyunits}{spaceqspace}
+\cs_set_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}
%
-%\subsection{Constants}
-% A number of macros are needed by the package that provide a
-% non-changing output. These are defined here; the intention is that
-% these should not be macros that the user is likely to need to
-% alter. All of these macros have preface \cs{si@fix@}, to flag that
-% that are intended as constants. The package may rely on the
-% contents of these macros for functionality.
+%\begin{macro}{\_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_set_protected_nopar:Npn \_siunitx_number_in_check:n #1 { }
+\cs_set_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_set_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:nV { misplaced-sign-token } \_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}
%
-%\begin{macro}{\si@fix@thin}
-%\begin{macro}{\si@fix@med}
-%\begin{macro}{\si@fix@medium}
-%\begin{macro}{\si@fix@thick}
-%\begin{macro}{\si@fix@space}
-%\changes{v1.0a}{2008/06/20}{Fixed problem with \opt{space} option}
-% First, there are the various space macros. To allow both \opt{med}
-% and \opt{medium} to be used as a space description, two macros are
-% needed for the same output.
+% 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}
-\newcommand*{\si@fix@thin}{\,}
-\newcommand*{\si@fix@med}{\:}
-\newcommand*{\si@fix@medium}{\:}
-\newcommand*{\si@fix@thick}{\;}
-\newcommand*{\si@fix@space}{\text{ }}
+\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}
-%\begin{macro}{\si@fix@cdot}
-%\begin{macro}{\si@fix@comma}
-%\begin{macro}{\si@fix@stop}
-%\begin{macro}{\si@fix@fullstop}
-%\begin{macro}{\si@fix@period}
-%\begin{macro}{\si@fix@times}
-%\begin{macro}{\si@fix@tighttimes}
-%\begin{macro}{\si@fix@tightcdot}
-% Next there are macros for material that is not simply whitespace.
-% To allow several options, the full-stop gets lots of names.
+%\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}
-\newcommand*{\si@fix@cdot}{{}\cdot{}}
-\newcommand*{\si@fix@comma}{{,}}
-\newcommand*{\si@fix@stop}{{.}}
-\newcommand*{\si@fix@fullstop}{{.}}
-\newcommand*{\si@fix@period}{{.}}
-\newcommand*{\si@fix@times}{\times}
-\newcommand*{\si@fix@tighttimes}{\bgroup\times\egroup}
-\newcommand*{\si@fix@tightcdot}{\bgroup\cdot\egroup}
+\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_decimal_zero_bool}
+%\begin{macro}{\_l_siunitx_process_integer_zero_bool}
+%\begin{macro}{\_l_siunitx_process_sign_tl}
+%\begin{macro}{\_l_siunitx_process_plus_tl}
+%\begin{macro}{\_l_siunitx_unity_mantissa_tl}
+%\begin{macro}{\_l_siunitx_process_zero_exponent_bool}
+%\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,
+ 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-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,
+}
+\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}
-%\begin{macro}{\si@fix@plus}
-%\begin{macro}{\si@fix@minus}
-%\begin{macro}{\si@fix@pm}
-%\begin{macro}{\si@fix@tightpm}
-%\begin{macro}{\si@fix@mp}
-% Signs for numbers are needed.
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_number_process:}
+% Post-processing is a series of small tasks.
% \begin{macrocode}
-\newcommand*{\si@fix@plus}{+}
-\newcommand*{\si@fix@minus}{-}
-\newcommand*{\si@fix@pm}{\pm}
-\newcommand*{\si@fix@tightpm}{\bgroup\pm\egroup}
-\newcommand*{\si@fix@mp}{\mp}
+\cs_set_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:
+ \_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_set_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_set_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
+ {
+ \intexpr_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}
+% Rather than count figures to start with, a completely different
+% approach is used here.
+% \begin{macrocode}
+\cs_set_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_set_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_round_int } >
+ { \int_use:N \_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_set_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}{\si@fix@two}
-%\begin{macro}{\si@fix@ten}
-% The literals ``2'' and ``10'' are needed for exponents.
+%\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}
-\newcommand*{\si@fix@two}{2}
-\newcommand*{\si@fix@ten}{10}
+\cs_set_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_set_protected_nopar:Npn
+ \_siunitx_number_process_figures_count_aux:n #1 {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:Nv \tl_head_i:n { _l_siunitx_round_ #1 _in_tl } }
+ \tl_set:cx { _l_siunitx_round_ #1 _in_tl }
+ { \exp_args:Nv \tl_tail:n { _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
+ {
+ \intexpr_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}{\si@fix@slash}
-% Another optional component that will probably not be used by many
-% people.
-% \begin{macrocode}
-\newcommand*{\si@fix@slash}{/}
+%\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_set_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_set_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}
-%\begin{macro}{\si@fix@none}
-% Finally for spacing, there is the possibility of nothing at all
-% \begin{macrocode}
-\newcommand*{\si@fix@none}{}
+%\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_set_protected_nopar:Npn \_siunitx_number_process_figures_integer: {
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_round_int } > { 0 }
+ { \tl_put_left:Nn \_l_siunitx_round_integer_out_tl { 0 } }
+ \intexpr_compare:nNnF
+ { \int_use:N \_l_siunitx_round_int } > { 1 }
+ {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:NV \tl_head_i:n \_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_round_int } = { 1 }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_tmp_int } > { 4 }
+ { \bool_set_true:N \_l_siunitx_round_bool }
+ }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_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
+ { \exp_args:NV \tl_tail:n \_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}{\si@fix@to}
-%\begin{macro}{\si@fix@dash}
-%\begin{macro}{\si@fix@dots}
-% For the range system.
+%\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}
-\newcommand*{\si@fix@to}{ to }
-\newcommand*{\si@fix@dash}{--}
-\newcommand*{\si@fix@dots}{\,\dots\,}
+\cs_set_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}{\_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_set_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}
%
-%\subsection{Symbols}
-%\begin{macro}{\si@symbol}
-% Each of the symbol macros needs to be set up; the options give a
-% maths and text mode sign, but internally a single macro is needed
-% for each.
-% \begin{macrocode}
-\newcommand*{\si@symbol}[1]{%
- \expandafter\protected\expandafter\def
- \csname si@sym@#1\endcsname{%
- \ifmmode
- \expandafter\csname si@maths#1\expandafter\endcsname
- \else
- \expandafter\csname si@text#1\expandafter\endcsname
- \fi}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@sym@Omega}
-%\begin{macro}{\si@sym@ringA}
-%\begin{macro}{\si@sym@mu}
-%\begin{macro}{\si@sym@degree}
-%\begin{macro}{\si@sym@minute}
-%\begin{macro}{\si@sym@second}
-%\begin{macro}{\si@sym@celsius}
-% The various symbols are now declared.
-% \begin{macrocode}
-\si@symbol{Omega}
-\si@symbol{ringA}
-\si@symbol{mu}
-\si@symbol{degree}
-\si@symbol{minute}
-\si@symbol{second}
-\si@symbol{celsius}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-% The issue of redefinition of symbols now arises. \currpkg can
-% check for the loading of a number of support package, and can then
-% redefine the appropriate symbols.
-% \begin{macrocode}
-\AtBeginDocument{%
- \ifsi@redefsymbols
- \@ifpackageloaded{textcomp}
- {\si@log@debug{Redefining symbols using textcomp}%
- \renewcommand*{\si@textdegree}{\textdegree}%
- \renewcommand*{\si@mathsdegree}{\text{\textdegree}}%
-% \end{macrocode}
-% \pkg{mathptmx} will give issues with \pkg{textcomp} and the
-% \si{\ohm} sign.
-% \begin{macrocode}
- \@ifpackageloaded{mathptmx}{}
- {\renewcommand*{\si@textmu}{\textmu}%
- \renewcommand*{\si@textOmega}{\textohm}}%
-% \end{macrocode}
-% The \si{\angstrom} symbol is only redefined if the encoding is
-% OT1; other encodings should have a proper glyph used for \cs{AA}.
-% The \cs{encodingdefault} macro is \cs{long} for some reason.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{OT1}%
- \ifx\si@tempa\encodingdefault
- \renewcommand*{\si@mathsringA}{%
- \text{\capitalring{A}}}%
- \renewcommand*{\si@textringA}{\capitalring{A}}
- \fi}{}
- \@ifpackageloaded{upgreek}
- {\si@log@debug{Redefining symbols using upgreek}%
- \renewcommand*{\si@mathsOmega}{\Upomega}}{}
- \fi}
-% \end{macrocode}
-%
-%\subsection{Handling fractions}
-%\begin{macro}{\si@frac}
-%\begin{macro}{\si@frc@hook}
-%\begin{macro}{\si@frc@frac}
-%\begin{macro}{\si@frc@slash}
-%\begin{macro}{\si@frc@nice}
-%\begin{macro}{\si@frc@sfrac}
-% Various methods of handling fractions are provided.
-% \begin{macrocode}
-\newcommand*{\si@frc@frac}[2]{%
- \ensuremath{\si@frc@hook\frac{%
- \expandafter\si@unt@out\expandafter{#1}}%
- {\expandafter\si@unt@out\expandafter{#2}}}}
-\let\si@frac\si@frc@frac
-\newcommand*{\si@frc@hook}{}
-\newcommand*{\si@frc@slash}[2]{%
- \expandafter\si@unt@out\expandafter{#1}%
- \si@out{\ensuremath{\si@slash}}%
- \expandafter\si@unt@out\expandafter{#2}}
-\newcommand*{\si@frc@nice}[2]{%
- \ensuremath{\si@frc@nicefrac{\expandafter\si@unt@out%
- \expandafter{#1}}{\expandafter\si@unt@out\expandafter
- {#2}}}}
-\newcommand*{\si@frc@sfrac}[2]{%
- \sfrac{\expandafter\si@unt@out\expandafter{#1}}%
- {\expandafter\si@unt@out\expandafter{#2}}}
-\AtBeginDocument{
- \@ifpackageloaded{xfrac}
- {}
- {\si@log@inf{xfrac package unavailable\MessageBreak
- using `fraction=sfrac' will fall back on\MessageBreak
- nicefrac-like method}%
- \renewcommand*{\si@frc@sfrac}[2]{%
- \si@log@warn{xfrac package unavailable}%
- \si@frc@nice{#1}{#2}}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@frc@nicefrac}
-%\begin{macro}{\si@frc@displen}
-%\begin{macro}{\si@frc@textlen}
-%\begin{macro}{\si@frc@suplen}
-%\begin{macro}{\si@frc@ssuplen}
-% To avoid needing \units installed, the \cs{nicefrac} macro needs
-% to be emulated here. The code is taken (with permission) from
-% \kg{nicefrac}.\footnote{The original is licensed under the GPL;
-% thanks to the author Axel Reichert for permission to copy the code
-% here.}
-% \begin{macrocode}
-\newlength\si@frc@displen
-\newlength\si@frc@textlen
-\newlength\si@frc@suplen
-\newlength\si@frc@ssuplen
-\newcommand*{\si@frc@nicefrac}{%
- \ifmmode
- \expandafter\si@frc@mathsnf
- \else
- \expandafter\si@frc@textnf
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@frc@mathsnf}
-%\darg{numerator}
-%\darg{denominator}
-% The maths mode system.
-% \begin{macrocode}
-\newcommand*{\si@frc@mathsnf}[2]{%
- \begingroup
- \settoheight{\si@frc@displen}{\ensuremath{%
- \displaystyle{M}}}%
- \settoheight{\si@frc@textlen}{\ensuremath{%
- \textstyle{M}}}%
- \settoheight{\si@frc@suplen}{\ensuremath{%
- \scriptstyle{M}}}%
- \settoheight{\si@frc@ssuplen}{%
- \ensuremath{\scriptscriptstyle{M}}}%
- \addtolength{\si@frc@displen}{-\si@frc@ssuplen}%
- \addtolength{\si@frc@textlen}{-\si@frc@ssuplen}%
- \addtolength{\si@frc@suplen}{-\si@frc@ssuplen}%
- \mathchoice
- {\raisebox{\si@frc@displen}{\ensuremath{%
- \scriptstyle{#1}}}}%
- {\raisebox{\si@frc@textlen}{\ensuremath{%
- \scriptstyle{#1}}}}%
- {\raisebox{\si@frc@suplen}%
- {\ensuremath{\scriptscriptstyle{#1}}}}%
- {\raisebox{\si@frc@ssuplen}%
- {\ensuremath{\scriptscriptstyle{#1}}}}%
- \mkern-2mu\relax/\mkern-1mu\relax
- \bgroup
- \mathchoice
- {\scriptstyle}%
- {\scriptstyle}%
- {\scriptscriptstyle}%
- {\scriptscriptstyle}%
- {#2}%
- \egroup
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@frc@textnf}
-%\darg{numerator}
-%\darg{denominator}
-% A stripped down version of the \pkg{nicefrac} system for text mode.
-% \begin{macrocode}
-\newcommand*{\si@frc@textnf}[2]{%
- \begingroup
- \settoheight{\si@frc@textlen}{M}%
- \settoheight{\si@frc@ssuplen}{\fontsize\sf@size\z@\relax
- \selectfont{M}}%
- \addtolength{\si@frc@textlen}{-\si@frc@ssuplen}%
- \raisebox{\si@frc@textlen}{\fontsize\sf@size\z@\relax
- \selectfont{#1}}%
- \hspace{-0.25ex}/\hspace{-0.25ex}%
- \hbox{\fontsize\sf@size\z@\selectfont{#2}}%
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@frc@ugly}
-%\darg{numerator}
-% The \cs{si@frc@ugly} macro is needed to emulate the \opt{ugly}
-% option in \units, where output depends on the current mode.
-% \begin{macrocode}
-\newcommand*{\si@frc@ugly}[1]{%
- \renewcommand*{\si@tempa}{#1}%
- \ifmmode
- \expandafter\si@frc@frac
- \else
- \renewcommand*{\si@tempb}{1}%
- \ifx\si@tempa\si@tempb
-% \end{macrocode}
-% The slash switch cannot be used, so the possibility of the
-% numerator being one is handled here.
-% \begin{macrocode}
- \setbox\si@tempboxa=\hbox{\ensuremath{\si@valuesep}}%
- \hskip-\wd\si@tempboxa\relax
- \renewcommand*{\si@tempa}{}%
- \fi
- \expandafter\si@frc@slash
- \fi
- {\si@tempa}}
-% \end{macrocode}
-%\end{macro}
-%
-%\subsection{Font control}
-% A number of controls and tests are needed to control the font used
-% for output. Underlying all of this is the \AMS\ package
-% \pkg{amstext} package, providing the \cs{text} command. Much of
-% the font control system here is taken more or less verbatim from
-% \SIstyle; modifications have been made to fit the \currpkg
-% interface.
-%
-%\begin{macro}{\si@fam@sf}
-%\begin{macro}{\si@fam@tt}
-% The package needs to know the maths font families in use. This is
-% set right at the start of the document, after any changes can have
-% been made by, for example, \pkg{fontspec}.
-% \begin{macrocode}
-\g@addto@macro{\document}{%
- \ifdefined\mathsf
- \setbox\si@tempboxa=\hbox{%
- $\mathsf{\global\chardef\si@fam@sf=\fam}$}%
- \else
- \si@log@inf{\string\mathsf not found}%
- \global\chardef\si@fam@sf=99\relax
- \fi
- \ifdefined\mathtt
- \setbox\si@tempboxa=\hbox{%
- $\mathtt{\global\chardef\si@fam@tt=\fam}$}%
- \else
- \si@log@inf{\string\mathtt not found}%
- \global\chardef\si@fam@tt=99\relax
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%
-%\begin{macro}{\si@fam@detect@default}
-%\changes{v1.4}{2010/01/16}{Detect entire document in non-serif font}
-%\changes{v1.4c}{2010/02/22}{Better testing}
-% Some packages (for example \pkg{cmbright}) 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{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}
-\newcommand*\si@fam@detect@default{%
- \edef\si@tempa{\familydefault}%
- \edef\si@tempb{\sfdefault}%
- \ifx\si@tempa\si@tempb
- \@ifpackageloaded{cmbright}{}{\sisetup{ mathsrm = mathsf}}%
- \sisetup{ textrm = sffamily }%
- \fi
- \edef\si@tempb{\ttdefault}%
- \ifx\si@tempa\si@tempb
- \sisetup
- {
- mathsrm = mathtt,
- textrm = ttfamily
- }%
- \fi
+\cs_set_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
+ {
+ \intexpr_while_do:nNnn
+ { \int_use:N \_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
+ }
}
-\AtBeginDocument{\si@fam@detect@default}
% \end{macrocode}
%\end{macro}
%
-%\begin{macro}{\si@fam@ifbtext}
-%\begin{macro}{\si@fam@ifbmaths}
-%\darg{code}
-% These tests check for bold in text and maths mode, respectively.
+%\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}
-\newcommand*{\si@fam@ifbtext}[1]{%
- \if b\expandafter\@car\f@series\@nil
- #1\fi}
-\newcommand*{\si@fam@ifbmaths}[1]{%
- \renewcommand*{\si@tempa}{bold}%
- \ifx\math@version\si@tempa
- #1\fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@fam@ifbinline}
-% For compatibility with \units, a method to change the behaviour
-% when in inline maths is needed for the bold detector.
-% \begin{macrocode}
-\newcommand*{\si@fam@ifbinline}{%
- \ifsi@inlinebtext
- \expandafter\si@fam@ifbtext
- \else
- \expandafter\si@fam@ifbmaths
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@fam@ifitext}
-%\darg{code}
-% This test check for italic or slanted text in text mode, by
-% negation (upright text is |n|).
-% \begin{macrocode}
-\newcommand*{\si@fam@ifitext}[1]{%
- \if n\expandafter\@car\f@series\@nil\else
- #1\fi}
-% \end{macrocode}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_number_process_places_aux_i:n #1 {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_process_precision_int } = { 0 }
+ { \prop_del:Nn \_l_siunitx_number_in_prop { #1 -decimal } }
+ {
+ \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 } }
+ \intexpr_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}{\si@fam@mode}
-% Detection of the current mode needs to happen``early'' (before any
-% change of \cs{ensuremath}). So a short macro is provided to do the
-% job.
+%\begin{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}
-\newcommand*{\si@fam@mode}{%
- \ifsi@obeymode
- \ifmmode
- \sisetup{mode=maths}%
- \else
- \sisetup{mode=text}%
- \fi
- \fi}
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_places_aux_ii:n #1 {
+ \int_sub:Nn \_l_siunitx_round_int
+ { \_l_siunitx_process_precision_int }
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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_set_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_set_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}{\si@fam@colourcmd}
-% The colour command is set up.
-% \begin{macrocode}
-\AtBeginDocument{
- \@ifpackageloaded{color}
- {\let\si@fam@colourcmd\color}
- {\let\si@fam@colourcmd\@gobble}}
+%\begin{macro}[aux]{\_siunitx_number_process_places_integer:n}
+% Rounding for integers is just a case of carrying digits.
+% \begin{macrocode}
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_places_integer:n #1 {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:NV \tl_head_i:n \_l_siunitx_round_integer_in_tl }
+ \tl_set:Nx \_l_siunitx_round_integer_in_tl
+ { \exp_args:NV \tl_tail:n \_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
+ \intexpr_compare:nNnT
+ { \int_use:N \_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}{\ifsi@fam@set}
-%\begin{macro}{\ifsi@textmode}
-% A marker is set up to check if font-matching has been taken place.
-% A second flag is used to track the use of text mode.
+%\begin{macro}{\_siunitx_number_process_round:}
+% The lead-off for rounding is the same for decimal places and
+% significant figures.
% \begin{macrocode}
-\newif\ifsi@fam@set
-\newif\ifsi@textmode
+\cs_set_protected_nopar:Npn \_siunitx_number_process_round: {
+ \tl_if_empty:NF \_l_siunitx_round_tl
+ {
+ \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}
-%\end{macro}
-%\begin{macro}{\si@fam@set}
-% Using the code from \SIstyle as a base, a set of tests are used to
-% set the current font families and weights. To begin with, the
-% mode to use is set up.
-% \begin{macrocode}
-\newcommand*{\si@fam@set}{%
- \ifsi@out@num
- \ifsi@numtextmode
- \expandafter\expandafter\expandafter\si@textmodetrue
- \else
- \expandafter\expandafter\expandafter\si@textmodefalse
- \fi
- \else
- \ifsi@unittextmode
- \expandafter\expandafter\expandafter\si@textmodetrue
- \else
- \expandafter\expandafter\expandafter\si@textmodefalse
- \fi
- \fi
-% \end{macrocode}
-%\begin{macro}{\si@mathsrm}
-%\begin{macro}{\si@mathssf}
-%\begin{macro}{\si@mathstt}
-%\begin{macro}{\si@textrm}
-%\begin{macro}{\si@textsf}
-%\begin{macro}{\si@texttt}
-%\begin{macro}{\si@colourcmd}
-%\begin{macro}{\si@colour}
-% The appropriate font macros are now established, if necessary.
-% \begin{macrocode}
- \ifsi@fam@set\else
- \let\si@colourcmd\@gobble
- \ifsi@out@num
- \let\si@mathsrm\si@valuemathsrm
- \let\si@mathssf\si@valuemathssf
- \let\si@mathstt\si@valuemathstt
- \let\si@textrm\si@valuetextrm
- \let\si@textsf\si@valuetextsf
- \let\si@texttt\si@valuetexttt
- \ifsi@colourvalues
- \let\si@colourcmd\si@fam@colourcmd
- \fi
- \let\si@colour\si@valuecolour
- \else
- \let\si@mathsrm\si@unitmathsrm
- \let\si@mathssf\si@unitmathssf
- \let\si@mathstt\si@unitmathstt
- \let\si@textrm\si@unittextrm
- \let\si@textsf\si@unittextsf
- \let\si@texttt\si@unittexttt
- \ifsi@colourunits
- \let\si@colourcmd\si@fam@colourcmd
- \fi
- \let\si@colour\si@unitcolour
- \fi
- \fi
- \si@fam@settrue
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-% The temporary macros are needed for the \cs{ifx} tests, which need to
-% be expanded once.
-% \begin{macrocode}
- \edef\si@tempa{\sfdefault}%
- \edef\si@tempb{\ttdefault}%
-% \end{macrocode}
-%\begin{macro}{\si@fam@maths}
-%\begin{macro}{\si@fam@text}
-% The surrounding font family is only tested if matching is
-% requested. First, the defaults are set up assuming no detection
-% takes place.
-% \begin{macrocode}
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathsrm\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textrm\endcsname
- \ifsi@obeyfamily
- \si@log@debug{Font detection: checking font}%
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-% The detection code has to check the mode currently in operation.
-% Display mathematics can be handled in two ways, so this means some
-% code is repeated: it is spun out to separate routines.
-% \begin{macrocode}
- \ifmmode
- \ifinner
- \si@log@debug{Font detection: inline maths}%
- \si@fam@dettext
- \else
- \si@log@debug{Font detection: display maths}%
- \ifsi@detectdisplay
- \si@fam@detmaths
- \else
- \si@fam@dettext
- \fi
- \fi
- \else
- \si@log@debug{Font detection: text}%
- \si@fam@dettext
- \fi
- \else
- \si@log@debug{Font detection: inactive}%
- \fi
-% \end{macrocode}
-%\begin{macro}{\si@fam@bold}
-% With the font family set, the next check is for bold text. This
-% again needs to examine the current mode. Things are a bit more
-% complex than in \SIstyle as it is possible to be typesetting in
-% either text or maths mode. The bold command is set up with
-% \cs{def}, as nested calls can occur.
-% \begin{macrocode}
- \def\si@fam@bold{\unboldmath\mdseries}%
- \ifsi@obeybold
- \si@log@debug{Weight detection: checking weight}%
- \ifmmode
- \ifdim\displaywidth>0pt\relax
- \ifsi@detectdisplay
- \expandafter\si@fam@ifbmaths
- \else
- \expandafter\si@fam@ifbtext
- \fi
- \si@fam@setbold
- \else
- \si@fam@ifbinline\si@fam@setbold
- \fi
- \else
- \si@fam@ifbtext\si@fam@setbold
- \fi
- \fi
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@fam@italic}
-% The value of \opt{obeyitalic} is now tested; as this does nothing
-% in maths mode, a reminder is added to the log.
-% \begin{macrocode}
- \let\si@fam@italic\upshape
- \ifsi@obeyitalic
- \si@log@debug{Italic detection: checking italic}%
- \si@fam@ifitext
- {\let\si@fam@italic\relax
- \si@log@debug{Italic detection: italic}}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@fam@detmaths}
-%\begin{macro}{\si@fam@dettext}
-% Two detection macros are needed for maths and text mode. This
-% allows handling of the various combinations without needing too
-% many code lines.
-% \begin{macrocode}
-\newcommand*{\si@fam@detmaths}{%
- \ifnum\the\fam=\si@fam@sf
- \si@log@debug{Font detection: sf}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathssf\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textsf\endcsname
- \else
- \ifnum\the\fam=\si@fam@tt
- \si@log@debug{Font detection: tt}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathstt\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@texttt\endcsname
- \else
- \si@log@debug{Font detection: rm}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathsrm\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textrm\endcsname
- \fi
- \fi}
-\newcommand*{\si@fam@dettext}{%
- \ifx\f@family\si@tempa
- \si@log@debug{Font detection: sf}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathssf\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textsf\endcsname
- \else
- \ifx\f@family\si@tempb
- \si@log@debug{Font detection: tt}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathstt\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@texttt\endcsname
- \else
- \si@log@debug{Font detection: rm}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathsrm\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textrm\endcsname
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@fam@setbold}
-%\begin{macro}{\si@fam@boldify}
-% For setting bold, a couple of control macros are needed.
-% \begin{macrocode}
-\newcommand*{\si@fam@setbold}{%
- \si@log@debug{Weight detection: bold weight}%
- \let\si@fam@bold\si@fam@boldify}
-\newcommand*{\si@fam@boldify}{\boldmath\bfseries}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%
-%\subsection{Formatting numbers}
-%\begin{macro}{\num}
-%\doarg{keyval options}
-%\darg{number}
-% The system used here is modelled on that in \numprint; the
-% input is broken down into single tokens, each one is examined and
-% the result is re-assembled into an output number. However, various
-% changes have been made to the system used, and so the macros here
-% are not simply renamed copies of those in \numprint. The user
-% macro \cs{num} sets any local keys, then calls the number
-% formatting macro on the processed number.
-% \begin{macrocode}
-\si@newrobustcmd*{\num}[2][]{%
- \begingroup
- \sisetup{#1}%
- \si@fam@mode
- \si@num@intabfalse
- \si@log@debug{Processing \string\num\space input `#2'}%
- \expandafter\si@out@num\expandafter{\si@num{#2}}%
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@num@intab}
-% A flag for processing inside a table is needed.
-% \begin{macrocode}
-\newif\ifsi@num@intab
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num}
-%\darg{number}
-% This is the main processing macro. Unlike the related macro in
-% \numprint, the output of this macro is not subjected to any font
-% changes. That is left to one of the \cs{si@out@\ldots} macros. No
-% grouping is applied here; any call to \cs{si@num} (or any of the
-% sub-macros) must be within a group as the definitions used rely on
-% this. Grouping is not applied here so that other macros can get
-% the various separated parts of the input.
-% \begin{macrocode}
-\newcommand*{\si@num}[1]{%
-% \end{macrocode}
-% The argument of the macro is fully expanded before any processing.
-% By using \cs{scantokens}, any odd problems from packages with
-% active characters can be avoided.
-% \begin{macrocode}
- \si@num@fixpm
- \begingroup
- \makeatletter
- \@makeother{\,}%
- \@makeother{\.}%
- \@makeother{\+}%
- \@makeother{\-}%
- \def~{}%
- \def\,{}%
- \catcode`\~=\active\relax
- \catcode`\^=\active\relax
- \catcode`\_=12\relax
- \everyeof{\noexpand}%
- \endlinechar\m@ne
- \protected@xdef\si@tempa{\scantokens{#1}}%
- \endgroup
-% \end{macrocode}
-% Processing only takes place if there is actually something in the
-% argument. This is tested once ``hard'' spaces have been stripped
-% out; if there is input other than spaces, the processor first
-% checks the validity of the input, then moves on to format it.
-% \begin{macrocode}
- \si@ifnotmtarg{\si@tempa}
- {\si@num@ifvalid{\si@tempa}
- {\si@num@format{\si@tempa}}
-% \end{macrocode}
-% The parser has to bailed-out, and so no further processing of
-% the input is done. Instead, whatever was passed to the macro is
-% returned as supplied.
-% \begin{macrocode}
- {\si@log@err{Invalid character `#1' in numerical input}%
- {Only characters from the list
- `\si@numvalid'\MessageBreak should be present in the
- argument of the \string\num\space macro\MessageBreak
- (or derivative such as an `s' column)}%
- {#1}}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@fixpm}
-%\begin{macro}{\si@num@pm}
-%\begin{macro}{\si@num@mp}
-%\begin{macro}{\pm}
-%\begin{macro}{\mp}
-% With certain packages loaded, there can be issues with \cs{pm} and
-% \cs{mp}. To avoid this, the \eTeX\ \cs{protected} system is
-% employed; this is only used within local groups.
+%\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}
-\newcommand*{\si@num@fixpm}{%
- \let\si@num@pm\pm
- \let\si@num@mp\mp
- \protected\def\pm{\si@num@pm}%
- \protected\def\mp{\si@num@mp}}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_round_decimal: {
+ \intexpr_compare:nNnF
+ { \int_use:N \_l_siunitx_round_int } > { 1 }
+ { \_siunitx_number_process_round_decimal_aux: }
+ \tl_set:Nx \_l_siunitx_round_decimal_in_tl
+ { \exp_args:NV \tl_tail:n \_l_siunitx_round_decimal_in_tl }
+
+ \int_decr:N \_l_siunitx_round_int
+}
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_round_decimal_aux: {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:NV \tl_head_i:n \_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_round_int } = { 1 }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_tmp_int } > { 4 }
+ { \bool_set_true:N \_l_siunitx_round_bool }
+ }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_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}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@ifvalid}
-%\begin{macro}{\si@num@valid}
-%\darg{chars}
-% Assuming that there is a non-space argument to \cs{si@num}, every
-% character is checked to ensure it is valid in the context, so that
-% further processing can occur without sanity checks. If the
-% character is valid, recursion occurs.
+%\begin{macro}{\_siunitx_number_process_round_tidy:n}
+% To put data back again.
% \begin{macrocode}
-\newcommand*{\si@num@ifvalid}[1]{%
- \begingroup
- \si@switchtrue
- \expandafter\si@num@valid#1\@empty\@empty
- \ifsi@switch
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@num@valid#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numvalid}
- {\ifx\@empty#2\@empty\else
- \si@num@valid#2\@empty\@empty\@empty
- \fi}
- {\si@switchfalse}}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_round_tidy:n #1 {
+ \prop_put:NnV \_l_siunitx_number_in_prop { #1 -integer }
+ \_l_siunitx_round_integer_out_tl
+ \prop_put:NnV \_l_siunitx_number_in_prop { #1 -decimal }
+ \_l_siunitx_round_decimal_out_tl
+}
% \end{macrocode}
%\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_set_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}{\si@num@in}
-%\begin{macro}{\si@num@out}
-%\begin{macro}{\si@num@exp}
-%\begin{macro}{\si@num@expsign}
-%\begin{macro}{\si@num@mant}
-%\begin{macro}{\si@num@mantsign}
-%\begin{macro}{\si@num@err}
-%\begin{macro}{\si@num@xpart}
-%\begin{macro}{\si@num@ambig}
-%\begin{macro}{\si@tab@out}
-%\begin{macro}{\si@tab@expout}
-% Various storage macros are needed.
-% \begin{macrocode}
-\newcommand*{\si@num@in}{}
-\newcommand*{\si@num@out}{}
-\newcommand*{\si@num@exp}{}
-\newcommand*{\si@num@expsign}{}
-\newcommand*{\si@num@mant}{}
-\newcommand*{\si@num@mantsign}{}
-\newcommand*{\si@num@err}{}
-\newcommand*{\si@num@xpart}{}
-\newcommand*{\si@num@ambig}{}
-\newcommand*{\si@tab@out}{}
-\newcommand*{\si@tab@expout}{}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
+%\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_set_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_set_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_set_protected_nopar:Npn \_siunitx_number_process_uncertainty: {
+ \clist_map_function:nN { mantissa , complex }
+ \_siunitx_number_process_uncertainty_aux:n
+}
+\cs_set_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_set_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_process_uncertainty_int }
+ > { \int_use:N \_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_set_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}{\ifsi@num@erropen}
-% A flag is set up for tracking unclosed errors.
-% \begin{macrocode}
-\newif\ifsi@num@erropen
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@format}
-%\begin{macro}{\si@num@arg}
-%\darg{number}
-% The number processor starts by saving |#1| (odd things happen
-% otherwise). A hook is also provided to allow modifications by
-% other macros.
-% \begin{macrocode}
-\newcommand*{\si@num@arg}{}
-\newcommand*{\si@num@format}[1]{%
- \protected@edef\si@num@arg{#1}%
- \si@log@debug{Formatting number `\si@num@arg'}%
-% \end{macrocode}
-%\end{macro}
-% The storage areas are emptied.
-% \begin{macrocode}
- \renewcommand*{\si@num@in}{}%
- \renewcommand*{\si@num@exp}{}%
- \renewcommand*{\si@num@expsign}{}%
- \renewcommand*{\si@num@mant}{}%
- \renewcommand*{\si@num@mantsign}{}%
- \renewcommand*{\si@num@err}{}%
- \renewcommand*{\si@num@xpart}{}%
-% \end{macrocode}
-% Any ``x-part'' is now found, leaving the first number in
-% \cs{si@num@in} and anything else in \cs{si@num@xpart}.
-% \begin{macrocode}
- \si@switchfalse
- \expandafter\si@num@findxpart\si@num@arg\@empty\@empty
-% \end{macrocode}
-% The input is split into an mantissa and an exponent; the flag is
-% used here to indicate if an exponent is found. The mantissa will
-% end up in \cs{si@num@mant}, and the exponent in \cs{si@num@exp}.
-% \begin{macrocode}
- \si@switchfalse
- \si@num@sepmantexp{\si@num@in}%
-% \end{macrocode}
-% The sign and value of the mantissa and exponent are separated; the
-% mantissa is done after the exponent as this makes life easier when
-% using the table-formatting fork. Checks are then needed, as a sign
-% with no value is potentially-valid for the mantissa (for example
-% \num{-e10}).
-% \begin{macrocode}
- \si@num@sepsign{exp}%
- \si@num@sepsign{mant}%
- \ifx\@empty\si@num@exp\@empty
- \ifx\@empty\si@num@expsign\@empty\else
- \si@log@warn{Sign but no number for `\si@num@arg'}%
- \fi
- \let\si@num@expsign\@empty
- \fi
- \ifx\@empty\si@num@mant\@empty
- \ifx\@empty\si@num@mantsign\@empty\else
- \ifx\@empty\si@num@exp\@empty
- \si@log@warn{Sign but no number for `\si@num@arg'}%
- \let\si@num@mantsign\@empty
- \fi
- \fi
- \fi
-% \end{macrocode}
-% A check for negative mantissa values is made, to allow some
-% colour-based trickery.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{{-}}%
- \ifx\si@num@mantsign\si@tempa
- \ifsi@colourneg
- \expandafter\expandafter\expandafter\si@fam@colourcmd
- \else
- \expandafter\expandafter\expandafter\@gobble
- \fi
- \else
- \expandafter\@gobble
- \fi
- {\si@negcolour}%
-% \end{macrocode}
-% The next stage is to process the remaining data, to find the
-% decimal marker and reformat correctly. These two macros control
-% this entire process. The exponent is processed first as this makes
-% life easier when the system is used to typeset tabular
-% material.\footnote{The contents of \cs{si@num@predec} and
-% \cs{si@num@postdec} are needed for the mantissa.}
-% \begin{macrocode}
- \si@num@procnum{exp}%
- \si@num@procnum{mant}%
-% \end{macrocode}
-% If the exponent is zero, then if might need to be deleted.
-% \begin{macrocode}
- \si@str@ifonlychrs{\si@num@exp}{0\si@numdecimal}
- {\ifsi@allowzeroexp\else
- \renewcommand*{\si@num@exp}{}%
- \ifx\@empty\si@num@mant\@empty
- \renewcommand*{\si@num@mant}{1}%
- \fi
- \fi}{}%
-% \end{macrocode}
-% To build up the number for typesetting, a rather complex series
-% of tests is needed. First, the ``ambiguous error'' flag is
-% set if there is an exponent and the package has been asked to check
-% this. The same flag will already be true if a unit is present and
-% checking is active.
-% \begin{macrocode}
- \ifx\@empty\si@num@exp\@empty\else
- \ifsi@trapambigerr
- \expandafter\expandafter\expandafter\si@num@ambigerrtrue
- \fi
- \fi
-% \end{macrocode}
-%\begin{macro}{\si@num@out}
-%\begin{macro}{\si@tab@out}
-%\begin{macro}{\si@tab@expout}
-% Processing now divides, as when used with the |S| column some extra
-% steps are needed. Inside a table, the macro \cs{si@tab@out} holds
-% the part of the mantissa before the decimal sign. The post-decimal
-% part then ends up in \cs{si@num@out}. On the other hand, under
-% normal circumstances the entire mantissa should be copied to
-% \cs{si@num@out}.
-% \begin{macrocode}
- \protected@edef\si@num@out{%
- \ensuremath{{\si@num@mantsign}}\si@num@mant}%
- \renewcommand*{\si@tempa}{num}%
- \ifsi@num@intab
- \protected@edef\si@tab@out{%
- \ensuremath{{\si@num@mantsign}}\si@num@predec}%
- \protected@edef\si@num@out{\si@num@postdec}%
- \renewcommand*{\si@tempa}{tab}%
- \fi
-% \end{macrocode}
-% Now there is the error part to handle. For tables, a check has to
-% be made so the error ends up in the correct part of the number. The
-% value of \cs{si@tempa} is used to track this., and so is set up
-% here.
-% \begin{macrocode}
- \ifx\@empty\si@num@postdec\@empty\else
- \renewcommand*{\si@tempa}{num}%
- \fi
- \ifx\@empty\si@num@err\@empty\else
-% \end{macrocode}
-% If there is an error, and it is begin separated, the problem arises
-% of the potential for ambiguous values. This can only apply outside
-% of a table, as \opt{seperr} is disabled in tabular material.
-% \begin{macrocode}
- \ifsi@seperr
- \ifsi@num@ambigerr
- \protected@edef\si@num@out{%
- \ensuremath{\si@openerr}\si@num@out}%
- \si@repeatunitsfalse
- \expandafter\si@num@erropentrue
- \else
-% \end{macrocode}
-% If there is an exponential part and an error, errors are being
-% separated and ambiguous errors are not trapped, then there is work
-% to do. The exponent part is added to the \emph{error}, and deleted
-% from the mantissa if necessary.
-% \begin{macrocode}
- \ifsi@trapambigerr\else
- \ifx\@empty\si@num@exp\@empty\else
- \protected@edef\si@num@err{%
- \si@num@err\expandafter\@car\si@numexp\@nil
- \si@num@expsign\si@num@exp}%
- \ifsi@repeatunits\else
- \renewcommand*{\si@num@exp}{}%
- \renewcommand*{\si@num@expsign}{}%
- \fi
- \fi
- \fi
- \fi
-% \end{macrocode}
-% If \opt{seperr} is not in force, the error and mantissa have to be
-% recombined. This is handled so that the same macro deals with
-% tables and normal processing.
-% \begin{macrocode}
- \else
- \expandafter\protected@edef\csname
- si@\si@tempa @out\endcsname{%
- \si@num@out\ensuremath{\si@errspace}\ensuremath
- {\si@openerr}\si@num@err\ensuremath{\si@closeerr}}%
- \renewcommand*{\si@num@err}{}%
- \fi
- \fi
-% \end{macrocode}
-% The main reconstruction can now occur. This performs various
-% checks on the validity of the input, and adds the necessary
-% ``filler'' between the supplied data.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{num@out}%
- \ifsi@num@erropen
- \renewcommand*{\si@tempa}{num@ambig}%
- \fi
- \ifsi@num@intab
- \renewcommand*{\si@tempa}{tab@expout}%
- \fi
- \ifx\@empty\si@num@exp\@empty
- \ifx\@empty\si@num@mant\@empty
- \si@log@err{Invalid number format `\si@num@arg'}
- {Something is wrong with the number format; does it
- contain \MessageBreak any numbers (from the list
- `\si@numdigits')?}%
- \renewcommand*\si@num@out{}%
- \fi
- \else
- \ifx\@empty\si@num@mant\@empty\else
- \expandafter\protected@edef\csname
- si@\si@tempa\endcsname{%
- \csname si@\si@tempa\endcsname\ensuremath{{}%
- \si@expproduct{}}}%
- \fi
- \expandafter\protected@edef\csname
- si@\si@tempa\endcsname{%
- \csname si@\si@tempa\endcsname\si@expbase
- \textsuperscript{\ensuremath{\si@num@expsign}%
- \si@num@exp}}%
- \fi
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-% With everything done, the result is output.
-% \begin{macrocode}
- \ifsi@num@intab\else
- \expandafter\si@num@out
- \fi
-% \end{macrocode}
-%\changes{2009/04/01}{v1.2i}{Minor change for another text mode issue}
-% If there is anything inside the ``x-part'', then there is now
-% more work to do.
-% \begin{macrocode}
- \ifx\@empty\si@num@err\@empty\else
- \expandafter\si@num@procerr
- \fi
- \ifsi@num@erropen
- \expandafter\si@out@num\expandafter{%
- \ensuremath{\si@closeerr}}%
- \ifx\@empty\si@num@ambig\@empty\else
- \si@out@num{\si@num@ambig}%
- \renewcommand*{\si@num@ambig}{}%
- \fi
- \fi
- \si@num@erropenfalse
- \ifx\@empty\si@num@xpart\@empty\else
- \expandafter\si@num@sepxpart
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@findxpart}
-% Before processing the number, any multiplied parts have to be found
-% and removed. As there can be more than one product sign, the
-% building process here has no error checking.
-% \begin{macrocode}
-\def\si@num@findxpart#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numprod}
- {\si@switchtrue\si@seperrfalse}{}%
- \ifsi@switch
- \protected@edef\si@num@xpart{\si@num@xpart#1}%
- \else
- \protected@edef\si@num@in{\si@num@in#1}%
- \fi
- \ifx\@empty#2\@empty\else
- \si@num@findxpart#2\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@sepmantexp}
-%\begin{macro}{\si@num@mantexp}
-%\darg{number}
-% Splitting the mantissa and exponent first checks for characters to
-% gobble, which are simply thrown away. For any other input, there
-% are two possibilities. If the character is an exponent marker,
-% then the package switches from collecting the mantissa to
-% collecting the exponent (after a sanity check). All other
-% characters are added to either the mantissa or the exponent, as
-% appropriate.
-% \begin{macrocode}
-\newcommand*{\si@num@sepmantexp}[1]{%
- \expandafter\si@num@mantexp#1\@empty\@empty}
-\def\si@num@mantexp#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numgobble}
- {\si@log@debug{Gobbling `#1' in \si@num@arg}}
- {\si@str@ifchrstr{#1}{\si@numexp}
- {\ifsi@switch
- \si@log@err{Duplicate exponent marker found}
- {Only a single exponent character \MessageBreak
- (from the list `\si@numexp')\MessageBreak may
- occur in a numerical argument}%
- \else
- \si@log@debug{Exponent marker `#1' found in
- `\si@num@arg'}%
- \fi
- \si@switchtrue}%
- {\ifsi@switch
- \expandafter\si@num@addexp
- \else
- \expandafter\si@num@addmnt
- \fi
- {#1}}}%
-% \end{macrocode}
-% If the recursion has not bottomed out, another loop occurs.
-% \begin{macrocode}
- \ifx\@empty#2\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@sepmantexp
- \fi
- {#2}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@addmnt}
-%\begin{macro}{\si@num@addexp}
-%\darg{char}
-% To allow \cs{expandafter} use in the above, the actual addition to
-% the appropriate macro is handled here. Two helper macros are
-% needed.
+%\begin{macro}{\_siunitx_number_process_uncertainty_pad:}
+% Uncertainty is short: add zeros.
% \begin{macrocode}
-\newcommand*{\si@num@addmnt}[1]{%
- \si@num@addmntexp{#1}{mant}{mantissa}}
-\newcommand*{\si@num@addexp}[1]{%
- \si@num@addmntexp{#1}{exp}{exponent}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@addmntexp}
-%\darg{char}
-%\darg{either \texttt{mant} or \texttt{exp}}
-%\darg{info-text}
-% Then the business end.
-% \begin{macrocode}
-\newcommand*{\si@num@addmntexp}[3]{%
- \si@log@debug{Adding `#1' to #3 for `\si@num@arg'}%
- \expandafter\protected@edef\csname si@num@#2\endcsname{%
- \csname si@num@#2\endcsname#1}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@sepsign}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% The input is now tested for a sign. If one exists, it is
-% transferred into the \cs{si@num@}|#1sign| storage macro, with the
-% remained of the number in \cs{si@num@}|#1|. The only check made
-% directly here is that there is something to process.
-% \begin{macrocode}
-\newcommand*{\si@num@sepsign}[1]{%
- \expandafter\ifx\expandafter\@empty
- \csname si@num@#1\endcsname\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@gensign
- \fi
- {#1}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@gensign}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% The sign generator starts by calling the procedure to check if the
-% input contains a valid one- or two-digit sign. The results are
-% returned as \cs{si@num@sign} and \cs{si@num@value}.
-% \begin{macrocode}
-\newcommand*{\si@num@gensign}[1]{%
- \expandafter\expandafter\expandafter\si@num@findsign
- \csname si@num@#1\endcsname\@empty\@empty
-% \end{macrocode}
-% If no sign has been found, then there may be a need to add one
-% anyway.
-% \begin{macrocode}
- \ifx\@empty\si@num@sign\@empty
- \ifx\@empty\si@num@value\@empty
- \expandafter\expandafter\expandafter\@gobble
- \else
- \expandafter\expandafter\expandafter\si@num@addsign
- \fi
- \else
- \expandafter\@gobble
- \fi
- {#1}%
-% \end{macrocode}
-% The appropriate storage areas are now assigned.
-% \begin{macrocode}
- \expandafter\let\csname si@num@#1sign\endcsname\si@num@sign
- \expandafter\let\csname si@num@#1\endcsname\si@num@value}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@findsign}
-%\begin{macro}{\si@num@sign}
-%\begin{macro}{\si@num@value}
-% The first one or two characters of the mantissa or exponent may
-% contain a sign. To test for this, the first two characters of the
-% number are split off, and examined. Two characters are used so
-% that \cs{pm} and \cs{mp} can be represented by |+-| and |-+|,
-% respectively. To allow the user to alter the valid signs, but
-% retain this conversion, the generic character test is used before
-% checking specific matches.
-% \begin{macrocode}
-\newcommand*{\si@num@sign}{}
-\def\si@num@findsign#1#2#3\@empty{%
- \si@num@delplusfalse
- \si@str@ifchrstr{#1}{\si@numsign}{%
- \si@str@ifchrstr{#2}{\si@numsign}{%
- \if +#1%
- \if -#2%
- \si@log@debug{Found sign combination +- for
- `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{{\si@pm}}%
- \else
- \si@log@inf{Unknown sign combination `#1#2'}%
- \renewcommand*{\si@num@sign}{{#1#2}}%
- \fi
- \else
- \if -#1%
- \if +#2%
- \si@log@debug{Found sign combination -+ for
- `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{{\mp}}%
- \else
- \si@log@inf{Unknown sign combination `#1#2'}%
- \renewcommand*{\si@num@sign}{{#1#2}}%
- \fi
- \else
- \si@log@inf{Unknown sign combination `#1#2'}%
- \renewcommand*{\si@num@sign}{{#1#2}}%
- \fi
- \fi
- \protected@edef\si@num@value{#3}}%
-% \end{macrocode}
-% Only one valid sign character.
-% \begin{macrocode}
- {\si@log@debug{Found single sign character `#1' for
- `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{{#1}}%
- \if +#1%
- \ifsi@retainplus\else
- \expandafter\expandafter\expandafter\si@num@killsign
- \fi
- \fi
- \protected@edef\si@num@value{#2#3}}}%
-% \end{macrocode}
-% No valid sign, so \cs{@empty} is returned for the sign .
-% \begin{macrocode}
- {\si@log@debug{No sign found for `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{}%
- \protected@edef\si@num@value{#1#2#3}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@num@delplus}
-%\begin{macro}{\si@num@killsign}
-% A simple spin-out to remove a plus sign. A flag is set as it might
-% be useful to know this.
-% \begin{macrocode}
-\newif\ifsi@num@delplus
-\newcommand*{\si@num@killsign}{%
- \si@num@delplustrue
- \renewcommand*{\si@num@sign}{}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@addsign}
-%\begin{macro}{\si@num@asign}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% The macro to add a sign to an unsigned number has to check whether
-% this is a mantissa or an exponent. The result is still placed in
-% \cs{si@num@sign} for ease of processing later.
-% \begin{macrocode}
-\newcommand*{\si@num@addsign}[1]{%
- \begingroup
- \renewcommand*{\si@tempa}{#1}%
- \renewcommand*{\si@tempb}{mant}%
- \ifx\si@tempa\si@tempb
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup
- {\ifsi@num@signmant
- \expandafter\si@num@asign
- \else
- \expandafter\@gobble
- \fi
- {mantissa}}
- {\ifsi@num@signexp
- \expandafter\si@num@asign
- \else
- \expandafter\@gobble
- \fi
- {exponent}}}
-\newcommand*{\si@num@asign}[1]{%
- \let\si@num@sign\si@sign
- \si@log@debug{Adding sign \si@sign\space to #1 for
- `\si@num@arg'}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@procnum}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% The control macro for processing the number (plus any extra
-% characters).
-% \begin{macrocode}
-\newcommand*{\si@num@procnum}[1]{%
- \expandafter\ifx\expandafter\@empty
- \csname si@num@#1\endcsname\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@finddigits
- \fi
- {#1}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@predec}
-%\begin{macro}{\si@num@postdec}
-% Two new storage areas are defined.
-% \begin{macrocode}
-\newcommand*{\si@num@predec}{}
-\newcommand*{\si@num@postdec}{}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@finddigits}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% The core digit processor divides the number into the parts before
-% and after the decimal point marker. The temporary switch is used
-% to indicate finding a decimal marker.
-% \begin{macrocode}
-\newcommand*{\si@num@finddigits}[1]{%
- \renewcommand*{\si@num@predec}{}%
- \renewcommand*{\si@num@postdec}{}%
- \si@switchfalse
- \expandafter\expandafter\expandafter\si@num@digits
- \csname si@num@#1\endcsname\@empty\@empty
-% \end{macrocode}
-% Tests are now made to see if padding zeros are needed. The
-% trailing test needs to verify if a decimal marker was found, as
-% well as if a zero is needed.
-% \begin{macrocode}
- \ifx\@empty\si@num@predec\@empty
- \ifsi@num@padlead
- \expandafter\expandafter\expandafter\si@num@addprezero
- \fi
- \fi
- \ifx\@empty\si@num@postdec\@empty
- \ifsi@num@padtrail
- \ifsi@switch
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter
- \si@num@addpostzero
- \fi
- \fi
- \fi
-% \end{macrocode}
-% The next checks to make concern input validity in a more
-% mathematical sense. First, if the number is zero, then no sign
-% should be given under any circumstances. Then leading zeros need
-% to be removed from the input. This is slightly complicated by the
-% potential presence of ``extra'' characters.
-% \begin{macrocode}
- \si@num@unsign{#1}%
- \ifx\@empty\si@num@predec\@empty
- \else
- \expandafter\si@num@nozero
- \fi
-% \end{macrocode}
-% A sanity check is made to ensure that the supplied number consisted
-% of more than a decimal marker.
-% \begin{macrocode}
- \ifx\@empty\si@num@predec\@empty
- \ifx\@empty\si@num@postdec\@empty
- \expandafter\expandafter\expandafter\@gobble
- \else
- \expandafter\expandafter\expandafter\si@num@sepdigits
- \fi
- \else
- \expandafter\si@num@sepdigits
- \fi
- {#1}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@digits}
-% The \cs{si@num@digits} macro compares each character in the input
-% against the list of characters valid at this stage: numbers,
-% decimal markers and ``extra'' characters.
-% \begin{macrocode}
-\def\si@num@digits#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numdecimal}
- {\ifsi@switch
- \si@log@err{Duplicate decimal marker in `\si@num@arg'}
- {Only a single decimal marker (from the list
- `\si@numdecimal')\MessageBreak may occur in a
- numerical argument}%
- \else
- \si@log@debug{Found decimal marker `#1' in
- `\si@num@arg'}%
- \expandafter\si@switchtrue
- \fi}
-% \end{macrocode}
-% The earlier code only checks for a sign at the start of the text. A
-% check is therefore needed for a sign after the first two
-% characters; if one is found, it is ignored.
-% \begin{macrocode}
- {\si@str@ifchrstr{#1}{\si@numsign}
- {\si@log@err{Misplaced sign character
- `#1' in `\si@num@arg'}
- {Sign characters `\si@numsign' can only
- occur\MessageBreak at the start of a number}}
-% \end{macrocode}
-% The current character is added to the appropriate stack; this is
-% ``spun out'' to avoid problems with expansion of the switch code.
-% \begin{macrocode}
- {\ifsi@switch
- \expandafter\si@num@post
- \else
- \expandafter\si@num@pre
- \fi
- {#1}}}%
- \ifx\@empty#2\@empty\else
- \si@num@digits#2\@empty\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@pre}
-%\begin{macro}{\si@num@post}
-%\darg{char}
-% Storage of the result is spun out.
-% \begin{macrocode}
-\newcommand*{\si@num@pre}[1]{%
- \si@num@prepost{#1}{pre}{integer}}
-\newcommand*{\si@num@post}[1]{%
- \si@num@prepost{#1}{post}{decimal}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@prepost}
-%\darg{char}
-%\darg{either \texttt{pre} or \texttt{post}}
-%\darg{info-text}
-% Then actually stored here.
-% \begin{macrocode}
-\newcommand*{\si@num@prepost}[3]{%
- \expandafter\protected@edef\csname si@num@#2dec\endcsname{%
- \csname si@num@#2dec\endcsname#1}%
- \si@log@debug{Adding `#1' to #3 part for `\si@num@arg'}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@addprezero}
-%\begin{macro}{\si@num@addpostzero}
-% A similar set of macros are used for the padding zeros.
-% \begin{macrocode}
-\newcommand*{\si@num@addprezero}{%
- \si@num@addpzero{pre}{leading}}
-\newcommand*{\si@num@addpostzero}{%
- \si@num@addpzero{post}{trailing}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@addpzero}
-%\darg{either \texttt{pre} or \texttt{post}}
-% In this case, there is no argument to be passed along.
-% \begin{macrocode}
-\newcommand*{\si@num@addpzero}[2]{%
- \si@log@debug{Adding #2 zero for `\si@num@arg'}%
- \@namedef{si@num@#1dec}{0}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@unsign}
-%\begin{macro}{\si@num@nosign}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% The trap for a sign with zero numerical input is made. First, a
-% check is made to see if there is a sign to worry about. The pre-
-% and post-decimal parts are then examined, to see if they contain
-% something other than ``0'' or an extra character.
-% \begin{macrocode}
-\newcommand*{\si@num@unsign}[1]{%
- \expandafter\ifx\expandafter\@empty
- \csname si@num@#1sign\endcsname\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@nosign
- \fi
- {#1}}
-\newcommand*{\si@num@nosign}[1]{%
- \begingroup
- \si@switchtrue
- \si@str@ifonlychrs{\si@num@predec\si@num@postdec}{0}
- {\si@switchfalse}{}%
- \ifsi@switch
- \aftergroup\@gobble
- \else
- \aftergroup\@firstofone
- \fi
- \endgroup
- {\si@log@debug{Zero value: removing any sign}%
- \ifsi@ang@sign\else
- \@namedef{si@num@#1sign}{}%
- \fi}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@nozero}
-% A very short test for a totally zero pre-decimal component.
-% \begin{macrocode}
-\newcommand*{\si@num@nozero}{%
- \si@str@ifonlychrs{\si@num@predec}{0}
- {\renewcommand*{\si@num@predec}{0}}{}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@decimalhook}
-% A hook is needed to attach things inside the group to happen
-% afterwards, if the number is a decimal.
-% \begin{macrocode}
-\newcommand*{\si@num@decimalhook}{}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@sepdigits}
-%\darg{either \texttt{mant} or \texttt{exp}}
-% The \cs{si@num@sepdigits} macro is only called if at least one of
-% the mantissa and exponent contain something to output.
-% \begin{macrocode}
-\newcommand*{\si@num@sepdigits}[1]{%
-% \end{macrocode}
-% First an overall check is needed for additional characters. By
-% altering the contents of \cs{si@numextra}, the same code can be
-% shared by two different checks.
-% \begin{macrocode}
- \begingroup
- \let\si@numextra\si@numaddn
- \protected@edef\si@tempa{\si@num@predec\si@num@postdec}%
- \si@num@ifextra{\si@tempa}
- {\aftergroup\@gobble}
- {\aftergroup\@firstofone}%
- \endgroup
-% \end{macrocode}
-% Separation of the error in a number from the number itself is only
-% attempted for the mantissa.
-% \begin{macrocode}
- {\renewcommand*{\si@tempb}{mant}%
- \renewcommand*{\si@tempc}{#1}%
- \ifx\si@tempb\si@tempc
- \expandafter\si@num@checkerr
- \fi}%
-% \end{macrocode}
-%\changes{v1.1}{2008/08/22}{Fixed-length code generalised}
-%\changes{v1.1}{2008/08/26}{Length-fixing only applies to
-% manitssa}
-% If both parts of the number contain only digits, then any rounding
-% can be attempted if there is no error part. Otherwise, the input
-% must be left alone.
-% \begin{macrocode}
- \protected@edef\si@tempa{\si@num@predec\si@num@postdec}%
- \expandafter\si@str@ifonlychrs\expandafter{\si@tempa}
- {0123456789}
- {\ifx\@empty\si@num@err\@empty
- \renewcommand*{\si@tempb}{mant}%
- \renewcommand*{\si@tempc}{#1}%
- \ifx\si@tempb\si@tempc
- \expandafter\expandafter\expandafter\si@num@fixlength
- \fi
- \fi}{}%
-% \end{macrocode}
-% If the pre-decimal part contains nothing except numbers, then
-% digit separation is carried out.
-% \begin{macrocode}
- \si@num@ifextra{\si@num@predec}{}
- {\expandafter\si@num@int\expandafter{\si@num@predec}}%
-% \end{macrocode}
-% A decision is made about the decimal sign, then digit separation
-% occurs on the post-decimal part of the number.
-% \begin{macrocode}
- \renewcommand*{\si@tempc}{}%
- \ifx\@empty\si@num@postdec\@empty\else
- \si@num@decimalhook
- \renewcommand*{\si@tempc}{%
- \ensuremath{{\si@decimalsymbol}}}%
- \si@num@ifextra{\si@num@postdec}{}
- {\expandafter\si@num@dec\expandafter{\si@num@postdec}}%
- \fi
-% \end{macrocode}
-% The construction is finalised by re-combining the number.
-% \begin{macrocode}
- \expandafter\protected@edef\csname si@num@#1\endcsname
- {\si@num@predec\si@tempc\si@num@postdec}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@ifextra}
-%\begin{macro}{\si@num@extra}
-%\darg{number}
-% A relatively simple test for ``extra'' characters. Once again, a
-% bit of group trickery is used.
-% \begin{macrocode}
-\newcommand*{\si@num@ifextra}[1]{%
- \begingroup
- \si@switchfalse
- \expandafter\si@num@extra#1\@empty\@empty
- \ifsi@switch
- \si@log@debug{Found `extra' characters in `#1'}%
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@num@extra#1#2\@empty{%
- \ifx\@empty#1\@empty\else
- \si@str@ifchrstr{#1}{\si@numextra}{\si@switchtrue}{}%
- \ifx\@empty#2\@empty\else
- \si@num@extra#2\@empty\@empty
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@num@ambigerr}
-%\begin{macro}{\si@num@checkerr}
-% When separating out an error from a number, the first step is to
-% see if there is a decimal part to the number. If so, any error
-% must be in that part of the decimal part; it is not possible to
-% have an error starting in the integer part and continuing into the
-% decimal part.
-% \begin{macrocode}
-\newif\ifsi@num@ambigerr
-\newcommand*{\si@num@checkerr}{%
- \ifx\@empty\si@num@postdec\@empty
- \expandafter\si@num@preerr
- \else
- \expandafter\si@num@posterr
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@preerr}
-% Errors in integers are easy to handle. After finding the error,
-% the result is simply stored in the error macro \cs{si@num@err}.
-% \begin{macrocode}
-\newcommand*{\si@num@preerr}{%
- \si@num@seperr{pre}%
- \ifx\@empty\si@tempb\@empty\else
- \expandafter\renewcommand\expandafter*\expandafter
- \si@num@err\expandafter{\si@tempb}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@posterr}
-%\begin{macro}{\si@num@psterr}
-% Life is more complex for an error in the decimal part. This is
-% found, then it may need zero-filling or the insertion of a decimal
-% point. This depends on whether the number of error digits is
-% larger than the number of post-decimal digits.
-% \begin{macrocode}
-\newcommand*{\si@num@posterr}{%
- \si@num@seperr{post}%
- \ifx\@empty\si@tempb\@empty\else
- \ifsi@seperr
- \expandafter\expandafter\expandafter\si@num@psterr
- \else
- \let\si@num@err\si@tempb
- \fi
- \fi}
-\newcommand*{\si@num@psterr}{%
- \si@num@cntdigits{\si@tempb}%
- \si@tempcntb\si@tempcnta\relax
- \si@num@cntdigits{\si@num@postdec}%
- \ifnum\si@tempcnta<\si@tempcntb\relax
- \expandafter\si@num@largeerr
- \else
- \expandafter\si@num@smallerr
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@seperr}
-%\begin{macro}{\si@num@finderr}
-%\darg{either \texttt{pre} or \texttt{post}}
-% The usual hand-off is made for searching for an error.
-% \begin{macrocode}
-\newcommand*{\si@num@seperr}[1]{%
- \si@switchfalse
- \renewcommand*{\si@tempa}{}%
- \renewcommand*{\si@tempb}{}%
- \expandafter\expandafter\expandafter\si@num@finderr
- \csname si@num@#1dec\endcsname\@empty\@empty
- \ifx\@empty\si@tempb\@empty\else
- \expandafter\let\csname si@num@#1dec\endcsname\si@tempa
- \fi}
-\def\si@num@finderr#1#2\@empty{%
-% \end{macrocode}
-% First a check for the opening character of an error.
-% \begin{macrocode}
- \si@str@ifchrstr{#1}{\si@numopenerr}
-% \end{macrocode}
-% If the switch is set when an error is found, then something is
-% wrong.
-% \begin{macrocode}
- {\ifsi@switch
- \si@log@err{Invalid error in number}
- {The numerical argument \si@num@arg\space has two (or
- more)\MessageBreak error-opening characters}%
- \else
- \expandafter\si@switchtrue
- \fi}
-% \end{macrocode}
-% The end-of-error character has to be the last item of the input,
-% and an error needs to start before it ends.
-% \begin{macrocode}
- {\si@str@ifchrstr{#1}{\si@numcloseerr}
- {\ifsi@switch
- \ifx\@empty#2\@empty\else
- \si@log@err{Invalid error in number}
- {The numerical argument \si@num@arg\space has an
- error-closing before the last character}%
- \fi
- \else
- \si@log@err{Invalid error in number}
- {The numerical argument \si@num@arg\space has an
- error-closing character\MessageBreak but no
- error-opening one}%
- \fi}
-% \end{macrocode}
-% The input must be a digit. It is stored in the appropriate area.
-% \begin{macrocode}
- {\ifsi@switch
- \expandafter\si@num@addtmpb
- \else
- \expandafter\si@num@addtmpa
- \fi
- {#1}}}%
- \ifx\@empty#2\@empty\else
- \si@num@finderr#2\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@addtmpa}
-%\begin{macro}{\si@num@addtmpb}
-%\darg{number}
-% Some quick methods for adding to the temporary macros with \cs{if}
-% expansion.
-% \begin{macrocode}
-\newcommand*{\si@num@addtmpa}[1]{\si@num@addtmp{a}{#1}}
-\newcommand*{\si@num@addtmpb}[1]{\si@num@addtmp{b}{#1}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@addtmp}
-%\darg{either \texttt{a} or \texttt{b}}
-%\darg{number}
-% The addition is committed.
-% \begin{macrocode}
-\newcommand*{\si@num@addtmp}[2]{%
- \expandafter\protected@edef\csname si@temp#1\endcsname{%
- \csname si@temp#1\endcsname#2}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@cntdigits}
-%\begin{macro}{\si@num@cntdgt}
-%\darg{number}
-% A recursive system for counting the number of characters in a given
-% input; only used here to count digits in a number.
-% \begin{macrocode}
-\newcommand*{\si@num@cntdigits}[1]{%
- \si@tempcnta\z@\relax
- \expandafter\si@num@cntdgt#1\@empty\@empty}
-\def\si@num@cntdgt#1#2\@empty{%
- \ifx\@empty#1\@empty\else
- \advance\si@tempcnta\@ne\relax
- \fi
- \ifx\@empty#2\@empty\else
- \expandafter\si@num@cntdgt#2\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@smallerr}
-%\begin{macro}{\si@num@serr}
-% For handling an error with no more digits than the post-decimal
-% part of a number, zero-padding is undertaken before adding a
-% decimal sign and (possibly) leading zero.
-% \begin{macrocode}
-\newcommand*{\si@num@smallerr}{%
- \si@tempcntb\si@tempcnta\relax
- \si@num@serr
- \protected@edef\si@num@err{%
- \ifsi@num@padlead0\fi\expandafter\@car\si@numdecimal\@nil
- \si@tempb}}
-\newcommand*{\si@num@serr}{%
- \si@num@cntdigits{\si@tempb}%
- \ifnum\si@tempcnta=\si@tempcntb\relax\else
- \protected@edef\si@tempb{0\si@tempb}%
- \expandafter\si@num@serr
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@largeerr}
-%\changes{v1.0m}{2008/09/16}{Fixed problem with error separation
-% crossing decimal boundary}
-%\begin{macro}{\si@num@lerr}
-%\begin{macro}{\si@num@movedigit}
-% When the error has more digits than the decimal part, some
-% shuffling is needed.
-% \begin{macrocode}
-\newcommand*{\si@num@largeerr}{%
- \renewcommand*{\si@tempa}{}%
- \si@tempcntb\si@tempcnta\relax
- \si@num@lerr
- \protected@edef\si@num@err{%
- \si@tempa\expandafter\@car\si@numdecimal\@nil\si@tempb}}
-\newcommand*{\si@num@lerr}{%
- \si@num@cntdigits{\si@tempb}%
- \ifnum\si@tempcnta=\si@tempcntb\relax\else
- \expandafter\si@num@movedigit\si@tempb\@empty\@empty
- \si@num@lerr
- \fi}
-\def\si@num@movedigit#1#2\@empty{%
- \protected@edef\si@tempa{\si@tempa#1}%
- \protected@edef\si@tempb{#2}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@fixlength}
-% The checks for fixing number length are spun out here.
-% \begin{macrocode}
-\newcommand*{\si@num@fixlength}{%
- \ifsi@fixdp
- \expandafter\si@num@fixdp
- \else
- \ifsi@fixsf
- \expandafter\expandafter\expandafter\si@num@fixsf
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@fixdp}
-% The test for fixing decimal places starts by counting up the number
-% of decimal digits. The number is then padded, rounded or left
-% alone.
-% \begin{macrocode}
-\newcommand*{\si@num@fixdp}{%
- \si@num@cntdigits{\si@num@postdec}%
- \ifx\@empty\si@num@postdec\@empty
- \si@tempcnta\z@\relax
- \fi
- \ifnum\si@tempcnta>\si@num@dp\relax
- \expandafter\si@num@round
- \else
- \ifnum\si@tempcnta<\si@num@dp\relax
- \expandafter\expandafter\expandafter\si@num@pad
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@pad}
-%\begin{macro}{\si@num@pd}
-% Padding a number is a relatively easy matter. The number of digits
-% is increased by adding ``$0$'' recursively.
-% \begin{macrocode}
-\newcommand*{\si@num@pad}{%
- \si@log@debug{Padding to \the\si@num@dp\space digits}%
- \loop\ifnum\si@tempcnta<\si@num@dp\si@num@pd\repeat}
-\newcommand*{\si@num@pd}{%
- \advance\si@tempcnta\@ne\relax
- \protected@edef\si@num@postdec{\si@num@postdec0}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@rndtarget}
-%\changes{v1.1}{2008/08/25}{New counter}
-% A scratch counter is created to allow some code sharing between
-% fixing decimal places and significant figures.
-% \begin{macrocode}
-\newcount\si@num@rndtarget
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@round}
-%\begin{macro}{\si@num@prernd}
-%\begin{macro}{\si@num@postrnd}
-%\begin{macro}{\si@num@rndstart}
-%\changes{v1.1}{2008/08/25}{Separated out from \cs{si@num@round}}
-% Rounding a number is more complicated. The main macro here relies
-% on several others, and is simply a set-up and hand-off system.
-% \begin{macrocode}
-\newcommand*{\si@num@prernd}{}
-\newcommand*{\si@num@postrnd}{}
-\newcommand*{\si@num@round}{%
- \si@log@debug{Rounding to \the\si@num@dp\space digits}%
- \si@num@rndtarget\si@num@dp\relax
- \si@num@rndstart}
-\newcommand*{\si@num@rndstart}{%
- \si@num@reverse{\si@num@postdec}%
- \si@num@reverse{\si@num@predec}%
- \let\si@num@prernd\si@num@predec
- \let\si@num@postrnd\si@num@postdec
- \renewcommand*{\si@num@predec}{}%
- \renewcommand*{\si@num@postdec}{}%
- \si@switchfalse
- \si@num@rnd}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@reverse}
-%\begin{macro}{\si@num@rev}
-%\darg{storage-macro}
-% The initial stage is to reverse the entire number, to make life
-% easier. This is then undone by the other macros as the output is
-% constructed.
-% \begin{macrocode}
-\newcommand*{\si@num@reverse}[1]{%
- \renewcommand*{\si@tempa}{}%
- \expandafter\si@num@rev#1\@empty\@empty
- \let#1\si@tempa}
-\def\si@num@rev#1#2\@empty{%
- \edef\si@tempa{#1\si@tempa}%
- \ifx\@empty#2\@empty\else
- \si@num@rev#2\@empty\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@rnd}
-%\changes{v1.1}{2008/08/25}{Altered check for ending to generalise
-% code}
-%\begin{macro}{\si@num@rndpre}
-%\begin{macro}{\si@num@rndpost}
-%\changes{v1.0b}{2008/06/23}{Corrected bug in rounding code}
-% The core looping macro of the system simply divides the flow
-% between rounding before and after the decimal. The two routines
-% are quite similar, but have subtly different requirements. Both
-% take one character at a time from the input, increment if there is
-% a carry digit, check its value, and add to the output string. This
-% is very similar to the same routines used in other macro packages
-% to achieve the same thing.
-% \begin{macrocode}
-\newcommand*{\si@num@rnd}{%
- \ifx\@empty\si@num@postrnd\@empty
- \expandafter\si@num@rndpre
- \else
- \expandafter\si@num@rndpost
- \fi}
-\newcommand*{\si@num@rndpre}{%
- \expandafter\edef\expandafter\si@tempa\expandafter{%
- \expandafter\@car\si@num@prernd\@nil}%
- \expandafter\edef\expandafter\si@num@prernd\expandafter{%
- \expandafter\@cdr\si@num@prernd\@nil}%
- \si@tempcntb\si@tempa\relax
- \ifsi@switch
- \advance\si@tempcntb\@ne\relax
- \fi
- \si@switchfalse
- \ifnum\si@tempcntb=10\relax
- \si@tempcntb\z@\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@predec{\the\si@tempcntb\si@num@predec}%
- \ifx\@empty\si@num@prernd\@empty
- \ifsi@switch
- \edef\si@num@predec{1\si@num@predec}%
- \fi
- \else
- \expandafter\si@num@rnd
- \fi}
-\newcommand*{\si@num@rndpost}{%
- \expandafter\edef\expandafter\si@tempa\expandafter{%
- \expandafter\@car\si@num@postrnd\@nil}%
- \expandafter\edef\expandafter\si@num@postrnd\expandafter{%
- \expandafter\@cdr\si@num@postrnd\@nil}%
- \si@tempcntb\si@tempa\relax
- \ifsi@switch
- \advance\si@tempcntb\@ne\relax
- \fi
- \si@switchfalse
- \advance\si@num@rndtarget\@ne\relax
- \ifnum\si@tempcnta>\si@num@rndtarget\relax
- \advance\si@num@rndtarget\m@ne\relax
- \else
- \advance\si@num@rndtarget\m@ne\relax
- \ifnum\si@tempcnta>\si@num@rndtarget\relax
- \ifnum\si@tempcntb>4\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \else
- \ifnum\si@tempcntb=10\relax
- \si@tempcntb\z@\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@postdec{\the\si@tempcntb\si@num@postdec}%
- \fi
- \fi
- \advance\si@tempcnta\m@ne\relax
-% \end{macrocode}
-% If \cs{si@tempcnta} is negative, this must be the significant
-% figures routine and one digit needs to be thrown away.
-% \begin{macrocode}
- \ifnum\si@tempcnta=\m@ne\relax
- \si@num@throw
- \fi
- \si@num@rnd}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@throw}
-% Throw one digit away from the end of the post-decimal part.
-% \begin{macrocode}
-\newcommand*{\si@num@throw}{%
- \si@num@reverse{\si@num@postdec}%
- \edef\si@num@postdec{\expandafter\@cdr\si@num@postdec\@nil}%
- \si@num@reverse{\si@num@postdec}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@fixsf}
-% Setting up a fixed number of significant figures is rather more
-% complicated than fixing the decimal places. There are a number of
-% tests needed to see what needs to be done.
-% \begin{macrocode}
-\newcommand*{\si@num@fixsf}{%
- \si@num@cntdigits{\si@num@predec}%
- \ifx\@empty\si@num@predec\@empty
- \si@tempcnta\z@\relax
- \fi
-% \end{macrocode}
-% If the pre-decimal component has only a single digit, it could be
-% ``0'': if so, only the significant figures in the decimal part are
-% counted.
-% \begin{macrocode}
- \ifnum\si@tempcnta=\@ne\relax
- \renewcommand*{\si@tempa}{0}%
- \ifx\si@num@predec\si@tempa
-% \end{macrocode}
-% The number of significant digits after the decimal point have to be
-% counted up. If there are enough digits there, then some rounding
-% will again be needed.
-% \begin{macrocode}
- \ifx\@empty\si@num@postdec\@empty\else
- \si@tempcnta\z@\relax
- \si@switchfalse
- \expandafter\si@num@cntpostsf\si@num@postdec
- \@empty\@empty
- \ifnum\si@tempcnta>\si@num@sf\relax
- \si@log@debug{Rounding to \the\si@num@sf\space
- figures}%
- \si@num@rndtarget\si@num@sf\relax
- \si@num@rndstart
- \fi
- \fi
- \else
- \si@num@cntprepost
- \fi
- \else
-% \end{macrocode}
-% If there are too many digits in the pre-decimal part, a check is
-% first made to see if there may be a need to round from the first
-% post-decimal digit. If not, the post decimal part is thrown away.
-% \begin{macrocode}
- \ifnum\si@tempcnta<\si@num@sf\relax
- \si@num@cntprepost
- \else
- \advance\si@tempcnta\m@ne\relax
- \si@switchfalse
- \ifnum\si@tempcnta>\si@num@sf\relax\else
- \ifx\@empty\si@num@postdec\@empty\else
- \edef\si@num@postdec{\expandafter\@car
- \si@num@postdec\@nil}%
- \ifnum\si@num@postdec>4\relax
- \expandafter\si@switchtrue
- \fi
- \fi
- \fi
- \advance\si@tempcnta\@ne\relax
- \renewcommand*{\si@num@postdec}{}%
- \si@num@reverse{\si@num@predec}%
- \let\si@num@prernd\si@num@predec
- \renewcommand*{\si@num@predec}{}%
- \si@num@sfpre
- \ifsi@switch
- \edef\si@num@predec{1\si@num@predec}%
- \fi
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@cntpostsf}
-% Counting up significant figures in the post-decimal part needs an
-% auxiliary macro.
-% \begin{macrocode}
-\def\si@num@cntpostsf#1#2\@empty{%
- \ifsi@switch
- \advance\si@tempcnta\@ne\relax
- \else
- \if 0#1\relax\else
- \si@tempcnta\@ne\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \fi
- \ifx\@empty#2\@empty\else
- \si@num@cntpostsf#2\@empty\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@cntprepost}
-% There are two routes to find that the number of digits in both
-% parts of the number are important. In either case, rounding is
-% only needed if the two parts have too many digits.
-% \begin{macrocode}
-\newcommand*{\si@num@cntprepost}{%
- \si@tempcntb\si@tempcnta\relax
- \si@num@cntdigits{\si@num@postdec}%
- \advance\si@tempcnta\si@tempcntb\relax
- \ifnum\si@tempcnta>\si@num@sf
- \si@log@debug{Rounding to \the\si@num@sf\space figures}%
- \si@num@rndtarget\si@num@sf\relax
- \si@num@rndstart
- \ifsi@switch
- \si@num@throw
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@sfpre}
-% The code here is very similar to that used to round to a fixed
-% number of decimal places.
-% \begin{macrocode}
-\newcommand*{\si@num@sfpre}{%
- \expandafter\edef\expandafter\si@tempa\expandafter{%
- \expandafter\@car\si@num@prernd\@nil}%
- \expandafter\edef\expandafter\si@num@prernd\expandafter{%
- \expandafter\@cdr\si@num@prernd\@nil}%
- \si@tempcntb\si@tempa\relax
- \ifsi@switch
- \advance\si@tempcntb\@ne\relax
- \fi
- \si@switchfalse
- \advance\si@num@sf\@ne\relax
- \ifnum\si@tempcnta>\si@num@sf\relax
- \advance\si@num@sf\m@ne\relax
- \edef\si@num@predec{0\si@num@predec}%
- \else
- \advance\si@num@sf\m@ne\relax
- \ifnum\si@tempcnta>\si@num@sf\relax
- \ifnum\si@tempcntb>4\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@predec{0\si@num@predec}%
- \else
- \ifnum\si@tempcntb=10\relax
- \si@tempcntb\z@\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@predec{\the\si@tempcntb\si@num@predec}%
- \fi
- \fi
- \advance\si@tempcnta\m@ne\relax
- \ifx\@empty\si@num@prernd\@empty\else
- \expandafter\si@num@sfpre
- \fi}
-% \end{macrocode}
-%\end{macro}
-%
-%\begin{macro}{\si@num@int}
-%\darg{integer-part}
-% The formatting code for separating thousands is taken more-or-less
-% directly from \SIstyle. A few changes are made to fit the various
-% conventions here. Following on from the code above, \cs{si@tempa}
-% is used to store the integer part of the number, and \cs{si@tempb}
-% is used for the decimal part.
-% \begin{macrocode}
-\newcommand*{\si@num@int}[1]{%
- \renewcommand*{\si@num@predec}{}%
- \ifsi@sepfour
- \si@num@intfmt{}#1\@empty\@empty\@empty
- \else
- \si@num@iffive{#1}
- {\si@num@intfmt{}#1\@empty\@empty\@empty}
- {\renewcommand*{\si@num@predec}{#1}}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@iffive}
-%\begin{macro}{\si@num@five}
-%\darg{number}
-% A test is needed for the presence of more than four characters.
-% \begin{macrocode}
-\newcommand*{\si@num@iffive}[1]{%
- \si@num@five#1\@empty\@empty\@empty\@empty\@empty\end}
-\def\si@num@five#1#2#3#4#5\end{%
- \ifx\@empty#5\@empty
- \expandafter\@secondoftwo
- \else
- \expandafter\@firstoftwo
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@intfmt}
-%\begin{macro}{\si@num@fiint}
-% The business end of the integer formatter.
-% \begin{macrocode}
-\newcommand*{\si@num@intfmt}[4]{%
- \ifx\@empty#2\@empty
- \si@num@intsep#1\relax
- \else
- \ifx\@empty#3\@empty
- \si@num@intsep\@empty\@empty#1#2\relax
- \else
- \ifx\@empty#4\@empty
- \si@num@intsep\@empty#1#2#3\relax
- \else
- \si@num@fiint{#1#2#3#4}%
- \fi
- \fi
- \fi}
-\def\si@num@fiint#1\fi\fi\fi{\fi\fi\fi\si@num@intfmt{#1}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@intsep}
-% For adding separation to integers, an extra function is needed.
-% \begin{macrocode}
-\newcommand*{\si@num@intsep}[4]{%
- \protected@edef\si@num@predec{\si@num@predec#1#2#3}%
- \if\relax#4\relax\else
- \protected@edef\si@num@predec{%
- \si@num@predec\ensuremath{\noexpand\si@digitsep}}%
- \expandafter\si@num@intsep\expandafter#4%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@dec}
-%\begin{macro}{\si@num@decfmt}
-%\darg{decimal-part}
-% Formatting a decimal uses a similar mechanism, but with a few
-% alterations needed.
-% \begin{macrocode}
-\newcommand*{\si@num@dec}[1]{%
- \renewcommand*{\si@num@postdec}{}%
- \ifsi@sepfour
- \si@num@decfmt#1\@empty\@empty\@empty\@empty
- \else
- \si@num@iffive{#1}
- {\si@num@decfmt#1\@empty\@empty\@empty\@empty}
- {\protected@edef\si@num@postdec{\si@num@postdec#1}}%
- \fi}
-\newcommand*{\si@num@decfmt}[4]{%
- \protected@edef\si@num@postdec{\si@num@postdec#1#2#3}%
- \ifx\@empty#4\@empty%
- \else
- \protected@edef\si@num@postdec{%
- \si@num@postdec\ensuremath{\noexpand\si@digitsep}}%
- \expandafter\si@num@decfmt\expandafter#4%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@num@procerr}
-% Any error is recycled to to formatted correctly. The $\pm$ sign,
-% and any unit, are also added.
-% \begin{macrocode}
-\newcommand*{\si@num@procerr}{%
- \si@num@addunit
- \ensuremath{\si@pm}%
- \expandafter\si@num\expandafter{\si@num@err}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@sepxpart}
-%\changes{v1.3}{2009/09/20}{Problem using \opt{textmode} corrected}
-% A similar approach for numbers containing products, except the
-% first token of the input has to be deleted.
-% \begin{macrocode}
-\newcommand*{\si@num@sepxpart}{%
- \si@num@addunit
- \ensuremath{{}\times{}}%
- \expandafter\expandafter\expandafter\si@num\expandafter
- \expandafter\expandafter{%
- \expandafter\@cdr\si@num@xpart\@nil}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@num@addunit}
-%\changes{v1.2h}{2008/03/26}{Minor bug fix for repeated units and text
-% mode values}
-% A short macro to add units if needed.
-% \begin{macrocode}
-\newcommand*{\si@num@addunit}{%
- \si@unt@numtrue
- \ifx\@empty\si@unt@unitarg\@empty\else
- \ifsi@repeatunits
- \begingroup
- \si@out@numfalse
- \si@fam@setfalse
- \si@fam@set
- \si@unt@printunit{\si@unt@unitarg}%
- \endgroup
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%
-%\subsection{Formatting angles}
-%\begin{macro}{\ang}
-%\doarg{keyval options}
-%\darg{angle, either in decimal or deg;min;sec format}
-% The approach used here is similar to that in \SIstyle, but has been
-% modified in a few ways.
-% \begin{macrocode}
-\si@newrobustcmd*{\ang}[2][]{%
- \begingroup
- \sisetup{#1}%
- \si@fam@mode
- \si@log@debug{Processing \string\ang\space input `#2'}%
- \@makeother{\;}%
- \makeatletter
- \scantokens{\si@ang@parse#2;;;\@nil}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@ang@parse}
-% With the correct catcodes in place, processing can take place strip
-% out the semi-colons. Here, the input must either contain no
-% semi-colons or two semi-colons.
-% \begin{macrocode}
-\def\si@ang@parse#1;#2;#3;#4\@nil{%
- \let\ifsi@ang@fixdp\ifsi@fixdp
- \si@fixdpfalse
- \si@ifmtarg{#4}
- {\si@log@debug{Angle argument contains no
- semi-colons:\MessageBreak decimal angle}%
- \si@ang@dec{#1}{}{}}
- {\si@log@debug{Angle argument contains
- semi-colons:\MessageBreak degree-minute-second angle}%
- \renewcommand*{\si@tempa}{#4}%
- \renewcommand*{\si@tempb}{;;}%
- \ifx\si@tempa\si@tempb\else
- \ifsi@strictarc
- \renewcommand*{\si@tempb}{;}%
- \ifx\si@tempa\si@tempb
- \si@log@err{Insufficient semi-colons in argument
- of \string\ang}{The argument of
- \string\ang\space must contain either no
- semi-colons or exactly two}%
- \else
- \si@log@err{Excess semi-colons in argument of
- \string\ang}{The argument of \string\ang\space
- must contain either no semi-colons or exactly
- two}%
- \fi
- \fi
- \fi
- \si@ang@arc{#1}{#2}{#3}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@ang@dec}
-%\begin{macro}{\si@ang@arc}
-% Two tests are needed, in case the input format requires conversion.
-% \begin{macrocode}
-\newcommand*{\si@ang@dec}{%
- \let\si@ang@fix\@gobble
- \ifsi@ang@toarc
- \expandafter\si@ang@dectoarc
- \else
- \sisetup{padangle=none,anglesep=none}\expandafter\si@ang@typeset
- \fi}
-\newcommand*{\si@ang@arc}{%
- \let\si@ang@fix\si@ang@arcfix
- \ifsi@ang@todec
- \expandafter\si@ang@arctodec
- \else
- \expandafter\si@ang@typeset
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@ang@fixdp}
-%\begin{macro}{\si@ang@fix}
-%\begin{macro}{\si@ang@arcfix}
-%\darg{number}
-% A check is needed so that rounding and zero filling are only
-% applied to the seconds of an arc angle.
-% \begin{macrocode}
-\newif\ifsi@ang@fixdp
-\newcommand*{\si@ang@fix}[1]{}
-\newcommand*{\si@ang@arcfix}[1]{%
- \renewcommand*{\si@tempa}{second}%
- \renewcommand*{\si@tempb}{#1}%
- \ifx\si@tempa\si@tempb
- \ifsi@ang@fixdp
- \expandafter\expandafter\expandafter\si@fixdptrue
- \else
- \expandafter\expandafter\expandafter\si@fixdpfalse
- \fi
- \else
- \expandafter\si@fixdpfalse
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@ang@ifnum}
-%\darg{number}
-% A test is required to check that the provided data consists of
-% numbers which can actually be processed by \TeX. This is achieved
-% by using \cs{si@num@ifvalid} with a fixed list of valid
-% characters.
-% \begin{macrocode}
-\newcommand*{\si@ang@ifnum}[1]{%
- \begingroup
- \renewcommand*{\si@numvalid}{0123456789,.+-}%
- \ifx\@empty#1\@empty
- \aftergroup\@firstoftwo
- \else
- \si@num@ifvalid{#1}
- {\aftergroup\@firstoftwo}
- {\aftergroup\@secondoftwo}%
- \fi
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@ang@arctodec}
-%\darg{degrees}
-%\darg{minutes}
-%\darg{seconds}
-% The business end of converting arcs to decimal angles is relatively
-% straight-forward, as it only needs one calculation. This has to be
-% divided up, so that disaster does not strike if there are empty
-% arguments; a check is also needed for the sign of the angle,
-% so that the maths makes sense.
-% \begin{macrocode}
-\newcommand*{\si@ang@arctodec}[3]{%
- \let\si@ang@fix\@gobble
- \ifnum\si@num@dp>\thr@@\relax
- \si@num@dp\thr@@\relax
- \fi
- \si@fixdptrue
- \si@ang@ifnum{#1}
- {\si@ang@ifnum{#2}
- {\si@ang@ifnum{#3}
- {\si@tempdima\z@\relax
- \renewcommand*{\si@tempa}{+}%
- \ifx\@empty#1\@empty\else
- \si@tempdima #1pt\relax
- \fi
- \ifdim\si@tempdima<\z@\relax
- \renewcommand*{\si@tempa}{-}%
- \fi
- \ifx\@empty#2\@empty\else
- \si@tempdima\dimexpr\si@tempdima\si@tempa
- #2pt/60\relax
- \fi
- \ifdim\si@tempdima<\z@\relax
- \renewcommand*{\si@tempa}{-}%
- \else
- \fi
- \ifx\@empty#3\@empty\else
- \si@tempdima\dimexpr\si@tempdima\si@tempa
- #3pt/3600\relax
- \fi
- \sisetup{numdecimal=.}%
- \expandafter\si@ang@typeset\expandafter{%
- \strip@pt\si@tempdima}{}{}}
- {\si@ang@notnum{#1}{#2}{#3}}}
- {\si@ang@notnum{#1}{#2}{#3}}}
- {\si@ang@notnum{#1}{#2}{#3}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@ang@dectoarc}
-%\begin{macro}{\si@ang@arcdeg}
-%\begin{macro}{\si@ang@arcmin}
-%\begin{macro}{\si@ang@arcsec}
-%\darg{number}
-% The conversion macros for decimal to arc angles. Life is more
-% complex here than above, even without the need for checks on the
-% input. A number of separation steps are needed, each of which
-% needs a separate macro.
-% \begin{macrocode}
-\newcommand*{\si@ang@dectoarc}[1]{%
- \let\si@ang@fix\si@ang@arcfix
- \si@ang@fixdptrue
- \ifnum\si@num@dp>\@ne\relax
- \si@num@dp\@ne\relax
- \fi
- \si@ang@ifnum{#1}
- {\si@tempdima\z@\relax
- \ifx\@empty#1\@empty\else
- \si@tempdima #1pt\relax
- \fi
- \si@ang@sepint{deg}%
- \si@tempdima\dimexpr\si@tempdima *60\relax
- \si@ang@sepint{min}%
- \edef\si@tempa{\the\dimexpr\si@tempdima *60\relax}%
- \expandafter\newcommand\expandafter*\expandafter{%
- \expandafter\si@ang@arcsec\expandafter}\expandafter{%
- \expandafter\si@ang@strippt\si@tempa}%
-% \end{macrocode}
-% A check is made for ``0.0'' seconds, which should be converted to
-% simply ``0''.
-% \begin{macrocode}
- \si@tempdima\z@\relax
- \edef\si@tempa{\the\si@tempdima}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \expandafter\si@tempa\expandafter}\expandafter{%
- \expandafter\si@ang@strippt\si@tempa}%
- \ifx\si@tempa\si@ang@arcsec
- \renewcommand*{\si@ang@arcsec}{0}%
- \fi
-% \end{macrocode}
-% To avoid adding zeros where they are not required, each part of the
-% angle is now checked.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{0}%
- \ifx\si@ang@arcdeg\si@tempa
- \si@temptoks{{}}%
- \else
- \si@temptoks{{\si@ang@arcdeg}}%
- \fi
- \ifx\si@ang@arcmin\si@tempa
- \si@temptoks\expandafter{\the\si@temptoks{}}%
- \else
- \si@temptoks\expandafter{\the\si@temptoks{%
- \si@ang@arcmin}}%
- \fi
- \ifx\si@ang@arcsec\si@tempa
- \si@temptoks\expandafter{\the\si@temptoks{}}%
- \else
- \si@temptoks\expandafter{\the\si@temptoks{%
- \si@ang@arcsec}}%
- \fi
- \expandafter\si@ang@typeset\the\si@temptoks}
- {\si@ang@notnum{#1}{}{}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@ang@sepint}
-%\begin{macro}{\si@ang@sint}
-%\begin{macro}{\si@ang@strippt}
-%\darg{either \texttt{deg} or \texttt{min}}
-% Support macros for the conversion from decimal to arc angles.
-% \begin{macrocode}
-\newcommand*{\si@ang@sepint}[1]{%
- \expandafter\si@ang@sint\the\si@tempdima\@empty
- \expandafter\let\csname si@ang@arc#1\endcsname\si@tempa}
-\def\si@ang@sint#1.#2\@empty{%
- \renewcommand*{\si@tempa}{#1}%
- \si@tempdima 0.#2\relax}
-\begingroup
- \catcode`P=12
- \catcode`T=12
- \lowercase{
- \renewcommand*{\si@tempa}{%
- \def\si@ang@strippt##1PT{##1}}}
- \expandafter\endgroup
-\si@tempa
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@ang@notnum}
-%\darg{degrees}
-%\darg{minutes}
-%\darg{seconds}
-% Not a \TeX\ number: complain.
-% \begin{macrocode}
-\newcommand*{\si@ang@notnum}[3]{%
- \si@log@warn{Angle `#1;#2;#3' is not a pure
- number:\MessageBreak output will be as given}%
- \si@ang@typeset{#1}{#2}{#3}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@ang@sign}
-% A flag is needed to leave signs along for angles, where
-% a zero value may still need a sign.
-% \begin{macrocode}
-\newif\ifsi@ang@sign
+\cs_set_protected_nopar:Npn \_siunitx_number_process_uncertainty_pad: {
+ \intexpr_while_do:nNnn
+ { \int_use:N \_l_siunitx_process_uncertainty_int }
+ < { \int_use:N \_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}{\si@ang@typeset}
-%\darg{degrees}
-%\darg{minutes}
-%\darg{seconds}
-% The \cs{si@ang@set} macro does the work of assigning the degrees,
-% minutes and seconds, and actually typesetting the result.
-% \begin{macrocode}
-\newcommand*{\si@ang@typeset}[3]{%
-% \end{macrocode}
-%\begin{macro}{\si@ang@degs}
-%\begin{macro}{\si@ang@mins}
-%\begin{macro}{\si@ang@secs}
-% First, the three macros that will contain the measures must exist.
+%\begin{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}
- \ifsi@ang@padlarge
- \newcommand*{\si@ang@degs}{0\si@sym@degree}%
- \newcommand*{\si@ang@mins}{0\si@sym@minute}%
- \newcommand*{\si@ang@secs}{0\si@sym@second}%
- \else
- \newcommand*{\si@ang@degs}{}%
- \newcommand*{\si@ang@mins}{}%
- \newcommand*{\si@ang@secs}{}%
- \fi
-% \end{macrocode}
-%\begin{macro}{\si@ang@decimalsymbol}
-% The current definition of \cs{si@decimalsymbol} needs to be saved.
-% \begin{macrocode}
- \protected@edef\si@ang@decimalsymbol{\si@decimalsymbol}%
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_uncertainty_separate: {
+ \tl_map_function:NN \_l_siunitx_tmpa_tl
+ \_siunitx_number_process_uncertainty_separate_aux:N
+}
+\cs_set_protected:Npn
+ \_siunitx_number_process_uncertainty_separate_aux:N #1 {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_process_uncertainty_int }
+ > { \int_use:N \_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}
-%\begin{macro}{\si@ang@movesign}
-% Either the signs need to be moved, or this needs to be killed off.
+%\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}
- \ifsi@astroang
- \let\si@ang@movesign\si@ang@astrosign
- \else
- \let\si@ang@movesign\@gobble
- \fi
+\cs_set_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}{\si@ang@secnum}
-%\begin{macro}{\si@ang@minnum}
-% The arguments are now examined in reverse order. If they are
-% empty, then nothing is done. Otherwise, the larger measures are
-% zero-filled, if this has been requested. Some steps are needed
-% to allow for addition of signs to numbers.
+%
+%\begin{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}
- \newcommand*{\si@ang@secnum}{\si@ang@num{second}}%
- \newcommand*{\si@ang@minnum}{\si@ang@num{minute}}%
- \si@ifnotmtarg{#3}
- {\si@log@debug{Found seconds `#3'}%
- \si@ang@ifnum{#3}
- {\ifdim #3 pt=\z@\relax\else
- \si@ang@signtrue
- \fi}{}%
- \renewcommand*{\si@ang@secs}
- {\si@ang@secnum{#3}\si@sym@second}%
- \renewcommand*{\si@ang@mins}
- {\si@ang@pad{0\si@sym@minute}}%
- \renewcommand*{\si@ang@degs}
- {\si@ang@pad{0\si@sym@degree}}}%
- \si@ifnotmtarg{#2}
- {\si@log@debug{Found minutes `#2'}%
- \si@ang@ifnum{#2}
- {\ifdim #2 pt=\z@\relax\else
- \si@ang@signtrue
- \fi}{}%
- \renewcommand*{\si@ang@secnum}{%
- \si@ang@signlessnum{second}}%
- \renewcommand*{\si@ang@mins}
- {\si@ang@minnum{#2}\si@sym@minute}%
- \renewcommand*{\si@ang@degs}
- {\si@ang@pad{0\si@sym@degree}}}%
- \si@ifnotmtarg{#1}
- {\si@log@debug{Found degrees `#1'}%
- \renewcommand*{\si@ang@secnum}{%
- \si@ang@signlessnum{second}}%
- \renewcommand*{\si@ang@minnum}{%
- \si@ang@signlessnum{minute}}%
- \renewcommand*{\si@ang@degs}
-% \end{macrocode}
-% The group here is needed to get the mechanism to move the symbol to
-% work properly.
-% \begin{macrocode}
- {\si@ang@num{degree}{#1}%
- \si@sym@degree}}%
- \si@out@num
- {\si@ang@degs\si@anglesep\si@ang@mins\si@anglesep
- \si@ang@secs}%
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-% The group opened by \cs{ang} is closed.
-% \begin{macrocode}
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@ang@pad}
-%\darg{number}
-% Padding is only added if requested; the zero is a literal.
-% \begin{macrocode}
-\newcommand*{\si@ang@pad}[1]{\ifsi@ang@padsmall #1\fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@ang@num}
-%\begin{macro}{\si@ang@signlessnum}
-%\darg{one of \texttt{degree}, \texttt{minute} or \texttt{second}}
-%\darg{number}
-% Modified versions of \cs{num}, one to typeset angles without a
-% leading sign and the other with.
-% \begin{macrocode}
-\newcommand*{\si@ang@num}[2]{%
- \begingroup
- \si@ang@fix{#1}%
- \si@ang@movesign{#1}%
- \si@num{#2}%
- \endgroup}
-\newcommand*{\si@ang@signlessnum}[2]{%
- \begingroup
- \si@ang@fix{#1}%
- \si@ang@movesign{#1}%
- \sisetup{addsign=none}%
- \si@num{#2}%
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@ang@killdegree}
-%\begin{macro}{\si@ang@killminute}
-%\begin{macro}{\si@ang@killsecond}
-% A mechanism is needed to handle moving the angle unit signs for the
-% \opt{astroang} option. First, some support macros are needed.
-% \begin{macrocode}
-\newcommand*{\si@ang@killdegree}{\let\si@sym@degree\relax}
-\newcommand*{\si@ang@killminute}{\let\si@sym@minute\relax}
-\newcommand*{\si@ang@killsecond}{\let\si@sym@second\relax}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@ang@astrosign}
-%\darg{one of \texttt{degree}, \texttt{minute} or \texttt{second}}
-% The method needs two steps, producing the sign over the decimal
-% sign and preventing duplicate symbols appearing. This is based on a
-% suggestion from Morten H{\o}gholm, but using \TeX\ internals as
-% \cs{makebox} does not work here. Note the need to correct for
-% \cs{scriptspace} (thanks to Donald Arseneau for that).
-% \begin{macrocode}
-\newcommand*{\si@ang@astrosign}[1]{%
- \renewcommand*{\si@decimalsymbol}{%
- \setbox\si@tempboxa=\hbox{%
- \ensuremath{{\si@ang@decimalsymbol}}}%
- \si@tempdima\wd\si@tempboxa\relax
- \setbox\si@tempboxb=\hbox to\z@{%
- \hss\unhbox\si@tempboxa\hss}%
- \setbox\si@tempboxa=\hbox{%
- \csname si@sym@#1\endcsname\hskip-\scriptspace}%
- \si@tempdimb\wd\si@tempboxa\relax
- \setbox\si@tempboxc=\hbox to\z@{%
- \hss\unhbox\si@tempboxa\hss}%
- \setbox\si@tempboxd=\hbox{%
- \usebox\si@tempboxb\usebox\si@tempboxc}%
- \ifdim\si@tempdima>\si@tempdimb\relax
- \setbox\si@tempboxa=\hbox to\si@tempdima{%
- \hss\unhbox\si@tempboxd\hss}%
- \else
- \setbox\si@tempboxa=\hbox to\si@tempdimb{%
- \hss\unhbox\si@tempboxd\hss}%
- \fi
- \usebox\si@tempboxa%
- \ifdim\si@tempdima>\si@tempdimb\relax\else
- \hskip\scriptspace
- \fi}%
- \renewcommand*{\si@num@decimalhook}{\expandafter\aftergroup
- \csname si@ang@kill#1\endcsname}}%
+\cs_set_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_set_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_set_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{Tabular material}
-% The automatic formatting and alignment of numerical data in columns
-% is handled here. The various other packages that work in this area
-% are basically ripped-off here. The letters |D|, |N| and |R| are
-% already taken by the other packages for numerical alignment, and so
-% |S| ($=$ \currpkg) is chosen for the alignment of numerical
-% material. The package also provides a second column type, |s|, for
-% units (the letter is taken from \cs{si}).
-%
-%\begin{macro}{\NC@list}
-%\changes{v1.1e}{2008/11/18}{Fixed issue with \pkg{cellspace} package}
-% The first part of the job is to create the basic apparatus for the
-% columns using the \pkg{array} package. To prevent any issues with
-% the content of optional arguments to the new columns, so
-% rearrangement is needed. The \currpkg columns have to come
-% \emph{before} any other column definitions. This is achieved by
-% saving \cs{NC@list}, creating the columns then restoring the list
-% with the appropriate extra parts.
-% \begin{macrocode}
-\@ifpackageloaded{cellspace}
- {\newcolumntype{C}[1]{>{\bcolumn #1\@nil}#1<{\ecolumn}}}
- {\AtBeginDocument{
- \@ifpackageloaded{cellspace}
- {\newcolumntype{C}[1]{>{\bcolumn #1\@nil}#1<{\ecolumn}}%
- \renewcommand*{\NC@rewrite@S}[1][]{%
- \edef\si@tempa{\the\@temptokena
- >{\noexpand\si@tab@begin@S[#1]}c%
- <{\noexpand\si@tab@end@S}}%
- \@temptokena\expandafter{\si@tempa}%
- \NC@find}}
- {}}}
-\edef\si@tempa{%
- \noexpand\NC@do S\noexpand\NC@do s\the\NC@list}
-\newcolumntype{S}{}
-\newcolumntype{s}{}
-\NC@list\expandafter{\si@tempa}
-% \end{macrocode}
-%\end{macro}
-%\changes{v1.1h}{2008/11/30}{Fixed problem with \pkg{colortbl} package}
-%\changes{v1.1i}{2008/11/30}{Better solution to \pkg{colortbl} issue}
-%\begin{macro}{\si@tab@corr@colortbl}
-% A correction if \pkg{colortbl} is loaded.
-% \begin{macrocode}
-\newcommand*{\si@tab@corr@colortbl}{\relax}
-\AtBeginDocument{
- \@ifpackageloaded{colortbl}{%
- \renewcommand*{\si@tab@corr@colortbl}{%
- \hskip\stretch{-0.5}\kern\z@
- }
- }{}
-}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\NC@rewrite@S}
-%\begin{macro}{\NC@rewrite@s}
-%\doarg{keyval options}
-% Following the \numprint approach, the \cs{NC@rewrite@\ldots} macros
-% are rewritten to collect the cell contents. This means messing
-% with the internal macros of another package, but there is no other
-% way to do this. As \pkg{array} is a standard package from the
-% \pkg{tools} bundle, this should be reasonably safe. Here the begin
-% and end code needed is added to the existing list if
-% \cs{@temptokena}, with the start and end macros unexpanded.
-% Argument |#1| contains any user setup options for this column.
-% Passing an argument at this stage will cause issues, so each column
-% type needs its own \texttt{begin} and \texttt{end} macros.
-% \begin{macrocode}
-\renewcommand*{\NC@rewrite@S}[1][]{%
- \edef\si@tempa{\the\@temptokena
- >{\noexpand\si@tab@begin@S[#1]}c%
- <{\noexpand\si@tab@end@S}}%
- \@temptokena\expandafter{\si@tempa}%
- \NC@find}
-\renewcommand*{\NC@rewrite@s}[1][]{%
- \edef\si@tempa{\the\@temptokena
- >{\noexpand\si@tab@begin@s[#1]}c%
- <{\noexpand\si@tab@end@s}}%
- \@temptokena\expandafter{\si@tempa}%
- \NC@find}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@begin@S}
-%\begin{macro}{\si@tab@begin@s}
-%\begin{macro}{\si@tab@gettok}
-%\doarg{keyval options}
-% At this stage, the appropriate token gathering macro is activated,
-% and the common starting macro is called. For the |S| column, the
-% \opt{seperr} is turned off, and an error is set to be raised by any
-% ``x-part'' input.
-% \begin{macrocode}
-\newcommand*{\si@tab@begin@S}[1][]{%
- \si@log@debug{Processing S column cell contents}%
- \let\si@tab@gettok\si@tab@gettok@S
- \si@seperrfalse
- \renewcommand*{\si@num@sepxpart}{%
- \si@log@err{Multiple numbers not allowed in
- tables\MessageBreak Only the first number used}
- \@ehb}%
- \si@tab@begin[#1]}
-\newcommand*{\si@tab@begin@s}[1][]{%
- \si@log@debug{Processing s column cell contents}%
- \let\si@tab@gettok\si@tab@gettok@s
- \si@tab@begin[#1]}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@toks}
-%\begin{macro}{\si@tab@pretoks}
-%\begin{macro}{\si@tab@posttoks}
-% Some storage is needed for the data to build up. In common with
-% \pkg{rccol} and \numprint, token registers are used for this (thus
-% leaving problematic input to be handled later).
-% \begin{macrocode}
-\newtoks\si@tab@toks
-\newtoks\si@tab@pretoks
-\newtoks\si@tab@posttoks
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@begin}
-%\doarg{keyval options}
-% The macro for gathering up input is common to both column types. It
-% uses the method for \pkg{rccol}; the cell contents are collected by
-% a second macro, which then stores all of the data in an appropriate
-% token store.
-% \begin{macrocode}
-\newcommand*{\si@tab@begin}[1][]{%
- \begingroup
- \sisetup{#1}%
- \si@tab@toks{}%
- \si@tab@pretoks{}%
- \si@tab@posttoks{}%
- \si@switchfalse
- \si@tab@gettok}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@next}
-% A macro is needed for recursion when collecting cell contents.
-% \begin{macrocode}
-\newcommand*{\si@tab@next}{}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@gettok@S}
-%\changes{v1.0j}{2008/08/21}{Token gathering code now checks for
-% expandable content}
-%\darg{token}
-% The cell-content collection system is inherited from \pkg{rccol}.
-% First, the current input is compared with a fixed list of macros
-% which need custom handling.
-% \begin{macrocode}
-\newcommand*{\si@tab@gettok@S}[1]{%
- \ifx\tabularnewline#1\relax
- \let\si@tab@next\si@tab@newline@S
- \else
- \ifx\end#1\relax
- \let\si@tab@next\end
- \else
- \ifx\si@tab@end@S#1\relax
- \let\si@tab@next\si@tab@end@S
- \else
- \ifx\endtabular#1\relax
- \let\si@tab@next\endtabular
- \else
- \ifx\csname#1\relax
- \let\si@tab@next\csname
- \else
- \ifx\relax#1\relax
- \let\si@tab@next\relax
- \else
-% \end{macrocode}
-% If the code gets to here, then recursion should occur.
-% \begin{macrocode}
- \let\si@tab@next\si@tab@gettok@S
-% \end{macrocode}
-% Cells always contain \cs{ignorespaces} and \cs{unskip}. These can
-% both be filtered out here and are saved to either the pre-number or
-% post-number token store, as appropriate. This is done without
-% fixing the destination in case the user adds addition copies to the
-% input.
-% \begin{macrocode}
- \ifx\ignorespaces#1\relax
- \si@tab@othertok{#1}%
- \else
- \ifx\unskip#1\relax
- \si@tab@othertok{#1}%
- \else
-% \end{macrocode}
-% If the current token is a valid numerical character, then the flag
-% is set and the input is saved into the ``processing'' token
-% register.
-% \begin{macrocode}
- \si@str@ifchrstr{#1}{\si@numvalid}
- {\si@switchtrue
- \si@log@debug{Found numerical cell
- contents `#1'}%
- \si@tab@toks=\expandafter{%
- \the\si@tab@toks#1}}
-% \end{macrocode}
-% For non-numerical content, some testing is needed. A check is made
-% to see if the current ``token'' is a single item. If it was wrapped
-% in one set of braces before being picked up here, they will have
-% been removed. So the input may now have more than one character to
-% it. If it is a single token, testing for expandability first
-% requires a check for another set of braces. This is handed off
-% using \cs{futurelet}.
-% \begin{macrocode}
- {\si@tab@ifonechar{#1}
- {\futurelet\si@tempa\si@tab@bracetest#1}%
- {\si@tab@othertok{#1}}}%
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \si@tab@next}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@othertok}
-%\changes{2009/12/25}{v1.3g}{Fix for multiple tokens in input}
-%\changes{2010/021/21}{v1.4b}{Back to plan A}
-%\darg{token}
-%\begin{macro}{\si@tab@othertok@aux}
-% Tokens which are not part of a number can occur before or after a
-% number. This is all sorted out here, with some debugging
-% information for good measure.
-% \begin{macrocode}
-\newcommand*{\si@tab@othertok}[1]{%
- \si@log@debug{Found other cell contents `\unexpanded{#1}'}%
- \ifsi@switch
- \si@log@debug{Adding to post-numeral part}%
- \si@tab@posttoks=\expandafter{\the\si@tab@posttoks#1}%
- \else
- \si@log@debug{Adding to pre-numeral part}%
- \si@tab@pretoks=\expandafter{\the\si@tab@pretoks#1}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@ifonechar}
-%\darg{token}
-%\begin{macro}{\si@tab@onechar}
-% A quick check for a single character.
-% \begin{macrocode}
-\newcommand*{\si@tab@ifonechar}[1]{\si@tab@onechar#1\@empty}
-\def\si@tab@onechar#1#2\@empty{%
- \ifx\@empty#2\@empty
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@bracetest}
-% For the \cs{futurelet} test, a separate macro is needed. If the
-% current token starts with a brace, then it is added to the
-% ``other'' stack. If not, a test can be made on its definition.
-% \begin{macrocode}
-\newcommand*{\si@tab@bracetest}{%
- \ifx\si@tempa\bgroup
- \expandafter\si@tab@othertok
- \else
- \expandafter\si@tab@exptest
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@exptest}
-%\changes{2009/12/25}{v1.3g}{Check dor \LaTeXe\ robust commands}
-%\begin{macro}{\si@tab@exptest@aux}
-%\begin{macro}{\si@tab@meaning}
-%\begin{macro}{\si@tab@strip}
-%\darg{token}
-% The meaning of the token is compared to that for a short macro. If
-% the two are of the same type, expansion is attempted. In this case,
-% the current pre-number tokens are also typeset.
-% \begin{macrocode}
-\newcommand*{\si@tab@exptest}[1]{%
- \edef\si@tempa{\si@tab@meaning{#1}}%
- \ifx\si@tempa\si@tab@macro
- \expandafter\si@tab@exptest@aux
- \else
- \expandafter\si@tab@othertok
- \fi
- {#1}%
-}
-\newcommand*{\si@tab@exptest@aux}[1]{%
- \ifcsname\expandafter\@gobble\string#1 \endcsname
- \si@tab@othertok{#1}%
- \else
- \si@log@debug{Expanding cell contents `\unexpanded{#1}'}%
- \the\si@tab@pretoks
- \si@tab@pretoks{}%
- \protected@edef\si@tab@next{\noexpand\si@tab@gettok@S#1}%
- \fi
-}
-\newcommand*{\si@tab@meaning}[1]{%
- \expandafter\si@tab@strip\meaning#1:->:->\@empty}
-\def\si@tab@strip#1:->#2:->#3\@empty{#1}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@macro}
-% A supporter macro for the above which always expands to ``macro''
-% with everything with category code 12.
-% \begin{macrocode}
-\newcommand*{\si@tab@macro}{}
-\edef\si@tab@macro{\si@tab@meaning{\si@tab@macro}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@gettok@s}
-%\changes{v1.0a}{2008/06/20}{Fixed issues with alignment of
-% \texttt{s} column contents}
-%\darg{token}
-% The situation for the |s| column is less complex, as there is only
-% one store and expansion is not an issue.
-% \begin{macrocode}
-\newcommand*{\si@tab@gettok@s}[1]{%
- \ifx\tabularnewline#1\relax
- \let\si@tab@next\si@tab@newline@s
- \else
- \ifx\end#1\relax
- \let\si@tab@next\end
- \else
- \ifx\si@tab@end@s#1\relax
- \let\si@tab@next\si@tab@end@s
- \else
- \ifx\endtabular#1\relax
- \let\si@tab@next\endtabular
- \else
- \ifx\csname#1\relax
- \let\si@tab@next\csname
- \else
- \ifx\relax#1\relax
- \let\si@tab@next\relax
- \else
- \let\si@tab@next\si@tab@gettok@s
- \ifx\ignorespaces#1\relax\else
- \ifx\unskip#1\relax\else
- \si@tab@toks=\expandafter{%
- \the\si@tab@toks#1}%
- \si@log@debug{Found cell contents `#1'}%
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \si@tab@next}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@end@S}
-%\changes{v1.0a}{2008/06/20}{Fixed mixed number/text column
-% alignment}
-%\changes{v1.0k}{2008/09/02}{Fixed problem with coloured cells}
-%\begin{macro}{\si@tab@rfill}
-%\begin{macro}{\si@tab@lfill}
-%\begin{macro}{\si@tab@end@s}
-% The end macros are similar, but with some minor differences. In
-% both cases, the appropriate filling is carried out. For the |S|
-% column, this depends on the cell contents, whereas for the |s|
-% column the fill is always the same. Output of a number in an |S|
-% column is only attempted if one was found, otherwise the cell
-% contents will all be in \cs{si@tab@pretoks}.
-% \begin{macrocode}
-\newcommand*{\si@tab@end@S}{%
- \ifsi@switch
- \let\si@tab@lfill\si@tab@lfill@S
- \let\si@tab@rfill\si@tab@rfill@S
- \else
- \let\si@tab@rfill\si@tab@rfill@t
- \let\si@tab@lfill\si@tab@lfill@t
- \fi
- \si@tab@corr@colortbl
- \hskip\stretch{\si@tab@lfill}\kern\z@
- \ifsi@switch
- \the\si@tab@pretoks
- \si@tab@numout
- \the\si@tab@posttoks
- \else
- \the\si@tab@pretoks
- \fi
- \hskip\stretch{\si@tab@rfill}\kern\z@
- \si@tab@corr@colortbl
- \endgroup}
-\newcommand*{\si@tab@end@s}{%
- \si@tab@corr@colortbl
- \hskip\stretch{\si@tab@lfill@s}\kern\z@
- \ignorespaces
- \expandafter\si\expandafter{\the\si@tab@toks}%
- \unskip
- \hskip\stretch{\si@tab@rfill@s}\kern\z@
- \si@tab@corr@colortbl
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@newline@S}
-%\begin{macro}{\si@tab@newline@s}
-%\begin{macro}{\si@tab@end}
-% If the column is the final one read, then some work is needed with
-% the \cs{tabularnewline} macro. Output has to happen \emph{before}
-% the new line, then the ending macro is made safe before calling the
-% \LaTeX\ line end. If the user makes use of the primitive \cs{cr}
-% then this problem does not arise as \cs{si@tab@end@\ldots} is
-% called correctly.
-% \begin{macrocode}
-\newcommand*{\si@tab@newline@S}{%
- \si@tab@end@S
- \hfil\relax
- \let\si@tab@end\si@tab@end@S
- \renewcommand*{\si@tab@end@S}{\let\si@tab@end@S\si@tab@end}%
- \tabularnewline}
-\newcommand*{\si@tab@newline@s}{%
- \si@tab@end@s
- \hfil\relax
- \let\si@tab@end\si@tab@end@s
- \renewcommand*{\si@tab@end@s}{\let\si@tab@end@s\si@tab@end}%
- \tabularnewline}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%
-%\begin{macro}{\si@tempcnta}
-%\begin{macro}{\si@tempcntb}
-% The second part of the tabular code is concerned with typesetting
-% numbers in |S| columns with the appropriate alignment. Counters are
-% needed for the digit-counting system.
-% \begin{macrocode}
-\newcount\si@tempcnta
-\newcount\si@tempcntb
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@numout}
-%\changes{v1.1}{2008/09/03}{Extended for non-aligned output}
-% If a number is found, then some secondary processing is needed to
-% format it correctly.
-% \begin{macrocode}
-\newcommand*{\si@tab@numout}{%
- \si@num@intabtrue
- \ifsi@tabparseonly\else
- \ifsi@tab@fixed
- \ifsi@tabautofit
- \si@num@dp\si@tab@mantpostcnt\relax
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@fixdptrue
- \fi
- \fi
- \fi
- \expandafter\si@num\expandafter{\the\si@tab@toks}%
- \si@tab@format}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@prebox}
-%\begin{macro}{\si@tab@postbox}
-%\begin{macro}{\si@tab@midbox}
-%\begin{macro}{\si@tab@expbox}
-% The various boxes needed for the column centring are declared
-% Unlike the \pkg{dcolumn} original, private boxes are used here.
-% \cs{si@tempboxa} is used when a space to measure one of the
-% constituents is needed; it is never used for output.
-% \begin{macrocode}
-\newbox\si@tab@prebox
-\newbox\si@tab@midbox
-\newbox\si@tab@postbox
-\newbox\si@tab@expbox
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@format}
-%\changes{v1.1}{2008/09/03}{Extended for non-aligned output}
-% The formatting set up is taken from \pkg{dcolumn}, but with
-% control of the output form the stored information. The choice
-% of a variable (decimal-centred) column or fixed width boxes is
-% made.
-% \begin{macrocode}
-\newcommand*{\si@tab@format}{%
- \ifsi@tabparseonly
- \expandafter\si@tab@outonly
- \else
- \ifsi@tab@fixed
- \expandafter\expandafter\expandafter\si@tab@fixed
- \else
- \expandafter\expandafter\expandafter\si@tab@unfixed
- \fi
- \fi
-% \end{macrocode}
-% A hack to get the correct colour everywhere without too much work.
-% \begin{macrocode}
- \ifsi@colourvalues
- \si@fam@colourcmd{\si@valuecolour}%
- \fi
- \box\si@tab@prebox\box\si@tab@midbox\box\si@tab@postbox
- \box\si@tab@expbox}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@outonly}
-% The non-alignment option means that no real processing is done: only font
-% control is required.
-% \begin{macrocode}
-\newcommand*{\si@tab@outonly}{%
- \si@log@debug{Using non-aligned S column}%
- \setbox\si@tab@prebox=\hbox{}%
- \setbox\si@tab@midbox=\hbox{}%
- \setbox\si@tab@postbox=\hbox{}%
- \setbox\si@tab@expbox=\hbox{}%
- \protected@edef\si@tempa{%
- \si@tab@out
- \ifx\@empty\si@num@out\@empty\else
- \ensuremath{{\si@decimalsymbol}}%
- \fi
- \si@num@out
- \si@tab@expout}%
- \expandafter\si@out@num\expandafter{\si@tempa}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@unfixed}
-%\changes{v1.0l}{2008/09/03}{Fixed issue with decimal sign and
-% integers}
-%\changes{v1.2e}{2009/02/04}{Various \cs{expandafter}s removed:
-% lead to a bug with \opt{textmode} option}
-% When the width of the contents is not fixed, the system creates a
-% block in which the decimal marker is always at the centre. This is
-% achieved by placing the pre- and post-decimal parts of the number
-% in boxes. The wider one is then used to set up the column width,
-% by resizing the other one.
-% \begin{macrocode}
-\newcommand*{\si@tab@unfixed}{%
- \si@log@debug{Using variable width S column}%
- \ifx\@empty\si@num@out\@empty
- \setbox\si@tab@midbox=\hbox
- {\phantom{\ensuremath{{\si@decimalsymbol}}}}%
- \else
- \setbox\si@tab@midbox=\hbox
- {\ensuremath{{\si@decimalsymbol}}}%
- \fi
- \protected@edef\si@num@out{\si@num@out\si@tab@expout}%
- \setbox\si@tab@prebox=\hbox{\si@out@num{\si@tab@out}}%
- \setbox\si@tab@postbox=\hbox{\si@out@num{\si@num@out}}%
- \ifdim\wd\si@tab@prebox>\wd\si@tab@postbox\relax
- \setbox\si@tab@postbox=\hbox to\wd\si@tab@prebox%
- {\unhbox\si@tab@postbox\hfill}%
- \else
- \setbox\si@tab@prebox=\hbox to\wd\si@tab@postbox%
- {\hfill\unhbox\si@tab@prebox}%
- \fi
- \setbox\si@tab@expbox=\hbox{}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@predim}
-%\begin{macro}{\si@tab@postdim}
-%\begin{macro}{\si@tab@expdim}
-%\begin{macro}{\si@tempdima}
-%\begin{macro}{\si@tempdimb}
-% Some storage dimensions are declared.
-% \begin{macrocode}
-\newdimen\si@tab@predim
-\newdimen\si@tab@postdim
-\newdimen\si@tab@expdim
-\newdimen\si@tempdima
-\newdimen\si@tempdimb
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@tab@sp}
-% A short macro to control superscript.
-% \begin{macrocode}
-\newcommand*{\si@tab@sp}{}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@fixed}
-%\changes{v1.0l}{2008/09/03}{Fixed issue with spacing when no digits
-% present after decimal marker}
-%\changes{v1.2e}{2009/02/04}{Various \cs{expandafter}s removed:
-% lead to a bug with \opt{textmode} option}
-% The column is not centred on the decimal marker; the user specifies
-% how many characters on each side are allowed for. First, the width
-% of a character is measured, and stored.
-% \begin{macrocode}
-\newcommand*{\si@tab@fixed}{%
- \si@log@debug{Using fixed-width S column}%
- \let\si@tab@sp\relax
- \setbox\si@tab@midbox=\hbox{}%
- \setbox\si@tab@expbox=\hbox{}%
- \setbox\si@tempboxa=\hbox{\si@out@num{1}}%
- \si@tempdima\wd\si@tempboxa\relax
-% \end{macrocode}
-% The width for the two output boxes is set up.
-% \begin{macrocode}
- \si@tab@predim\the\si@tab@mantprecnt\si@tempdima\relax
- \si@tab@sepcorr{mantpre}{pre}%
- \si@tab@postdim\si@tab@mantpostcnt\si@tempdima\relax
- \setbox\si@tempboxa=\hbox{\ensuremath{{\si@decimalsymbol}}}%
- \ifnum\si@tab@mantpostcnt=\z@\relax\else
- \advance\si@tab@postdim\wd\si@tempboxa\relax
- \fi
- \si@tab@sepcorr{mantpost}{post}%
-% \end{macrocode}
-% If space is needed for an exponent, it needs to be allowed for in
-% the exponent box dimension. First, the digits of the two parts are
-% checked for; the width of a character is altered to be superscript.
-% \begin{macrocode}
- \setbox\si@tempboxa=\hbox{\si@out@num{^{1}}}%
- \si@tempdima\wd\si@tempboxa\relax
- \ifnum\si@tab@expprecnt>\z@\relax
- \si@tab@expdim\si@tab@expprecnt\si@tempdima\relax
- \si@tab@sepcorr{exppre}{exp}%
- \fi
- \let\si@tab@sp\sp
- \ifnum\si@tab@exppostcnt>\z@\relax
- \advance\si@tab@expdim\si@tab@exppostcnt\si@tempdima\relax
- \setbox\si@tempboxa=\hbox{%
- \ensuremath{^{\si@decimalsymbol}}}%
- \advance\si@tab@expdim\wd\si@tempboxa\relax
- \si@tab@sepcorr{exppost}{exp}%
- \fi
-% \end{macrocode}
-% Space is reserved for signs.
-% \begin{macrocode}
- \setbox\si@tempboxa=\hbox{\ensuremath{-}}%
- \ifsi@tab@mantsign
- \advance\si@tab@predim\wd\si@tempboxa\relax
- \fi
- \setbox\si@tempboxa=\hbox{\ensuremath{^{-}}}%
- \ifsi@tab@expsign
- \advance\si@tab@expdim\wd\si@tempboxa\relax
- \fi
-% \end{macrocode}
-% Now, if there is space to be saved for an exponent under any
-% circumstances, the space for the ``$\times 10$'' part is needed.
-% This is done by adding both counters together, then using this
-% result for the logic.
-% \begin{macrocode}
- \si@tempcnta\si@tab@expprecnt\relax
- \advance\si@tempcnta\si@tab@exppostcnt\relax
- \ifnum\si@tempcnta>\z@\relax
- \setbox\si@tempboxa=\hbox{\ensuremath{%
- {}\si@expproduct{}\si@expbase}}%
- \advance\si@tab@expdim\wd\si@tempboxa\relax
- \fi
-% \end{macrocode}
-% Finally for the box dimensions, if the exponent is not aligned,
-% the space reserved for it is added to the post box.
-% \begin{macrocode}
- \ifsi@tabalignexp\else
- \advance\si@tab@postdim\si@tab@expdim\relax
- \fi
-% \end{macrocode}
-% With the boxes set up, the contents can be sorted out. A bit of
-% shuffling may be needed, depending on the treatment of exponents.
-% \begin{macrocode}
- \setbox\si@tab@prebox=\hbox to\si@tab@predim{\hss\hfill
- \si@out@num{\si@tab@out}}%
- \ifx\@empty\si@num@out\@empty
- \setbox\si@tab@postbox=\hbox to\si@tab@postdim{\hfil}%
- \else
- \ifsi@tabalignexp\else
- \protected@edef\si@num@out{\si@num@out\si@tab@expout}%
- \fi
- \setbox\si@tab@postbox=\hbox to\si@tab@postdim
- {\ensuremath{{\si@decimalsymbol}}\si@out@num
- {\si@num@out}\hfil}%
- \fi
- \ifx\@empty\si@tab@expout\@empty
- \ifsi@tabalignexp
- \setbox\si@tab@expbox=\hbox to\si@tab@expdim{\hfil}%
- \fi
- \else
- \ifsi@tabalignexp
- \setbox\si@tab@expbox=\hbox to\si@tab@expdim
- {\si@out@num{\si@tab@expout}\hfil}%
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@tab@sepcorr}
-%\darg{one of \texttt{mantpre}, \texttt{mantpost}, \texttt{exppre} or
-% \texttt{exppost}}
-%\darg{one of \texttt{pre}, \texttt{post} or \texttt{exp}}
-% A spacing correction is needed \emph{if} the number of digits to be
-% allowed for will lead to the introduction of a separator. A counter
-% and dimension are needed for the testing.
-% \begin{macrocode}
-\newcommand*{\si@tab@sepcorr}[2]{%
- \expandafter\si@tempcnta\expandafter\the
- \csname si@tab@#1cnt\endcsname\relax
-% \end{macrocode}
-% Calculate how many groups of three there are, then allow for not
-% separating four characters if \cs{ifsi@sepfour} is false.
-% \begin{macrocode}
- \divide\si@tempcnta\thr@@\relax
- \ifsi@sepfour\else
- \expandafter\ifnum\expandafter\the
- \csname si@tab@#1cnt\endcsname=4\relax
- \si@tempcnta\z@\relax
- \fi
- \fi
-% \end{macrocode}
-% The width of the separators is measured, and the correct number of
-% separator widths are added to the box dimension.
-% \begin{macrocode}
- \setbox\si@tempboxa=\hbox{%
- \ensuremath{\si@tab@sp{\si@digitsep}}}%
- \expandafter\advance\csname si@tab@#2dim\endcsname
- \si@tempcnta\wd\si@tempboxa}
+%\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_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-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}
+%
+%\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_set_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_color:
+ \_siunitx_number_format_final:
+ }
+}
% \end{macrocode}
%\end{macro}
%
-%\subsection{Units}
-%\begin{macro}{\SI}
-%\doarg{keyval options}
-%\darg{number}
-% There are two types of user macros for the units system; those for
-% defining new units, prefixes and powers, and those for using them.
-% There are two macros for using units, \cs{SI} and \cs{si}, which
-% work in very similar ways. argument to \cs{SI}
+%\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}
-\si@newrobustcmd*{\SI}[2][]{%
- \@ifnextchar[%]
- {\si@SI[#1]{#2}}
- {\si@SI[#1]{#2}[]}}
+\cs_set_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_set_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
+ \tl_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}
-%\begin{macro}{\si}
-%\doarg{keyval options}
-%\darg{unit}
-% \cs{si} is just an alias for \cs{SI} with no number; everything is
-% handed off into an internal macro. The internal macro also handles
-% the optional prefix
+%\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}
-\si@newrobustcmd*{\si}[2][]{\si@SI[#1]{}[]{#2}}
+\cs_set_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_set_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
+ {
+ \tl_if_eq:nVT { - } \_l_siunitx_tmpa_tl
+ {
+ \prop_put:NnV \_l_siunitx_number_out_prop { color }
+ \_l_siunitx_negative_color_tl
+ }
+ }
+}
% \end{macrocode}
%\end{macro}
-
-%\begin{macro}{\newunit}
-%\begin{macro}{\renewunit}
-%\begin{macro}{\provideunit}
-%\doarg{keyval options}
-%\darg{unit}
-%\darg{symbol}
-% The \cs{newunit} and \cs{renewunit} macros create the new unit
-% macros. To allow a mechanism for checking an existing definition,
-% these macros simply carry out the appropriate tests, before handing
-% off to the internal macro. \cs{@ifdefinable} is not used here as a
-% customised error is desirable. Other than that, the code here gives
-% very similar results to \cs{newcommand} and \cs{renewcommand}.
-% Finally, \cs{provideunit} adds the unit definition only if it does
-% not already exist.
-% \begin{macrocode}
-\newcommand*{\newunit}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defunit[#1]{#2}{#3}}
- {\si@log@err{Unit \string#2 already defined!}\@eha}}
-\newcommand*{\renewunit}[3][]{%
- \si@ifdefinable{#2}
- {\si@log@err{Unit \string#2 undefined}\@ehc
- \si@unt@defunit[#1]{#2}{#3}}
- {\si@log@inf{Redefining unit \string#2}%
- \si@unt@defunit[#1]{#2}{#3}}}
-\newcommand*{\provideunit}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defunit[#1]{#2}{#3}}
- {}}
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_number_format_complex:}
+%\begin{macro}[aux]{\_siunitx_number_format_complex_aux:n}
+% The real and complex parts of each number are reassembled, with
+% brackets if needed.
+% \begin{macrocode}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_number_format_complex_aux:n #1 {
+ \prop_get:NnN \_l_siunitx_number_out_prop {#1} \_l_siunitx_tmpa_tl
+ \bool_if:NTF \_l_siunitx_complex_after_bool
+ {
+ \_siunitx_tl_put_right_math:NV \_l_siunitx_tmpa_tl
+ \_l_siunitx_output_complex_tl
+ }
+ {
+ \_siunitx_tl_put_left_math:NV \_l_siunitx_tmpa_tl
+ \_l_siunitx_output_complex_tl
+ }
+ \prop_put:NnV \_l_siunitx_number_out_prop {#1} \_l_siunitx_tmpa_tl
+}
% \end{macrocode}
%\end{macro}
%\end{macro}
+%
+%\begin{macro}{\_siunitx_number_format_copy:n}
+%\begin{macro}{\_siunitx_number_format_copy:nn}
+% Just copy across.
+% \begin{macrocode}
+\cs_set_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_set_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}
-%\begin{macro}{\newprefix}
-%\begin{macro}{\renewprefix}
-%\begin{macro}{\provideprefix}
-%\doarg{\texttt{binary}}
-%\darg{multiple}
-%\darg{powers-ten}
-%\darg{symbol}
-% The multiples of units are defined here; very similar code is used
-% to the \cs{newunit}, \etc, macros. The multiple prefixes cannot
-% take an optional argument, and must represent some power. Hence
-% the arguments required are different.
-% \begin{macrocode}
-\newcommand*{\newprefix}[4][]{%
- \si@ifdefinable{#2}
- {\si@unt@defprefix[#1]{#2}{#3}{#4}}
- {\si@log@err{Prefix \string#2 already defined!}\@eha}}
-\newcommand*{\renewprefix}[4][]{%
- \si@ifdefinable{#2}
- {\si@log@err{Prefix \string#2 undefined}\@ehc
- \si@unt@defprefix[#1]{#2}{#3}{#4}}
- {\si@log@inf{Redefining prefix \string#2}%
- \si@unt@defprefix[#1]{#2}{#3}{#4}}}
-\newcommand*{\provideprefix}[4][]{%
- \si@ifdefinable{#2}
- {\si@unt@defprefix[#1]{#2}{#3}{#4}}
- {}}
+%\end{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_set_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 }
+ }
+}
% \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_set_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
+ \tl_set_eq:NN \_l_siunitx_tmpb_tl \_l_siunitx_exponent_product_tl
+ \bool_if:NT \_l_siunitx_tight_bool
+ {
+ \tl_set:Nx \_l_siunitx_tmpb_tl
+ { { \exp_not:V \_l_siunitx_tmpb_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_set_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}{\newpower}
-%\begin{macro}{\renewpower}
-%\begin{macro}{\providepower}
-%\doarg{\texttt{post}}
-%\darg{number}
-%\darg{power}
-% Here power multiples for units are set up. As with units and
-% multiples, a layered approach is used to keep things easy to
-% maintain.
-% \begin{macrocode}
-\newcommand*{\newpower}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defpower[#1]{#2}{#3}}
- {\si@log@err{Power \string#2 already defined!}\@eha}}
-\newcommand*{\renewpower}[3][]{%
- \si@ifdefinable{#2}
- {\si@log@err{Power \string#2 undefined}\@ehc
- \si@unt@defpower[#1]{#2}{#3}}
- {\si@log@inf{Redefining power \string#2}%
- \si@unt@defpower[#1]{#2}{#3}}}
-\newcommand*{\providepower}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defpower[#1]{#2}{#3}}
- {}}
+%\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_set_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_set_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_set_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}{\newqualifier}
-%\changes{v1.1}{2008/09/04}{New user macro}
-%\begin{macro}{\renewqualifier}
-%\changes{v1.1}{2008/09/04}{New user macro}
-%\begin{macro}{\providequalifier}
-%\changes{v1.1}{2008/09/04}{New user macro}
-%\darg{qualifier}
-%\darg{symbol}
-% Creating unit qualifiers is much the same method.
-% \begin{macrocode}
-\newcommand*{\newqualifier}[2]{%
- \si@ifdefinable{#1}
- {\si@unt@defqual{#1}{#2}}
- {\si@log@err{Qualifier \string#1 already defined!}\@eha}}
-\newcommand*{\renewqualifier}[2]{%
- \si@ifdefinable{#1}
- {\si@log@err{Qualifier \string#1 undefined}\@ehc
- \si@unt@defqual{#1}{#2}}
- {\si@unt@defqual{#1}{#2}}}
-\newcommand*{\providequalifier}[2]{%
- \si@ifdefinable{#1}
- {\si@unt@defqual{#1}{#2}}
- {}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@unt@num}
-% A flag is needed to tell the processor whether there is a number,
-% to get the correct spacing.
-% \begin{macrocode}
-\newif\ifsi@unt@num
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@unitarg}
-% A storage macro for the argument of the unit macro.
-% \begin{macrocode}
-\newcommand*{\si@unt@unitarg}{}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@SI}
-%\changes{v1.2e}{2009/02/04}{Fixed issue with mode detection and units}
-%\begin{macro}{\si@unt@SIopts}
-%\doarg{keyval options}
-%\darg{unit}
-%\doarg{preunit}
-%\darg{unit}
-% The internal processing starts with \cs{si@SI}, which processes the
-% second optional argument to \cs{SI} (which is empty for \cs{si}).
-% Everything is set up in a group, and processing begins by handling
-% the options.
-% \begin{macrocode}
-\newcommand*{\si@unt@SIopts}{}
-\def\si@SI[#1]#2[#3]#4{%
- \begingroup
- \let\fg\SIfg
- \sisetup{#1}%
- \renewcommand*{\si@unt@SIopts}{#1}%
- \si@fam@mode
-% \end{macrocode}
-%\end{macro}
-% The prefix unit is handled before any processing of the number; the
-% flags are set to get spacing correct.
-% \begin{macrocode}
- \si@unt@numfalse
- \si@xspacefalse
- \si@ifnotmtarg{#3}
- {\si@log@debug{Prefix unit found}%
- \si@unt@printunit{#3}}%
-% \end{macrocode}
-% The numerical argument may be empty, in which case no extra space
-% should be produced.
-% \begin{macrocode}
- \si@ifnotmtarg{#4}
- {\renewcommand*{\si@unt@unitarg}{#4}}%
- \si@ifnotmtarg{#2}
- {\si@log@debug{Number found in \string\SI\space
- argument}%
- \ifsi@repeatunits\else
- \ifsi@trapambigerr
- \expandafter\expandafter\expandafter
- \si@num@ambigerrtrue
- \fi
- \fi
- \num{#2}%
- \si@unt@numtrue}%
-% \end{macrocode}
-% If there is a unit, a check is needed in case the units need to
-% have a power added.
-% \begin{macrocode}
- \si@ifnotmtarg{#4}
- {\si@ifmtarg{#2}
- {\si@unt@printunit{#4}}
- {\si@tempcnta\z@\relax
- \ifsi@addunitpower
- \si@unt@countx{#2}%
- \fi
- \ifnum\si@tempcnta>\z@\relax
- \advance\si@tempcnta\@ne\relax
- \edef\si@tempa{\noexpand\tothe{\si@tempcnta}}%
- \renewcommand*{\si@tempb}{#4}%
- \expandafter\expandafter\expandafter
- \si@unt@printunit\expandafter\expandafter
- \expandafter{%
- \expandafter\si@tempb\si@tempa}%
- \else
- \si@unt@printunit{#4}%
- \fi}}%
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@countx}
-% A short macro to count up any multiplication in numerical input.
-% \begin{macrocode}
-\newcommand*{\si@unt@countx}[1]{%
- \si@tempcnta\z@\relax
- \expandafter\si@unt@cntx#1\@empty\@empty}
-\def\si@unt@cntx#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numprod}
- {\advance\si@tempcnta\@ne\relax}
- {}%
- \ifx\@empty#2\@empty\else
- \si@unt@cntx#2\@empty\@empty
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@ifliteral}
-%\begin{macro}{\ifsi@unt@littest}
-%\darg{unit}
-% The next stage of the processor is to determine whether or not the
-% argument of the unit macro is processable. For literal arguments,
-% this is not the case, and the argument is typeset ``as is''. On
-% the other hand, any units, \etc., declared by the package will work
-% with the processor, and so need to be executed before typesetting
-% the result.
-% \begin{macrocode}
-\newif\ifsi@unt@littest
-\newcommand*{\si@unt@ifliteral}[1]{%
- \begingroup
- \si@unt@littesttrue
-% \end{macrocode}
-% The test relies on any non-processable test having some width;
-% hopefully, this should be the case.
-% \begin{macrocode}
- \setbox\si@tempboxa=\hbox{\si@unt@out{#1}}%
- \ifdim\wd\si@tempboxa>\z@\relax
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\ifsi@unt@litout}
-%\begin{macro}{\si@unt@printunit}
-%\darg{unit}
-% The printing macro uses the above test to determine how to act. It
-% then carries out the appropriate action: either typesetting or
-% executing. A flag is also provided so that any macro units inside
-% a partially-literal argument will work (this is also needed to
-% emulate \unitsdef).
-% \begin{macrocode}
-\newif\ifsi@unt@litout
-\newcommand*{\si@unt@printunit}[1]{%
- \si@unt@ifliteral{#1}
-% \end{macrocode}
-% The unit includes one or more literal items; typeset using the
-% unit typesetting macro.
-% \begin{macrocode}
- {\ifsi@allowlitunits
- \expandafter\si@unt@litprint
- \else
- \expandafter\si@unt@nolitprint
- \fi
- {#1}}
-% \end{macrocode}
-% For processable output, the argument is executed; the macros are
-% all designed for this.
-% \begin{macrocode}
- {\si@log@debug{Macro unit found:\MessageBreak
- processing to format output}%
- \si@unt@init
- \advance\si@unt@depthcnt\@ne\relax
- #1%
- \si@unt@final}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@litprint}
-%\begin{macro}{\si@unt@nolitprint}
-% A couple of related macros to cope with literal printing (or not).
-% \begin{macrocode}
-\newcommand*{\si@unt@litprint}[1]{%
- \si@log@debug{%
- Literal items found in unit argument:\MessageBreak outputting
- without further processing}%
- \si@unt@litouttrue
- \si@unt@addvaluesep
- \si@unt@out{#1}%
-}
-\newcommand*{\si@unt@nolitprint}[1]{%
- \si@log@err{Literal units disabled}{%
- You can the literal input `#1' for a unit\MessageBreak
- but the allowliteralunits option is off.
- }
+%\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_set_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_after:wN \_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_nil
+ { \_siunitx_number_format_copy:n {#1 - #2} }
+ { \_siunitx_number_format_group_four_aux:nn {#1} {#2} }
+ }
+}
+\cs_set_protected:Npn \_siunitx_number_format_group_four_aux:NNNNNNw
+ #1#2#3#4#5#6 \q_nil {
+ \quark_if_no_value:NTF #5
+}
+\cs_set_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}
-%\begin{macro}{\si@unt@addvaluesep}
-%\begin{macro}{\si@unt@addvalsep}
-%\begin{macro}{\si@unt@litvalsep}
-%\begin{macro}{\si@unt@stackvalsep}
-% To ensure no problems pop up with expansion, adding the value--unit
-% space is handled by a macro.
-% \begin{macrocode}
-\newcommand*{\si@unt@addvaluesep}{%
- \ifsi@unt@num
- \expandafter\si@unt@addvalsep
- \fi}
-\newcommand*{\si@unt@addvalsep}{%
- \ifsi@unt@litout
- \expandafter\si@unt@litvalsep
- \else
- \expandafter\si@unt@stackvalsep
- \fi}
-\newcommand*{\si@unt@stackvalsep}{%
- \protected@edef\si@unt@spstack{\si@valuesep}}
-\newcommand*{\si@unt@litvalsep}{%
- \nobreak\ensuremath{\si@valuesep}\nobreak}
-% \end{macrocode}
%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@spstack}
-%\begin{macro}{\si@unt@stacka}
-%\begin{macro}{\si@unt@stackb}
-%\begin{macro}{\si@unt@unitcnta}
-%\begin{macro}{\si@unt@unitcntb}
-%\begin{macro}{\si@unt@depthcnt}
-%\begin{macro}{\ifsi@unt@first}
-%\begin{macro}{\ifsi@unt@first}
-%\begin{macro}{\si@unt@init}
-% The initialisation macro sets up the various switches, and clears
-% the storage areas for the formatted output. There are two stacks,
-% as when typesetting as fractions, the two parts of the number have
-% to be stored separately. The depth counter is used to tell when
-% recursion ends in the processor. The ``first'' switch is needed as
-% the depth counter will not be at one for items processed by
-% \cs{SI}.
-% \begin{macrocode}
-\newcommand*{\si@unt@spstack}{}
-\newcommand*{\si@unt@stacka}{}
-\newcommand*{\si@unt@stackb}{}
-\newcount\si@unt@unitcnta
-\newcount\si@unt@unitcntb
-\newcount\si@unt@depthcnt
-\newif\ifsi@unt@first
-\si@unt@depthcnt\m@ne\relax
-\newcommand*{\si@unt@init}{%
- \begingroup
- \si@unt@litoutfalse
- \si@unt@litprefixfalse
- \si@unt@firsttrue
- \si@unt@perfalse
- \si@unt@perseenfalse
- \si@unt@prepowerfalse
- \si@unt@depthcnt\z@\relax
- \si@unt@powerdim\z@\relax
- \si@unt@unitcnta\z@\relax
- \si@unt@unitcntb\z@\relax
- \si@unt@prefixcnt\z@\relax
- \renewcommand*{\si@unt@spstack}{}%
- \renewcommand*{\si@unt@stacka}{}%
- \renewcommand*{\si@unt@stackb}{}%
- \renewcommand*{\si@unt@spacestacka}{}%
- \renewcommand*{\si@unt@spacestackb}{}%
- \renewcommand*{\si@unt@lastadda}{space}%
- \renewcommand*{\si@unt@lastaddb}{space}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@final}
-% The finalisation macro finishes off the output and resets the flags.
-% \begin{macrocode}
-\newcommand*{\si@unt@final}{%
- \si@unt@third
- \si@unt@stackout
- \endgroup
- \ifsi@xspace
- \expandafter\expandafter\expandafter\xspace
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@defunit}
-%\doarg{keyval options}
-%\darg{unit}
-%\darg{symbol}
-% The internal macro for defining a unit does not check for
-% redefinition; that is done by the user macros.
-% \begin{macrocode}
-\newcommand*{\si@unt@defunit}[3][]{%
- \si@log@debug{Declaring unit \string#2 with \MessageBreak
- meaning \string#3}%
-% \end{macrocode}
-% The optional argument needs to be saved. The macro name is reversed
-% so that life is easier with the expansions here.
-% \begin{macrocode}
- \si@ifnotmtarg{#1}
- {\expandafter\@namedef\expandafter{%
- \expandafter\@gobble\string#2@opt@unt@si}{#1}}%
-% \end{macrocode}
-% The unit macro itself is now defined. The definition simply
-% selects the correct path for the rest of the processing to go down.
-% \begin{macrocode}
- \protected\def#2{%
- \ifsi@allowoptarg
- \expandafter\si@unt@withopt
- \else
- \expandafter\si@unt@noopt
- \fi
- {#2}{#3}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@withopt}
-%\begin{macro}{\si@unt@noopt}
-%\darg{unit}
-%\darg{symbol}
-% To allow the correct expansion, the potential optional argument to
-% a unit macro has to come last. So \cs{@ifnextchar} is needed to
-% detect it and pass data through. To keep variation down, when the
-% argument is not allowed, the empty |[]| is supplied.
-% \begin{macrocode}
-\newcommand*{\si@unt@withopt}[2]{%
- \@ifnextchar[%]
- {\si@unt@opt{#1}{#2}}
- {\si@unt@opt{#1}{#2}[]}}
-\newcommand*{\si@unt@noopt}[2]{\si@unt@opt{#1}{#2}[]}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@opt}
-%\darg{unit}
-%\darg{symbol}
-%\doarg{number}
-% The optional argument to the unit macro (if present) is converted
-% to a normal one for ease. The correct route for processing is then
-% picked.
-% \begin{macrocode}
-\def\si@unt@opt#1#2[#3]{%
- \ifsi@unt@littest
- \expandafter\si@gobblethree
- \else
-% \end{macrocode}
-% For literal output, the second argument is all that is needed.
-% \begin{macrocode}
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\@gobbletwo
- \else
- \expandafter\expandafter\expandafter\si@unt@unit
- \fi
- \fi
- {#3}{#1}{#2}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@gobblethree}
-% \LaTeX\ does not have a \cs{@gobblethree} macro, but one is needed.
-% \begin{macrocode}
-\long\def\si@gobblethree #1#2#3{}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@defprefix}
-%\begin{macro}{\ifsi@unt@litprefix}
-%\doarg{\texttt{binary}}
-%\darg{multiple}
-%\darg{powers-ten}
-%\darg{symbol}
-% As with units, multiples are defined by an internal macro.
-% \begin{macrocode}
-\newif\ifsi@unt@litprefix
-\si@unt@litprefixtrue
-\newcommand*{\si@unt@defprefix}[4][]{%
- \si@log@debug{Declaring multiple \string#1 with\MessageBreak
- meaning \string#4}%
-% \end{macrocode}
-% The optional argument is saved, using \cs{def} as no check is made
-% on an existing definition of the storage macro.
-% \begin{macrocode}
- \expandafter\expandafter\expandafter\def\expandafter
- \csname\expandafter\@gobble\string#2@opt@si\endcsname{#1}%
- \protected\def#2{%
- \ifsi@unt@littest
- \expandafter\si@gobblethree
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\@gobbletwo
- \else
- \ifsi@unt@litprefix
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\@gobbletwo
- \else
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@unt@prefix
- \fi
- \fi
- \fi
- {#2}{#3}{#4}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@defpower}
-%\doarg{\texttt{post}}
-%\darg{number}
-%\darg{power}
-% The definition of powers is complicated by the need to handle both
-% those given before units (such as \cs{cubic}) and those given after
-% (\eg \cs{cubed}). This means that an optional argument is needed.
-% \begin{macrocode}
-\newcommand*{\si@unt@defpower}[3][]{%
- \si@log@debug{Declaring power \string#2 with\MessageBreak
- meaning \string#3}%
-% \end{macrocode}
-% Once again the optional argument is saved.
-% \begin{macrocode}
- \expandafter\expandafter\expandafter\def\expandafter
- \csname\expandafter\@gobble\string#2@opt@si\endcsname{#1}%
- \protected\def#2{%
- \ifsi@unt@littest
- \expandafter\@gobbletwo
- \else
-% \end{macrocode}
-% The literal output here does not need to gobble anything.
-% \begin{macrocode}
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\si@unt@litpower
- \else
- \expandafter\expandafter\expandafter\si@unt@power
- \fi
- \fi
- {#2}{#3}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@defqual}
-%\darg{qualifier}
-%\darg{symbol}
-% Qualifiers are defined in a similar manner.
-% \begin{macrocode}
-\newcommand*{\si@unt@defqual}[2]{%
- \si@log@debug{Declaring qualifier \string#1 with\MessageBreak
- meaning \string#2}%
- \protected\def#1{%
- \ifsi@unt@littest
- \expandafter\@gobble
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\si@unt@litqual
- \else
- \expandafter\expandafter\expandafter\si@unt@qual
- \fi
- \fi
- {#2}}}
-% \end{macrocode}
-%\end{macro}
-%
-%\begin{macro}{\si@unt@unithook}
-%\begin{macro}{\si@unt@unit}
-%\darg{number}
-%\darg{unit}
-%\darg{symbol}
-% The macro for units is actually a processor, rather than
-% typesetting anything, which is handled elsewhere. The first
-% argument to the macro is optional, but does not have square
-% brackets to keep things simple with gobbling.
-% \begin{macrocode}
-\newcommand*{\si@unt@unithook}{}
-\newcommand*{\si@unt@unit}[3]{%
-% \end{macrocode}
-% When the count is minus one at the start of the processor, then the
-% unit is begin used on its own: initialisation occurs.
-% \begin{macrocode}
- \ifnum\si@unt@depthcnt=\m@ne\relax
- \expandafter\si@unt@init
- \fi
- \advance\si@unt@depthcnt\@ne\relax
- \si@log@debug{Unit processing: level \the\si@unt@depthcnt,
- \MessageBreak unit \string#2}%
- \si@unt@firstorsecond{#1}{#2}%
-% \end{macrocode}
-% The core of the \cs{si@unt@unit} macro is testing if the symbol for
-% the unit is a literal value or another macro. Depending on the
-% result, the symbol is either used as a literal or executed.
-% \begin{macrocode}
- \si@unt@ifliteral{#3}
- {\si@unt@addtostack{unit}{#3}%
- \ifsi@unt@prepower
- \expandafter\si@unt@stkpower
- \fi}
- {#3}%
-% \end{macrocode}
-% The counter is now stepped down, before checking if this is
-% the end of a compound unit.
-% \begin{macrocode}
- \advance\si@unt@depthcnt\m@ne\relax
- \ifnum\si@unt@depthcnt=\z@\relax
- \expandafter\si@unt@final
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@firstorsecond}
-%\darg{number}
-%\darg{unit-macro}
-% At this stage, the flag will be set for the first item to be
-% processed whichever route the unit has been called by.
-% \begin{macrocode}
-\newcommand*{\si@unt@firstorsecond}[2]{%
- \ifsi@unt@first
- \expandafter\si@unt@first
- \else
- \expandafter\si@unt@second
- \fi
- {#1}{#2}}%
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@first}
-%\darg{number}
-%\darg{unit-macro}
-% For the first unit in the input, some extra tasks are needed.
-% First, the optional argument for the unit macro needs to be
-% tested.
-% \begin{macrocode}
-\newcommand*{\si@unt@first}[2]{%
- \si@ifnotmtarg{#1}
- {\num{#1}%
- \si@unt@numtrue}%
- \si@unt@unithook
-% \end{macrocode}
-% To avoid filling up the macro list with useless values, the \eTeX\
-% primitive \cs{ifcsname} is employed here (it also avoids complex
-% expansion issues). If some options exist, they are set.
-% \begin{macrocode}
- \ifcsname\expandafter\@gobble\string#2@opt@unt@si\endcsname
- \expandafter\si@unt@setopts
- \else
- \expandafter\@gobble
- \fi
- {#2}%
- \si@unt@addvaluesep
- \si@unt@firstfalse}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@setopts}
-%\begin{macro}{\si@unt@setSIopts}
-%\darg{unit}
-% A rather long set of \cs{expandafter} commands to get the options
-% to set safely.
-% \begin{macrocode}
-\newcommand*{\si@unt@setopts}[1]{%
- \expandafter\expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\si@temptoks\expandafter
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter{\expandafter%
- \csname\expandafter\@gobble\string#1@opt@unt@si%
- \endcsname}%
- \expandafter\sisetup\expandafter{\the\si@temptoks}%
- \si@log@debug{Applying options `\the\si@temptoks'
- for\MessageBreak unit \string#1}%
-% \end{macrocode}
-% The user options are reloaded, if defined, to ensure that they
-% still work as expected.
-% \begin{macrocode}
- \@ifundefined{si@unt@SIopts}{}
- {\ifx\@empty\si@unt@SIopts\@empty\else
- \expandafter\expandafter\si@unt@setSIopts
- \fi}}
-\newcommand*{\si@unt@setSIopts}{%
- \expandafter\si@temptoks\expandafter{\si@unt@SIopts}%
- \expandafter\sisetup\expandafter{\the\si@temptoks}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@second}
-%\begin{macro}{\si@unt@third}
-%\darg{number}
-%\darg{unit}
-% For everything apart from the first item to be processed, spacing
-% may need to be added to separated different units. The macro is
-% divided into two, so that everything except the space can be added
-% in finalisation.
-% \begin{macrocode}
-\newcommand*{\si@unt@second}[2]{%
- \si@ifnotmtarg{#1}
- {\si@log@warn{Optional argument to unit macro\MessageBreak
- allowed only for outer unit}}%
- \si@unt@third
- \si@unt@addtostack{space}{\ensuremath{\si@unitsep}}}
-\newcommand*{\si@unt@third}{%
- \ifsi@unt@prepower\else
- \expandafter\si@unt@stkpower
- \fi
-% \end{macrocode}
-% A check is made to avoid adding $-1$ to prefixes. If \opt{frac} is
-% active, then the |b| stack will be in use, otherwise it will be
-% |a|.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{prefix}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \else
- \expandafter\si@unt@spacecheck
- \fi
- \ifsi@unt@per
- \expandafter\si@unt@perseentrue
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@spacecheck}
-% A check to prevent adding $-1$ at the very beginning of the unit,
-% where there is a space on the stack.
-% \begin{macrocode}
-\newcommand*{\si@unt@spacecheck}{%
- \renewcommand*{\si@tempa}{space}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \else
- \expandafter\si@unt@reciptest
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@prefix}
-%\darg{multiple}
-%\darg{power-ten}
-%\darg{symbol}
-% Actual output of the prefixes.
-% \begin{macrocode}
-\newcommand*{\si@unt@prefix}[3]{%
- \si@unt@firstorsecond{}{#1}%
- \ifsi@prefixsymbolic
- \expandafter\si@unt@addprefix
- \else
- \expandafter\si@unt@countprefix
- \fi
- {#1}{#2}{#3}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@addprefix}
-%\darg{gobbled}
-%\darg{gobbled}
-%\darg{symbol}
-% To add the prefix, a little translation is needed.
-% \begin{macrocode}
-\newcommand*{\si@unt@addprefix}[3]{%
- \si@unt@addtostack{prefix}{#3}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@prefixcnt}
-% A storage area is created.
-% \begin{macrocode}
-\newcount\si@unt@prefixcnt
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@countprefix}
-%\begin{macro}{\si@unt@invprefix}
-%\darg{multiple}
-%\darg{powers-ten}
-%\darg{gobbled}
-% To count the prefix numeral, the symbol is thrown away. First, a
-% check is made for binary units.
-% \begin{macrocode}
-\newcommand*{\si@unt@countprefix}[3]{%
- \renewcommand*{\si@tempa}{binary}%
- \expandafter\expandafter\expandafter\ifx\expandafter
- \csname\expandafter\@gobble\string#1@opt@si\endcsname
- \si@tempa
- \expandafter\sisetup
- \else
- \expandafter\@gobble
- \fi
- {prefixbase=two}%
- \si@tempcnta#2\relax
- \ifsi@unt@per
- \expandafter\si@unt@invprefix
- \fi
- \advance\si@unt@prefixcnt\si@tempcnta\relax}
-\newcommand*{\si@unt@invprefix}{%
- \si@tempcntb\si@tempcnta\relax
- \si@tempcnta -\si@tempcntb\relax}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@litpower}
-%\darg{gobbled}
-%\darg{number}
-% For literal power output, the number can't simply be dumped, so
-% a macro is needed.
-% \begin{macrocode}
-\newcommand*{\si@unt@litpower}[2]{\textsuperscript{#2}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@unt@prepower}
-% If a power is seen before a unit, tracking is needed.
-% \begin{macrocode}
-\newif\ifsi@unt@prepower
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@power}
-%\darg{power}
-%\darg{number}
-% The handling of powers starts by ensuring that ``pre'' powers
-% follow \cs{per} cleanly. Then a check is needed for inversion.
-% \begin{macrocode}
-\newcommand*{\si@unt@power}[2]{%
- \renewcommand*{\si@tempa}{post}%
- \expandafter\expandafter\expandafter\ifx\expandafter
- \csname\expandafter\@gobble\string#1@opt@si\endcsname
- \si@tempa
- \expandafter\@gobbletwo
- \else
- \expandafter\si@unt@firstorsecond
- \fi
- {}{\power}%
- \si@unt@powerdim #2 pt\relax
- \ifsi@frac\else
- \ifsi@unt@per
- \expandafter\expandafter\expandafter\si@unt@invpower
- \fi
- \fi
- \renewcommand*{\si@tempa}{post}%
- \si@unt@prepowertrue
- \expandafter\expandafter\expandafter\ifx\expandafter
- \csname\expandafter\@gobble\string#1@opt@si\endcsname
- \si@tempa
- \expandafter\si@unt@stackpower
- \else
- \si@log@debug{Power \strip@pt\si@unt@powerdim\space saved
- to be added after\MessageBreak next unit}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@powerdim}
-% To do sign-inversion on the power, a dimension is used (this allows
-% non-integer values to be handled).
-% \begin{macrocode}
-\newdimen\si@unt@powerdim
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@stackpower}
-%\begin{macro}{\si@unt@stkpower}
-%\begin{macro}{\si@unt@stkpwr}
-%\begin{macro}{\si@unt@skpwr}
-% Adding powers to the stack should also clear the power list. If
-% the number is already zero, then of course nothing happens.
-% \begin{macrocode}
-\newcommand*{\si@unt@stackpower}{%
- \si@unt@prepowerfalse
-% \end{macrocode}
-% A trap is used for $-1$ added to the denominator of a fraction.
-% \begin{macrocode}
- \si@unt@stkpower
- \ifsi@stickyper\else
- \si@unt@perfalse
- \si@unt@perseenfalse
- \fi}
-% \end{macrocode}
-% The \cs{si@unt@stkpower} macro needs to be called from a few
-% places, so is spun out from the above.
-% \begin{macrocode}
-\newcommand*{\si@unt@stkpower}{%
- \ifdim\si@unt@powerdim=\m@ne pt\relax
- \ifsi@frac\else
- \expandafter\expandafter\expandafter\si@unt@stkpwr
- \fi
- \else
- \expandafter\si@unt@stkpwr
- \fi}
-% \end{macrocode}
-%\changes{v1.1}{2008/09/04}{Altered to account for qualifiers}
-% Finally, the actual adding (set up to avoid problems with the
-% \cs{if} above).
-% \begin{macrocode}
-\newcommand*{\si@unt@stkpwr}{%
- \ifdim\si@unt@powerdim=\z@\relax\else
- \renewcommand*{\si@tempa}{unit}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname
- \si@tempa
- \si@unt@skpwr
- \else
- \renewcommand*{\si@tempa}{qual}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname
- \si@tempa
- \si@unt@skpwrqual
- \fi
- \fi
- \fi
- \si@unt@powerdim\z@\relax}
-\newcommand*{\si@unt@skpwr}{%
- \si@log@debug{Adding power
- \strip@pt\si@unt@powerdim\space to output stack}%
- \si@unt@addtostack{power}{^{\num[fixdp=false]{%
- \strip@pt\si@unt@powerdim}}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@invpower}
-% A macro to change the sign of the current power.
-% \begin{macrocode}
-\newcommand*{\si@unt@invpower}{%
- \si@tempdima\si@unt@powerdim\relax
- \si@unt@powerdim -\si@tempdima\relax
-% \end{macrocode}
-% The power might end up as ``1'', which is not wanted. So it is
-% chucked away.
-% \begin{macrocode}
- \ifdim\si@unt@powerdim=\p@\relax
- \si@unt@powerdim\z@\relax
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@litqual}
-% \begin{macrocode}
-\newcommand*{\si@unt@litqual}[1]{(#1)}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@qual}
+%\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}
-\newcommand*{\si@unt@qual}[1]{%
- \ifsi@unt@first
- \si@log@err{Qualifier before units}
- {A unit qualifier can only be given after\MessageBreak
- one or more units. You tried to open a unit
- with\MessageBreak \string#1}%
- \fi
+\cs_set_protected_nopar:Npn \_siunitx_number_format_group_decimal: {
+ \tl_if_empty:NF \_l_siunitx_tmpa_tl
+ {
+ \exp_after:wN \_siunitx_number_format_group_decimal_aux:NNNN
+ \_l_siunitx_tmpa_tl { } { } { }
+ }
+}
+\cs_set_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}
-% The space after the current unit is shuffled so it will come
-% after the qualifier.
+%\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}
- \expandafter\let\expandafter\si@unt@spacestack
- \csname si@unt@spacestack\si@unt@checkstack\endcsname
- \expandafter\let\csname si@unt@spacestack\si@unt@checkstack
- \endcsname\@empty
+\cs_set_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_set_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_set_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_set_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}
-%\begin{macro}{\si@unt@skpwrqual}
-% Some protection against trying to add two powers.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{power}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \let\si@unt@skpwrqual\relax
- \else
- \let\si@unt@skpwrqual\si@unt@skpwr
- \fi
- \si@unt@addtostack{qual}{_{#1}}%
- \expandafter\let\csname si@unt@spacestack\si@unt@checkstack
- \endcsname\si@unt@spacestack}
-% \end{macrocode}
-%\end{macro}
%\end{macro}
-%\begin{macro}{\ifsi@unt@per}
-%\begin{macro}{\ifsi@unt@perseen}
-%\begin{macro}{\per}
-%\begin{macro}{\si@per}
-%\begin{macro}{\si@unt@per}
-% The \cs{per} macro sets the correct flags; almost everything else
-% is done elsewhere. There is always the case of two \cs{per}
-% instructions; so the flag is flipped rather than set arbitrarily.
-% The second flag is needed so that \cs{per} can give powers of $-1$
-% properly.
-% \begin{macrocode}
-\newif\ifsi@unt@per
-\newif\ifsi@unt@perseen
-\si@newrobustcmd*{\si@per}{%
- \ifsi@unt@littest\else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter /%
- \else
- \ifsi@unt@litprefix
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter /%
- \else
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@unt@per
- \fi
- \fi
- \fi}
-\newcommand*{\si@unt@per}{%
- \si@unt@firstorsecond{}{\per}%
- \ifsi@unt@per
- \ifsi@stickyper\else
- \expandafter\expandafter\expandafter\si@unt@perfalse
- \fi
- \else
- \expandafter\si@unt@pertrue
- \fi}
-\let\per\si@per
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@reciptest}
-%\begin{macro}{\si@unt@recip}
-% A test is needed for adding $-1$ when needed. The second macro is
-% fired only if the power should be reciprocal.
-% \begin{macrocode}
-\newcommand*{\si@unt@reciptest}{%
- \ifsi@unt@per
- \ifsi@unt@perseen
- \expandafter\expandafter\expandafter\si@unt@recip
- \fi
- \fi}
-\newcommand*{\si@unt@recip}{%
- \si@unt@powerdim\m@ne pt\relax
- \si@unt@stackpower}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@lastadda}
-%\begin{macro}{\si@unt@lastaddb}
-% Items cannot be added directly to the stacks (except the spacing
-% stack, a) as the fractional handling may need to add the item to
-% either storage area. First, a track is kept of what has
-% been added at each stage.
-% \begin{macrocode}
-\newcommand*{\si@unt@lastadda}{}
-\newcommand*{\si@unt@lastaddb}{}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@addtostack}
-%\changes{v1.1b}{2008/10/12}{Added warning for multiple prefixes}
-%\darg{type}
-%\darg{token}
-% By indicating the type of data to be added to the stack, problems
-% can be avoided.
-% \begin{macrocode}
-\newcommand*{\si@unt@addtostack}[2]{%
- \renewcommand*{\si@tempa}{#1}%
-% \end{macrocode}
-% Two consecutive items cannot be of the same type; there must be spaces
-% between units, units between prefixes, \etc.
-% \begin{macrocode}
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \renewcommand*{\si@tempa}{prefix}%
- \expandafter\ifx\csname si@unt@lastadd\si@unt@checkstack
- \endcsname\si@tempa
- \si@log@warn{Two prefixes found: only first printed}%
- \fi
- \expandafter\@gobbletwo
- \else
- \expandafter\si@unt@preplussp
- \fi
- {#1}{#2}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@preplussp}
-%\darg{type}
-%\darg{stack}
-%\darg{token}
-%\darg{gobbled}
-% The space added after a prefix needs to be ignored.
-% \begin{macrocode}
-\newcommand*{\si@unt@preplussp}[2]{%
- \renewcommand*{\si@tempa}{prefix+space}%
- \edef\si@tempb{%
- \csname si@unt@lastadd\si@unt@checkstack\endcsname+#1}%
- \ifx\si@tempa\si@tempb
- \expandafter\@gobbletwo
- \else
- \expandafter\si@unt@stack
- \fi
- {#1}{#2}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@stack}
-%\darg{type}
-%\darg{token}
-% The macro for actually doing the stacking up.
-% \begin{macrocode}
-\newcommand*{\si@unt@stack}[2]{%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@unt@lastadd\si@unt@checkstack\endcsname}{#1}%
-% \end{macrocode}
-% A count is kept of the number of \emph{units} added to each stack.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{#1}%
- \renewcommand*{\si@tempb}{unit}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@unt@inccnt
- \fi
-% \end{macrocode}
-% If a space is added, it is actually held until the next add.
+%\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}
- \renewcommand*{\si@tempb}{space}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@unt@holdspace
- \else
- \expandafter\si@unt@addstack
- \fi
- {#2}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@inccnt}
-% The appropriate counter is added to.
-% \begin{macrocode}
-\newcommand*{\si@unt@inccnt}{%
- \expandafter\advance
- \csname si@unt@unitcnt\si@unt@checkstack\endcsname
- \@ne\relax}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@spacestack}
-%\begin{macro}{\si@unt@spacestacka}
-%\begin{macro}{\si@unt@spacestackb}
-% The stacked material needs somewhere to live.
-% \begin{macrocode}
-\newcommand*{\si@unt@spacestack}{}
-\newcommand*{\si@unt@spacestacka}{}
-\newcommand*{\si@unt@spacestackb}{}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@holdspace}
-%\begin{macro}{\si@unt@addstack}
-%\darg{token}
-% Depending on the nature of the addition, it is either held or added
-% to the stack. For the ``b'' space stack, a check is made to ensure
-% that a space cannot be added before the first item.
-% \begin{macrocode}
-\newcommand*{\si@unt@holdspace}[1]{%
- \renewcommand*{\si@tempa}{b}%
- \edef\si@tempb{\si@unt@checkstack}%
- \ifx\si@tempa\si@tempb
- \ifx\@empty\si@unt@stackb\@empty
- \else
- \protected@edef\si@unt@spacestackb{#1}%
- \fi
- \else
- \protected@edef\si@unt@spacestacka{#1}%
- \fi}
-\newcommand*{\si@unt@addstack}[1]{%
- \expandafter\protected@edef
- \csname si@unt@stack\si@unt@checkstack\endcsname
- {\csname si@unt@stack\si@unt@checkstack\endcsname
- \csname si@unt@spacestack\si@unt@checkstack\endcsname#1}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@unt@spacestack\si@unt@checkstack\endcsname}{}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@stackout}
-% The stack contents are actually typeset here. First the spacing
-% between units and values is added.
-% \begin{macrocode}
-\newcommand*{\si@unt@stackout}{%
- \si@unt@litouttrue
- \ifsi@frac
- \expandafter\si@unt@fracout
- \else
- \expandafter\si@unt@normout
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@checkstack}
-% Which stack is in use needs to be tested.
-% \begin{macrocode}
-\newcommand*{\si@unt@checkstack}{%
- \ifsi@frac
- \ifsi@unt@per
- \expandafter\expandafter\expandafter b%
- \else
- \expandafter\expandafter\expandafter a%
- \fi
- \else
- \expandafter a%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@spaceout}
-% The space before a unit might not be needed, so it crops up a few
-% times in the output routine.
-% \begin{macrocode}
-\newcommand*{\si@unt@spaceout}{%
- \ensuremath{\si@unt@spstack}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@prefixout}
-% If the prefix counter is not zero, then there is something to
-% typeset.
-% \begin{macrocode}
-\newcommand*{\si@unt@prefixout}{%
- \ifnum\si@unt@prefixcnt=\z@\relax\else
- \ifsi@unt@num
- \si@out{\ensuremath{{}\si@prefixproduct{}}}%
- \fi
- \si@unt@stackvalsep
- \let\si@expbase\si@prefixbase
- \num[fixdp=false]{e\the\si@unt@prefixcnt}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@normout}
-% The normal output mode is set up here; nothing much needs to be
-% done as there is no need for complex checks.
-% \begin{macrocode}
-\newcommand*{\si@unt@normout}{%
- \si@unt@prefixout
- \si@unt@spaceout
- \expandafter\si@unt@out\expandafter{\si@unt@stacka}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@fracout}
-% For fractions, some checks are needed.
-% \begin{macrocode}
-\newcommand*{\si@unt@fracout}{%
- \si@unt@notambig
- \ifx\@empty\si@unt@stacka\@empty
- \ifx\@empty\si@unt@stackb\@empty
- \ifsi@unt@litout\else
- \si@log@err{Empty fractional unit}{The unit
- argument\MessageBreak given does not contain any
- symbols}%
- \fi
- \else
-% \end{macrocode}
-% With an empty numerator, no space is added
-% \begin{macrocode}
- \ifsi@slash
- \si@unt@prefixout
- \si@frac{}{\si@unt@stackb}%
- \else
- \si@unt@prefixout
- \si@unt@spaceout
- \si@frac{1}{\si@unt@stackb}%
- \fi
- \fi
- \else
-% \end{macrocode}
-% If the denominator is empty, then the usual output system can be
-% used.
-% \begin{macrocode}
- \ifx\@empty\si@unt@stackb\@empty
- \si@unt@normout
- \else
- \si@unt@prefixout
- \si@unt@spaceout
- \si@frac{\si@unt@stacka}{\si@unt@stackb}%
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@notambig}
-%\begin{macro}{\si@unt@notabg}
-% A trap is set for adding brackets to units using a slash, when more
-% than one unit is in the denominator.
-% \begin{macrocode}
-\newcommand*{\si@unt@notambig}{%
- \ifnum\si@unt@unitcntb>\@ne\relax
- \ifsi@slash
- \ifsi@trapambigfrac
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@unt@notabg
- \fi
- \fi
- \fi}
-\newcommand*{\si@unt@notabg}{%
- \protected@edef\si@unt@stackb{\si@openfrac\si@unt@stackb
- \si@closefrac}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%
-%\begin{macro}{\si@unt@out}
-%\changes{v1.0d}{2008/06/25}{Sanitise one level of unit input
-% only}
-%\darg{unit}
-% The final part of the units system is the output routine. This has
-% to cope with units not only as macros but also as direct input
-% (\SIstyle-type input). Non-Latin characters are also handled
-% cleanly. The \cs{scantokens} system deals with everything except
-% full stops; these are left out so that a single level system can be
-% used \latin{via} a token register.
-% \begin{macrocode}
-\begingroup
- \catcode`\~=\active
- \catcode`\.=\active
- \gdef\si@unt@out#1{%
- \si@temptoks{#1}%
- \si@unt@fullstop
- \def.{\ensuremath{\si@unitsep}}%
- \def~{\ensuremath{\si@unitspace}}%
- \expandafter\protected@edef\expandafter\si@tempa
- \expandafter{\the\si@temptoks}%
- \begingroup
- \si@unt@nonlatin
- \makeatletter
- \endlinechar\m@ne
- \expandafter\si@out\expandafter{%
- \expandafter\scantokens\expandafter{\si@tempa}}%
- \endgroup}
-\endgroup
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@fullstop}
-%\begin{macro}{\si@unt@stp}
-% Two macros modified from \pkg{kvsetkeys} to deal with a single
-% level of active full stops only.
-% \begin{macrocode}
-\begingroup
- \catcode`\.=\active
- \catcode`\&=12\relax
- \begingroup
- \lccode`\.=`\.\relax
- \lccode`\&=`\.\relax
- \lowercase{\endgroup
- \gdef\si@unt@fullstop{%
- \si@temptoks\expandafter{\expandafter}\expandafter
- \si@unt@stp\the\si@temptoks&\@nil}
- \gdef\si@unt@stp#1&#2\@nil{%
- \edef\si@tempa{\the\si@temptoks}%
- \ifx\si@tempa\@empty
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
- {\si@temptoks{#1}}
- {\si@temptoks\expandafter{\the\si@temptoks.#1}}%
- \si@ifmtarg{#2}
- {}
- {\si@unt@stp#2\@nil}}}
-\endgroup
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@unt@nonlatin}
-% To handle non-Latin symbols in the input, a single macro is
-% provided. If \XeTeX\ is in use, this can be detected immediately.
-% \begin{macrocode}
-\newcommand*{\si@unt@nonlatin}{}
-\ifdefined\XeTeXrevision
- \renewcommand*{\si@unt@nonlatin}{%
- \catcode176=\active
- \catcode181=\active
- \catcode197=\active
- \si@unt@sym{176}{\si@sym@degree}%
- \si@unt@sym{181}{\si@sym@mu}%
- \si@unt@sym{197}{\si@sym@ringA}}%
-\fi
-% \end{macrocode}
-% If \pkg{inputenc} has been loaded, then a check is made that the
-% encoding is correct. If all is well, the non-Latin symbols are
-% handled. The degree symbol is character 176, the micro
-% symbol is character 181 and ring capital A is character 197 in
-% latin1.
-% \begin{macrocode}
-\AtBeginDocument{
- \@ifpackageloaded{inputenc}
- {\@for\si@tempa:=latin1,latin5,latin9\do{
- \ifx\inputencodingname\si@tempa
- \renewcommand*{\si@unt@nonlatin}{%
- \catcode176=\active
- \catcode181=\active
- \catcode197=\active
- \si@unt@sym{176}{\si@sym@degree}%
- \si@unt@sym{181}{\si@sym@mu}%
- \si@unt@sym{197}{\si@sym@ringA}}%
- \fi}}
- {}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@unt@sym}
-%\darg{charcode}
-% A macro for declaring symbols: a copy of \cs{DeclareInputMath} from
-% \pkg{inputenc}.
-% \begin{macrocode}
-\newcommand*{\si@unt@sym}[1]{%
- \bgroup
- \uccode`\~#1%
- \uppercase{%
- \egroup
- \def~}}
+\cs_set_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}{\kilogram}
-%\begin{macro}{\metre}
-%\begin{macro}{\meter}
-%\begin{macro}{\mole}
-%\begin{macro}{\kelvin}
-%\begin{macro}{\candela}
-%\begin{macro}{\second}
-%\begin{macro}{\ampere}
-% With the system set up, the basic unit macros are implemented. The
-% only units defined whatever options are given are the base SI
-% units.
+%\begin{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}
-\newunit{\kilogram}{kg}
-\newunit{\metre}{m}
-\newunit{\meter}{\metre}
-\newunit{\mole}{mol}
-\AtBeginDocument{\provideunit{\second}{s}}
-\newunit{\ampere}{A}
-\newunit{\kelvin}{K}
-\newunit{\candela}{cd}
+\cs_set_protected_nopar:Npn \_siunitx_number_format_join_uncert: {
+ \_siunitx_number_format_join_uncert:n { mantissa }
+ \_siunitx_number_format_join_uncert:n { complex }
+}
+\cs_set_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_set_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_set_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_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_set_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_set_protected_nopar:Npn \_siunitx_number_format_sign_complex: {
+ \_siunitx_number_format_sign_complex:n { complex }
+ \_siunitx_number_format_sign_complex:n { complex-result }
+}
+\cs_set_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}
-%\end{macro}
-%\begin{macro}{\Square}
-%\changes{v1.1b}{2008/10/12}{Only defined if not otherwise available}
-%\begin{macro}{\ssquare}
-%\begin{macro}{\squared}
-%\begin{macro}{\cubic}
-%\begin{macro}{\cubed}
-% Unlike multiples (which can be skipped if needed), the basic powers
-% are also always defined.
+%
+%\begin{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}
-\AtBeginDocument{
- \@ifundefined{Square}{%
- \newpower{\Square}{2}}{}}
-\newpower{\ssquare}{2}
-\newpower[post]{\squared}{2}
-\newpower{\cubic}{3}
-\newpower[post]{\cubed}{3}
+\cs_set_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_set_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_set_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}
-%\end{macro}
-%\begin{macro}{\tothe}
-%\begin{macro}{\raiseto}
-% The user macros for arbitraty powers are simple
-% calling macros to a common internal macro.
+%
+%\begin{macro}{\_l_siunitx_number_compound_bool}
+% To help with brackets.
% \begin{macrocode}
-\newcommand*{\tothe}{\si@tothe{\tothe}}
-\newcommand*{\raiseto}{\si@tothe{\raiseto}}
+\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}{\si@tothe}
-%\begin{macro}{\tothe@opt@si}
-%\begin{macro}{\raiseto@opt@si}
-%\darg{either \texttt{\cs{tothe}} or \texttt{\cs{raiseto}}}
-%\darg{number}
-% A macro for arbitrary powers, which comes after the unit and so
-% needs to be marked as such. Two fake option-storage macros are
-% created so that everything works correctly.
+%
+%\begin{macro}{\_siunitx_fraction:nn}
+% The function used for fractions should be stored here.
% \begin{macrocode}
-\newcommand*{\si@tothe}[2]{%
- \ifsi@unt@littest
- \expandafter\@gobbletwo
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\si@unt@litpower
- \else
- \expandafter\expandafter\expandafter\si@unt@power
- \fi
- \fi
- {#1}{#2}}
-\newcommand*{\tothe@opt@si}{post}
-\newcommand*{\raiseto@opt@si}{}
+\cs_set_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}
-%
-%\subsection{Ranges}
-%
-%\begin{macro}{\numrange}
-%\changes{v1.2}{2009/01/22}{New user macro}
-%\begin{macro}{\SIrange}
-%\changes{v1.2}{2009/01/22}{New user macro}
-% Ranges are essentially just repeated calls to \cs{num} or \cs{SI}.
-% However, a nice wrapper is useful.
-% \begin{macrocode}
-\si@newrobustcmd*{\numrange}[3][]{%
- \begingroup
- \sisetup{#1}%
- \num{#2}%
- \text{\si@tophrase}%
- \num{#3}%
- \endgroup
-}
-\si@newrobustcmd*{\SIrange}[4][]{%
- \begingroup
- \sisetup{#1}%
- \ifsi@repeatunits
- \SI{#2}{#4}%
- \else
- \ifsi@trapambigrange
- \ensuremath{\si@openrange}%
- \fi
- \num{#2}%
- \fi
- \text{\si@tophrase}%
- \ifsi@repeatunits
- \SI{#3}{#4}%
- \else
- \ifsi@trapambigrange
- \num{#3}%
- \ensuremath{\si@closerange\si@valuesep}%
- \si{#4}%
- \else
- \SI{#3}{#4}%
- \fi
- \fi
- \endgroup
-}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%
-%\subsection{Locales}
-%\begin{macro}{\si@loc@load}
-%\begin{macro}{\si@loc@sisetup}
-%\darg{locale}
-% When loading a locale, the setup is saved rather than applied.
-% Anything other than simple settings should be inside
-% \cs{addtolocale}, which is already defined.
-% \begin{macrocode}
-\newcommand*{\si@loc@load}[1]{%
- \let\si@loc@sisetup\sisetup
- \renewcommand*{\sisetup}[1]{%
- \expandafter\gdef\csname si@loc@#1\endcsname{##1}}%
- \si@loadfile{#1}%
- \let\sisetup\si@loc@sisetup}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@loc@set}
-%\darg{locale}
-% Setting the locale transfers the settings to \cs{sisetup}, and runs
-% any extra macros.
-% \begin{macrocode}
-\newcommand*{\si@loc@set}[1]{%
- \ifcsname si@loc@#1\endcsname
- \si@log@inf{Setting locale to `#1'}%
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@temptoks
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter{%
- \expandafter\csname si@loc@#1\endcsname}%
- \expandafter\sisetup\expandafter{\the\si@temptoks}%
- \ifcsname si@loc@#1@extra\endcsname
- \csname si@loc@#1@extra\endcsname
- \fi
- \else
- \ifcsname si@loc@#1@extra\endcsname
- \si@log@inf{Setting locale to `#1'}%
- \csname si@loc@#1@extra\endcsname
- \else
- \si@log@warn{Unknown locale `#1'}%
- \fi
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@loc@ltol}
-%\changes{v1.0a}{2008/06/20}{\pkg{babel} support fixed for default
-% document language}
-%\darg{list of locales and languages}
-% The necessary loading for language modules occurs.
-% \begin{macrocode}
-\newcommand*{\si@loc@ltol}[1]{%
- \def\si@tempa##1:##2\@nil{\si@loc@load{##1}}
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb:\@nil}
- \AtBeginDocument{
- \@ifpackageloaded{babel}
- {\def\si@tempa##1:##2:##3\@nil{%
- \expandafter\addto\expandafter{%
- \csname extras##2\endcsname}%
- {\si@loc@set{##1}}}%
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb::\@nil}%
- \expandafter\selectlanguage\expandafter{\languagename}}
- {\si@log@warn{babel not loaded \MessageBreak
- loctolang option ignored}}}}
-\AtBeginDocument{
- \@ifpackageloaded{babel}
- {\renewcommand*{\si@loc@ltol}[1]{%
- \def\si@tempa##1:##2\@nil{\si@loc@load{##1}}%
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb:\@nil}%
- \def\si@tempa##1:##2:##3\@nil{%
- \expandafter\addto\expandafter{%
- \csname extras##2\endcsname}%
- {\si@loc@set{##1}}}%
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb::\@nil}}}
- {\renewcommand*{\si@loc@ltol}[1]{%
- \si@log@warn{babel not loaded \MessageBreak
- loctolang option ignored}}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\addtolocale}
-%\darg{locale}
-%\darg{commands}
-% Arbitrary macros may need to be added to the locale.
-% \begin{macrocode}
-\newcommand*{\addtolocale}[2]{%
- \si@addtocsname{si@loc@#1@extra}{#2}}
-% \end{macrocode}
-%\end{macro}
-%
-%\subsection{Output routine}
-%\begin{macro}{\si@out}
-%\changes{v1.1}{2008/07/22}{Extended handling to subscripts}
-%\darg{text}
-% With all of the setup done, the text can finally be typeset. This
-% is done inside a \cs{text} block, which takes care of
-% \cs{ensuremath}, \etc. First of all, the various catcode settings
-% needed to get maths-in-text mode are made. \cs{makeatletter} is
-% needed so that \cs{scantokens} still allows internal macros to
-% work.
-% \begin{macrocode}
-\begingroup
- \catcode`\^=\active
- \catcode`\-=\active
- \catcode`\_=\active
- \gdef\si@out#1{%
- \begingroup
- \catcode`\^=\active
- \catcode`\_=\active
- \makeatletter
- \endlinechar\m@ne
-% \end{macrocode}
-%\changes{v1.0f}{2008/07/17}{Fixed bug with colour and spacing}
-% The various font families can now be set up. First a check is made
-% in case there are nested calls to \cs{si@out@text}.
-% \begin{macrocode}
- \ifsi@fam@set\else
- \expandafter\si@fam@set
- \fi
- \text{%
- \si@colourcmd{\si@colour}%
- \si@fam@italic\si@fam@bold\si@fam@text
-% \end{macrocode}
-% The correct mode is selected, and the input is handed off for
-% typesetting.
-% \begin{macrocode}
- \ifsi@textmode
- \expandafter\si@out@text
- \else
- \expandafter\si@out@maths
- \fi
- {\scantokens{#1}}}%
- \endgroup
- \check@mathfonts}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@out@text}
-%\begin{macro}{\si@out@maths}
-%\darg{text}
-% Output occurs with the correct changes to superscript behaviour.
-% \begin{macrocode}
- \gdef\si@out@text#1{%
- \let^\si@out@sp
- \let_\si@out@sb
- \let\textsuperscript\si@out@sp
- \let\textsubscript\si@out@sb
- \catcode`\-=\active\relax
- \let-\si@out@minus
- #1}
- \gdef\si@out@maths#1{%
- \let^\sp
- \let_\sb
- \let\textsuperscript\sp
- \let\textsubscript\sb
- $\si@fam@maths{#1}$}
-\endgroup
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@out@sp}
-%\begin{macro}{\si@out@sb}
-%\darg{text}
-% \cs{textsuperscript} gives slightly different alignment of numbers
-% to using |^| in text mode. To avoid this, a slightly different
-% definition is used. Elsewhere \cs{textsuperscript} is used, as the
-% code above sorts out the text/maths mode issues. The same is done
-% for subscripts.
-% \begin{macrocode}
-\newcommand*{\si@out@sp}[1]{\ensuremath{^{\text{#1}}}}
-\newcommand*{\si@out@sb}[1]{\ensuremath{_{\text{#1}}}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\si@out@minus}
-%\changes{v1.1j}{2008/12/22}{Fixed infinite loop with \pkg{breqn}}
-% An active minus sign is needed.
-% \begin{macrocode}
-\newcommand*{\si@out@minus}{}
-\DeclareTextSymbolDefault{\si@out@minus}{TS1}
-\DeclareTextSymbol{\si@out@minus}{TS1}{61}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\ifsi@out@num}
-% A flag is needed to control output settings. This will be
-% false unless inside \cs{si@out@num}.
-% \begin{macrocode}
-\newif\ifsi@out@num
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@out@num}
-%\darg{number}
-% For numerical output, the default fonts are controlled slightly
-% differently to text output.
-% \begin{macrocode}
-\newcommand*{\si@out@num}[1]{%
- \begingroup
- \si@out@numtrue
- \si@out{#1}%
- \endgroup}
+%
+%\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_set_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}
-%
-%\subsection{Finalisation}
-%\begin{macro}{\si@extension}
-%\begin{macro}{\si@fileprefix}
-% To keep the code easy to maintain, the reusable filename components
-% are macros rather than literals.
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_number_output_bracket:}
+% Compound numbers may need brackets adding.
% \begin{macrocode}
-\newcommand*{\si@extension}{cfg}
-\newcommand*{\si@fileprefix}{si-}
+\cs_set_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_set_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}{\si@ifl@aded}
-%\begin{macro}{\si@ifloaded}
-%\darg{package}
-% A bit of borrowing from the \LaTeX\ kernel. A copy of
-% \cs{@ifl@aded} is needed as things aren't always done in the
-% preamble by \currpkg.
+%
+%\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}
-\newcommand*{\si@ifl@aded}{}
-\let\si@ifl@aded\@ifl@aded
-\newcommand*{\si@ifloaded}[1]{%
- \si@ifl@aded\si@extension{\si@fileprefix#1}}
+\cs_set_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_set_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:
+ \prop_if_in:NnT \_l_siunitx_number_in_prop { exponent }
+ { \bool_set_true:N \_l_siunitx_brackets_bool }
+ \_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}
-%\begin{macro}{\si@loadfile}
-%\darg{file}
-% Loading configuration files is handled here.
+%\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}
-\newcommand*{\si@loadfile}[1]{%
- \si@ifloaded{#1}{}
- {\si@InputIfFileExists{\si@fileprefix#1.\si@extension}
- {}
- {\si@log@err{Failed to load file
- \si@fileprefix#1.\si@extension}
- {The configuration file requested could not be
- found}}}}
+\cs_set_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_set_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 }
+ {
+ \tl_set_eq:NN \_l_siunitx_tmpb_tl
+ \_l_siunitx_exponent_product_tl
+ \bool_if:NT \_l_siunitx_tight_bool
+ {
+ \tl_set:Nx \_l_siunitx_tmpb_tl
+ { { \exp_not:V \_l_siunitx_tmpb_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_set_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_set_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}
-%\begin{macro}{\ifsi@outerinput}
-% At various points, the package needs to know if the
-% currently-read configuration file is the
-% outer one.
+%\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}
-\newif\ifsi@outerinput\si@outerinputtrue
+\cs_set_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}{\si@InputIfFileExists}
-% To allow reading configuration files after the start of the
-% document, a private copy of \cs{InputIfFileExists} is needed. The
-% main macro here simply checks if the modified version is needed.
-% \begin{macrocode}
-\let\si@InputIfFileExists\InputIfFileExists
-\AtBeginDocument{
- \renewcommand*{\si@InputIfFileExists}{%
- \ifsi@outerinput
- \expandafter\si@outerinput
- \else
- \expandafter\InputIfFileExists
- \fi}}
+%\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_set_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}{\si@outerinput}
-%\darg{file}
-%\darg{true-code}
-%\darg{false-code}
-% The outer call to load a file needs to set |@| to a letter and turn
-% of printing using \cs{nullfont}.
-% \begin{macrocode}
-\newcommand*{\si@outerinput}[3]{%
- \makeatletter
- \nullfont
- \si@outerinputfalse
- \IfFileExists{#1}%
- {#2\@addtofilelist{#1}\@@input \@filef@und\normalsize}
- {#3}%
- \normalsize
- \makeatother}
+%\begin{macro}[aux]{\_siunitx_number_output_product_aux:}
+% Printing the products needs a looping function.
+% \begin{macrocode}
+\cs_set_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}{\requiresiconfigs}
-%\darg{config-file}
-% The configuration files depend on each other.
-% \begin{macrocode}
-\newcommand*{\requiresiconfigs}[1]{%
- \@for\si@tempb:=#1\do{\si@loadfile{\si@tempb}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@loademfile}
-%\darg{file}
-% For emulation files, an additional check is made.
-% \begin{macrocode}
-\newcommand*{\si@loademfile}[1]{%
- \@ifpackageloaded{#1}
- {\si@log@err{Emulation clash for package `#1'}
- {You have asked for emulation of package
- `#1'\MessageBreak
- (perhaps by giving siunitx a back-compatibility
- option)\MessageBreak but the package is already
- loaded!}}
- {\si@loadfile{#1}}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@emclash}
-%\darg{package}
-%\darg{package}
-% A macro for emulation clashes.
-% \begin{macrocode}
-\newcommand*{\si@emclash}[2]{%
- \si@log@err{Emulation clash: `#1' and `#2'}
- {You have asked for emulation of package `#1'\MessageBreak
- but have already loaded emulation of `#2'}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@emulating}
-%\darg{package}
-%\darg{version}
-% For packages that are emulated, the \LaTeX\ mechanism to prevent
-% re-loading is used. The list of packages to check at the start
-% of the document also has to be altered.
-% \begin{macrocode}
-\newcommand*{\si@emulating}[2]{%
- \@namedef{ver@#1.sty}{#2 siunitx emulation of #1}%
- \let\si@tempa\si@blockpkgs
- \renewcommand*{\si@blockpkgs}{}%
- \@for\si@tempb:=\si@tempa\do{%
- \renewcommand*{\si@tempa}{#1}%
- \ifx\si@tempa\si@tempb\else
- \lowercase{\edef\si@tempa{#1}}%
- \lowercase{\edef\si@tempc{\si@tempb}}%
- \ifx\si@tempa\si@tempc
- \@namedef{ver@\si@tempc.sty}{#2 siunitx emulation of
- #1}%
- \else
- \si@addtolist{\si@blockpkgs}{\si@tempb}%
- \fi
- \fi}%
- \let\si@tempa\si@checkpkgs
- \renewcommand*{\si@checkpkgs}{}%
- \renewcommand*{\si@tempb}{#1}%
- \@for\si@tempc:=\si@tempa\do{%
- \ifx\si@tempb\si@tempc\else
- \si@addtolist{\si@checkpkgs}{\si@tempc}%
- \fi}}
-% \end{macrocode}
-%\end{macro}
-% With the \currpkg kernel macros defined, the package can now run
-% through finalisation. First, the default key values are set. The
-% user options are then processed.
+%
+%\begin{macro}{\_siunitx_number_output_quotient:}
+% For quotients, there are two options.
% \begin{macrocode}
-\sisetup{
- addsign=none,
- allowlitunits=true,
- allowzeroexp=false,
- angformat=unchanged,
- astroang=false,%(
- closeerr=),%(
- closefrac=),%(
- closerange=),
- colour=black,
- colourall=false,
- colourneg=false,
- decimalsymbol=fullstop,
- detectdisplay=true,
- digitsep=thin,
- dp=3,
- eVcorra=0.3ex,
- eVcorrb=0ex,
- errspace=none,
- fixdp=false,
- inlinebold=text,
- load=default,
- mathsrm=mathrm,
- mathssf=mathsf,
- mathstt=mathtt,
- mode=maths,
- negcolour=red,
- noload={},
- numaddn={},%(
- numcloseerr=),
- numdecimal={.,},
- numdigits=0123456789,
- numdiv=/,
- numexp=eEdD,
- numgobble={},
- numopenerr=(,%)
- numprod=x,
- numsign=+-\pm\mp,
- obeybold=false,
- obeyitalic=false,
- obeymode=false,
- openerr=(,%)
- openfrac=(,%)
- openrange=(,%
- padangle=small,
- padnumber=lead,
- per=reciprocal,
- prefixbase=ten,
- prefixproduct=times,
- prefixsymbolic=true,
- prespace=false,
- redefsymbols=true,
- repeatunits=true,
- retainplus=false,
- seperr=false,
- sepfour=false,
- sign=plus,
- slash=slash,
- stickyper=false,
- strictarc=true,
- tabalignexp=true,
- tabautofit=false,
- tabformat=3.2,
- tabnumalign=centredecimal,
- tabparseonly=false,
- tabtextalign=centre,
- tabunitalign=left,
- textrm=rmfamily,
- textsf=sffamily,
- texttt=ttfamily,
- tightpm=false,
- tophrase=to,
- trapambigerr=true,
- trapambigfrac=true,
- trapambigrange=true,
- unitsep=thin,
- valuesep=thin,
- xspace=false}
-\ProcessOptionsX[si]<key>
-% \end{macrocode}
-% A check is now made so that emulation takes place one file at a
-% time, and that each file is loaded only once.
-% \begin{macrocode}
-\ifx\@empty\si@emulate\@empty\else
- \@for\si@tempa:=\si@emulate\do{%
- \expandafter\si@loademfile\expandafter{\si@tempa}}
-\fi
-% \end{macrocode}
-%\begin{macro}{\si@expanddefault}
-% For turning the list of default choices into a loadable list.
-% \begin{macrocode}
-\newcommand*{\si@expanddefault}[2]{%
- \expandafter\ifx\expandafter\@empty\csname si@#1\endcsname
- \@empty
- \else
- \renewcommand*{\si@tempb}{default}%
- \renewcommand*{\si@tempc}{}%
- \expandafter\@for\expandafter\si@tempa\expandafter
- :\expandafter=\csname si@#1\endcsname\do{%
- \ifx\si@tempa\si@tempb
- \si@addtolist{\si@tempc}{#2}%
- \else
- \si@addtolist{\si@tempc}{\si@tempa}%
- \fi}
- \expandafter\edef\csname si@#1\endcsname{\si@tempc}%
- \expandafter\si@addtolist\expandafter{%
- \csname si@no#1\endcsname}%
- {default}%
- \renewcommand*{\si@tempc}{}%
- \expandafter\@for\expandafter\si@tempa\expandafter
- :\expandafter=\csname si@#1\endcsname\do{%
- \si@switchfalse
- \expandafter\@for\expandafter\si@tempb\expandafter
- :\expandafter=\csname si@no#1\endcsname\do{%
- \ifx\si@tempa\si@tempb
- \si@switchtrue
- \fi
- \ifsi@switch\else
- \si@addtolist{\si@tempc}{\si@tempa}%
- \fi}}
- \@for\si@tempa:=\si@tempc\do{%
- \si@loadfile{\si@tempa}}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-% The configuration and abbreviation files are loaded.
-% \begin{macrocode}
-\si@expanddefault{load}{prefix,named,addn,prefixed,accepted,%
- physical,abbr}
-% \end{macrocode}
-% The very last job is to load a local configuration file, if one
-% exists, and restore catcodes.
-% \begin{macrocode}
-\IfFileExists{siunitx.cfg}
- {\si@log@inf{Local configuration file found}%
- \InputIfFileExists{siunitx.cfg}{}{}}
- {}
-\si@catcodes
-% \end{macrocode}
-%
-%\iffalse
-%</package>
-%\fi
-%
-%\section{Loadable modules}
-% To keep the package relatively clear, and to make maintenance
-% easier, the only units defined in the package itself are the base
-% units. Everything else is a loadable module (similar to the
-% approach in \unitsdef).
-%
-%\iffalse
-%<*prefix>
-%\fi
-%\subsection{Multiple prefixes}
-%\begin{macro}{\yocto}
-%\begin{macro}{\zepto}
-%\begin{macro}{\atto}
-%\begin{macro}{\femto}
-%\begin{macro}{\pico}
-%\begin{macro}{\nano}
-%\begin{macro}{\micro}
-%\begin{macro}{\Micro}
-%\begin{macro}{\milli}
-%\begin{macro}{\centi}
-%\begin{macro}{\deci}
-% The various SI multiple prefixes are defined here. First the small
-% powers.
-% \begin{macrocode}
-\ProvidesFile{si-prefix.cfg}
- [2010/02/22 v1.4c siunitx: SI Multiple prefixes]
-\newprefix{\yocto}{-24}{y}
-\newprefix{\zepto}{-21}{z}
-\newprefix{\atto}{-18}{a}
-\newprefix{\femto}{-15}{f}
-\newprefix{\pico}{-12}{p}
-\newprefix{\nano}{-9}{n}
-% \end{macrocode}
-% Some testing is needed for \unitsdef compatibility.
-% \begin{macrocode}
-\ifsi@old@OHM
- \newprefix{\Micro}{-6}{\si@sym@mu}
-\else
- \ifsi@gensymb\else
- \newprefix{\micro}{-6}{\si@sym@mu}
- \fi
-\fi
-\newprefix{\milli}{-3}{m}
-\newprefix{\centi}{-2}{c}
-\newprefix{\deci}{-1}{d}
+\cs_set_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_set_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_set_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_set_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_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_set_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_set_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_set_protected_nopar:Npn \_siunitx_number_output_single_aux: {
+ \_siunitx_unit_output_pre_print:
+ \_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}{\deca}
-%\begin{macro}{\hecto}
-%\begin{macro}{\kilo}
-%\begin{macro}{\mega}
-%\begin{macro}{\giga}
-%\begin{macro}{\tera}
-%\begin{macro}{\peta}
-%\begin{macro}{\exa}
-%\begin{macro}{\zetta}
-%\begin{macro}{\yotta}
-% Now the large ones.
+%
+%\begin{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}
-\newprefix{\deca}{1}{da}
-\newprefix{\hecto}{2}{h}
-\newprefix{\kilo}{3}{k}
-\newprefix{\mega}{6}{M}
-\newprefix{\giga}{9}{G}
-\newprefix{\tera}{12}{T}
-\newprefix{\peta}{15}{P}
-\newprefix{\exa}{18}{E}
-\newprefix{\zetta}{21}{Z}
-\newprefix{\yotta}{24}{Y}
+\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}
-%\end{macro}
-%\begin{macro}{\deka}
-% Apparently, ``deka'' is common in the US for deca.
+%
+%\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}
-\newprefix{\deka}{1}{da}
+\cs_set_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:nn { invalid-arc-format } { #1 ; #2 } }
+ { \_siunitx_angle_output_aux:nnn {#1} {#2} {#3} }
+ }
+}
+\cs_set_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}
-%\begin{macro}{\gram}
-%\begin{macro}{\kilogram}
-% As the base unit of mass is the kilogram, rather than the gram, a
-% bit of extra work is needed; by default the package only defines
-% \cs{kilogram}, but with the prefixes available, this is altered to
-% be \cs{kilo}\cs{gram}. For that, the \cs{gram} must be defined first.
-% \begin{macrocode}
-\newunit{\gram}{g}
-\renewunit{\kilogram}{\kilo\gram}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_angle_init:}
+% The usual separation of initial storage resets.
+% \begin{macrocode}
+\cs_set_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}
-%\end{macro}
-%\iffalse
-%</prefix>
-%<*named>
-%\fi
-%\subsection{Derived units with specific names}
-%\begin{macro}{\becquerel}
-%\begin{macro}{\coulomb}
-%\begin{macro}{\farad}
-%\begin{macro}{\Gray}
-%\begin{macro}{\ggray}
-%\begin{macro}{\hertz}
-%\begin{macro}{\henry}
-%\begin{macro}{\joule}
-%\begin{macro}{\katal}
-%\begin{macro}{\lumen}
-%\begin{macro}{\lux}
-%\begin{macro}{\newton}
-% Derived units with specific names and symbols are defined. Litre
-% is an awkward one, but here the UK standard is used.
+%
+%\begin{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}
-\ProvidesFile{si-named.cfg}
- [2010/02/22 v1.4c siunitx: SI Named units]
-\newunit{\becquerel}{Bq}
-\newunit{\coulomb}{C}
-\newunit{\farad}{F}
-\newunit{\Gray}{Gy}
-\newunit{\ggray}{Gy}
-\newunit{\hertz}{Hz}
-\newunit{\henry}{H}
-\newunit{\joule}{J}
-\newunit{\katal}{kat}
-\newunit{\lumen}{lm}
-\newunit{\lux}{lx}
-\newunit{\newton}{N}
+\cs_set_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_set_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_set_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_set_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_set_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_set_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_set_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_set_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_set_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_set_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_set_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}
@@ -10987,625 +8026,2544 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\end{macro}
-%\begin{macro}{\ohm}
-%\begin{macro}{\Ohm}
-%\begin{macro}{\pascal}
-%\begin{macro}{\siemens}
-%\begin{macro}{\sievert}
-%\begin{macro}{\tesla}
-%\begin{macro}{\volt}
-%\begin{macro}{\watt}
-%\begin{macro}{\weber}
-% Some testing is needed for \unitsdef compatibility.
-% \begin{macrocode}
-\ifsi@old@OHM
- \newunit{\Ohm}{\si@sym@Omega}
-\else
- \ifsi@gensymb\else
-% \end{macrocode}
-% To be on the safe side, use \cs{provideunit}.
+%
+%\begin{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}
- \provideunit{\ohm}{\si@sym@Omega}
- \fi
-\fi
-\newunit{\pascal}{Pa}
-\newunit{\siemens}{S}
-\newunit{\sievert}{Sv}
-\newunit{\tesla}{T}
-\newunit{\volt}{V}
-\newunit{\watt}{W}
-\newunit{\weber}{Wb}
+\cs_set_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_set_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_set_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_set_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_set_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_set_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_clear:N \_l_siunitx_angle_marker_box
+ \tex_hss:D
+ }
+ \box_use:N \_l_siunitx_angle_marker_box
+}
+\cs_set_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_clear: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_set_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_set_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}
-%\begin{macro}{\celsius}
-%\begin{macro}{\degreeCelsius}
-%\begin{macro}{\Celsius}
-% The degree celsius is a named unit.
+%
+%\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}
-\ifsi@old@OHM
- \newunit{\Celsius}{\si@sym@celsius}
-\else
- \ifsi@gensymb\else
- \newunit{\celsius}{\si@sym@celsius}
- \fi
-\fi
-\newunit\degreeCelsius{\si@sym@celsius}
+\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_set_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_set_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_set_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}{\radian}
-%\begin{macro}{\steradian}
-% The radian and steradian are officially derived units.
+%
+%\begin{macro}{\_siunitx_declare_qualifier:Nn}
+% Qualifiers just need storing.
% \begin{macrocode}
-\newunit{\radian}{rad}
-\newunit{\steradian}{sr}
+\cs_set_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_set_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 }
+ {
+ \cs_if_exist:cTF
+ { _siunitx_ \_siunitx_unit_first_token:n {#2} _function:w }
+ {#2}
+ { \_siunitx_unit_parse_unit:Nn #1 {#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_set_protected:Npn \_siunitx_unit_first_token:n #1 {
+ \exp_after:wN \token_to_str:N \tl_head_i:w #1 \q_nil
+}
+% \end{macrocode}
+%\end{macro}
%\end{macro}
-%\iffalse
-%</named>
-%<*prefixed>
-%\fi
-%\subsection{Units with prefixes}
-% As in \unitsdef, some commonly used prefixed units are set up.
-% This requires \file{si-prefix.cfg} and \file{si-named.cfg}.
+%
+%\begin{macro}{\per}
+% The \cs{per} function is pretty simple.
% \begin{macrocode}
-\ProvidesFile{si-prefixed.cfg}
- [2010/02/22 v1.4c siunitx: SI Prefixed units]
-\requiresiconfigs{prefix,named,accepted,physical}
+\cs_set:cpn { _siunitx_ \token_to_str:N \per _literal:w } { / }
+\cs_set_protected:cpn { _siunitx_ \token_to_str:N \per _function:w } {
+ \bool_set_true:N \_l_siunitx_per_bool
+ \_siunitx_unit_parse_per:
+}
% \end{macrocode}
-%\begin{macro}{\picometre}
-%\begin{macro}{\nanometre}
-%\begin{macro}{\micrometre}
-%\begin{macro}{\millimetre}
-%\begin{macro}{\centimetre}
-%\begin{macro}{\decimetre}
-%\begin{macro}{\kilometre}
-% Extra distances.
+%\end{macro}
+%
+%\begin{macro}{\raiseto}
+%\begin{macro}{\tothe}
+% Generic versions of the pre-set powers.
% \begin{macrocode}
-\newunit{\picometre}{\pico\metre}
-\newunit{\nanometre}{\nano\metre}
-\newunit{\micrometre}{\micro\metre}
-\newunit{\millimetre}{\milli\metre}
-\newunit{\centimetre}{\centi\metre}
-\newunit{\decimetre}{\deci\metre}
-\newunit{\kilometre}{\kilo\metre}
+\cs_set:cpn { _siunitx_ \token_to_str:N \raiseto _literal:w } #1#2 {
+ #2
+ \textsuperscript {#1}
+}
+\cs_set_protected:cpn { _siunitx_ \token_to_str:N \raiseto _function:w }
+ #1 {
+ \_siunitx_unit_parse_power_before:n {#1}
+}
+\cs_set:cpn { _siunitx_ \token_to_str:N \tothe _literal:w } #1 {
+ \textsuperscript {#1}
+}
+\cs_set_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_set_protected:cpn { _siunitx_ \token_to_str:N \of _literal:w } #1 {
+ \text { ~ } ( #1 )
+}
+\cs_set_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}
-%\begin{macro}{\femtogram}
-%\begin{macro}{\picogram}
-%\begin{macro}{\nanogram}
-%\begin{macro}{\microgram}
-%\begin{macro}{\milligram}
-% Extra masses.
+%\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}
-\newunit{\femtogram}{\femto\gram}
-\newunit{\picogram}{\pico\gram}
-\newunit{\nanogram}{\nano\gram}
-\newunit{\microgram}{\micro\gram}
-\newunit{\milligram}{\milli\gram}
+\cs_set_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_set_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_set_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_set_protected:Npn \_siunitx_unit_create:N #1 {
+ \cs_if_free:NT #1
+ {
+ \cs_set:Npx \_siunitx_tmp:w
+ {
+ \ProvideDocumentCommand \exp_not:N #1 { }
+ {
+ \bool_if:NT \_l_siunitx_create_prespace_bool
+ {
+ \exp_not:n
+ {
+ \_siunitx_ensuremath:n
+ { \_l_siunitx_number_unit_sep_tl }
+ }
+ }
+ \exp_not:n { \_siunitx_unit_in:nn {#1} { } }
+ \bool_if:NT \_l_siunitx_create_xspace_bool
+ { \exp_not:N \xspace }
+ }
+ }
+ \_siunitx_tmp:w
+ }
+}
+\cs_set_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 }
+ {
+ \exp_not:N \IfNoValueTF {####1}
+ { \exp_not:n { \_siunitx_unit_in:nn {#1} { } } }
+ {
+ \bool_if:NT \_l_siunitx_create_prespace_bool
+ {
+ \exp_not:n
+ {
+ \_siunitx_ensuremath:n
+ { \_l_siunitx_number_unit_sep_tl }
+ }
+ }
+ \SI {####1} { \exp_not:N #1 }
+ }
+ \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.
+% \begin{macrocode}
+\AtBeginDocument {
+ \tl_map_function:nN { \bar \color \ng \pm }
+ \_siunitx_protect_symbols:N
+}
+\cs_set_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}
-%\begin{macro}{\femtomole}
-%\begin{macro}{\picomole}
-%\begin{macro}{\nanomole}
-%\begin{macro}{\micromole}
-%\begin{macro}{\millimole}
-%\begin{macro}{\kilomole}
-%\changes{v1.1e}{2008/11/18}{New unit}
-% Now some moles.
+%
+%\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}
-\newunit{\femtomole}{\femto\mole}
-\newunit{\picomole}{\pico\mole}
-\newunit{\nanomole}{\nano\mole}
-\newunit{\micromole}{\micro\mole}
-\newunit{\millimole}{\milli\mole}
-\newunit{\kilomole}{\kilo\mole}
+\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}
+% The master function does a very simple checks then hands off.
+% \begin{macrocode}
+\cs_set_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 } {#1} }
+ { \_siunitx_unit_format_literal:n {#1} }
+ }
+ {
+ \bool_if:NT \_l_siunitx_per_auto_bool
+ {
+ \tl_set:Nn \_l_siunitx_per_mode_tl { symbol }
+ \mode_if_inner:F
+ {
+ \mode_if_math:T
+ {
+ \tl_set:Nn \_l_siunitx_per_mode_tl
+ { fraction }
+ }
+ }
+ }
+ \_siunitx_unit_parse:nn {#1} {#2}
+ \_siunitx_unit_format:
+ }
+ }
+ }
+ { \_siunitx_unit_format_literal:n {#1} }
+}
+\cs_generate_variant:Nn \_siunitx_unit_in:nn { Vn }
% \end{macrocode}
%\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_set_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_set_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}{\attosecond}
-%\begin{macro}{\femtosecond}
-%\begin{macro}{\picosecond}
-%\begin{macro}{\nanosecond}
-%\begin{macro}{\microsecond}
-%\begin{macro}{\millisecond}
-% Prefixed seconds.
+%
+%\begin{macro}{\_l_siunitx_per_bool}
+% To allow \cs{per} to be \enquote{sticky}.
% \begin{macrocode}
-\newunit{\attosecond}{\atto\second}
-\newunit{\femtosecond}{\femto\second}
-\newunit{\picosecond}{\pico\second}
-\newunit{\nanosecond}{\nano\second}
-\newunit{\microsecond}{\micro\second}
-\newunit{\millisecond}{\milli\second}
+\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_set_protected:Npn \_siunitx_unit_parse:nn #1#2 {
+ \_siunitx_unit_parse_init:
+ \_siunitx_unit_parse_options:nn {#1} {#2}
+ #1
+ \cs_set_eq:NN \pm \_siunitx_pm:
+}
+% \end{macrocode}
%\end{macro}
+%
+%\begin{macro}{\_siunitx_unit_parse_init:}
+%\begin{macro}[aux]{\_siunitx_unit_parse_init_aux:N}
+%\begin{macro}{\_siunitx_pm:}
+% 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_set_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
+ \cs_set_eq:NN \_siunitx_pm: \pm
+ \tl_map_function:NN \_l_siunitx_declare_list_tl
+ \_siunitx_unit_parse_init_aux:N
+}
+\cs_set_protected:Npn \_siunitx_unit_parse_init_aux:N #1 {
+ \cs_set_eq:Nc #1 { _siunitx_ \token_to_str:N #1 _function:w }
+}
+\cs_set_protected_nopar:Npn \_siunitx_pm: { }
+% \end{macrocode}
%\end{macro}
%\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_set_protected:Npn \_siunitx_unit_parse_options:nn #1#2 {
+ \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}{\picoampere}
-%\begin{macro}{\nanoampere}
-%\begin{macro}{\microampere}
-%\begin{macro}{\milliampere}
-%\begin{macro}{\kiloampere}
-% The last prefixed base units are amperes.
+%
+%\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}
-\newunit{\picoampere}{\pico\ampere}
-\newunit{\nanoampere}{\nano\ampere}
-\newunit{\microampere}{\micro\ampere}
-\newunit{\milliampere}{\milli\ampere}
-\newunit{\kiloampere}{\kilo\ampere}
+\cs_set_protected:Npn \_siunitx_unit_parse_power_before:n #1 {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ { power- \intexpr_eval:n { \_l_siunitx_unit_int + 1 } }
+ \prop_put:NVn \_l_siunitx_unit_prop \_l_siunitx_tmpa_tl {#1}
+}
+\cs_set_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_set_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_set_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_set_protected_nopar:Npn \_siunitx_unit_parse_per: {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ { per- \intexpr_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_set_protected_nopar:Npn \_siunitx_unit_parse_per_error: {
+ \msg_error:nn { siunitx } { duplicate-sticky-per }
+}
+% \end{macrocode}
%\end{macro}
-%\begin{macro}{\millivolt}
-%\begin{macro}{\kilovolt}
-%\begin{macro}{\milliwatt}
-%\begin{macro}{\kilowatt}
-%\begin{macro}{\megawatt}
-%\begin{macro}{\femtofarad}
-%\begin{macro}{\picofarad}
-%\begin{macro}{\nanofarad}
-%\begin{macro}{\microfarad}
-%\begin{macro}{\millifarad}
-%\begin{macro}{\millisiemens}
-% More electricity-related units.
+%
+%\begin{macro}{\_siunitx_unit_parse_qualifier:n}
+% Qualifiers never alter the number of units.
% \begin{macrocode}
-\newunit{\millivolt}{\milli\volt}
-\newunit{\kilovolt}{\kilo\volt}
-\newunit{\milliwatt}{\milli\watt}
-\newunit{\kilowatt}{\kilo\watt}
-\newunit{\megawatt}{\mega\watt}
-\newunit{\femtofarad}{\femto\farad}
-\newunit{\picofarad}{\pico\farad}
-\newunit{\nanofarad}{\nano\farad}
-\newunit{\microfarad}{\micro\farad}
-\newunit{\millifarad}{\milli\farad}
-\newunit{\millisiemens}{\milli\siemens}
+\cs_set_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_set_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_set_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}{\kilohm}
-%\changes{v1.1f}{2008/11/25}{Renamed from \cs{kiloohm}}
-%\begin{macro}{\megohm}
-%\changes{v1.1f}{2008/11/25}{Renamed from \cs{megaohm}}
-%\begin{macro}{\gigaohm}
-% For resistance, checks are needed again for the definition of
-% \cs{ohm}.
+%
+%\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}
-\ifsi@old@OHM
- \newunit{\kilohm}{\kilo\Ohm}
- \newunit{\megohm}{\mega\Ohm}
- \newunit{\gigaohm}{\giga\Ohm}
-\else
- \ifsi@gensymb\else
- \newunit{\kilohm}{\kilo\ohm}
- \newunit{\megohm}{\mega\ohm}
- \newunit{\gigaohm}{\giga\ohm}
- \fi
-\fi
+\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}{\microlitre}
-%\begin{macro}{\millilitre}
-%\begin{macro}{\microliter}
-%\begin{macro}{\milliliter}
-%\begin{macro}{\cubicmetre}
-%\begin{macro}{\cubiccentimetre}
-%\begin{macro}{\centimetrecubed}
-%\begin{macro}{\cubicmicrometre}
-%\begin{macro}{\cubicmillimetre}
-%\begin{macro}{\cubicdecimetre}
-% Volumes (unlike \unitsdef, with litre and metre spelled
-% correctly). \cs{millilitre} and \cs{microlitre} are defined
-% as they are the two officially-sanctioned prefixes for the litre.
+%
+%\begin{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}
-\newunit{\microlitre}{\micro\litre}
-\newunit{\millilitre}{\milli\litre}
-\newunit{\microliter}{\micro\liter}
-\newunit{\milliliter}{\milli\liter}
-\newunit{\cubicmetre}{\metre\cubed}
-\newunit{\cubiccentimetre}{\centi\metre\cubed}
-\newunit{\centimetrecubed}{\centi\metre\cubed}
-\newunit{\cubicmicrometre}{\micro\metre\cubed}
-\newunit{\cubicmillimetre}{\milli\metre\cubed}
-\newunit{\cubicdecimetre}{\cubic\deci\metre}
+\int_new:N \_l_siunitx_unit_prefix_gram_int
% \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_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_two_parts_bool
+\tl_new:N \_l_siunitx_qualifier_mode_tl
+% \end{macrocode}
%\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
+ },
+ per-symbol .tl_set:N = \_l_siunitx_per_symbol_tl,
+ 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 } },
+}
+\keys_set:nn { siunitx } {
+ bracket-unit-denominator = true,
+ inter-unit-separator = \,,
+ per-mode = reciprocal,
+ per-symbol = /,
+ 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_set_protected_nopar:Npn \_siunitx_unit_format: {
+ \_siunitx_unit_format_init:
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_unit_int } = { 1 }
+ {
+ \tl_if_eq:VnT \_l_siunitx_per_mode_tl { symbol }
+ {
+ \prop_if_in:NnT \_l_siunitx_unit_prop { per-1 }
+ { \tl_clear:N \_l_siunitx_number_unit_separator_tl }
+ }
+ }
+ \intexpr_while_do:nNnn
+ { \int_use:N \_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_set_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_set_protected_nopar:Npn \_siunitx_unit_format_add_aux:n #1 {
+ \tl_if_empty:cF { _l_siunitx_unit #1 _tl }
+ {
+ \tl_if_eq:nVTF { repeat } \_l_siunitx_per_mode_tl
+ {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ { per- \intexpr_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}
-%\begin{macro}{\squaremetre}
-%\begin{macro}{\squarecentimetre}
-%\begin{macro}{\centimetresquared}
-%\begin{macro}{\squarekilometre}
-% Areas, with metre spelled corrected; \cs{are} and \cs{hectare} are
-% in the ``temporarily accepted'' file.
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_unit_format_fraction:}
+%\begin{macro}[aux]{\_siunitx_unit_format_fraction:}
+%\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}
-\newunit{\squaremetre}{\Square\metre}
-\newunit{\squarecentimetre}{\Square\centi\metre}
-\newunit{\centimetresquared}{\centi\metre\squared}
-\newunit{\squarekilometre}{\Square\kilo\metre}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_fraction: {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_unit_denominator_int } > { 0 }
+ {
+ \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_set_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 } }
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_fraction_symbol: {
+ \_siunitx_unit_format_fraction_symbol_aux:
+ \intexpr_compare:nNnT
+ { \int_use:N \_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_set_protected_nopar:Npn \_siunitx_unit_format_fraction_symbol_aux: {
+}
+\cs_set_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}
-%\begin{macro}{\millijoule}
-%\begin{macro}{\kilojoule}
-%\begin{macro}{\megajoule}
-%\begin{macro}{\millielectronvolt}
-%\begin{macro}{\kiloelectronvolt}
-%\begin{macro}{\megaelectronvolt}
-%\begin{macro}{\gigaelectronvolt}
-%\begin{macro}{\teraelectronvolt}
-%\begin{macro}{\kilowatthour}
-% Some energy is needed by now! Notice the definition of
-% \cs{kilowatthour}
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_unit_format_init:}
+% The normal initialisation stuff.
% \begin{macrocode}
-\newunit{\millijoule}{\milli\joule}
-\newunit{\kilojoule}{\kilo\joule}
-\newunit{\megajoule}{\mega\joule}
-\newunit{\millielectronvolt}{\milli\electronvolt}
-\newunit{\kiloelectronvolt}{\kilo\electronvolt}
-\newunit{\megaelectronvolt}{\mega\electronvolt}
-\newunit{\gigaelectronvolt}{\giga\electronvolt}
-\newunit{\teraelectronvolt}{\tera\electronvolt}
-\newunit[unitsep=none]{\kilowatthour}{\kilo\watt\hour}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_init: {
+ \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
+}
% \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_set_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_set_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_set_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_set_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 {
+ \AtBeginDocument
+ {
+ \@ifpackageloaded { inputenc }
+ {
+ \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_set_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}
+% 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_set_protected_nopar:Npn \_siunitx_unit_format_power_aux: {
+ \tl_if_eq:nVTF { repeat } \_l_siunitx_per_mode_tl
+ { \_siunitx_unit_format_power_repeat: }
+ { \_siunitx_unit_format_power_per: }
+ \tl_if_eq:nVF { 1 } \_l_siunitx_tmpa_tl
+ {
+ \_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_set_protected:Npn \_siunitx_unit_format_power_aux:n #1 {
+ \bool_if:NTF \_l_siunitx_number_math_mode_bool
+ { \_siunitx_print:nn { number } {#1} }
+ {
+ \tl_set:Nn \_l_siunitx_tmpa_tl {#1}
+ \tl_replace_all_in:Nnn \_l_siunitx_tmpa_tl { - }
+ { \text { \_c_siunitx_minus_tl } }
+ \_siunitx_print:nV { number } \_l_siunitx_tmpa_tl
+ }
+}
+% \end{macrocode}
%\end{macro}
%\end{macro}
-%\end{macro}
-%\begin{macro}{\millihertz}
-%\begin{macro}{\kilohertz}
-%\begin{macro}{\megahertz}
-%\begin{macro}{\gigahertz}
-%\begin{macro}{\terahertz}
-% Frequencies.
+%\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}
-\newunit{\millihertz}{\milli\hertz}
-\newunit{\kilohertz}{\kilo\hertz}
-\newunit{\megahertz}{\mega\hertz}
-\newunit{\gigahertz}{\giga\hertz}
-\newunit{\terahertz}{\tera\hertz}
+\cs_set_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_set_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_afer:wN \_siunitx_tmp:w \_l_siunitx_tmpa_tl \q_stop
+ }
+ { \tl_put_left:Nn \_l_siunitx_tmpa_tl { - } }
+ }
+ }
+}
+\cs_set_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_set_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_set_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
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_unit_prefix_base_int } = { 0 }
+ {
+ \int_set:Nn \_l_siunitx_unit_prefix_base_int
+ { \_l_siunitx_tmpa_tl }
+ }
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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_set_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
+ \tl_if_eq:nVT { \gram } \_l_siunitx_tmpb_tl
+ {
+ \tl_set:Nx \_l_siunitx_unit_prefix_current_tl
+ { \intexpr_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
+ {
+ \intexpr_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
+ {
+ \int_use:N \_l_siunitx_unit_prefix_int
+ - \_l_siunitx_unit_prefix_current_tl
+ }
+ }
+ {
+ \int_set:Nn \_l_siunitx_unit_prefix_int
+ {
+ \int_use:N \_l_siunitx_unit_prefix_int
+ + \_l_siunitx_unit_prefix_current_tl
+ }
+ }
+}
+\cs_set_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}{\millinewton}
-%\begin{macro}{\kilonewton}
-%\begin{macro}{\hectopascal}
-%\begin{macro}{\megabecquerel}
-%\begin{macro}{\millisievert}
-% A few more from various areas.
+%
+%\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:}
+% Three 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}
-\newunit{\millinewton}{\milli\newton}
-\newunit{\kilonewton}{\kilo\newton}
-\newunit{\hectopascal}{\hecto\pascal}
-\newunit{\megabecquerel}{\mega\becquerel}
-\newunit{\millisievert}{\milli\sievert}
+\cs_set_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_set_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_set_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:No \_l_siunitx_unit_current_tl
+ { \exp_after:wN @ \exp_after:wN { \_l_siunitx_tmpa_tl } }
+ }
+}
% \end{macrocode}
%\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_set_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}
-%\iffalse
-%</prefixed>
-%<*abbr>
-%\fi
-%\subsection{Abbreviated units}
-%\begin{macro}{\pA}
-%\begin{macro}{\nA}
-%\begin{macro}{\micA}
-%\begin{macro}{\mA}
-%\begin{macro}{\kA}
-% The abbreviated units are sorted in one file. To allow
-% back-compatibility with \unitsdef, each one is inside an \cs{if}
-% block for the appropriate option. First currents.
+%
+%\begin{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}
-\ProvidesFile{si-abbr.cfg}
- [2010/02/22 v1.4c siunitx: Abbreviated units]
-\requiresiconfigs{prefix,named,accepted,physical}
-\newunit{\pA}{\pico\ampere}
-\newunit{\nA}{\nano\ampere}
-\newunit{\micA}{\micro\ampere}
-\newunit{\mA}{\milli\ampere}
-\newunit{\kA}{\kilo\ampere}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_unit_format_symbol_aux: {
+ \msg_error:nn { siunitx } { prefix-only }
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_symbol_aux_alt: {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_unit_int } = { 1 }
+ {
+ \prop_del:Nn \_l_siunitx_unit_prop { prefix-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}{\Hz}
-%\begin{macro}{\mHz}
-%\begin{macro}{\kHz}
-%\begin{macro}{\MHz}
-%\begin{macro}{\GHz}
-%\begin{macro}{\THz}
-% Then frequencies.
+%
+%\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}
-\newunit{\Hz}{\hertz}
-\newunit{\mHz}{\milli\hertz}
-\newunit{\kHz}{\kilo\hertz}
-\newunit{\MHz}{\mega\hertz}
-\newunit{\GHz}{\giga\hertz}
-\newunit{\THz}{\tera\hertz}
+\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_set_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:
+ \_siunitx_unit_format_fraction_symbol_aux_alt:
+ \_siunitx_unit_in:nn {#1} {#2}
+ \intexpr_compare:nNnF
+ { \int_use:N\_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 { Vn }
+% \end{macrocode}
+%\end{macro}
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_unit_output_number_sep:}
+% For printing the number separator.
+% \begin{macrocode}
+\cs_set_protected_nopar:Npn \_siunitx_unit_output_number_sep: {
+ \bool_if:NTF \_l_siunitx_number_unit_breaks_bool
+ { \allowbreak } { \nobreak }
+ \_siunitx_ensuremath:n { \_l_siunitx_number_unit_separator_tl }
+}
+% \end{macrocode}
%\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_set_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_set_protected_nopar:Npn \_siunitx_unit_output_print: {
+ \intexpr_compare:nNnF
+ { \int_use:N \_l_siunitx_unit_prefix_int } = { 0 }
+ {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ {
+ \bool_if:NTF \_l_siunitx_tight_bool
+ { { \exp_not:V \_l_siunitx_exponent_product_tl } }
+ { { } \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}{\fmol}
-%\begin{macro}{\pmol}
-%\begin{macro}{\nmol}
-%\begin{macro}{\micmol}
-%\begin{macro}{\mmol}
-%\begin{macro}{\kmol}
-%\changes{v1.1e}{2008/11/18}{New unit}
-% Amounts of substance.
+%
+%\begin{macro}{\_l_siunitx_number_product_int}
+% Used to count up the number of product tokens in a number.
% \begin{macrocode}
-\newunit{\fmol}{\femto\mole}
-\newunit{\pmol}{\pico\mole}
-\newunit{\nmol}{\nano\mole}
-\newunit{\micmol}{\micro\mole}
-\newunit{\mmol}{\milli\mole}
-\newunit{\kmol}{\kilo\mole}
+\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_set_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_set_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_set_protected:Npn \_siunitx_combined_unit:nnn #1#2#3 {
+ \bool_if:NTF \_l_siunitx_product_power_bool
+ {
+ \_siunitx_combined_product_count:n {#1}
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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_set_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_set_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}
-%\begin{macro}{\kV}
-%\begin{macro}{\mV}
-% Potentials.
+%
+%\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}
-\newunit{\kV}{\kilo\volt}
-\newunit{\mV}{\milli\volt}
+\bool_new:N \_l_siunitx_list_brackets_bool
+\bool_new:N \_l_siunitx_list_repeat_bool
% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ml}
-%\begin{macro}{\micl}
-%\begin{macro}{\mL}
-%\begin{macro}{\micL}
-%\begin{macro}{\cmc}
-%\begin{macro}{\dmc}
-%\begin{macro}{\cms}
-% Volumes and areas
+%
+%\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}
-\provideunit{\ml}{\milli\litre}
-\provideunit{\micl}{\micro\litre}
-\provideunit{\mL}{\milli\liter}
-\provideunit{\micL}{\micro\liter}
-\newunit{\cmc}{\centi\metre\cubed}
-\newunit{\dmc}{\deci\metre\cubed}
-\newunit{\cms}{\centi\metre\squared}
+\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_set_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_set_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_set_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}{\fg}
-%\begin{macro}{\SIfg}
-%\begin{macro}{\kg}
-%\begin{macro}{\fg}
-%\begin{macro}{\pg}
-%\begin{macro}{\nanog}
-%\begin{macro}{\micg}
-%\begin{macro}{\mg}
-%\begin{macro}{\amu}
-% Masses.
+%
+%\begin{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}
-\newunit{\kg}{\kilo\gram}
+\cs_set_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}
-% There is a name clash with \pkg{babel} here in French; hopefully
-% there will not be too many complaints.
+%\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}
-\AtBeginDocument{\provideunit{\fg}{\femto\gram}}
-\newunit{\SIfg}{\femto\gram}
-\newunit{\pg}{\pico\gram}
-\newunit{\nanog}{\nano\gram}
-\newunit{\micg}{\micro\gram}
-\newunit{\mg}{\milli\gram}
-\newunit{\amu}{\atomicmass}
+\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_set_protected:Npn \_siunitx_range_numbers:nn #1#2 {
+ \_siunitx_range_numbers_aux:n {#1}
+ \text { \_l_siunitx_range_phrase_tl }
+ \_siunitx_range_numbers_aux:n {#2}
+}
+\cs_set_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_set_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_set_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}
-%\begin{macro}{\kJ}
-%\begin{macro}{\eV}
-%\begin{macro}{\meV}
-%\begin{macro}{\keV}
-%\begin{macro}{\MeV}
-%\begin{macro}{\GeV}
-%\begin{macro}{\TeV}
-%\begin{macro}{\kWh}
-% Energies.
+%\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}
-\newunit{\kJ}{\kilo\joule}
-\newunit{\eV}{\electronvolt}
-\newunit{\meV}{\milli\electronvolt}
-\newunit{\keV}{\kilo\electronvolt}
-\newunit{\MeV}{\mega\electronvolt}
-\newunit{\GeV}{\giga\electronvolt}
-\newunit{\TeV}{\tera\electronvolt}
-\newunit[unitsep=none]{\kWh}{\kilo\watt\hour}
+\tl_new:N \_l_siunitx_number_valid_tl
% \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_set_protected:Npn \_siunitx_table_collect_begin:Nn #1#2 {
+ \keys_set:nn { siunitx } {#2}
+ \use:c { _siunitx_table_collect_begin_ #1 : }
+}
+\cs_set_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_set_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_set_protected:Npn \_siunitx_table_collect_braced:n #1 { }
+% \end{macrocode}
%\end{macro}
+%
+%\begin{macro}{\_siunitx_table_collect_expand: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_set_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} }
+ {
+ \bool_set_true:N \_l_siunitx_table_collect_post_bool
+ \tl_put_right:Nn \_l_siunitx_table_collect_post_tl {#1}
+ }
+ }
+ }
+}
+% \end{macrocode}
%\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_set_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:
+ {
+ \if_catcode:w \exp_not:N \l_peek_token \c_group_begin_token
+ \exp_after:wN \_siunitx_table_collect_braced:n
+ \else:
+ \exp_after:wN \_siunitx_table_collect_not_braced:N
+ \fi:
+ }
+ \peek_after:NN \peek_ignore_spaces_execute_branches:
+}
+% \end{macrocode}
%\end{macro}
-%\begin{macro}{\picom}
-%\begin{macro}{\nm}
-%\begin{macro}{\micm}
-%\begin{macro}{\mm}
-%\begin{macro}{\cm}
-%\begin{macro}{\dm}
-%\begin{macro}{\km}
-% Lengths.
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_table_collect_init:}
+% The usual spin-out of basics.
% \begin{macrocode}
-\newunit{\picom}{\pico\metre}
-\newunit{\nm}{\nano\metre}
-\newunit{\micm}{\micro\metre}
-\newunit{\mm}{\milli\metre}
-\newunit{\cm}{\centi\metre}
-\newunit{\dm}{\deci\metre}
-\newunit{\km}{\kilo\metre}
+\cs_set_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
+}
+% \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_set_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_set_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_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_set_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_set_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_set_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_set_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_set_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_set_protected:Npn \_siunitx_table_collect_token:N #1 { }
+\cs_set_protected:Npn \_siunitx_table_collect_token_s:N #1 {
+ \tl_put_right:Nn \_l_siunitx_table_collect_tl {#1}
+}
+% \end{macrocode}
%\end{macro}
-%\begin{macro}{\Sec}
-%\begin{macro}{\as}
-%\begin{macro}{\fs}
-%\begin{macro}{\ps}
-%\begin{macro}{\ns}
-%\begin{macro}{\mics}
-%\begin{macro}{\ms}
-% Finally, times.
+%\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}
-\newunit{\Sec}{\second}
-\newunit{\as}{\atto\second}
-\newunit{\fs}{\femto\second}
+\cs_set_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}
-% The letter class (and others) define \cs{ps} for postscripts, so
-% \cs{provideunit} is best here.
+%\end{macro}
+%
+%\subsection{Table printing: general code}
+%
+%\begin{macro}{\_c_siunitx_one_fill_skip}
+% A fixed skip of one \texttt{fill}.
% \begin{macrocode}
-\provideunit{\ps}{\pico\second}
-\newunit{\ns}{\nano\second}
-\newunit{\mics}{\micro\second}
-\newunit{\ms}{\milli\second}
+\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_set_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_set_protected_nopar:Npn \_siunitx_table_align_left:n #1 {
+ \_siunitx_table_colortbl_correction:
+ \skip_horizontal:n {#1}
+ \tex_kern:D \c_zero_skip
+}
+\cs_set_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_set_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}
-%\iffalse
-%</abbr>
-%<*addn>
-%\fi
-%\subsection{Additional (temporary) SI units}
-%\begin{macro}{\angstrom}
-%\begin{macro}{\are}
-%\begin{macro}{\hectare}
-%\begin{macro}{\barn}
-%\begin{macro}{\BAR}
-%\begin{macro}{\bbar}
-%\begin{macro}{\millibar}
-%\begin{macro}{\gal}
-%\begin{macro}{\curie}
-%\begin{macro}{\roentgen}
-%\begin{macro}{\rad}
-%\begin{macro}{\rem}
-%\changes{v1.1c}{2008/10/22}{Uses \cs{provideunit}}
-% Some units are ``temporarily'' acceptable for use in the SI system.
-% These are defined here, although some are in very general use.
+%
+%\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}
-\ProvidesFile{si-addn.cfg}
- [2010/02/22 v1.4c siunitx: SI Additional units]
-\provideunit{\angstrom}{\si@sym@ringA}
-\AtBeginDocument{%
- \ifdefined\Saveangstrom
- \def\Saveangstrom{\si@sym@ringA}%
- \def\SaveAngstrom{\si@sym@ringA}%
- \fi
-}
-\newunit{\are}{a}
-\newunit{\hectare}{\hecto\are}
-\newunit{\barn}{b}
-\newunit{\BAR}{bar}
-\newunit{\bbar}{bar}
-\newunit{\millibar}{\milli\BAR}
-\newunit{\gal}{Gal}
-\newunit{\curie}{Ci}
-\newunit{\roentgen}{R}
-\newunit{\rad}{rad}
-\provideunit{\rem}{rem}
+\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_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_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}
@@ -11613,55 +10571,122 @@ author.
%\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}
-%\iffalse
-%</addn>
-%<*accepted>
-%\fi
-%\subsection{Units accepted for use with SI}
-% The units which are accepted but do not fit in the above, plus
-% \cs{percent} which seems to fit into this category.
-%\begin{macro}{\minute}
-%\begin{macro}{\hour}
-%\begin{macro}{\Day}
-%\begin{macro}{\dday}
-%\begin{macro}{\degree}
-%\changes{v1.1c}{2008/10/22}{Uses \cs{provideunit}}
-%\begin{macro}{\Degree}
-%\begin{macro}{\arcmin}
-%\begin{macro}{\arcsec}
-%\begin{macro}{\litre}
-%\begin{macro}{\liter}
-%\begin{macro}{\tonne}
-%\begin{macro}{\neper}
-%\begin{macro}{\bel}
+%
+%\begin{macro}{\_l_siunitx_table_model_prop}
+% To store the model version of a number, used when reserving space.
% \begin{macrocode}
-\ProvidesFile{si-accepted.cfg}
- [2010/02/22 v1.4c siunitx: SI Accepted units]
-\newunit{\minute}{min}
-\newunit{\hour}{h}
-\newunit{\Day}{d}
-\newunit{\dday}{d}
-\ifsi@old@OHM
- \AtBeginDocument{
- \provideunit[valuesep=none]{\Degree}{\si@sym@degree}
- }
-\else
- \ifsi@gensymb\else
- \AtBeginDocument{
- \provideunit[valuesep=none]{\degree}{\si@sym@degree}
- }
- \fi
-\fi
-\newunit[valuesep=none]{\arcmin}{\si@sym@minute}
-\newunit[valuesep=none]{\arcsec}{\si@sym@second}
-\newunit{\litre}{l}
-\newunit{\liter}{L}
-\newunit{\tonne}{t}
-\newunit{\neper}{Np}
-\newunit{\bel}{B}
+\prop_new:N \_l_siunitx_table_model_prop
% \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_post_bool}
+%\begin{macro}{\_l_siunitx_table_auto_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-text-post .bool_set:N
+ = \_l_siunitx_table_align_post_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-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-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-text-post = 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}
@@ -11669,154 +10694,916 @@ author.
%\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_set_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 { 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_mantissa_bool }
+ { \bool_set_false:N \_l_siunitx_table_sign_mantissa_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_set_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_set_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_set_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
+ {
+ \_siunitx_number_process:
+ \_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_set_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 }
+ \_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: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}{\percent}
-%\changes{v1.2c}{2009/01/28}{Definition changed}
-%\changes{v1.2d}{2009/02/01}{Definition changed again}
+%\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_set_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 } }
+ \hbox_set:Nn \_l_siunitx_table_post_box
+ { \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_clear: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_clear: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}
-\newunit{\percent}{\char37}
+\cs_set_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_set_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}
-%\iffalse
-%</accepted>
-%<*physical>
-%\fi
-%\subsection{Units based on physical measurements}
-%\begin{macro}{\si@eVspacea}
-%\begin{macro}{\si@eVspaceb}
-%\begin{macro}{\electronvolt}
-%\begin{macro}{\atomicmassunit}
-%\begin{macro}{\atomicmass}
-% A few units based on physical measurements exist. For \cs{eV}, the need
-% for a negative kern does make things a bit complicated.
+%\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}
-\ProvidesFile{si-physical.cfg}
- [2010/02/22 v1.4c siunitx: SI Physically-measured units]
-\newcommand*{\si@eVspacea}{\text{\kern-\si@eVcorra}}%
-\newcommand*{\si@eVspaceb}{\text{\kern-\si@eVcorrb}}%
-\newunit{\electronvolt}{e\protect\si@eVspacea V\protect%
- \si@eVspaceb}
-\newunit{\atomicmass}{u}
-\newunit{\atomicmassunit}{u}
+\cs_set_protected_nopar:Npn \_siunitx_table_print_S_reserved: {
+ \dim_zero:N \_l_siunitx_table_gap_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 }
+ \_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:
+ \intexpr_compare:nNnTF
+ {
+ \int_use:N \_l_siunitx_table_integer_int
+ + \int_use:N \_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 }
+ }
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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: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_set_protected_nopar:Npn \_siunitx_table_print_S_reserved_ends: {
+ \hbox_set:Nn \_l_siunitx_tmp_box { \_l_siunitx_table_pre_tl }
+ \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 }
+ {
+ \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_set_protected_nopar:Npn \_siunitx_table_print_S_model_create: {
+ \prop_clear:N \_l_siunitx_number_in_prop
+ \_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 }
+ \intexpr_compare:nNnF
+ {
+ \int_use:N \_l_siunitx_table_integer_int
+ + \int_use:N \_l_siunitx_table_decimal_int
+ }
+ = { 0 }
+ {
+ \prop_put:Nnn \_l_siunitx_number_in_prop { mantissa }
+ { true }
+ }
+ \intexpr_compare:nNnT
+ { \int_use:N \_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 } { - } }
+ \intexpr_compare:nNnT
+ { \int_use:N \_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:
+ \_siunitx_number_format:
+ \prop_set_eq:NN \_l_siunitx_table_model_prop
+ \_l_siunitx_number_out_prop
+}
+\cs_set_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_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.
+% \begin{macrocode}
+\cs_set_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 { }
+ \hbox_set_to_wd:Nnn \_l_siunitx_table_result_box
+ { \_l_siunitx_table_mantissa_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
+ \_siunitx_table_print_S_reserved_uncert:n { mantissa }
+}
+\cs_set_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}
-%\iffalse
-%</physical>
-%\fi
-%
-%\section{Additional configurations}
-% To provide flexibility for people in specific areas, specialised
-% units can be set up. These are then stored separately to ease use.
%
-%\iffalse
-%<*synchem>
-%\fi
-%\subsection{Synthetic chemistry}
-%\begin{macro}{\mmHg}
-%\begin{macro}{\molar}
-%\begin{macro}{\Molar}
-%\begin{macro}{\torr}
-%\begin{macro}{\dalton}
-% Some useful units for synthetic chemists; although \cs{mmHg} and
-% \cs{Molar} are outside of the SI system, they are used a lot.
-% These are set up using \cs{provideunit} as people may have their
-% own definitions.
-% \begin{macrocode}
-\ProvidesFile{si-synchem.cfg}
- [2010/02/22 v1.4c siunitx: Units for synthetic chemists]
-\requiresiconfigs{prefix}
-\newunit{\mmHg}{mmHg}
-\newunit{\molar}{\mole\per\cubic\deci\metre}
-\newunit{\Molar}{\textsc{m}}
-\newunit{\torr}{Torr}
-\newunit{\dalton}{Da}
+%\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_set_protected_nopar:Npn
+ \_siunitx_table_print_S_reserved_uncert:n #1 {
+ \bool_if:NT \_l_siunitx_uncert_sep_bool
+ {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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_set_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
+}
+\cs_set_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 }
+ }
+ \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_set_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
+}
+\cs_set_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: }
+ }
+ \box_use:N \_l_siunitx_table_result_box
+}
+\cs_set_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_set_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_set_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}
-%\iffalse
-%</synchem>
-%<*hep>
-%\fi
-%\subsection{High-energy physics}
-% Some units inspired by \pkg{hepunits}.
+%\begin{macro}{\_siunitx_table_print_S_get_decimal:Nn}
+% Grabbing the decimal part is a simple operation.
% \begin{macrocode}
-\ProvidesFile{si-hep.cfg}
- [2010/02/22 v1.4c siunitx: Units for high-energy physics]
-\requiresiconfigs{prefix,named}
+\cs_set_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}
-%\begin{macro}{\micron}
-%\begin{macro}{\mrad}
-%\begin{macro}{\gauss}
-% These specific to high-energy physics, but are not defined
-% elsewhere in \currpkg.\footnote{It is not clear from
-% \pkg{hepunits}, but the assumption is that \cs{mrad} represents
-% millirad and not milliradian.}
+%\end{macro}
+%\begin{macro}{\_siunitx_table_print_S_get_exponent:Nn}
+% Getting the exponent part is quite easy.
% \begin{macrocode}
-\provideunit{\micron}{\micro\metre}
-\newunit{\mrad}{\milli\rad}
-\newunit{\gauss}{G}
+\cs_set_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_set_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_set_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}{\clight}
-%\begin{macro}{\eVperc}
-% The speed of light is used in units for the area, although of
-% course it is not strictly a unit. However, this makes it easier to
-% use in other units.
+%\begin{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}
-\newunit{\clight}{\ensuremath{\mathnormal{c}}}
-\newunit{\eVperc}{\eV\per\clight}
+\cs_set_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_set_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}{\nanobarn}
-%\begin{macro}{\picobarn}
-%\begin{macro}{\femtobarn}
-%\begin{macro}{\attobarn}
-%\begin{macro}{\zeptobarn}
-%\begin{macro}{\yoctobarn}
-% Various prefixed barns.
+%\begin{macro}{\_siunitx_table_print_S_get_uncert:Nn}
% \begin{macrocode}
-\newunit{\nanobarn}{\nano\barn}
-\newunit{\picobarn}{\pico\barn}
-\newunit{\femtobarn}{\femto\barn}
-\newunit{\attobarn}{\atto\barn}
-\newunit{\zeptobarn}{\zepto\barn}
-\newunit{\yoctobarn}{\yocto\barn}
+\cs_set_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_set_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_set_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_set_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_set_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_set_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_set_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_set_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}
-%\begin{macro}{\nb}
-%\begin{macro}{\pb}
-%\begin{macro}{\fb}
-%\begin{macro}{\ab}
-%\begin{macro}{\zb}
-%\begin{macro}{\yb}
-% Abbreviations for the same, but using \cs{provideunit} to avoid any
-% clashes.
+%\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}
-\provideunit{\nb}{\nano\barn}
-\provideunit{\pb}{\pico\barn}
-\provideunit{\fb}{\femto\barn}
-\provideunit{\ab}{\atto\barn}
-\provideunit{\zb}{\zepto\barn}
-\provideunit{\yb}{\yocto\barn}
+\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 } }
+ }
+ \tl_if_eq:nVT { OT1 } \encodingdefault
+ {
+ \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}
@@ -11824,82 +11611,75 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\iffalse
-%</hep>
-%<*astro>
-%\fi
-%\subsection{Astronomy}
-%\begin{macro}{\parsec}
-%\begin{macro}{\lightyear}
-% For astronomy, the \cs{parsec} unit is needed.
+%\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}
-\ProvidesFile{si-astro.cfg}
- [2010/02/22 v1.4c siunitx: Units for astronomy]
-\newunit{\parsec}{pc}
-\newunit{\lightyear}{ly}
+\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}
-%\iffalse
-%</astro>
-%<*geophys>
-%\fi
-%\subsection{Geophysics}
-%\begin{macro}{\lightyear}
-% The unit \cs{gon} is useful here.
-% \begin{macrocode}
-\ProvidesFile{si-geophys.cfg}
- [2010/02/22 v1.4c siunitx: Units for astronomy]
-\newunit{\gon}{gon}
-% \end{macrocode}
%\end{macro}
-%\iffalse
-%</geophys>
-%<*chemeng>
-%\fi
-%\subsection{Chemical engineering}
-%\begin{macro}{\gmol}
-%\begin{macro}{\kgmol}
-%\begin{macro}{\lbmol}
-% For astronomy, the \cs{parsec} unit is needed.
-% \begin{macrocode}
-\ProvidesFile{si-chemeng.cfg}
- [2010/02/22 v1.4c siunitx: Units for chemical engineering]
-\newunit{\gmol}{g\text{-}mol}
-\newunit{\kgmol}{kg\text{-}mol}
-\newunit{\lbmol}{lb\text{-}mol}
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\iffalse
-%</chemeng>
-%<*binary>
-%\fi
-%\subsection{Binary units}
-%\begin{macro}{\kibi}
-%\begin{macro}{\mebi}
-%\begin{macro}{\gibi}
-%\begin{macro}{\tebi}
-%\begin{macro}{\pebi}
-%\begin{macro}{\exbi}
-%\begin{macro}{\zebi}
-%\begin{macro}{\yobi}
-% The binary units, as specified by the IEC and made available by
-% \SIunits. First, the binary prefixes.
+%\end{macro}
+%
+%\begin{macro}{\_siunitx_symbol_new:n}
+% For creating the outer symbol macro.
% \begin{macrocode}
-\ProvidesFile{si-binary.cfg}
- [2010/02/22 v1.4c siunitx: Binary units]
-\newprefix[binary]{\kibi}{10}{Ki}
-\newprefix[binary]{\mebi}{20}{Mi}
-\newprefix[binary]{\gibi}{30}{Gi}
-\newprefix[binary]{\tebi}{40}{Ti}
-\newprefix[binary]{\pebi}{50}{Pi}
-\newprefix[binary]{\exbi}{60}{Ei}
-\newprefix[binary]{\zebi}{70}{Zi}
-\newprefix[binary]{\yobi}{80}{Yi}
+\cs_set_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}
@@ -11907,442 +11687,548 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\bit}
-%\begin{macro}{\byte}
-% Now the units.
+%
+%\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}
-\newunit{\bit}{bit}
-\newunit{\byte}{B}
+\clist_new:N \_l_siunitx_pgf_link_clist
+\cs_set_protected_nopar:Npn \_siunitx_pgf_link: {
+ \clist_clear:N \_l_siunitx_pgf_link_clist
+ \tl_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 }
+ }
+ \tl_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}
%
-%\iffalse
-%</binary>
-%\fi
-%
-%\section{Loadable locales}
-% Some short files to provide the correct settings for various places.
-%
-%\iffalse
-%<*UK>
-%\fi
-%\subsection{United Kingdom}
-% This is identical to the USA locale, and contains the package
-% default values.\footnote{The package author is in the UK.}
-% \begin{macrocode}
-\ProvidesFile{si-UK.cfg}
- [2010/02/22 v1.4c siunitx: UK locale]
-\sisetup{
- unitsep=thin,
- expproduct=times,
- valuesep=thin,
- decimalsymbol=fullstop,
- digitsep=thin,
- sepfour=false,
- tophrase={{ to }}}
-% \end{macrocode}
-%\iffalse
-%</UK>
-%<*USA>
-%\fi
-%\subsection{United States}
-% The same as for the UK.
-% \begin{macrocode}
-\ProvidesFile{si-USA.cfg}
- [2010/02/22 v1.4c siunitx: USA locale]
-\sisetup{
- unitsep=thin,
- expproduct=times,
- valuesep=thin,
- decimalsymbol=fullstop,
- digitsep=thin,
- sepfour=false,
- tophrase={{ to }}}
-% \end{macrocode}
-%\iffalse
-%</USA>
-%<*DE>
-%\fi
-%\subsection{Germany}
-% Germany, hopefully.
-% \begin{macrocode}
-\ProvidesFile{si-DE.cfg}
- [2010/02/22 v1.4c siunitx: Germany locale]
-\sisetup{
- unitsep=cdot,
- valuesep=thin,
- decimalsymbol=comma,
- expproduct=cdot,
- digitsep=thin,
- sepfour=false,
- tophrase={{ bis }}}
-% \end{macrocode}
-%\iffalse
-%</DE>
-%<*ZA>
-%\fi
-%\subsection{South Africa}
-% Design decisions taken from the same section of \SIstyle.
-% \begin{macrocode}
-\ProvidesFile{si-ZA.cfg}
- [2010/02/22 v1.4c siunitx: South Africa locale]
-\sisetup{
- unitsep=cdot,
- valuesep=thin,
- expproduct=times,
- decimalsymbol=comma,
- digitsep=thin,
- sepfour=false,
- tophrase={{ to }}}
-% \end{macrocode}
-%\iffalse
-%</ZA>
-%\fi
-%
-%\section{Emulation code}
-% Each emulation mode loads an appropriate definition file. This
-% then alters the package defaults, and defines new macros provided
-% by the emulated package.
-%
-%\iffalse
-%<*units>
-%\fi
-%\subsection{\units}
-% The very first thing to do here is a reload check, as things
-% could go wrong with \unitsdef emulation.
-% \begin{macrocode}
-\si@ifloaded{units}{\endinput}{}
-% \end{macrocode}
-% The \units package is quite easy to emulate, as it only has a
-% few options and macros. There is also no error checking in
-% \units for conflicting options, so users probably expect none.
-% \begin{macrocode}
-\ProvidesFile{si-units.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of units]
-\si@emulating{units}{1998/08/04 v0.9b}
-\si@ifloaded{SIunits}
- {\si@emclash{units}{SIunits}\endinput}{}
-\si@ifloaded{sistyle}
- {\si@emclash{units}{sistyle}\endinput}{}
-% \end{macrocode}
-% To emulate \units, \cs{per} must give fractions.
-% \begin{macrocode}
-\sisetup{per=fraction,fraction=nice,obeybold,inlinebold=maths,
- ,obeymode}
-\ifsi@old@tight
- \sisetup{valuesep=thin}
-\fi
-\ifsi@old@loose
- \sisetup{valuesep=space}
-\fi
-\ifsi@old@ugly
- \sisetup{fraction=ugly}
-\fi
+%\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.
+ }
% \end{macrocode}
-%\begin{macro}{\unit}
-%\doarg{number}
-%\darg{unit}
-% The \units version of \cs{unit} is similar to \cs{SI}. Here and
-% in \cs{unitfrac} the \cs{num} macro is used; thus the number given
-% really has to be a number. However, if users are using \currpkg
-% rather than \units they should expect more checking of input. As
-% the \units package uses the current mode, this has to be
-% detected.
-% \begin{macrocode}
-\si@newrobustcmd*{\unit}[2][]{%
- \ifmmode
- \SI{#1}{#2}%
- \else
- \SI[obeyfamily,obeyitalic]{#1}{#2}%
- \fi}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\unitfrac}
-%\doarg{number}
-%\darg{numerator}
-%\darg{denominator}
-% \cs{unitfrac} is a bit more of a hack.
-% \begin{macrocode}
-\si@newrobustcmd*{\unitfrac}[3][]{%
- \begingroup
- \si@fam@mode%
- \ifmmode\else
- \sisetup{obeyfamily,obeyitalic}%
- \fi
- \si@ifnotmtarg{#1}
- {\num{#1}\ensuremath{\si@valuesep}}%
- \si@frac{#2}{#3}
- \endgroup}
-% \end{macrocode}
-%\end{macro}
-%\iffalse
-%</units>
-%\fi
-%\iffalse
-%<*unitsdef>
-%\fi
-%\subsection{\unitsdef}
-% The package begins with the usual identification of what is
-% happening. Although \file{si-units.cfg} makes the same checks,
-% the error will make more sense if it comes here, in the event of a
-% clash.
-% \begin{macrocode}
-\ProvidesFile{si-unitsdef.cfg}
- [2010/02/22 v1.4c siunitx:
- Emulation of unitsdef]
-\si@emulating{unitsdef}{2005/01/04 v0.2}
-\si@ifloaded{SIunits}
- {\si@emclash{unitsdef}{SIunits}\endinput}{}
-\si@ifloaded{sistyle}
- {\si@emclash{unitsdef}{sistyle}\endinput}{}
-% \end{macrocode}
-% Emulation of \units is needed for \unitsdef to work.
-% \begin{macrocode}
-\requiresiconfigs{units}
-% \end{macrocode}
-% The \unitsdef package loads some packages that \currpkg does not.
-% In particular, it loads \pkg{textcomp} and \pkg{fontenc}. This
-% could be important for output, and so the same is done here.
-% \begin{macrocode}
-\RequirePackage{textcomp}
-\RequirePackage[T1]{fontenc}
-% \end{macrocode}
-% The multitude of package options for \unitsdef need to be handled.
-% \begin{macrocode}
-\sisetup{mode=text,allowoptarg,prespace}
-\ifsi@old@noxspace
- \sisetup{xspace=false}
-\fi
+%
+%\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_set_protected_nopar:Npn \DeclareBinaryPrefix #1#2#3 {
+ \_siunitx_declare_prefix:Nnnn #1 {#2} { 2 } {#3}
+}
+\cs_set_protected_nopar:Npn \DeclareSIPostPower #1#2 {
+ \_siunitx_declare_power_after:Nn #1 {#2}
+}
+\cs_set_protected_nopar:Npn \DeclareSIPrefix #1#2#3 {
+ \_siunitx_declare_prefix:Nnnn #1 {#2} { 10 } {#3}
+}
+\cs_set_protected_nopar:Npn \DeclareSIPrePower #1#2 {
+ \_siunitx_declare_power_before:Nn #1 {#2}
+}
+\cs_set_protected_nopar:Npn \DeclareSIQualifier #1#2 {
+ \_siunitx_declare_qualifier:Nn #1 {#2}
+}
+\cs_set_protected_nopar:Npn \DeclareSIUnit #1#2 {
+ \_siunitx_declare_unit:Nnn #1 {#2} { }
+}
+\cs_set_protected_nopar:Npn \DeclareSIUnitWithOptions #1#2#3 {
+ \_siunitx_declare_unit:Nnn #1 {#2} {#3}
+}
% \end{macrocode}
-% The various options for loading unit abbreviations have to be
-% handled. Here, any request to avoid abbreviations prevents any
-% loading.
+%\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}
-\ifsi@old@noabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@nofrequncyabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@nomolabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@novoltageabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@novolumeabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@noweightabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@noenergyabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@nolengthabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@notimeabbr
- \sisetup{noload=abbr}
-\fi
+\@onlypreamble \DeclareBinaryPrefix
+\@onlypreamble \DeclareSIPostPower
+\@onlypreamble \DeclareSIPrefix
+\@onlypreamble \DeclareSIPrePower
+\@onlypreamble \DeclareSIQualifier
+\@onlypreamble \DeclareSIUnit
+\@onlypreamble \DeclareSIUnitWithOptions
% \end{macrocode}
-%\begin{macro}{\unitvaluesep}
-% To emulate the \cs{unitvaluesep} macro, a hack is needed of the original
-% \pkg{xkeyval} macro for \opt{valuesep}, as well of course as a definition
-% of the macro itself.
+%
+%\begin{macro}{\SendSettingsToPgf}
+% A settings transfer function.
% \begin{macrocode}
-\newcommand*{\unitvaluesep}{\,}
-\renewcommand*{\si@valuesep}{\text{\unitvaluesep}}
-\define@choicekey*+[si]{key}{valuesep}[\si@tempa]
- {space,thin,med,medium,thick,none}
- {\renewcommand*\unitvaluesep\@nameuse{si@fix@##1}%
- \si@log@debug{Option valuesep set to ##1}}
- {\si@log@debug{Option valuesep set to ##1}%
- \renewcommand*\unitvaluesep{##1}}
+\cs_set_protected_nopar:Npn \SendSettingsToPgf { \_siunitx_pgf_link: }
+\@onlypreamble \SendSettingsToPgf
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\unitsignonly}
-%\begin{macro}{\ilu}
-%\begin{macro}{\arc}
-% Some rather straight-forward definitions, with just a bit of fun to
-% get the spacing correct.
-% \begin{macrocode}
-\let\unitsignonly\si
-\si@newrobustcmd*{\ilu}[2][]{%
- \begingroup
- #1\unitvaluesep%
- \unit{#2}%
- \endgroup}
-\let\arc\ang
+%
+%\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}
-%\end{macro}
-%\begin{macro}{\unitSIdef}
-%\begin{macro}{\si@unitSIdef}
-% The \unitsdef package uses a different approach to setting the font
-% inside its version of \cs{SI}. The problem is the same as for
-% \cs{unitvaluesep}, but with the added problem that \currpkg uses
-% \cs{csname} \ldots \cs{endcsname}.
+%
+%\begin{macro}{\numlist}
+% Lists of numbers are trivially easy to work with.
% \begin{macrocode}
-\newcommand*{\unitSIdef}{\upshape}
-\newcommand*{\si@unitSIdef}{\unitSIdef\selectfont}
-\sisetup{textrm=si@unitSIdef}
+\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}
-%\end{macro}
-%\begin{macro}{\per}
-% Rather awkwardly, \unitsdef uses \cs{per} in a different way to
-% \currpkg.
-% \begin{macrocode}
-\let\per\relax
-\si@newrobustcmd*{\per}[2]{%
- \begingroup
- \si@xspacefalse
- \renewcommand*{\unitvaluesep}{}%
- \unitfrac{#1}{#2}%
- \endgroup}
+%
+%\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}{\unittimes}
-%\begin{macro}{\unitsep}
-%\begin{macro}{\unitsuperscript}
-% Some pretty straight-forward stuff again; notice that the automatic
-% analyser for units has to be turned off for this to work.
-% \begin{macrocode}
-\newcommand*{\unittimes}{\ensuremath{\cdot}}
-\newcommand*{\unitsep}{\,}
-\renewcommand*{\si@unt@unithook}{\si@unt@litouttrue}
-\sisetup{unitsep=none}
-\newcommand*{\unitsuperscript}{\tothe}
+%
+%\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}{\newnosepunit}
-%\begin{macro}{\renewnosepunit}
-% Simple aliases.
+%
+%\begin{macro}{\SI}
+% The main \cs{SI} function follows the same pattern as the previous
+% ones.
% \begin{macrocode}
-\newcommand*{\newnosepunit}{\newunit[valuesep=none]}
-\newcommand*{\renewnosepunit}{\renewunit[valuesep=none]}
+\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}
-%\end{macro}
-%\begin{macro}{\setTextOmega}
-%\begin{macro}{\setMathOmega}
-%\begin{macro}{\setTextmu}
-%\begin{macro}{\setMathmu}
-%\begin{macro}{\setTextCelsius}
-%\begin{macro}{\setMathCelsius}
-%\begin{macro}{\setMathDegree}
-%\begin{macro}{\setTextDegree}
-% Controlling symbols is a simple translation job; as only one
-% setting is used by \currpkg in text mode, a bit of extra work is
-% needed.
+%
+%\begin{macro}{\sisetup}
+% The set up macro simply moves to the correct path and executes
+% whatever has been passed.
% \begin{macrocode}
-\newcommand*{\setTextOmega}[2]{%
- \renewcommand*{\si@textOmega}{%
- \begingroup
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setMathOmega}[1]{\sisetup{mathsOmega=#1}}
-\newcommand*{\setTextmu}[2]{%
- \renewcommand*{\si@textmu}{%
- \begingroup
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setMathmu}[1]{\sisetup{mathsmu=#1}}
-\newcommand*{\setTextCelsius}[2]{%
- \renewcommand*{\si@textcelsius}{%
- \begingroup
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setMathCelsius}[1]{\sisetup{mathscelsius=#1}}
-\newcommand*{\setMathDegree}[2]{%
- \renewcommand*{\si@textdegree}{%
- \begingroup%
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setTextDegree}[1]{\sisetup{textdegree=#1}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-% The \opt{ohm} and \opt{OHM} options are checked, and some sanity is
-% ensured. This needs to happen before loading the configuration
-% files.
-% \begin{macrocode}
-\ifsi@old@OHM
- \ifsi@old@ohm
- \si@log@inf{Both `ohm' and `OHM' options given\MessageBreak
- Using default behaviour for unitsdef}
- \expandafter\expandafter\expandafter\si@old@OHMfalse
- \fi
-\fi
+\NewDocumentCommand \sisetup { m } {
+ \keys_set:nn { siunitx } {#1}
+}
% \end{macrocode}
-%\begin{macro}{\liter}
-%\begin{macro}{\ton}
-%\begin{macro}{\days}
-% Tonne is spelled as ``ton'' by \unitsdef, which is wrong in the UK
-% at least (\SI{1}{ton} $=$ \SI{40}{cwt} $=$ \SI{2240}{lb}!).
-% \begin{macrocode}
-\ifsi@old@liter
- \ifsi@old@LITER
- \si@log@inf{Both `liter' and `LITER' options
- given\MessageBreak Using default behaviour for unitsdef}
- \else
- \renewunit{\liter}{l}
- \fi
-\fi
-\newunit{\ton}{t}
-\newunit{\days}{d}
+%\end{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_set_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_set_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}
-%\begin{macro}{\picometer}
-%\begin{macro}{\nanometer}
-%\begin{macro}{\micrometer}
-%\begin{macro}{\millimeter}
-%\begin{macro}{\centimeter}
-%\begin{macro}{\decimeter}
-%\begin{macro}{\kilometer}
-% Extra distances.
+%\end{macro}
+%
+% A short check to get things working.
% \begin{macrocode}
-\newunit{\picometer}{\pico\meter}
-\newunit{\nanometer}{\nano\meter}
-\newunit{\micrometer}{\micro\meter}
-\newunit{\millimeter}{\milli\meter}
-\newunit{\centimeter}{\centi\meter}
-\newunit{\decimeter}{\deci\meter}
-\newunit{\kilometer}{\kilo\meter}
+\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}
@@ -12350,32 +12236,38 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\femtoliter}
-%\begin{macro}{\picoliter}
-%\begin{macro}{\nanoliter}
-%\begin{macro}{\microliter}
-%\begin{macro}{\milliliter}
-%\begin{macro}{\centiliter}
-%\begin{macro}{\deciliter}
-%\begin{macro}{\hectoliter}
-%\begin{macro}{\cubicmeter}
-%\begin{macro}{\cubicmicrometer}
-%\begin{macro}{\cubicmillimeter}
-% Volumes with US spellings.
+%
+%\begin{macro}{\gram}
+% The gram is an odd unit as it is needed for the base unit kilogram.
% \begin{macrocode}
-\newunit{\femtoliter}{\femto\liter}
-\newunit{\picoliter}{\pico\liter}
-\newunit{\nanoliter}{\nano\liter}
-\newunit{\microliter}{\micro\liter}
-\newunit{\milliliter}{\milli\liter}
-\newunit{\centiliter}{\centi\liter}
-\newunit{\deciliter}{\deci\liter}
-\newunit{\hectoliter}{\hecto\liter}
-\newunit{\cubicmeter}{\meter\cubed}
-\newunit{\cubicmicrometer}{\micro\meter\cubed}
-\newunit{\cubicmillimeter}{\milli\meter\cubed}
+\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}
@@ -12386,374 +12278,236 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\squaremeter}
-%\begin{macro}{\squarecentimeter}
-%\begin{macro}{\squarekilometer}
-%\begin{macro}{\ar}
-%\begin{macro}{\hectar}
-% Areas, including the mis-spellings for \cs{are} and
-% \cs{hectare}.
+%\begin{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}
-\newunit{\squaremeter}{\Square\meter}
-\newunit{\squarecentimeter}{\Square\centi\meter}
-\newunit{\squarekilometer}{\Square\kilo\meter}
-\newunit{\ar}{a}
-\newunit{\hectar}{\hecto\ar}
+\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}
-%\begin{macro}{\kv}
-%\begin{macro}{\mv}
-% The code for \unitsdef has the capitalisation wrong for \cs{kV} and
-% \cs{mV}.
-% \begin{macrocode}
-\ifsi@old@noabbr
-\else
- \ifsi@old@novoltageabbr\else
- \newunit{\kv}{\kilo\volt}
- \newunit{\mv}{\milli\volt}
- \fi
-\fi
-% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\sek}
-%\begin{macro}{\fg}
-%\begin{macro}{\fl}
-%\begin{macro}{\pl}
-%\begin{macro}{\nl}
-%\begin{macro}{\micl}
-%\begin{macro}{\ml}
-%\begin{macro}{\cl}
-%\begin{macro}{\dl}
-%\begin{macro}{\hl}
-% There are some slightly different abbreviations, plus some which
-% are not officially allowed.
-% \begin{macrocode}
-\ifsi@old@noabbr\else
- \ifsi@old@notimeabbr\else
- \newunit{\sek}{\second}
- \fi
- \ifsi@old@noweightabbr\else
- \newunit{\fg}{\femto\gram}
- \fi
- \ifsi@old@novolumeabbr\else
- \newunit{\fl}{\femto\liter}
- \newunit{\pl}{\pico\liter}
- \newunit{\nl}{\nano\liter}
- \newunit{\micl}{\micro\liter}
- \newunit{\ml}{\milli\liter}
- \newunit{\cl}{\centi\liter}
- \newunit{\dl}{\deci\liter}
- \newunit{\hl}{\hecto\liter}
- \fi
-\fi
-% \end{macrocode}
-%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
+%
+%\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}
-%\begin{macro}{\calory}
-%\begin{macro}{\kilocalory}
-% \unitsdef spells calorie incorrectly, and it is also not an SI unit.
-% \begin{macrocode}
-\newunit{\calory}{cal}
-\newunit{\kilocalory}{\kilo\calory}
-% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\uBar}
-% \unitsdef uses \cs{ubar} for bar.
-% \begin{macrocode}
-\newunit{\uBar}{ba}
-% \end{macrocode}
%\end{macro}
-%\begin{macro}{\gensymbohm}
-%\begin{macro}{\gensymbcelsius}
-%\begin{macro}{\gensymbmicro}
-%\begin{macro}{\gensymbdegree}
-% If the options relating to \pkg{gensymb} are given, then the
-% package \emph{has} to be loaded. The definitions are then renamed;
-% a slight awkward feature is that the hyphen character needs to be a
-% letter. To avoid needing to worry about this again, a second
-% switch is set up.
-% \begin{macrocode}
-\catcode`\-=11\relax
-\ifsi@old@redef-gensymb
- \expandafter\si@gensymbtrue
-\fi
-\catcode`\-=12\relax
-\ifsi@gensymb
- \RequirePackage{gensymb}
- \AtBeginDocument{
- \let\gensymbohm\ohm
- \let\gensymbcelsius\celsius
- \let\gensymbmicro\micro
- \let\gensymbdegree\degree
- \let\ohm\@undefined
- \let\celsius\@undefined
- \let\micro\@undefined
- \let\degree\@undefined
- \ifsi@old@OHM\else
- \newunit{\ohm}{\si@sym@Omega}
- \newunit{\celsius}{\si@sym@celsius}
- \newprefix{\micro}{\si@sym@mu}{-6}
- \newunit{\degree}{\si@sym@degree}
- \fi}
-\fi
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
-% The configuration files can now be loaded.
-% \begin{macrocode}
-\requiresiconfigs{prefix,named,addn,accepted}
-% \end{macrocode}
-% The \opt{noconfig} option could be ignored, but it costs little to
-% let is be used.
-% \begin{macrocode}
-\ifsi@old@noconfig\else
- \InputIfFileExists{unitsdef.cfg}
- {\si@log@inf{unitsdef config file loaded}}
- {\si@log@inf{unitsdef config file not found}}
-\fi
-% \end{macrocode}
-%
-%\iffalse
-%</unitsdef>
-%<*sistyle>
-%\fi
-%\subsection{\SIstyle}
-% After setting the necessary defaults, the emulation code defines
-% the macros in \SIstyle as given in the manual for that package.
-% \begin{macrocode}
-\ProvidesFile{si-sistyle.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- SIstyle]
-\si@emulating{sistyle}{2006/12/20 v2.3}
-\sisetup{%
- sepfour=true,
- obeyfamily,
- obeyitalic=true,
- numsign=+-,
- strictarc=false,
- unitsep=cdot}
-% \end{macrocode}
-%\begin{macro}{\SIobeyboldtrue}
-%\begin{macro}{\SIobeyboldfalse}
-% Some simple switches, but not using \cs{newif}.
+%\begin{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}
-\newcommand*{\SIobeyboldtrue}{\sisetup{obeybold=true}}
-\newcommand*{\SIobeyboldfalse}{\sisetup{obeybold=false}}
+\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}
-%\begin{macro}{\num}
-%\begin{macro}{\si@sis@num}
-%\begin{macro}{\si@sis@numstar}
-% To get the correct behaviour for \cs{num}, some redefinitions are
-% needed to handle to optional |*|.
-% \begin{macrocode}
-\let\num\relax
-\si@newrobustcmd*{\num}{%
- \@ifstar
- {\si@sis@numstar}
- {\si@sis@num}}
-\newcommand*{\si@sis@num}[2][]{%
- \begingroup%
- \sisetup{#1}%
- \expandafter\si@out@num\expandafter{\si@num{#2}}%
- \endgroup}
-\newcommand*{\si@sis@numstar}[2][]{%
- \begingroup%
- \sisetup{mode=text,obeybold}%
- \sisetup{#1}%
- \expandafter\si@out@num\expandafter{\si@num{#2}}%
- \endgroup}
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\pnt}
-% The \cs{pnt} macro is needed as |.| is active inside \cs{SI}. The
-% name is exactly the same as in \SIstyle, but the implementation is
-% different. This is not defined by the main package as there are
-% better ways of including numbers in the output than this.
-% \begin{macrocode}
-\newcommand*{\pnt}{\ensuremath{\si@decimalsymbol}}
-% \end{macrocode}
%\end{macro}
-%\begin{macro}{\SIgroupfourtrue}
-%\begin{macro}{\SIgroupfourfalse}
-% Switches for grouping four characters.
-% \begin{macrocode}
-\newcommand*{\SIgroupfourtrue}{\sisetup{sepfour=true}}
-\newcommand*{\SIgroupfourfalse}{\sisetup{sepfour=false}}
-% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\SIunitsep}
-%\begin{macro}{\SIunitspace}
-%\begin{macro}{\SIunitdot}
-% Whatever is given here is passed through to \cs{sisetup}.
-% \begin{macrocode}
-\newcommand*{\SIunitsep}[1]{\sisetup{valuesep={#1}}}
-\newcommand*{\SIunitspace}[1]{\sisetup{unitspace={#1}}}
-\newcommand*{\SIunitdot}[1]{\sisetup{unitsep={#1}}}
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\SIdecimalsymbol}
-%\begin{macro}{\SIthousandsep}
-%\begin{macro}{\SIproductsign}
-%\begin{macro}{\SIdecimalsign}
-% The same is true here, with the appropriate translation.
+%
+%\begin{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}
-\newcommand*{\SIdecimalsymbol}[1]{\sisetup{decimalsymbol={#1}}}
-\newcommand*{\SIthousandsep}[1]{\sisetup{digitsep={#1}}}
-\newcommand*{\SIproductsign}[1]{\sisetup{expproduct={#1}}}
-\newcommand*{\SIdecimalsign}[1]{\sisetup{decimalsymbol={#1}}}
+\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}
-%\begin{macro}{\si@sis@savefont}
-%\darg{setting}
-%\darg{argument}
-% The font definitions need a bit of extra work doing. As both
-% settings here have |@| as a letter, all should be fine.
-% \begin{macrocode}
-\newcommand*{\si@sis@savefont}[2]{%
- \@namedef{si@sis@#1}{#2}%
- \sisetup{#1=si@sis@#1}}
-% \end{macrocode}
%\end{macro}
-%\begin{macro}{\SImathrm}
-%\begin{macro}{\SImathsf}
-%\begin{macro}{\SImathtt}
-% The font control macros have to ensure that a macro name is passed
-% to \cs{sisetup}.
-% \begin{macrocode}
-\newcommand*{\SImathrm}[1]{\si@sis@savefont{mathrm}{#1}}
-\newcommand*{\SImathsf}[1]{\si@sis@savefont{mathsf}{#1}}
-\newcommand*{\SImathtt}[1]{\si@sis@savefont{mathtt}{#1}}
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\SIdefaultMfam}
-%\begin{macro}{\SIdefaultNfam}
-%\begin{macro}{\SIdefaultTfam}
-% The same for the default keys.
-% \begin{macrocode}
-\newcommand*{\SIdefaultMfam}[1]{\si@sis@savefont{mathrm}{#1}}
-\newcommand*{\SIdefaultNfam}[1]{\si@sis@savefont{mathnumrm}{#1}}
-\newcommand*{\SIdefaultTfam}[1]{\si@sis@savefont{textrm}{#1}}
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\ensureupmath}
-% The \cs{ensureupmath} command guarantees processing by the
-% font-matching system. The argument cannot be processed here, so
-% care is needed.
+%
+%\begin{macro}{\astronomicalunit}
+%\begin{macro}{\atomicmassunit}
+%\begin{macro}{\electronvolt}
+%\begin{macro}{\dalton}
+% A few units based on physical measurements exist.
% \begin{macrocode}
-\si@newrobustcmd*{\ensureupmath}[1]{%
- \begingroup
- \sisetup{mode=maths,obeyitalic=false}%
- \si@out{#1}%
- \endgroup}
+\DeclareSIUnit \astronomicalunit { ua }
+\DeclareSIUnit \atomicmassunit { u }
+\DeclareSIUnit \electronvolt { eV }
+\DeclareSIUnit \dalton { Da }
% \end{macrocode}
%\end{macro}
-%\begin{macro}{\degC}
-%\begin{macro}{\degF}
-%\begin{macro}{\arcdeg}
-% A few extra symbol names are needed.
-% \begin{macrocode}
-\newcommand*{\degC}{\si@sym@celsius}
-\newcommand*{\arcdeg}{\si@sym@degree}
-\newcommand*{\degF}{\si@sym@degree F}
+%\end{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}{\AddToSIstyle}
-%\begin{macro}{\SIstyle}
-%\begin{macro}{\SIstyleToLang}
-%\begin{macro}{\si@sis@addtolocale}
-% Finally, the locale control.
+%\begin{macro}{\elementarycharge}
+%\begin{macro}{\bohr}
+%\begin{macro}{\hartree}
+% A set of \enquote{atomic units}.
% \begin{macrocode}
-\newcommand*{\SIstyle}[1]{\sisetup{locale=#1}}
-\newcommand*{\SIstyleToLang}[2]{\sisetup{loctolang=#1:#2}}
-\newcommand*{\AddToSIstyle}{%
- \si@switchfalse
- \@ifstar
- {\si@switchtrue
- \si@sis@addtolocale}
- {\si@sis@addtolocale}}
-\newcommand*{\si@sis@addtolocale}[2]{%
- \ifsi@switch
- \expandafter\let\csname si@loc@#1@extra\endcsname\relax
- \fi
- \addtolocale{#1}{#2}}
+\DeclareSIUnit \elementarycharge { \text { \ensuremath { e } } }
+\group_begin:
+ \char_set_lccode:nn { `\@ } { `\_ }
+ \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}
-%\end{macro}
%
-%\iffalse
-%</sistyle>
-%<*SIunits>
-%\fi
-%\subsection{\SIunits}
-% \SIunits emulation starts in much the same way.
-% \begin{macrocode}
-\ProvidesFile{si-SIunits.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- SIunits]
-\si@emulating{SIunits}{2007/12/02 v1.36}
-\sisetup{
- unitsep=thick,
- valuesep=thick,
- prefixproduct=\si@valuesep,
- trapambigfrac=false,
- stickyper}
-\requiresiconfigs{prefix,named,accepted,physical}
-% \end{macrocode}
-%\begin{macro}{\reciprocal}
-%\begin{macro}{\rp}
-%\begin{macro}{\per}
-%\begin{macro}{\usk}
-%\begin{macro}{\power}
-%\begin{macro}{\rpsquare}
-%\begin{macro}{\rpcubic}
-%\begin{macro}{\fourth}
-%\begin{macro}{\rpfourth}
-% A few very simple translations, using the internal version of
-% \cs{per} to allow changes of output style.
+%\begin{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}
-\newcommand*{\reciprocal}{\sisetup{per=reciprocal}\si@per}
-\let\rp\reciprocal
-\renewcommand*{\per}{\sisetup{per=slash}\si@per}
-\newcommand*{\usk}{}
-\newcommand*{\power}[1]{#1\tothe}
-\newcommand*{\rpsquare}{\sisetup{per=reciprocal}\si@per\Square}
-\newcommand*{\rpcubic}{\sisetup{per=reciprocal}\si@per\cubic}
-\newpower{\fourth}{4}
-\newcommand*{\rpfourth}{\sisetup{per=reciprocal}\si@per\fourth}
+\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}
@@ -12761,415 +12515,839 @@ author.
%\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}
-%\begin{macro}{\rpsquared}
-%\begin{macro}{\rpcubed}
-% Here, some low-level switch changing is needed.
+%
+%\subsection{Odds and ends}
+%
+%\begin{macro}{\requiresiconfigs}
+%\begin{macro}{\_siunitx_requireconfig:n}
+% Version one provides this, and it might pop up so should not
+% cause errors.
% \begin{macrocode}
-\newcommand*{\rpsquared}{%
- \sisetup{per=reciprocal}\si@unt@pertrue\si@unt@perseentrue%
- \squared}
-\newcommand*{\rpcubed}{%
- \sisetup{per=reciprocal}\si@unt@pertrue\cubed}
+\NewDocumentCommand \requiresiconfigs { m } {
+ \keys_set:nn { siunitx } { load-configurations = version-1 }
+ \clist_map_function:nN {#1} \_siunitx_requireconfig:n
+}
+\cs_set_protected_nopar:Npn \_siunitx_requireconfig:n #1 {
+ \tl_if_eq:nnT {#1} { synchem }
+ { \keys_set:nn { siunitx } { load-configurations = chemistry } }
+}
% \end{macrocode}
%\end{macro}
%\end{macro}
-%\begin{macro}{\SIsetup}
-%\begin{macro}{\si@siu@setup}
-% The various package spacing options are processed. They also have
-% to be correctly handled by the \cs{SIsetup} macro.
+%
+%\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-italic = false,
+ detect-mode = 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-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_set_protected_nopar:Npn \_siunitx_strict_option:n #1 {
+ \clist_map_function:nN {#1} \_siunitx_strict_option_aux:n
+}
+\cs_set_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{Loading additional configurations}
+%
+% There is only only option for loading files: keeps things simple.
% \begin{macrocode}
-\newcommand*{\SIsetup}[1]{%
- \@for\si@tempa:=#1\do{%
- \@ifundefined{ifsi@old@#1}
- {\si@log@warn{Unknown SIunits option `#1'}}
- {\csname si@old@#1true\endcsname}}
- \si@siu@setup}
-\newcommand*{\si@siu@setup}{%
- \ifsi@old@cdot
- \sisetup{unitsep=cdot}%
- \fi
- \ifsi@old@thickspace
- \sisetup{unitsep=thick}%
- \fi
- \ifsi@old@mediumspace
- \sisetup{unitsep=medium}%
- \fi
- \ifsi@old@thinspace
- \sisetup{unitsep=thin}%
- \fi
- \ifsi@old@thickqspace
- \sisetup{valuesep=thick}%
- \fi
- \ifsi@old@mediumqspace
- \sisetup{valuesep=medium}%
- \fi
- \ifsi@old@thinqspace
- \sisetup{valuesep=thin}%
- \fi}
-\si@siu@setup
+\keys_define:nn { siunitx } {
+ load-configurations .code:n =
+ { \_siunitx_load_configuration:n {#1} }
+}
% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\square}
-%\begin{macro}{\squaren}
-% \SIunits does slightly different things about the clash with
-% \cs{square}, and either redefines this macro or provides
-% \cs{squaren}.
+%
+%\begin{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 LaTeX2e \cs{@onefilewithoptions}
+% function is used for file loading, as LaTeX3 currently needs the
+% LaTeX2e category code stack to keep things sane.
+% \begin{macrocode}
+\cs_set_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_set_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}
-\ifsi@old@squaren
- \newpower{\squaren}{2}
-\fi
-\AtBeginDocument{%
- \@ifundefined{square}
- {\newpower{\square}{2}}
- {\ifsi@old@amssymb
- \renewpower{\square}{2}
- \else
- \ifsi@old@squaren\else
- \si@log@warn{\string\square\space already
- defined\MessageBreak SIunits mode may cause
- errors}%
- \fi
- \fi}}
+\file_if_exist:nT { siunitx . \_c_siunitx_configuration_ext_tl }
+ {
+ \@onefilewithoptions { siunitx } [ ] [ ]
+ \_c_siunitx_configuration_ext_tl
+ }
% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\gray}
-% The potential clash with \pkg{PStricks} is also handled
-% differently; here, \cs{Gray} will already be defined by the
-% \currpkg kernel.
-% \begin{macrocode}
-\AtBeginDocument{
- \@ifundefined{gray}
- {\newunit{\gray}{Gy}}
- {\ifsi@old@pstricks
- \renewunit{\gray}{Gy}
- \else
- \ifsi@old@Gray\else
- \si@log@warn{\string\gray\space already
- defined\MessageBreak SIunits mode may cause
- errors}%
- \fi
- \fi}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\unit}
-%\begin{macro}{\unita}
-% The \cs{unit} macro is defined.
-% \begin{macrocode}
-\ifsi@old@italian
- \let\unita\SI
-\else
- \let\unit\SI
-\fi
+%
+% Finally apply the settings given at load time.
+% \begin{macrocode}
+\ProcessKeysOptions { siunitx }
% \end{macrocode}
-%\end{macro}
-%\end{macro}
-% The miscellaneous options are moped up.
+%
% \begin{macrocode}
-\ifsi@old@textstyle
- \sisetup{mode=text}
-\fi
-\ifsi@old@binary
- \sisetup{alsoload=binary}
-\fi
+%</package>
% \end{macrocode}
-%\begin{macro}{\arcminute}
-%\begin{macro}{\arcsecond}
-%\begin{macro}{\rperminute}
-%\begin{macro}{\ton}
-%\begin{macro}{\degreecelsius}
-% The unit macros defined by \SIunits that are not defined by
-% \currpkg (by default).
-% \begin{macrocode}
-\newunit[valuesep=none]{\arcminute}{\si@sym@minute}
-\newunit[valuesep=none]{\arcsecond}{\si@sym@second}
-\newunit{\rperminute}{r/min}
-\newunit{\ton}{t}
-\newunit{\degreecelsius}{\celsius}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-%\begin{macro}{\addunit}
-% This is an alias for \cs{newunit}.
-% \begin{macrocode}
-\let\addunit\newunit
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\addprefix}
-% A little more work for \cs{addprefix}.
-% \begin{macrocode}
-\newcommand*{\addprefix}[2]{\newprefix{#1}{#2}}
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\si@siu@newunit}
-%\changes{v1.1a}{2008/09/30}{Corrected very minor bug in definition}
-%\begin{macro}{\si@siu@power}
-%\begin{macro}{\si@siu@newunithook}
-%\doarg{power}
-%\darg{numerator}
-%\darg{denominator}
-% To save some code, making new units which need a \texttt{\ldots np}
-% variant is handled by a dedicated macro.
-% \begin{macrocode}
-\newcommand*{\si@siu@newunit}[3][]{%
-% \end{macrocode}
-% A test is needed to sort out \cs{square}.
-% \begin{macrocode}
- \renewcommand*{\si@tempa}{#1}%
- \renewcommand*{\si@tempb}{square}%
- \def\si@siu@power{}%
- \ifx\@empty\si@tempa\@empty\else
- \ifx\si@tempa\si@tempb
- \renewcommand*{\si@siu@power}{\ssquare}%
- \else
- \edef\si@siu@power{%
- \expandafter\noexpand\csname #1\endcsname}%
- \fi
- \fi
-% \end{macrocode}
-% The necessary information is now stored in temporary macros.
-% \begin{macrocode}
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3\endcsname}%
- \edef\si@tempb{%
- \expandafter\noexpand\csname #2\endcsname\noexpand\per
- \expandafter\noexpand\si@siu@power
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter%
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempb}
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3np\endcsname}%
- \edef\si@tempb{%
- \expandafter\noexpand\csname #2\endcsname\noexpand
- \reciprocal\expandafter\noexpand\si@siu@power
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempb}%
- \si@siu@newunithook[#1]{#2}{#3}}
-\providecommand*{\si@siu@newunithook}[3][]{}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-%\end{macro}
-% The basic units are now defined; these only have a single csname in
-% each of the numerator and denominator.
-% \begin{macrocode}
-\si@siu@newunit{gray}{second}
-\si@siu@newunit[square]{metre}{second}
-\si@siu@newunit{joule}{mole}
-\si@siu@newunit[cubic]{mole}{metre}
-\si@siu@newunit[square]{radian}{second}
-\si@siu@newunit{radian}{second}
-\si@siu@newunit[cubic]{squaremetre}{metre}
-\si@siu@newunit[cubic]{katal}{metre}
-\si@siu@newunit{coulomb}{mol}
-\si@siu@newunit[square]{ampere}{metre}
-\si@siu@newunit[cubic]{kilogram}{metre}
-\si@siu@newunit[cubic]{coulomb}{metre}
-\si@siu@newunit{volt}{metre}
-\si@siu@newunit[square]{coulomb}{squaremetre}
-\si@siu@newunit{farad}{metre}
-\si@siu@newunit[square]{watt}{metre}
-\si@siu@newunit[square]{joule}{metre}
-\si@siu@newunit[cubic]{newton}{metre}
-\si@siu@newunit{newton}{kilogram}
-\si@siu@newunit{joule}{kelvin}
-\si@siu@newunit{joule}{kilogram}
-\si@siu@newunit{coulomb}{kilogram}
-\si@siu@newunit{squaremetre}{second}
-\si@siu@newunit[square]{squaremetre}{second}
-\si@siu@newunit[square]{candela}{metre}
-\si@siu@newunit{ampere}{metre}
-\si@siu@newunit{joule}{tesla}
-\si@siu@newunit{henry}{metre}
-\si@siu@newunit{kilogram}{second}
-\si@siu@newunit[square]{kilogram}{metre}
-\si@siu@newunit{kilogram}{metre}
-\si@siu@newunit[square]{newton}{metre}
-\si@siu@newunit{watt}{kilogram}
-\si@siu@newunit[cubic]{watt}{metre}
-\si@siu@newunit{squaremetre}{kilogram}
-\si@siu@newunit{cubicmetre}{kilogram}
-\si@siu@newunit{newton}{metre}
-\si@siu@newunit[cubic]{squaremetre}{second}
-\si@siu@newunit{metre}{second}
-\si@siu@newunit[cubic]{joule}{metre}
-\si@siu@newunit{cubicmetre}{second}
-% \end{macrocode}
-%\begin{macro}{\si@siu@newunitx}
-%\begin{macro}{\si@siu@newunitxhook}
-% For the more complex units, a slightly different approach is used;
-% four arguments are required, and have to cover everything.
-% \begin{macrocode}
-\newcommand*{\si@siu@newunitx}[4]{%
- \expandafter\newunit\expandafter{\csname #1per#2\endcsname}
- {#3\per#4}%
- \expandafter\newunit\expandafter{\csname #1per#2np\endcsname}
- {#3\reciprocal#4}
- \si@siu@newunitxhook{#1}{#2}{#3}{#4}}
-\providecommand*{\si@siu@newunitxhook}[4]{}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-% The units are defined.
-% \begin{macrocode}
-\si@siu@newunitx{kilogramsquaremetre}{second}
- {\kilogram\squaremetre}{\second}
-\si@siu@newunitx{squaremetre}{newtonsecond}{\squaremetre}
- {\newton\second}
-\si@siu@newunitx{kilogrammetre}{second}{\kilogram\metre}
- {\second}
-\si@siu@newunitx{kilogram}{squaremetresecond}{\kilogram}
- {\squaremetre\second}
-\si@siu@newunitx{joule}{molekelvin}{\joule}{\mole\kelvin}
-\si@siu@newunitx{kilogram}{kilomole}{\kilogram}{\kilo\mole}
-\si@siu@newunitx{kilogrammetre}{squaresecond}{\kilogram\metre}
- {\second\squared}
-\si@siu@newunitx{watt}{squaremetresteradian}{\watt}
- {\squaremetre\steradian}
-\si@siu@newunitx{joule}{kilogramkelvin}{\joule}
- {\kilogram\kelvin}
-\si@siu@newunitx{watt}{metrekelvin}{\watt}{\metre\kelvin}
-\si@siu@newunitx{kilogram}{cubicmetrecoulomb}{\kilogram}
- {\cubic\metre\coulomb}
-\si@siu@newunitx{kilogram}{secondcubicmetre}{\kilogram}
- {\second\cubicmetre}
-% \end{macrocode}
-%\begin{macro}{\si@siu@unity}
-% A bit of cleverness to get the ``1'' correct; to avoid any clash, the unit
-% is given an internal name.
-% \begin{macrocode}
-\newunit{\si@siu@unity}{1}
-\si@siu@newunitx{}{squaremetresecond}{\si@siu@unity}
- {\squaremetre\second}
-% \end{macrocode}
-%\end{macro}
-% A few compound units that are best defined directly.
-% \begin{macrocode}
-\newunit{\pascalsecond}{\pascal\second}
-\newunit{\amperemetresecond}{\ampere\metre\second}
-\newunit{\ohmmetre}{\ohm\metre}
-\newunit{\newtonmetre}{\newton\metre}
-\let\newtonmetrenp\newtonmetre
-\newunit{\kilogramsquaremetre}{\kilogram\squaremetre}
-\let\kilogramsquaremetrenp\kilogramsquaremetre
-% \end{macrocode}
-%\begin{macro}{\si@siu@newprefix}
-%\darg{prefix}
-% To generate the prefixes correctly, a small saving in repetition.
-% \begin{macrocode}
-\newcommand*{\si@siu@newprefix}[1]{%
- \edef\si@tempa{\expandafter\noexpand\csname #1d\endcsname}%
- \edef\si@tempb{\expandafter\noexpand\csname #1\endcsname}%
- \expandafter\expandafter\expandafter\newcommand\expandafter
- \expandafter\expandafter*\expandafter\expandafter
- \expandafter{\expandafter\si@tempa\expandafter}\expandafter
- {\expandafter\si@prefixsymbolicfalse\si@tempb}}
-% \end{macrocode}
-%\end{macro}
-% This is now implemented.
-% \begin{macrocode}
-\si@siu@newprefix{yocto}
-\si@siu@newprefix{zepto}
-\si@siu@newprefix{atto}
-\si@siu@newprefix{femto}
-\si@siu@newprefix{pico}
-\si@siu@newprefix{nano}
-\si@siu@newprefix{micro}
-\si@siu@newprefix{milli}
-\si@siu@newprefix{centi}
-\si@siu@newprefix{deca}
-\si@siu@newprefix{deka}
-\si@siu@newprefix{hecto}
-\si@siu@newprefix{kilo}
-\si@siu@newprefix{mega}
-\si@siu@newprefix{giga}
-\si@siu@newprefix{tera}
-\si@siu@newprefix{peta}
-\si@siu@newprefix{exa}
-\si@siu@newprefix{zetta}
-\si@siu@newprefix{yotta}
-\ifsi@old@binary
- \si@siu@newprefix{kibi}
- \si@siu@newprefix{mebi}
- \si@siu@newprefix{gibi}
- \si@siu@newprefix{tebi}
- \si@siu@newprefix{pebi}
- \si@siu@newprefix{exbi}
-\fi
+%
+%\subsection{Support for version one}
+%
+% \begin{macrocode}
+%<*version-1>
% \end{macrocode}
-%\begin{macro}{\derradian}
-%\begin{macro}{\dersteradian}
-%\begin{macro}{\derhertz}
-%\begin{macro}{\dernewton}
-%\begin{macro}{\derpascal}
-%\begin{macro}{\derjoule}
-%\begin{macro}{\derwatt}
-%\begin{macro}{\dercoulomb}
-%\begin{macro}{\dervolt}
-%\begin{macro}{\derfarad}
-%\begin{macro}{\derohm}
-% The derived units may need to be defined.
+%
% \begin{macrocode}
-\ifsi@old@derived
- \newunit{\derradian}{\metre\reciprocal\metre}
- \newunit{\dersteradian}{\squaremetre\rpsquare\metre}
- \newunit{\derhertz}{\reciprocal\second}
- \newunit{\dernewton}{\metre\kilogram\second\rpsquared}
- \newunit{\derpascal}{\newton\rpsquare\metre}
- \newunit{\derjoule}{\newton\metre}
- \newunit{\derwatt}{\joule\reciprocal\second}
- \newunit{\dercoulomb}{\ampere\second}
- \newunit{\dervolt}{\watt\reciprocal\ampere}
- \newunit{\derfarad}{\coulomb\reciprocal\volt}
- \newunit{\derohm}{\volt\reciprocal\ampere}
+\ProvidesExplFile {siunitx-version-1.cfg} {2010/05/23} {2.0}
+ {siunitx: Version 1 settings}
+% \end{macrocode}
+%
+% The abbreviations are loaded by default be version one.
+% \begin{macrocode}
+\keys_set:nn { siunitx } { load-configurations = abbreviations }
+% \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 /
+ false .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 },
+% angformat & List & Conversion of angle format \\
+ angelsep .choice: ,
+ angelsep /
+ cdot .meta:n =
+ { arc-separator = { } \cdot { } },
+ angelsep /
+ comma .meta:n = { arc-separator = { {,} } },
+ angelsep /
+ fullstop .meta:n = { arc-separator = { { . } } },
+ angelsep /
+ med .meta:n = { arc-separator = \: },
+ angelsep /
+ medium .meta:n = { arc-separator = \: },
+ angelsep /
+ none .meta:n = { arc-separator = },
+ angelsep /
+ period .meta:n = { arc-separator = { { . } } },
+ angelsep /
+ space .meta:n = { arc-separator = \text { ~ } },
+ angelsep /
+ stop .meta:n = { arc-separator = { { . } } },
+ angelsep /
+ thick .meta:n = { arc-separator = \; },
+ angelsep /
+ thin .meta:n = { arc-separator = \, },
+ angelsep /
+ tightcdot .meta:n =
+ { arc-separator = \bgroup \cdot \egroup },
+ angelsep /
+ tighttimes .meta:n =
+ { arc-separator = \bgroup \times \egroup },
+ angelsep /
+ times .meta:n = { arc-separator = \times },
+ angelsep /
+ 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 },
+ 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
+ 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 /
+ 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 = ,
+ 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 },
+ obeyitalic .meta:n = { detect-italic = #1 },
+ opbeyitalic .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
+ },
+ 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 /
+ 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-numbers = single,
+ product-units = single,
+ },
+ repeatunits /
+ power .meta:n =
+ {
+ multi-part-numbers = repeat,
+ product-units = power,
+ },
+ repeatunits /
+ true .meta:n =
+ {
+ multi-part-numbers = 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 .meta:n =
+ {
+ table-number-alignment = #1,
+ table-text-alignment = #1,
+ table-unit-alignment = #1
+ },
+ tabalignexp .code:n = ,
+ tabautofit .meta:n = { table-auto-round = #1 },
+ tabformat .meta:n = { table-format = #1 },
+ tabnumalign .meta:n = { table-number-alignment = #1 },
+ tabparseonly .meta:n = { table-parse-only = #1 },
+ tabparseonly .default:n = { true },
+ tabtextalign .meta:n = { table-text-numbers = #1 },
+ tabunitalign .meta:n = { 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 =
+ { unit-value-separator = { } \cdot { } },
+ valuesep /
+ comma .meta:n = { unit-value-separator = { {,} } },
+ valuesep /
+ fullstop .meta:n = { unit-value-separator = { { . } } },
+ valuesep /
+ med .meta:n = { unit-value-separator = \: },
+ valuesep /
+ medium .meta:n = { unit-value-separator = \: },
+ valuesep /
+ none .meta:n = { unit-value-separator = },
+ valuesep /
+ period .meta:n = { unit-value-separator = { { . } } },
+ valuesep /
+ space .meta:n = { unit-value-separator = \text { ~ } },
+ valuesep /
+ stop .meta:n = { unit-value-separator = { { . } } },
+ valuesep /
+ thick .meta:n = { unit-value-separator = \; },
+ valuesep /
+ thin .meta:n = { unit-value-separator = \, },
+ valuesep /
+ tightcdot .meta:n =
+ { unit-value-separator = \bgroup \cdot \egroup },
+ valuesep /
+ tighttimes .meta:n =
+ { unit-value-separator = \bgroup \times \egroup },
+ valuesep /
+ times .meta:n = { unit-value-separator = \times },
+ valuesep /
+ unknown .meta:n = { unit-value-separator = #1 },
+ xspace .meta:n = { use-xspace = #1 },
+ xpace .default:n = { true }
+}
+% \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}
+\cs_set_eq:NN \newunit \DeclareSIUnit
+\cs_set_eq:NN \renewunit \DeclareSIUnit
+\cs_set_eq:NN \provideunit \DeclareSIUnit
% \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}
+\cs_set_eq:NN \newqualifier \DeclareSIQualifier
+\cs_set_eq:NN \renewqualifier \DeclareSIQualifier
+\cs_set_eq:NN \providequalifier \DeclareSIQualifier
+% \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}
-%\end{macro}
-%\begin{macro}{\dersiemens}
-%\begin{macro}{\derweber}
-%\begin{macro}{\dertesla}
-%\begin{macro}{\derhenry}
-%\begin{macro}{\dercelsius}
-%\begin{macro}{\derlumen}
-%\begin{macro}{\derlux}
-%\begin{macro}{\derbecquerel}
-%\begin{macro}{\dergray}
-%\begin{macro}{\dersievert}
-%\begin{macro}{\derkatal}
-% In two blocks!
+%
+%\begin{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}
- \newunit{\dersiemens}{\ampere\reciprocal\volt}
- \newunit{\derweber}
- {\squaremetre\kilogram\second\rpsquared\reciprocal\ampere}
- \newunit{\dertesla}{\weber\rpsquare\metre}
- \newunit{\derhenry}{\weber\reciprocal\ampere}
- \newunit{\dercelsius}{\kelvin}
- \newunit{\derlumen}{\candela\steradian}
- \newunit{\derlux}{\lumen\rpsquare\metre}
- \newunit{\derbecquerel}{\derhertz}
- \newunit{\dergray}{\joule\reciprocal\kilogram}
- \newunit{\dersievert}{\dergray}
- \newunit{\derkatal}{\rp\second\usk\mole}
-\fi
+\DeclareSIUnit \BAR { \bar }
+\DeclareSIUnit \bbar { \bar }
+\DeclareSIUnit \Day { \day }
+\DeclareSIUnit \dday { \day }
+\DeclareSIUnit \Gray { \gray }
+\DeclareSIUnit \ggray { \gray }
% \end{macrocode}
%\end{macro}
%\end{macro}
@@ -13177,41 +13355,70 @@ author.
%\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}{\radianbase}
-%\begin{macro}{\steradianbase}
-%\begin{macro}{\hertzbase}
-%\begin{macro}{\newtonbase}
-%\begin{macro}{\pascalbase}
-%\begin{macro}{\joulebase}
-%\begin{macro}{\wattbase}
-%\begin{macro}{\coulombbase}
-%\begin{macro}{\voltbase}
-%\begin{macro}{\faradbase}
-%\begin{macro}{\ohmbase}
-% Also the ``derived-in-base''.
+%
+%\begin{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}
-\ifsi@old@derivedinbase
- \newunit{\radianbase}{\metre\reciprocal\metre}
- \newunit{\steradianbase}{\squaremetre\rpsquare\metre}
- \newunit{\hertzbase}{\reciprocal\second}
- \newunit{\newtonbase}{\metre\kilogram\second\rpsquared}
- \newunit{\pascalbase}{\reciprocal\metre\kilogram\second%
- \rpsquared}
- \newunit{\joulebase}{\squaremetre\kilogram\second\rpsquared}
- \newunit{\wattbase}{\squaremetre\kilogram\rpcubic\second}
- \newunit{\coulombbase}{\ampere\second}
- \newunit{\voltbase}
- {\squaremetre\kilogram\rpcubic\second\reciprocal\ampere}
- \newunit{\faradbase}
- {\rpsquare\metre\reciprocal\kilogram\fourth\second\ampere%
- \squared}
- \newunit{\ohmbase}
- {\squaremetre\kilogram\rpcubic\second\rpsquare\ampere}
+\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}
@@ -13224,107 +13431,127 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\siemensbase}
-%\begin{macro}{\weberbase}
-%\begin{macro}{\teslabase}
-%\begin{macro}{\henrybase}
-%\begin{macro}{\celsiusbase}
-%\begin{macro}{\lumenbase}
-%\begin{macro}{\luxbase}
-%\begin{macro}{\becquerelbase}
-%\begin{macro}{\graybase}
-%\begin{macro}{\sievertbase}
-%\begin{macro}{\katalbase}
-% Also in two blocks.
-% \begin{macrocode}
- \newunit{\siemensbase}
- {\rpsquare\metre\reciprocal\kilogram\cubic\second\ampere%
- \squared}
- \newunit{\weberbase}
- {\squaremetre\kilogram\second\rpsquared\reciprocal\ampere}
- \newunit{\teslabase}{\kilogram\second\rpsquared\reciprocal%
- \ampere}
- \newunit{\henrybase}
- {\squaremetre\kilogram\second\rpsquared\rpsquare\ampere}
- \newunit{\celsiusbase}{\kelvin}
- \newunit{\lumenbase}{\candela\squaremetre\rpsquare\metre}
- \newunit{\luxbase}{\candela\squaremetre\rpfourth\metre}
- \newunit{\becquerelbase}{\hertzbase}
- \newunit{\graybase}{\squaremetre\second\rpsquared}
- \newunit{\sievertbase}{\graybase}
- \newunit{\katalbase}{\rp\second\mole}
-\fi
-% \end{macrocode}
%\end{macro}
%\end{macro}
+%
+%\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}
-% Any configuration file is used if found.
+%
% \begin{macrocode}
-\InputIfFileExists{SIunits.cfg}
- {\si@log@inf{SIunits config file loaded}}
- {\si@log@inf{SIunits config file not found}}
+%</version-1>
% \end{macrocode}
-%\iffalse
-%</SIunits>
-%<*hepunits>
-%\fi
-%\subsection{\pkg{hepunits}}
-% The \pkg{hepunits} package provides some rather odd unit names,
-% which are not really to be encouraged.
+%
+%\subsection{Abbreviated units}
+%
% \begin{macrocode}
-\ProvidesFile{si-hepunits.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- hepunits]
-\si@emulating{hepunits}{2007/09/27}
-\requiresiconfigs{SIunits,accepted,prefix,hep}
+%<*abbreviations>
% \end{macrocode}
-%\begin{macro}{\invbarn}
-%\begin{macro}{\invnanobarn}
-%\begin{macro}{\invpicobarn}
-%\begin{macro}{\invfemtobarn}
-%\begin{macro}{\invattobarn}
-%\begin{macro}{\invzeptobarn}
-%\begin{macro}{\invyoctobarn}
-% Inverses barn units.
+%
% \begin{macrocode}
-\ifsi@old@noprefixcmds\else
- \newunit{\invbarn}{\per\barn}
- \newunit{\invnanobarn}{\per\nano\barn}
- \newunit{\invpicobarn}{\per\pico\barn}
- \newunit{\invfemtobarn}{\per\femto\barn}
- \newunit{\invattobarn}{\per\atto\barn}
- \newunit{\invzeptobarn}{\per\zepto\barn}
- \newunit{\invyoctobarn}{\per\yocto\barn}
+\ProvidesExplFile {siunitx-abbreviations.cfg} {2010/05/23} {2.0}
+ {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}{\pA}
+%\begin{macro}{\nA}
+%\begin{macro}{\uA}
+%\begin{macro}{\mA}
+%\begin{macro}{\kA}
+% Currents.
+% \begin{macrocode}
+\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}
+%\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}
-%\begin{macro}{\invnb}
-%\begin{macro}{\invpb}
-%\begin{macro}{\invfb}
-%\begin{macro}{\invab}
-%\begin{macro}{\invzb}
-%\begin{macro}{\invyb}
-% Also available abbreviated.
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\begin{macro}{\fmol}
+%\begin{macro}{\pmol}
+%\begin{macro}{\nmol}
+%\begin{macro}{\umol}
+%\begin{macro}{\mmol}
+%\begin{macro}{\kmol}
+% Amounts of substance (moles).
% \begin{macrocode}
- \newunit{\invnb}{\per\nano\barn}
- \newunit{\invpb}{\per\pico\barn}
- \newunit{\invfb}{\per\femto\barn}
- \newunit{\invab}{\per\atto\barn}
- \newunit{\invzb}{\per\zepto\barn}
- \newunit{\invyb}{\per\yocto\barn}
-\fi
+\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}
@@ -13332,34 +13559,48 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
+%\begin{macro}{\mV}
+%\begin{macro}{\kV}
+% Potentials.
+% \begin{macrocode}
+\DeclareSIUnit \mV { \milli \volt }
+\DeclareSIUnit \kV { \kilo \volt }
+% \end{macrocode}
+%\end{macro}
%\end{macro}
-%\begin{macro}{\invcmsqpersecond}
-%\begin{macro}{\invcmsqpersec}
-%\begin{macro}{\lumiunits}
-% Luminosity.
+%\begin{macro}{\ml}
+%\begin{macro}{\ul}
+%\begin{macro}{\mL}
+%\begin{macro}{\uL}
+% Volumes.
% \begin{macrocode}
-\newunit{\invcmsqpersecond}{\per\Square\centi\metre\per\second}
-\newunit{\invcmsqpersec}{\per\Square\centi\metre\per\second}
-\newunit{\lumiunits}{\per\Square\centi\metre\per\second}
+\DeclareSIUnit \ml { \milli \litre }
+\DeclareSIUnit \ul { \micro \litre }
+\DeclareSIUnit \mL { \milli \liter }
+\DeclareSIUnit \uL { \micro \liter }
% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\inveV}
-%\begin{macro}{\minveV}
-%\begin{macro}{\minveV}
-%\begin{macro}{\kinveV}
-%\begin{macro}{\MinveV}
-%\begin{macro}{\GinveV}
-%\begin{macro}{\TinveV}
-% The inverse of an electron-volt, plus prefixes.
+%\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}
-\newunit{\inveV}{\per\electronvolt}
-\newunit{\minveV}{\per\milli\electronvolt}
-\newunit{\kinveV}{\per\kilo\electronvolt}
-\newunit{\MinveV}{\per\mega\electronvolt}
-\newunit{\GinveV}{\per\giga\electronvolt}
-\newunit{\TinveV}{\per\tera\electronvolt}
+\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}
@@ -13368,493 +13609,181 @@ author.
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\eVoverc}
-%\begin{macro}{\eVovercsq}
-% Some combinations of electron-volts and the speed of light. As
-% these are called |over|, they are set with a slash. The
-% \opt{eVcorrb} values have been set for Computer Modern.
+%\end{macro}
+%\begin{macro}{\kJ}
+%\begin{macro}{\eV}
+%\begin{macro}{\meV}
+%\begin{macro}{\keV}
+%\begin{macro}{\MeV}
+%\begin{macro}{\GeV}
+%\begin{macro}{\TeV}
+%\begin{macro}{\kWh}
+% Energies.
% \begin{macrocode}
-\newunit[per=slash,eVcorrb=0.6ex]{\eVoverc}
- {\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\eVovercsq}
- {\electronvolt\per\Square\clight}
+\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}
-%\begin{macro}{\meVoverc}
-%\begin{macro}{\keVoverc}
-%\begin{macro}{\MeVoverc}
-%\begin{macro}{\GeVoverc}
-%\begin{macro}{\TeVoverc}
-% Prefixed combinations, first of the speed of light.
-% \begin{macrocode}
-\newunit[per=slash,eVcorrb=0.6ex]{\meVoverc}
- {\milli\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\keVoverc}
- {\kilo\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\MeVoverc}
- {\mega\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\GeVoverc}
- {\giga\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\TeVoverc}
- {\tera\electronvolt\per\clight}
-% \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
-%\begin{macro}{\meVovercsq}
-%\begin{macro}{\keVovercsq}
-%\begin{macro}{\MeVovercsq}
-%\begin{macro}{\GeVovercsq}
-%\begin{macro}{\TeVovercsq}
-% Then of the square.
+%\end{macro}
+%\begin{macro}{\pm}
+%\begin{macro}{\nm}
+%\begin{macro}{\um}
+%\begin{macro}{\mm}
+%\begin{macro}{\cm}
+%\begin{macro}{\dm}
+%\begin{macro}{\km}
+% Lengths.
% \begin{macrocode}
-\newunit[per=slash,eVcorrb=0.6ex]{\meVovercsq}
- {\milli\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\keVovercsq}
- {\kilo\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\MeVovercsq}
- {\mega\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\GeVovercsq}
- {\giga\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\TeVovercsq}
- {\tera\electronvolt\per\Square\clight}
+\DeclareSIUnit \nm { \nano \metre }
+\DeclareSIUnit \pm { \pico \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}
-%\iffalse
-%</hepunits>
-%<*fancynum>
-%\fi
-%\subsection{\pkg{fancynum}}
-% \pkg{fancynum} only does things with numbers, so there is only
-% a little emulation and a few macros needed.
-% \begin{macrocode}
-\ProvidesFile{si-fancynum.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- fancynum]
-\si@emulating{fancynum}{2000/08/08 0.92}
-\sisetup{decimalsymbol=cdot,digitsep=comma}
-% \end{macrocode}
-%\begin{macro}{\fnum}
-% The \cs{fnum} macro is rather restricted, but this is not
-% reproduced. Instead, it is \cs{let} as an alias to the \cs{num}
-% macro.
-% \begin{macrocode}
-\let\fnum\num
-% \end{macrocode}
%\end{macro}
-%\begin{macro}{\setfnumdsym}
-%\begin{macro}{\setfnumgsym}
-%\begin{macro}{\setfnummsym}
-% The control macros are defined.
+%\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}
-\newcommand*{\setfnumdsym}[1]{\sisetup{decimalsymbol={#1}}}
-\newcommand*{\setfnumgsym}[1]{\sisetup{digitsep={#1}}}
-\newcommand*{\setfnummsym}[1]{\sisetup{expproduct={#1}}}
+\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}
-% The various package options are now processed if necessary.
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%\end{macro}
+%
% \begin{macrocode}
-\ifsi@old@english
- \sisetup{decimalsymbol=cdot,digitsep=comma}
-\fi
-\ifsi@old@french
- \sisetup{decimalsymbol=comma,digitsep=fullstop}
-\fi
-\ifsi@old@tight
- \sisetup{expproduct=tighttimes}
-\fi
-\ifsi@old@loose
- \sisetup{expproduct=times}
-\fi
-\ifsi@old@thinspaces
- \sisetup{digitsep=thin}
-\fi
-\ifsi@old@commas
- \sisetup{digitsep=comma}
-\fi
-\ifsi@old@plain
- \sisetup{digitsep=none}
-\fi
-% \end{macrocode}
+%</abbreviations>
+% \end{macrocode}
+%
+%\subsection{Binary units}
%
-%\iffalse
-%</fancynum>
-%<*fancyunits>
-%\fi
-%\subsection{\pkg{fancyunits}}
-% The \pkg{fancyunits} package is not available on \textsc{ctan}, but
-% is available from its authors homepage \cite{fancyunits}. It is
-% similar to \SIunits, and so most of the code is shared here.
-% However, a few bits of set up occur first, and an emulation-clash
-% test is needed.
-% \begin{macrocode}
-\ProvidesFile{si-fancyunits.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- fancyunits]
-\si@emulating{fancyunits}{2007/02/01 v1.0.1}
-\si@ifloaded{SIunits}
- {\si@log@err{SIunits emulation loaded\MessageBreak before
- fancyunits emulation}{You need to load the fancyunits
- emualtion\MessageBreak code before that for
- SIunits.\MessageBreak Try emulate=fancyunits as the first
- option when\MessageBreak loading siunitx}}{}
-% \end{macrocode}
-%\begin{macro}{\si@siu@newunithook}
-%\begin{macro}{\si@siu@newunitxhook}
-% To create the extra macros provided by \pkg{fancyunits}, the
-% \SIunits emulation code is changed to add the ``\texttt{uf}''
-% variants.
-% \begin{macrocode}
-\newcommand*{\si@siu@newunithook}[3][]{%
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3uf\endcsname}%
- \renewcommand*{\si@tempb}{stickyper,per=fraction,
- fraction=nice}%
- \edef\si@tempc{%
- \noexpand\sisetup{\si@tempb}%
- \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
- \expandafter\noexpand\si@siu@power%
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempc}%
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3Uf\endcsname}%
- \renewcommand*{\si@tempb}{stickyper,per=fraction,
- fraction=frac}%
- \edef\si@tempc{%
- \noexpand\sisetup{\si@tempb}%
- \noexpand\def\noexpand\si@frc@hook{\noexpand\textstyle}%
- \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
- \expandafter\noexpand\si@siu@power%
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempc}%
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3UF\endcsname}%
- \edef\si@tempc{%
- \noexpand\sisetup{\si@tempb}%
- \noexpand\def\noexpand\si@frc@hook{\noexpand\displaystyle}%
- \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
- \expandafter\noexpand\si@siu@power%
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempc}}
-\newcommand*{\si@siu@newunitxhook}[4]{%
- \expandafter\newunit\expandafter{\csname #1per#2uf\endcsname}
- {\sisetup{stickyper,per=fraction,fraction=nice}%
- #3\si@per#4}%
- \expandafter\newunit\expandafter{\csname #1per#2Uf\endcsname}
- {\sisetup{stickyper,per=fraction,fraction=frac}%
- \renewcommand*{\si@frc@hook}{\textstyle}%
- #3\si@per#4}%
- \expandafter\newunit\expandafter{\csname #1per#2UF\endcsname}
- {\sisetup{stickyper,per=fraction,fraction=frac}%
- \renewcommand*{\si@frc@hook}{\displaystyle}%
- #3\si@per#4}}
-% \end{macrocode}
-%\end{macro}
-%\end{macro}
-% With that done, the emulation modules can be loaded.
-% \begin{macrocode}
-\requiresiconfigs{SIunits,addn,astro}
-\sisetup{obeyall}
-% \end{macrocode}
-% There is one \pkg{fancyunits}-specific option to handle. The other
-% options all get sent through to the \SIunits system.\footnote{As
-% \SIunits is rather more widely known than \pkg{fancyunits}, any
-% other options which could be for either are assumed to be for
-% \SIunits.}
-% \begin{macrocode}
-\ifsi@old@spaceqspace
- \sisetup{valuesep=space}
-\fi
+% \begin{macrocode}
+%<*binary>
+% \end{macrocode}
+%
+% \begin{macrocode}
+\ProvidesExplFile {siunitx-binary.cfg} {2010/05/23} {2.0}
+ {siunitx: Binary units}
% \end{macrocode}
-%\begin{macro}{\paminute}
-%\begin{macro}{\parsecond}
-%\begin{macro}{\AstroE}
-%\begin{macro}{\oersted}
-%\begin{macro}{\ton}
-% \pkg{fancyunits} provides some extra units, plus tonne spelled
-% incorrectly (again).
+%
+%\begin{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}
-\newunit{\paminute}{'}
-\newunit{\parsecond}{''}
-\newunit{\AstroE}{AE}
-\newunit{\oersted}{OE}
-\provideunit{\ton}{t}
+\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}
-%\begin{macro}{\decaD}
-% An additional prefix.
-% \begin{macrocode}
-\let\decaD\decad
-% \end{macrocode}
%\end{macro}
-%\begin{macro}{\ufrac}
-%\begin{macro}{\Ufrac}
-%\begin{macro}{\UFrac}
-% The fractional unit macros need to be reproduced.
-% \begin{macrocode}
-\newcommand*{\ufrac}[2]{%
- \si[stickyper,per=fraction,fraction=nice]{#1\si@per#2}}
-\newcommand*{\Ufrac}[2]{%
- \ensuremath{\textstyle{%
- \si[stickyper,per=fraction,fraction=frac]{#1\si@per#2}}}}
-\newcommand*{\UFrac}[2]{%
- \ensuremath{\displaystyle{%
- \si[stickyper,per=fraction,fraction=frac]{#1\si@per#2}}}}
-% \end{macrocode}
%\end{macro}
%\end{macro}
-%\end{macro}
-%\begin{macro}{\pow}
-% A slightly-shorted named \cs{power}.
-% \begin{macrocode}
-\let\pow\power
-% \end{macrocode}
-%\end{macro}
-%\begin{macro}{\Squaremetre}
-% An alias for \cs{squaremetre}.
+%\begin{macro}{\bit}
+%\begin{macro}{\byte}
+% Now the units.
% \begin{macrocode}
-\let\Squaremetre\squaremetre
+\DeclareSIUnit \bit { bit }
+\DeclareSIUnit \byte { B }
% \end{macrocode}
%\end{macro}
-% As with \SIunits, there is now a list of compound units to add.
-% Only a few are not covered by the \SIunits emulation.
+%\end{macro}
+%
% \begin{macrocode}
-\si@siu@newunit{Gray}{second}
-\si@siu@newunit[square]{Squaremetre}{metre}
-\si@siu@newunitx{Squaremetre}{newtonsecond}{\Square\metre}
- {\newton\second}
-\si@siu@newunit{Squaremetre}{second}
-\si@siu@newunit[square]{Squaremetre}{squaresecond}
-\si@siu@newunit{Squaremetre}{kilogram}
-\si@siu@newunit[cubic]{Squaremetre}{second}
-% \end{macrocode}
-%\iffalse
-%</fancyunits>
-%\fi
+%</binary>
+% \end{macrocode}
%
-%\Finale
-%\iffalse
-%<*refs>
-@misc{BIPM:EN,
- note = {\url{http://www.bipm.org/en/si/}},
-}
-
-@misc{BIPM:FR,
- note = {\url{http://www.bipm.org/fr/si/}},
-}
-
-@misc{BIPM:PDF,
- note = {\url{http://www.bipm.org/en/si/si_brochure/}},
-}
-
-@misc{Eijkhout,
- author = {Victor Eijkhout},
- note = {\url{http://www.eijkhout.net/tbt/}},
- title = {{\TeX} by {T}opic},
- year = {2007},
-}
-
-@misc{fancyunits,
- author = {Heiko Bauke},
- note = {\url{http://www.mpi-hd.mpg.de/personalhomes/bauke/LaTeX/Tips_und_Tricks/fancyunits/index.php}},
- title = {\pkg{fancyunits}},
- year = 2007,
-}
-
-@misc{IUPAC,
- note = {\url{http://old.iupac.org/publications/books/gbook/green_book_2ed.pdf}},
- title = {The \textsc{iupac} {G}reen {B}ook},
- year = 1993,
-}
-
-@misc{NIST,
- note = {\url{http://physics.nist.gov/cuu/Units/index.html}},
-}
-%</refs>
-%<*jawltxdoc>
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{jawltxdoc}
-\usepackage[T1]{fontenc}
-\usepackage{lmodern}
-\usepackage[final]{listings,graphicx,microtype}
-\usepackage[scaled=0.95]{helvet}
-\usepackage[osf]{mathpazo}
-\usepackage{booktabs,array,url,courier,xspace,varioref}
-\usepackage{upgreek,ifpdf,float,caption,longtable,babel}
-\begingroup
- \@ifundefined{eTeXversion}
- {\aftergroup\@gobble}
- {\aftergroup\@firstofone}
-\endgroup
-{\usepackage{etoolbox}}
-\floatstyle{plaintop}
-\restylefloat{table}
-\labelformat{figure}{\figurename~#1}
-\labelformat{table}{\tablename~#1}
-\IfFileExists{\jobname.sty}
- {\usepackage{\jobname}}{}
-\usepackage[numbered]{hypdoc}
-\setcounter{IndexColumns}{2}
-\newlength\LaTeXwidth
-\newlength\LaTeXoutdent
-\newlength\LaTeXgap
-\setlength\LaTeXgap{1em}
-\setlength\LaTeXoutdent{-0.15\textwidth}
-\newbox\lst@samplebox
-\edef\LaTeXexamplefile{\jobname.tmp}
-\lst@RequireAspects{writefile}
-\lstnewenvironment{LaTeXexample}[1][example]{%
- \global\let\lst@intname\@empty
- \ifcsname LaTeXcode#1\endcsname
- \expandafter\let\expandafter\LaTeXcode
- \csname LaTeXcode#1\endcsname
- \expandafter\let\expandafter\LaTeXcodeend
- \csname LaTeXcode#1end\endcsname
- \else
- \PackageError{jawltxdoc}
- {Undefined example type `#1'}
- \@ehd
- \let\LaTeXcode\relax
- \let\LaTeXcodeend\relax
- \fi
- \LaTeXcode}
- {\lst@EndWriteFile
- \LaTeXcodeend}
-\newcommand*{\LaTeXcodeexample}{%
- \setbox\lst@samplebox=\hbox\bgroup
- \LaTeXcodefloat}
-\let\LaTeXcoderesultonly\LaTeXcodeexample
-\newcommand*{\LaTeXcodeexampleend}{%
- \egroup
- \setlength\LaTeXwidth{\wd\lst@samplebox}%
- \begin{list}{}{%
- \setlength\itemindent{0pt}
- \setlength\leftmargin\LaTeXoutdent
- \setlength\rightmargin{0pt}}%
- \item
- \setlength\LaTeXoutdent{-0.15\textwidth}
- \begin{minipage}[c]{%
- \textwidth-\LaTeXwidth-\LaTeXoutdent-\LaTeXgap}
- \LaTeXcodefloatend
- \end{minipage}%
- \hfill
- \begin{minipage}[c]{\LaTeXwidth}%
- \hbox to\linewidth{\box\lst@samplebox\hss}%
- \end{minipage}%
- \end{list}}
-\newcommand*{\LaTeXcodefloat}{%
- \setkeys{lst}{tabsize=4,gobble=3,breakindent=0pt,
- basicstyle=\small\ttfamily,basewidth=0.51em,
- keywordstyle=\color{blue}}%
- \lst@BeginAlsoWriteFile{\LaTeXexamplefile}}
-\let\LaTeXcodenoexample\LaTeXcodefloat
-\let\LaTeXcodenoexampleend\@empty
-\newcommand*{\LaTeXcodefloatend}{%
- \MakePercentComment\catcode`\^^M=10\relax
- \small
- {\setkeys{lst}{SelectCharTable=\lst@ReplaceInput{\^\^I}%
- {\lst@ProcessTabulator}}%
- \leavevmode \input{\LaTeXexamplefile}}%
- \MakePercentIgnore}
-\newcommand*{\LaTeXcoderesultonlyend}{\egroup\LaTeXcodefloatend}
-\lstnewenvironment{BibTeXexample}{%
- \global\let\lst@intname\@empty
- \setbox\lst@samplebox=\hbox\bgroup
- \setkeys{lst}{tabsize=4,gobble=3,breakindent=0pt,
- basicstyle=\small\ttfamily,basewidth=0.51em,
- keywordstyle=\color{black}}
- \lst@BeginAlsoWriteFile{\LaTeXexamplefile}}
- {\lst@EndWriteFile
- \LaTeXcodeexampleend}
-\newcommand*{\DescribeOption}{%
- \leavevmode\@bsphack\begingroup\MakePrivateLetters
- \Describe@Option}
-\newcommand*{\Describe@Option}[1]{\endgroup
- \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
- \SpecialOptionIndex{#1}\@esphack\ignorespaces}
-\newcommand*{\SpecialOptionIndex}[1]{\@bsphack
- \index{#1\actualchar{\protect\ttfamily#1}
- (option)\encapchar usage}%
- \index{options:\levelchar#1\actualchar{\protect\ttfamily#1}%
- \encapchar usage}\@esphack}
-\newcommand*{\indexopt}[1]{\DescribeOption{#1}\opt{#1}}
-\newcommand*{\DescribeOptionInfo}[2]{%
- \DescribeOption{#1}%
- \opt{#1=\meta{#2}}\xspace}
-\newcommand*{\ofixarg}[1]{%
- {\ttfamily[}%
- \ifmmode \expandafter \nfss@text \fi
- {%
- \meta@font@select
- \edef\meta@hyphen@restore{%
- \hyphenchar\the\font\the\hyphenchar\font}%
- \hyphenchar\font\m@ne
- \language\l@nohyphenation
- #1\/%
- \meta@hyphen@restore
- }%
- {\ttfamily]}}
-\newcommand*{\pkg}[1]{\textsf{#1}}
-\newcommand*{\currpkg}{\pkg{\jobname}\xspace}
-\newcommand*{\opt}[1]{\texttt{#1}}
-\newcommand*{\defaultopt}[1]{\opt{\textbf{#1}}}
-\newcommand*{\file}[1]{\texttt{#1}}
-\newcommand*{\ext}[1]{\file{.#1}}
-\newcommand*{\latin}[1]{\emph{#1}}
-\newcommand*{\etc}{%
- \@ifnextchar.
- {\latin{etc}}
- {\latin{etc}.\xspace}}
-\newcommand*{\eg}{%
- \@ifnextchar.
- {\latin{e.g}}
- {\latin{e.g}.\xspace}}
-\newcommand*{\ie}{%
- \@ifnextchar.
- {\latin{i.e}}
- {\latin{i.e}.\xspace}}
-\newcommand*{\etal}{%
- \@ifnextchar.
- {\latin{et~al.}}
- {\latin{et~al}.\xspace}}
-\newcommand*{\AMS}{{\protect\usefont{OMS}{cmsy}{m}{n}%
- A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
-\providecommand*{\eTeX}{\ensuremath{\varepsilon}-\TeX}
-\DeclareRobustCommand*{\XeTeX}
- {X\kern-.125em\lower.5ex\hbox{\reflectbox{E}}\kern-.1667em\TeX}
-\providecommand*{\CTAN}{\textsc{ctan}}
-\@ifpackageloaded{etoolbox}
- {\patchcmd{\@addmarginpar}
- {\@latex@warning@no@line {Marginpar on page \thepage\space moved}}
- {\relax}{}{}}
- {}
-\newcounter{argument}
-\g@addto@macro\endmacro{\setcounter{argument}{0}}
-\newcommand*\darg[1]{%
- \stepcounter{argument}%
- {\ttfamily\char`\#\theargument~:~}#1\par\noindent\ignorespaces}
-\newcommand*\doarg[1]{%
- \stepcounter{argument}%
- {\ttfamily\makebox[0pt][r]{[}%
- \char`\#\theargument]:~}#1\par\noindent\ignorespaces}
-%</jawltxdoc>
-%\fi
+%\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}.
+%
+%\end{thebibliography}
+%
+%\PrintChanges
+%
+%\PrintIndex \ No newline at end of file
diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.ins b/Master/texmf-dist/source/latex/siunitx/siunitx.ins
index 7b9ed834e45..e6388ab7554 100644
--- a/Master/texmf-dist/source/latex/siunitx/siunitx.ins
+++ b/Master/texmf-dist/source/latex/siunitx/siunitx.ins
@@ -43,11 +43,8 @@ This work is "maintained" (as per LPPL maintenance status) by
This work consists of the file siunitx.dtx
and the derived files siunitx.pdf,
- siunitx.sty
- siunitx.bib,
- siunitx.ins,
- siunitx-bug.tex and
- various .cfg files.
+ siunitx.sty and
+ siunitx.ins.
\endpostamble
\usedir{tex/latex/siunitx}
@@ -55,33 +52,11 @@ This work consists of the file siunitx.dtx
\file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
\usedir{tex/latex/siunitx/config}
-\generate{\file{si-SIunits.cfg}{\from{\jobname.dtx}{SIunits}}
- \file{si-sistyle.cfg}{\from{\jobname.dtx}{sistyle}}
- \file{si-unitsdef.cfg}{\from{\jobname.dtx}{unitsdef}}
- \file{si-units.cfg}{\from{\jobname.dtx}{units}}
- \file{si-hepunits.cfg}{\from{\jobname.dtx}{hepunits}}
- \file{si-fancynum.cfg}{\from{\jobname.dtx}{fancynum}}
- \file{si-fancyunits.cfg}{\from{\jobname.dtx}{fancyunits}}
-}
-\generate{\file{si-prefix.cfg}{\from{\jobname.dtx}{prefix}}
- \file{si-named.cfg}{\from{\jobname.dtx}{named}}
- \file{si-prefixed.cfg}{\from{\jobname.dtx}{prefixed}}
- \file{si-addn.cfg}{\from{\jobname.dtx}{addn}}
- \file{si-accepted.cfg}{\from{\jobname.dtx}{accepted}}
- \file{si-physical.cfg}{\from{\jobname.dtx}{physical}}
- \file{si-abbr.cfg}{\from{\jobname.dtx}{abbr}}
-}
-\generate{\file{si-synchem.cfg}{\from{\jobname.dtx}{synchem}}
- \file{si-hep.cfg}{\from{\jobname.dtx}{hep}}
- \file{si-astro.cfg}{\from{\jobname.dtx}{astro}}
- \file{si-geophys.cfg}{\from{\jobname.dtx}{geophys}}
- \file{si-chemeng.cfg}{\from{\jobname.dtx}{chemeng}}
- \file{si-binary.cfg}{\from{\jobname.dtx}{binary}}
-}
-\generate{\file{si-UK.cfg}{\from{\jobname.dtx}{UK}}
- \file{si-USA.cfg}{\from{\jobname.dtx}{USA}}
- \file{si-DE.cfg}{\from{\jobname.dtx}{DE}}
- \file{si-ZA.cfg}{\from{\jobname.dtx}{ZA}}
+\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}}
}
\endbatchfile
%%
@@ -100,11 +75,8 @@ This work consists of the file siunitx.dtx
%%
%% This work consists of the file siunitx.dtx
%% and the derived files siunitx.pdf,
-%% siunitx.sty
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
+%% siunitx.sty and
+%% siunitx.ins.
%%
%%
%% End of file `siunitx.ins'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-DE.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-DE.cfg
deleted file mode 100644
index 7c233a15ba3..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-DE.cfg
+++ /dev/null
@@ -1,49 +0,0 @@
-%%
-%% This is file `si-DE.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `DE')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-DE.cfg}
- [2010/02/22 v1.4c siunitx: Germany locale]
-\sisetup{
- unitsep=cdot,
- valuesep=thin,
- decimalsymbol=comma,
- expproduct=cdot,
- digitsep=thin,
- sepfour=false,
- tophrase={{ bis }}}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-DE.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-SIunits.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-SIunits.cfg
deleted file mode 100644
index d8d97003060..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-SIunits.cfg
+++ /dev/null
@@ -1,346 +0,0 @@
-%%
-%% This is file `si-SIunits.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `SIunits')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-SIunits.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- SIunits]
-\si@emulating{SIunits}{2007/12/02 v1.36}
-\sisetup{
- unitsep=thick,
- valuesep=thick,
- prefixproduct=\si@valuesep,
- trapambigfrac=false,
- stickyper}
-\requiresiconfigs{prefix,named,accepted,physical}
-\newcommand*{\reciprocal}{\sisetup{per=reciprocal}\si@per}
-\let\rp\reciprocal
-\renewcommand*{\per}{\sisetup{per=slash}\si@per}
-\newcommand*{\usk}{}
-\newcommand*{\power}[1]{#1\tothe}
-\newcommand*{\rpsquare}{\sisetup{per=reciprocal}\si@per\Square}
-\newcommand*{\rpcubic}{\sisetup{per=reciprocal}\si@per\cubic}
-\newpower{\fourth}{4}
-\newcommand*{\rpfourth}{\sisetup{per=reciprocal}\si@per\fourth}
-\newcommand*{\rpsquared}{%
- \sisetup{per=reciprocal}\si@unt@pertrue\si@unt@perseentrue%
- \squared}
-\newcommand*{\rpcubed}{%
- \sisetup{per=reciprocal}\si@unt@pertrue\cubed}
-\newcommand*{\SIsetup}[1]{%
- \@for\si@tempa:=#1\do{%
- \@ifundefined{ifsi@old@#1}
- {\si@log@warn{Unknown SIunits option `#1'}}
- {\csname si@old@#1true\endcsname}}
- \si@siu@setup}
-\newcommand*{\si@siu@setup}{%
- \ifsi@old@cdot
- \sisetup{unitsep=cdot}%
- \fi
- \ifsi@old@thickspace
- \sisetup{unitsep=thick}%
- \fi
- \ifsi@old@mediumspace
- \sisetup{unitsep=medium}%
- \fi
- \ifsi@old@thinspace
- \sisetup{unitsep=thin}%
- \fi
- \ifsi@old@thickqspace
- \sisetup{valuesep=thick}%
- \fi
- \ifsi@old@mediumqspace
- \sisetup{valuesep=medium}%
- \fi
- \ifsi@old@thinqspace
- \sisetup{valuesep=thin}%
- \fi}
-\si@siu@setup
-\ifsi@old@squaren
- \newpower{\squaren}{2}
-\fi
-\AtBeginDocument{%
- \@ifundefined{square}
- {\newpower{\square}{2}}
- {\ifsi@old@amssymb
- \renewpower{\square}{2}
- \else
- \ifsi@old@squaren\else
- \si@log@warn{\string\square\space already
- defined\MessageBreak SIunits mode may cause
- errors}%
- \fi
- \fi}}
-\AtBeginDocument{
- \@ifundefined{gray}
- {\newunit{\gray}{Gy}}
- {\ifsi@old@pstricks
- \renewunit{\gray}{Gy}
- \else
- \ifsi@old@Gray\else
- \si@log@warn{\string\gray\space already
- defined\MessageBreak SIunits mode may cause
- errors}%
- \fi
- \fi}}
-\ifsi@old@italian
- \let\unita\SI
-\else
- \let\unit\SI
-\fi
-\ifsi@old@textstyle
- \sisetup{mode=text}
-\fi
-\ifsi@old@binary
- \sisetup{alsoload=binary}
-\fi
-\newunit[valuesep=none]{\arcminute}{\si@sym@minute}
-\newunit[valuesep=none]{\arcsecond}{\si@sym@second}
-\newunit{\rperminute}{r/min}
-\newunit{\ton}{t}
-\newunit{\degreecelsius}{\celsius}
-\let\addunit\newunit
-\newcommand*{\addprefix}[2]{\newprefix{#1}{#2}}
-\newcommand*{\si@siu@newunit}[3][]{%
- \renewcommand*{\si@tempa}{#1}%
- \renewcommand*{\si@tempb}{square}%
- \def\si@siu@power{}%
- \ifx\@empty\si@tempa\@empty\else
- \ifx\si@tempa\si@tempb
- \renewcommand*{\si@siu@power}{\ssquare}%
- \else
- \edef\si@siu@power{%
- \expandafter\noexpand\csname #1\endcsname}%
- \fi
- \fi
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3\endcsname}%
- \edef\si@tempb{%
- \expandafter\noexpand\csname #2\endcsname\noexpand\per
- \expandafter\noexpand\si@siu@power
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter%
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempb}
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3np\endcsname}%
- \edef\si@tempb{%
- \expandafter\noexpand\csname #2\endcsname\noexpand
- \reciprocal\expandafter\noexpand\si@siu@power
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempb}%
- \si@siu@newunithook[#1]{#2}{#3}}
-\providecommand*{\si@siu@newunithook}[3][]{}
-\si@siu@newunit{gray}{second}
-\si@siu@newunit[square]{metre}{second}
-\si@siu@newunit{joule}{mole}
-\si@siu@newunit[cubic]{mole}{metre}
-\si@siu@newunit[square]{radian}{second}
-\si@siu@newunit{radian}{second}
-\si@siu@newunit[cubic]{squaremetre}{metre}
-\si@siu@newunit[cubic]{katal}{metre}
-\si@siu@newunit{coulomb}{mol}
-\si@siu@newunit[square]{ampere}{metre}
-\si@siu@newunit[cubic]{kilogram}{metre}
-\si@siu@newunit[cubic]{coulomb}{metre}
-\si@siu@newunit{volt}{metre}
-\si@siu@newunit[square]{coulomb}{squaremetre}
-\si@siu@newunit{farad}{metre}
-\si@siu@newunit[square]{watt}{metre}
-\si@siu@newunit[square]{joule}{metre}
-\si@siu@newunit[cubic]{newton}{metre}
-\si@siu@newunit{newton}{kilogram}
-\si@siu@newunit{joule}{kelvin}
-\si@siu@newunit{joule}{kilogram}
-\si@siu@newunit{coulomb}{kilogram}
-\si@siu@newunit{squaremetre}{second}
-\si@siu@newunit[square]{squaremetre}{second}
-\si@siu@newunit[square]{candela}{metre}
-\si@siu@newunit{ampere}{metre}
-\si@siu@newunit{joule}{tesla}
-\si@siu@newunit{henry}{metre}
-\si@siu@newunit{kilogram}{second}
-\si@siu@newunit[square]{kilogram}{metre}
-\si@siu@newunit{kilogram}{metre}
-\si@siu@newunit[square]{newton}{metre}
-\si@siu@newunit{watt}{kilogram}
-\si@siu@newunit[cubic]{watt}{metre}
-\si@siu@newunit{squaremetre}{kilogram}
-\si@siu@newunit{cubicmetre}{kilogram}
-\si@siu@newunit{newton}{metre}
-\si@siu@newunit[cubic]{squaremetre}{second}
-\si@siu@newunit{metre}{second}
-\si@siu@newunit[cubic]{joule}{metre}
-\si@siu@newunit{cubicmetre}{second}
-\newcommand*{\si@siu@newunitx}[4]{%
- \expandafter\newunit\expandafter{\csname #1per#2\endcsname}
- {#3\per#4}%
- \expandafter\newunit\expandafter{\csname #1per#2np\endcsname}
- {#3\reciprocal#4}
- \si@siu@newunitxhook{#1}{#2}{#3}{#4}}
-\providecommand*{\si@siu@newunitxhook}[4]{}
-\si@siu@newunitx{kilogramsquaremetre}{second}
- {\kilogram\squaremetre}{\second}
-\si@siu@newunitx{squaremetre}{newtonsecond}{\squaremetre}
- {\newton\second}
-\si@siu@newunitx{kilogrammetre}{second}{\kilogram\metre}
- {\second}
-\si@siu@newunitx{kilogram}{squaremetresecond}{\kilogram}
- {\squaremetre\second}
-\si@siu@newunitx{joule}{molekelvin}{\joule}{\mole\kelvin}
-\si@siu@newunitx{kilogram}{kilomole}{\kilogram}{\kilo\mole}
-\si@siu@newunitx{kilogrammetre}{squaresecond}{\kilogram\metre}
- {\second\squared}
-\si@siu@newunitx{watt}{squaremetresteradian}{\watt}
- {\squaremetre\steradian}
-\si@siu@newunitx{joule}{kilogramkelvin}{\joule}
- {\kilogram\kelvin}
-\si@siu@newunitx{watt}{metrekelvin}{\watt}{\metre\kelvin}
-\si@siu@newunitx{kilogram}{cubicmetrecoulomb}{\kilogram}
- {\cubic\metre\coulomb}
-\si@siu@newunitx{kilogram}{secondcubicmetre}{\kilogram}
- {\second\cubicmetre}
-\newunit{\si@siu@unity}{1}
-\si@siu@newunitx{}{squaremetresecond}{\si@siu@unity}
- {\squaremetre\second}
-\newunit{\pascalsecond}{\pascal\second}
-\newunit{\amperemetresecond}{\ampere\metre\second}
-\newunit{\ohmmetre}{\ohm\metre}
-\newunit{\newtonmetre}{\newton\metre}
-\let\newtonmetrenp\newtonmetre
-\newunit{\kilogramsquaremetre}{\kilogram\squaremetre}
-\let\kilogramsquaremetrenp\kilogramsquaremetre
-\newcommand*{\si@siu@newprefix}[1]{%
- \edef\si@tempa{\expandafter\noexpand\csname #1d\endcsname}%
- \edef\si@tempb{\expandafter\noexpand\csname #1\endcsname}%
- \expandafter\expandafter\expandafter\newcommand\expandafter
- \expandafter\expandafter*\expandafter\expandafter
- \expandafter{\expandafter\si@tempa\expandafter}\expandafter
- {\expandafter\si@prefixsymbolicfalse\si@tempb}}
-\si@siu@newprefix{yocto}
-\si@siu@newprefix{zepto}
-\si@siu@newprefix{atto}
-\si@siu@newprefix{femto}
-\si@siu@newprefix{pico}
-\si@siu@newprefix{nano}
-\si@siu@newprefix{micro}
-\si@siu@newprefix{milli}
-\si@siu@newprefix{centi}
-\si@siu@newprefix{deca}
-\si@siu@newprefix{deka}
-\si@siu@newprefix{hecto}
-\si@siu@newprefix{kilo}
-\si@siu@newprefix{mega}
-\si@siu@newprefix{giga}
-\si@siu@newprefix{tera}
-\si@siu@newprefix{peta}
-\si@siu@newprefix{exa}
-\si@siu@newprefix{zetta}
-\si@siu@newprefix{yotta}
-\ifsi@old@binary
- \si@siu@newprefix{kibi}
- \si@siu@newprefix{mebi}
- \si@siu@newprefix{gibi}
- \si@siu@newprefix{tebi}
- \si@siu@newprefix{pebi}
- \si@siu@newprefix{exbi}
-\fi
-\ifsi@old@derived
- \newunit{\derradian}{\metre\reciprocal\metre}
- \newunit{\dersteradian}{\squaremetre\rpsquare\metre}
- \newunit{\derhertz}{\reciprocal\second}
- \newunit{\dernewton}{\metre\kilogram\second\rpsquared}
- \newunit{\derpascal}{\newton\rpsquare\metre}
- \newunit{\derjoule}{\newton\metre}
- \newunit{\derwatt}{\joule\reciprocal\second}
- \newunit{\dercoulomb}{\ampere\second}
- \newunit{\dervolt}{\watt\reciprocal\ampere}
- \newunit{\derfarad}{\coulomb\reciprocal\volt}
- \newunit{\derohm}{\volt\reciprocal\ampere}
- \newunit{\dersiemens}{\ampere\reciprocal\volt}
- \newunit{\derweber}
- {\squaremetre\kilogram\second\rpsquared\reciprocal\ampere}
- \newunit{\dertesla}{\weber\rpsquare\metre}
- \newunit{\derhenry}{\weber\reciprocal\ampere}
- \newunit{\dercelsius}{\kelvin}
- \newunit{\derlumen}{\candela\steradian}
- \newunit{\derlux}{\lumen\rpsquare\metre}
- \newunit{\derbecquerel}{\derhertz}
- \newunit{\dergray}{\joule\reciprocal\kilogram}
- \newunit{\dersievert}{\dergray}
- \newunit{\derkatal}{\rp\second\usk\mole}
-\fi
-\ifsi@old@derivedinbase
- \newunit{\radianbase}{\metre\reciprocal\metre}
- \newunit{\steradianbase}{\squaremetre\rpsquare\metre}
- \newunit{\hertzbase}{\reciprocal\second}
- \newunit{\newtonbase}{\metre\kilogram\second\rpsquared}
- \newunit{\pascalbase}{\reciprocal\metre\kilogram\second%
- \rpsquared}
- \newunit{\joulebase}{\squaremetre\kilogram\second\rpsquared}
- \newunit{\wattbase}{\squaremetre\kilogram\rpcubic\second}
- \newunit{\coulombbase}{\ampere\second}
- \newunit{\voltbase}
- {\squaremetre\kilogram\rpcubic\second\reciprocal\ampere}
- \newunit{\faradbase}
- {\rpsquare\metre\reciprocal\kilogram\fourth\second\ampere%
- \squared}
- \newunit{\ohmbase}
- {\squaremetre\kilogram\rpcubic\second\rpsquare\ampere}
- \newunit{\siemensbase}
- {\rpsquare\metre\reciprocal\kilogram\cubic\second\ampere%
- \squared}
- \newunit{\weberbase}
- {\squaremetre\kilogram\second\rpsquared\reciprocal\ampere}
- \newunit{\teslabase}{\kilogram\second\rpsquared\reciprocal%
- \ampere}
- \newunit{\henrybase}
- {\squaremetre\kilogram\second\rpsquared\rpsquare\ampere}
- \newunit{\celsiusbase}{\kelvin}
- \newunit{\lumenbase}{\candela\squaremetre\rpsquare\metre}
- \newunit{\luxbase}{\candela\squaremetre\rpfourth\metre}
- \newunit{\becquerelbase}{\hertzbase}
- \newunit{\graybase}{\squaremetre\second\rpsquared}
- \newunit{\sievertbase}{\graybase}
- \newunit{\katalbase}{\rp\second\mole}
-\fi
-\InputIfFileExists{SIunits.cfg}
- {\si@log@inf{SIunits config file loaded}}
- {\si@log@inf{SIunits config file not found}}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-SIunits.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-UK.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-UK.cfg
deleted file mode 100644
index a750691c66f..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-UK.cfg
+++ /dev/null
@@ -1,49 +0,0 @@
-%%
-%% This is file `si-UK.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `UK')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-UK.cfg}
- [2010/02/22 v1.4c siunitx: UK locale]
-\sisetup{
- unitsep=thin,
- expproduct=times,
- valuesep=thin,
- decimalsymbol=fullstop,
- digitsep=thin,
- sepfour=false,
- tophrase={{ to }}}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-UK.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-ZA.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-ZA.cfg
deleted file mode 100644
index d61cc8b02a6..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-ZA.cfg
+++ /dev/null
@@ -1,49 +0,0 @@
-%%
-%% This is file `si-ZA.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `ZA')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-ZA.cfg}
- [2010/02/22 v1.4c siunitx: South Africa locale]
-\sisetup{
- unitsep=cdot,
- valuesep=thin,
- expproduct=times,
- decimalsymbol=comma,
- digitsep=thin,
- sepfour=false,
- tophrase={{ to }}}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-ZA.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-abbr.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-abbr.cfg
deleted file mode 100644
index a4714d6c512..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-abbr.cfg
+++ /dev/null
@@ -1,98 +0,0 @@
-%%
-%% This is file `si-abbr.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `abbr')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-abbr.cfg}
- [2010/02/22 v1.4c siunitx: Abbreviated units]
-\requiresiconfigs{prefix,named,accepted,physical}
-\newunit{\pA}{\pico\ampere}
-\newunit{\nA}{\nano\ampere}
-\newunit{\micA}{\micro\ampere}
-\newunit{\mA}{\milli\ampere}
-\newunit{\kA}{\kilo\ampere}
-\newunit{\Hz}{\hertz}
-\newunit{\mHz}{\milli\hertz}
-\newunit{\kHz}{\kilo\hertz}
-\newunit{\MHz}{\mega\hertz}
-\newunit{\GHz}{\giga\hertz}
-\newunit{\THz}{\tera\hertz}
-\newunit{\fmol}{\femto\mole}
-\newunit{\pmol}{\pico\mole}
-\newunit{\nmol}{\nano\mole}
-\newunit{\micmol}{\micro\mole}
-\newunit{\mmol}{\milli\mole}
-\newunit{\kmol}{\kilo\mole}
-\newunit{\kV}{\kilo\volt}
-\newunit{\mV}{\milli\volt}
-\provideunit{\ml}{\milli\litre}
-\provideunit{\micl}{\micro\litre}
-\provideunit{\mL}{\milli\liter}
-\provideunit{\micL}{\micro\liter}
-\newunit{\cmc}{\centi\metre\cubed}
-\newunit{\dmc}{\deci\metre\cubed}
-\newunit{\cms}{\centi\metre\squared}
-\newunit{\kg}{\kilo\gram}
-\AtBeginDocument{\provideunit{\fg}{\femto\gram}}
-\newunit{\SIfg}{\femto\gram}
-\newunit{\pg}{\pico\gram}
-\newunit{\nanog}{\nano\gram}
-\newunit{\micg}{\micro\gram}
-\newunit{\mg}{\milli\gram}
-\newunit{\amu}{\atomicmass}
-\newunit{\kJ}{\kilo\joule}
-\newunit{\eV}{\electronvolt}
-\newunit{\meV}{\milli\electronvolt}
-\newunit{\keV}{\kilo\electronvolt}
-\newunit{\MeV}{\mega\electronvolt}
-\newunit{\GeV}{\giga\electronvolt}
-\newunit{\TeV}{\tera\electronvolt}
-\newunit[unitsep=none]{\kWh}{\kilo\watt\hour}
-\newunit{\picom}{\pico\metre}
-\newunit{\nm}{\nano\metre}
-\newunit{\micm}{\micro\metre}
-\newunit{\mm}{\milli\metre}
-\newunit{\cm}{\centi\metre}
-\newunit{\dm}{\deci\metre}
-\newunit{\km}{\kilo\metre}
-\newunit{\Sec}{\second}
-\newunit{\as}{\atto\second}
-\newunit{\fs}{\femto\second}
-\provideunit{\ps}{\pico\second}
-\newunit{\ns}{\nano\second}
-\newunit{\mics}{\micro\second}
-\newunit{\ms}{\milli\second}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-abbr.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-accepted.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-accepted.cfg
deleted file mode 100644
index 8492a1d6d0f..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-accepted.cfg
+++ /dev/null
@@ -1,64 +0,0 @@
-%%
-%% This is file `si-accepted.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `accepted')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-accepted.cfg}
- [2010/02/22 v1.4c siunitx: SI Accepted units]
-\newunit{\minute}{min}
-\newunit{\hour}{h}
-\newunit{\Day}{d}
-\newunit{\dday}{d}
-\ifsi@old@OHM
- \AtBeginDocument{
- \provideunit[valuesep=none]{\Degree}{\si@sym@degree}
- }
-\else
- \ifsi@gensymb\else
- \AtBeginDocument{
- \provideunit[valuesep=none]{\degree}{\si@sym@degree}
- }
- \fi
-\fi
-\newunit[valuesep=none]{\arcmin}{\si@sym@minute}
-\newunit[valuesep=none]{\arcsec}{\si@sym@second}
-\newunit{\litre}{l}
-\newunit{\liter}{L}
-\newunit{\tonne}{t}
-\newunit{\neper}{Np}
-\newunit{\bel}{B}
-\newunit{\percent}{\char37}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-accepted.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-addn.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-addn.cfg
deleted file mode 100644
index 12fa08637a4..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-addn.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-%%
-%% This is file `si-addn.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `addn')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-addn.cfg}
- [2010/02/22 v1.4c siunitx: SI Additional units]
-\provideunit{\angstrom}{\si@sym@ringA}
-\AtBeginDocument{%
- \ifdefined\Saveangstrom
- \def\Saveangstrom{\si@sym@ringA}%
- \def\SaveAngstrom{\si@sym@ringA}%
- \fi
-}
-\newunit{\are}{a}
-\newunit{\hectare}{\hecto\are}
-\newunit{\barn}{b}
-\newunit{\BAR}{bar}
-\newunit{\bbar}{bar}
-\newunit{\millibar}{\milli\BAR}
-\newunit{\gal}{Gal}
-\newunit{\curie}{Ci}
-\newunit{\roentgen}{R}
-\newunit{\rad}{rad}
-\provideunit{\rem}{rem}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-addn.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-astro.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-astro.cfg
deleted file mode 100644
index e5839f65994..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-astro.cfg
+++ /dev/null
@@ -1,43 +0,0 @@
-%%
-%% This is file `si-astro.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `astro')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-astro.cfg}
- [2010/02/22 v1.4c siunitx: Units for astronomy]
-\newunit{\parsec}{pc}
-\newunit{\lightyear}{ly}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-astro.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-binary.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-binary.cfg
deleted file mode 100644
index 3feb2cf0443..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-binary.cfg
+++ /dev/null
@@ -1,51 +0,0 @@
-%%
-%% This is file `si-binary.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `binary')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-binary.cfg}
- [2010/02/22 v1.4c siunitx: Binary units]
-\newprefix[binary]{\kibi}{10}{Ki}
-\newprefix[binary]{\mebi}{20}{Mi}
-\newprefix[binary]{\gibi}{30}{Gi}
-\newprefix[binary]{\tebi}{40}{Ti}
-\newprefix[binary]{\pebi}{50}{Pi}
-\newprefix[binary]{\exbi}{60}{Ei}
-\newprefix[binary]{\zebi}{70}{Zi}
-\newprefix[binary]{\yobi}{80}{Yi}
-\newunit{\bit}{bit}
-\newunit{\byte}{B}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-binary.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-chemeng.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-chemeng.cfg
deleted file mode 100644
index 620620bc0d9..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-chemeng.cfg
+++ /dev/null
@@ -1,44 +0,0 @@
-%%
-%% This is file `si-chemeng.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `chemeng')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-chemeng.cfg}
- [2010/02/22 v1.4c siunitx: Units for chemical engineering]
-\newunit{\gmol}{g\text{-}mol}
-\newunit{\kgmol}{kg\text{-}mol}
-\newunit{\lbmol}{lb\text{-}mol}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-chemeng.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-fancynum.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-fancynum.cfg
deleted file mode 100644
index f7a940ec760..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-fancynum.cfg
+++ /dev/null
@@ -1,69 +0,0 @@
-%%
-%% This is file `si-fancynum.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `fancynum')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-fancynum.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- fancynum]
-\si@emulating{fancynum}{2000/08/08 0.92}
-\sisetup{decimalsymbol=cdot,digitsep=comma}
-\let\fnum\num
-\newcommand*{\setfnumdsym}[1]{\sisetup{decimalsymbol={#1}}}
-\newcommand*{\setfnumgsym}[1]{\sisetup{digitsep={#1}}}
-\newcommand*{\setfnummsym}[1]{\sisetup{expproduct={#1}}}
-\ifsi@old@english
- \sisetup{decimalsymbol=cdot,digitsep=comma}
-\fi
-\ifsi@old@french
- \sisetup{decimalsymbol=comma,digitsep=fullstop}
-\fi
-\ifsi@old@tight
- \sisetup{expproduct=tighttimes}
-\fi
-\ifsi@old@loose
- \sisetup{expproduct=times}
-\fi
-\ifsi@old@thinspaces
- \sisetup{digitsep=thin}
-\fi
-\ifsi@old@commas
- \sisetup{digitsep=comma}
-\fi
-\ifsi@old@plain
- \sisetup{digitsep=none}
-\fi
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-fancynum.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-fancyunits.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-fancyunits.cfg
deleted file mode 100644
index 25d26baf616..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-fancyunits.cfg
+++ /dev/null
@@ -1,127 +0,0 @@
-%%
-%% This is file `si-fancyunits.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `fancyunits')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-fancyunits.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- fancyunits]
-\si@emulating{fancyunits}{2007/02/01 v1.0.1}
-\si@ifloaded{SIunits}
- {\si@log@err{SIunits emulation loaded\MessageBreak before
- fancyunits emulation}{You need to load the fancyunits
- emualtion\MessageBreak code before that for
- SIunits.\MessageBreak Try emulate=fancyunits as the first
- option when\MessageBreak loading siunitx}}{}
-\newcommand*{\si@siu@newunithook}[3][]{%
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3uf\endcsname}%
- \renewcommand*{\si@tempb}{stickyper,per=fraction,
- fraction=nice}%
- \edef\si@tempc{%
- \noexpand\sisetup{\si@tempb}%
- \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
- \expandafter\noexpand\si@siu@power%
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempc}%
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3Uf\endcsname}%
- \renewcommand*{\si@tempb}{stickyper,per=fraction,
- fraction=frac}%
- \edef\si@tempc{%
- \noexpand\sisetup{\si@tempb}%
- \noexpand\def\noexpand\si@frc@hook{\noexpand\textstyle}%
- \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
- \expandafter\noexpand\si@siu@power%
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempc}%
- \edef\si@tempa{%
- \expandafter\noexpand\csname #2per#1#3UF\endcsname}%
- \edef\si@tempc{%
- \noexpand\sisetup{\si@tempb}%
- \noexpand\def\noexpand\si@frc@hook{\noexpand\displaystyle}%
- \expandafter\noexpand\csname #2\endcsname\noexpand\si@per%
- \expandafter\noexpand\si@siu@power%
- \expandafter\noexpand\csname #3\endcsname}%
- \expandafter\expandafter\expandafter\newunit\expandafter
- \expandafter\expandafter{\expandafter\si@tempa\expandafter}%
- \expandafter{\si@tempc}}
-\newcommand*{\si@siu@newunitxhook}[4]{%
- \expandafter\newunit\expandafter{\csname #1per#2uf\endcsname}
- {\sisetup{stickyper,per=fraction,fraction=nice}%
- #3\si@per#4}%
- \expandafter\newunit\expandafter{\csname #1per#2Uf\endcsname}
- {\sisetup{stickyper,per=fraction,fraction=frac}%
- \renewcommand*{\si@frc@hook}{\textstyle}%
- #3\si@per#4}%
- \expandafter\newunit\expandafter{\csname #1per#2UF\endcsname}
- {\sisetup{stickyper,per=fraction,fraction=frac}%
- \renewcommand*{\si@frc@hook}{\displaystyle}%
- #3\si@per#4}}
-\requiresiconfigs{SIunits,addn,astro}
-\sisetup{obeyall}
-\ifsi@old@spaceqspace
- \sisetup{valuesep=space}
-\fi
-\newunit{\paminute}{'}
-\newunit{\parsecond}{''}
-\newunit{\AstroE}{AE}
-\newunit{\oersted}{OE}
-\provideunit{\ton}{t}
-\let\decaD\decad
-\newcommand*{\ufrac}[2]{%
- \si[stickyper,per=fraction,fraction=nice]{#1\si@per#2}}
-\newcommand*{\Ufrac}[2]{%
- \ensuremath{\textstyle{%
- \si[stickyper,per=fraction,fraction=frac]{#1\si@per#2}}}}
-\newcommand*{\UFrac}[2]{%
- \ensuremath{\displaystyle{%
- \si[stickyper,per=fraction,fraction=frac]{#1\si@per#2}}}}
-\let\pow\power
-\let\Squaremetre\squaremetre
-\si@siu@newunit{Gray}{second}
-\si@siu@newunit[square]{Squaremetre}{metre}
-\si@siu@newunitx{Squaremetre}{newtonsecond}{\Square\metre}
- {\newton\second}
-\si@siu@newunit{Squaremetre}{second}
-\si@siu@newunit[square]{Squaremetre}{squaresecond}
-\si@siu@newunit{Squaremetre}{kilogram}
-\si@siu@newunit[cubic]{Squaremetre}{second}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-fancyunits.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-geophys.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-geophys.cfg
deleted file mode 100644
index 8b62aa11907..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-geophys.cfg
+++ /dev/null
@@ -1,42 +0,0 @@
-%%
-%% This is file `si-geophys.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `geophys')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-geophys.cfg}
- [2010/02/22 v1.4c siunitx: Units for astronomy]
-\newunit{\gon}{gon}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-geophys.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-hep.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-hep.cfg
deleted file mode 100644
index 63c80359f3a..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-hep.cfg
+++ /dev/null
@@ -1,59 +0,0 @@
-%%
-%% This is file `si-hep.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `hep')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-hep.cfg}
- [2010/02/22 v1.4c siunitx: Units for high-energy physics]
-\requiresiconfigs{prefix,named}
-\provideunit{\micron}{\micro\metre}
-\newunit{\mrad}{\milli\rad}
-\newunit{\gauss}{G}
-\newunit{\clight}{\ensuremath{\mathnormal{c}}}
-\newunit{\eVperc}{\eV\per\clight}
-\newunit{\nanobarn}{\nano\barn}
-\newunit{\picobarn}{\pico\barn}
-\newunit{\femtobarn}{\femto\barn}
-\newunit{\attobarn}{\atto\barn}
-\newunit{\zeptobarn}{\zepto\barn}
-\newunit{\yoctobarn}{\yocto\barn}
-\provideunit{\nb}{\nano\barn}
-\provideunit{\pb}{\pico\barn}
-\provideunit{\fb}{\femto\barn}
-\provideunit{\ab}{\atto\barn}
-\provideunit{\zb}{\zepto\barn}
-\provideunit{\yb}{\yocto\barn}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-hep.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-hepunits.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-hepunits.cfg
deleted file mode 100644
index b6aa8527901..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-hepunits.cfg
+++ /dev/null
@@ -1,92 +0,0 @@
-%%
-%% This is file `si-hepunits.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `hepunits')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-hepunits.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- hepunits]
-\si@emulating{hepunits}{2007/09/27}
-\requiresiconfigs{SIunits,accepted,prefix,hep}
-\ifsi@old@noprefixcmds\else
- \newunit{\invbarn}{\per\barn}
- \newunit{\invnanobarn}{\per\nano\barn}
- \newunit{\invpicobarn}{\per\pico\barn}
- \newunit{\invfemtobarn}{\per\femto\barn}
- \newunit{\invattobarn}{\per\atto\barn}
- \newunit{\invzeptobarn}{\per\zepto\barn}
- \newunit{\invyoctobarn}{\per\yocto\barn}
- \newunit{\invnb}{\per\nano\barn}
- \newunit{\invpb}{\per\pico\barn}
- \newunit{\invfb}{\per\femto\barn}
- \newunit{\invab}{\per\atto\barn}
- \newunit{\invzb}{\per\zepto\barn}
- \newunit{\invyb}{\per\yocto\barn}
-\fi
-\newunit{\invcmsqpersecond}{\per\Square\centi\metre\per\second}
-\newunit{\invcmsqpersec}{\per\Square\centi\metre\per\second}
-\newunit{\lumiunits}{\per\Square\centi\metre\per\second}
-\newunit{\inveV}{\per\electronvolt}
-\newunit{\minveV}{\per\milli\electronvolt}
-\newunit{\kinveV}{\per\kilo\electronvolt}
-\newunit{\MinveV}{\per\mega\electronvolt}
-\newunit{\GinveV}{\per\giga\electronvolt}
-\newunit{\TinveV}{\per\tera\electronvolt}
-\newunit[per=slash,eVcorrb=0.6ex]{\eVoverc}
- {\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\eVovercsq}
- {\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\meVoverc}
- {\milli\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\keVoverc}
- {\kilo\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\MeVoverc}
- {\mega\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\GeVoverc}
- {\giga\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\TeVoverc}
- {\tera\electronvolt\per\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\meVovercsq}
- {\milli\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\keVovercsq}
- {\kilo\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\MeVovercsq}
- {\mega\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\GeVovercsq}
- {\giga\electronvolt\per\Square\clight}
-\newunit[per=slash,eVcorrb=0.6ex]{\TeVovercsq}
- {\tera\electronvolt\per\Square\clight}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-hepunits.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-named.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-named.cfg
deleted file mode 100644
index 0469bfd3144..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-named.cfg
+++ /dev/null
@@ -1,77 +0,0 @@
-%%
-%% This is file `si-named.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `named')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-named.cfg}
- [2010/02/22 v1.4c siunitx: SI Named units]
-\newunit{\becquerel}{Bq}
-\newunit{\coulomb}{C}
-\newunit{\farad}{F}
-\newunit{\Gray}{Gy}
-\newunit{\ggray}{Gy}
-\newunit{\hertz}{Hz}
-\newunit{\henry}{H}
-\newunit{\joule}{J}
-\newunit{\katal}{kat}
-\newunit{\lumen}{lm}
-\newunit{\lux}{lx}
-\newunit{\newton}{N}
-\ifsi@old@OHM
- \newunit{\Ohm}{\si@sym@Omega}
-\else
- \ifsi@gensymb\else
- \provideunit{\ohm}{\si@sym@Omega}
- \fi
-\fi
-\newunit{\pascal}{Pa}
-\newunit{\siemens}{S}
-\newunit{\sievert}{Sv}
-\newunit{\tesla}{T}
-\newunit{\volt}{V}
-\newunit{\watt}{W}
-\newunit{\weber}{Wb}
-\ifsi@old@OHM
- \newunit{\Celsius}{\si@sym@celsius}
-\else
- \ifsi@gensymb\else
- \newunit{\celsius}{\si@sym@celsius}
- \fi
-\fi
-\newunit\degreeCelsius{\si@sym@celsius}
-\newunit{\radian}{rad}
-\newunit{\steradian}{sr}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-named.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-physical.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-physical.cfg
deleted file mode 100644
index 79da81cf1ad..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-physical.cfg
+++ /dev/null
@@ -1,47 +0,0 @@
-%%
-%% This is file `si-physical.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `physical')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-physical.cfg}
- [2010/02/22 v1.4c siunitx: SI Physically-measured units]
-\newcommand*{\si@eVspacea}{\text{\kern-\si@eVcorra}}%
-\newcommand*{\si@eVspaceb}{\text{\kern-\si@eVcorrb}}%
-\newunit{\electronvolt}{e\protect\si@eVspacea V\protect%
- \si@eVspaceb}
-\newunit{\atomicmass}{u}
-\newunit{\atomicmassunit}{u}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-physical.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-prefix.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-prefix.cfg
deleted file mode 100644
index b006a92d2b2..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-prefix.cfg
+++ /dev/null
@@ -1,70 +0,0 @@
-%%
-%% This is file `si-prefix.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `prefix')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-prefix.cfg}
- [2010/02/22 v1.4c siunitx: SI Multiple prefixes]
-\newprefix{\yocto}{-24}{y}
-\newprefix{\zepto}{-21}{z}
-\newprefix{\atto}{-18}{a}
-\newprefix{\femto}{-15}{f}
-\newprefix{\pico}{-12}{p}
-\newprefix{\nano}{-9}{n}
-\ifsi@old@OHM
- \newprefix{\Micro}{-6}{\si@sym@mu}
-\else
- \ifsi@gensymb\else
- \newprefix{\micro}{-6}{\si@sym@mu}
- \fi
-\fi
-\newprefix{\milli}{-3}{m}
-\newprefix{\centi}{-2}{c}
-\newprefix{\deci}{-1}{d}
-\newprefix{\deca}{1}{da}
-\newprefix{\hecto}{2}{h}
-\newprefix{\kilo}{3}{k}
-\newprefix{\mega}{6}{M}
-\newprefix{\giga}{9}{G}
-\newprefix{\tera}{12}{T}
-\newprefix{\peta}{15}{P}
-\newprefix{\exa}{18}{E}
-\newprefix{\zetta}{21}{Z}
-\newprefix{\yotta}{24}{Y}
-\newprefix{\deka}{1}{da}
-\newunit{\gram}{g}
-\renewunit{\kilogram}{\kilo\gram}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-prefix.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-prefixed.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-prefixed.cfg
deleted file mode 100644
index a970a3ba2e5..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-prefixed.cfg
+++ /dev/null
@@ -1,126 +0,0 @@
-%%
-%% This is file `si-prefixed.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `prefixed')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-prefixed.cfg}
- [2010/02/22 v1.4c siunitx: SI Prefixed units]
-\requiresiconfigs{prefix,named,accepted,physical}
-\newunit{\picometre}{\pico\metre}
-\newunit{\nanometre}{\nano\metre}
-\newunit{\micrometre}{\micro\metre}
-\newunit{\millimetre}{\milli\metre}
-\newunit{\centimetre}{\centi\metre}
-\newunit{\decimetre}{\deci\metre}
-\newunit{\kilometre}{\kilo\metre}
-\newunit{\femtogram}{\femto\gram}
-\newunit{\picogram}{\pico\gram}
-\newunit{\nanogram}{\nano\gram}
-\newunit{\microgram}{\micro\gram}
-\newunit{\milligram}{\milli\gram}
-\newunit{\femtomole}{\femto\mole}
-\newunit{\picomole}{\pico\mole}
-\newunit{\nanomole}{\nano\mole}
-\newunit{\micromole}{\micro\mole}
-\newunit{\millimole}{\milli\mole}
-\newunit{\kilomole}{\kilo\mole}
-\newunit{\attosecond}{\atto\second}
-\newunit{\femtosecond}{\femto\second}
-\newunit{\picosecond}{\pico\second}
-\newunit{\nanosecond}{\nano\second}
-\newunit{\microsecond}{\micro\second}
-\newunit{\millisecond}{\milli\second}
-\newunit{\picoampere}{\pico\ampere}
-\newunit{\nanoampere}{\nano\ampere}
-\newunit{\microampere}{\micro\ampere}
-\newunit{\milliampere}{\milli\ampere}
-\newunit{\kiloampere}{\kilo\ampere}
-\newunit{\millivolt}{\milli\volt}
-\newunit{\kilovolt}{\kilo\volt}
-\newunit{\milliwatt}{\milli\watt}
-\newunit{\kilowatt}{\kilo\watt}
-\newunit{\megawatt}{\mega\watt}
-\newunit{\femtofarad}{\femto\farad}
-\newunit{\picofarad}{\pico\farad}
-\newunit{\nanofarad}{\nano\farad}
-\newunit{\microfarad}{\micro\farad}
-\newunit{\millifarad}{\milli\farad}
-\newunit{\millisiemens}{\milli\siemens}
-\ifsi@old@OHM
- \newunit{\kilohm}{\kilo\Ohm}
- \newunit{\megohm}{\mega\Ohm}
- \newunit{\gigaohm}{\giga\Ohm}
-\else
- \ifsi@gensymb\else
- \newunit{\kilohm}{\kilo\ohm}
- \newunit{\megohm}{\mega\ohm}
- \newunit{\gigaohm}{\giga\ohm}
- \fi
-\fi
-\newunit{\microlitre}{\micro\litre}
-\newunit{\millilitre}{\milli\litre}
-\newunit{\microliter}{\micro\liter}
-\newunit{\milliliter}{\milli\liter}
-\newunit{\cubicmetre}{\metre\cubed}
-\newunit{\cubiccentimetre}{\centi\metre\cubed}
-\newunit{\centimetrecubed}{\centi\metre\cubed}
-\newunit{\cubicmicrometre}{\micro\metre\cubed}
-\newunit{\cubicmillimetre}{\milli\metre\cubed}
-\newunit{\cubicdecimetre}{\cubic\deci\metre}
-\newunit{\squaremetre}{\Square\metre}
-\newunit{\squarecentimetre}{\Square\centi\metre}
-\newunit{\centimetresquared}{\centi\metre\squared}
-\newunit{\squarekilometre}{\Square\kilo\metre}
-\newunit{\millijoule}{\milli\joule}
-\newunit{\kilojoule}{\kilo\joule}
-\newunit{\megajoule}{\mega\joule}
-\newunit{\millielectronvolt}{\milli\electronvolt}
-\newunit{\kiloelectronvolt}{\kilo\electronvolt}
-\newunit{\megaelectronvolt}{\mega\electronvolt}
-\newunit{\gigaelectronvolt}{\giga\electronvolt}
-\newunit{\teraelectronvolt}{\tera\electronvolt}
-\newunit[unitsep=none]{\kilowatthour}{\kilo\watt\hour}
-\newunit{\millihertz}{\milli\hertz}
-\newunit{\kilohertz}{\kilo\hertz}
-\newunit{\megahertz}{\mega\hertz}
-\newunit{\gigahertz}{\giga\hertz}
-\newunit{\terahertz}{\tera\hertz}
-\newunit{\millinewton}{\milli\newton}
-\newunit{\kilonewton}{\kilo\newton}
-\newunit{\hectopascal}{\hecto\pascal}
-\newunit{\megabecquerel}{\mega\becquerel}
-\newunit{\millisievert}{\milli\sievert}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-prefixed.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-sistyle.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-sistyle.cfg
deleted file mode 100644
index d7bee0542b3..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-sistyle.cfg
+++ /dev/null
@@ -1,108 +0,0 @@
-%%
-%% This is file `si-sistyle.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `sistyle')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-sistyle.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of
- SIstyle]
-\si@emulating{sistyle}{2006/12/20 v2.3}
-\sisetup{%
- sepfour=true,
- obeyfamily,
- obeyitalic=true,
- numsign=+-,
- strictarc=false,
- unitsep=cdot}
-\newcommand*{\SIobeyboldtrue}{\sisetup{obeybold=true}}
-\newcommand*{\SIobeyboldfalse}{\sisetup{obeybold=false}}
-\let\num\relax
-\si@newrobustcmd*{\num}{%
- \@ifstar
- {\si@sis@numstar}
- {\si@sis@num}}
-\newcommand*{\si@sis@num}[2][]{%
- \begingroup%
- \sisetup{#1}%
- \expandafter\si@out@num\expandafter{\si@num{#2}}%
- \endgroup}
-\newcommand*{\si@sis@numstar}[2][]{%
- \begingroup%
- \sisetup{mode=text,obeybold}%
- \sisetup{#1}%
- \expandafter\si@out@num\expandafter{\si@num{#2}}%
- \endgroup}
-\newcommand*{\pnt}{\ensuremath{\si@decimalsymbol}}
-\newcommand*{\SIgroupfourtrue}{\sisetup{sepfour=true}}
-\newcommand*{\SIgroupfourfalse}{\sisetup{sepfour=false}}
-\newcommand*{\SIunitsep}[1]{\sisetup{valuesep={#1}}}
-\newcommand*{\SIunitspace}[1]{\sisetup{unitspace={#1}}}
-\newcommand*{\SIunitdot}[1]{\sisetup{unitsep={#1}}}
-\newcommand*{\SIdecimalsymbol}[1]{\sisetup{decimalsymbol={#1}}}
-\newcommand*{\SIthousandsep}[1]{\sisetup{digitsep={#1}}}
-\newcommand*{\SIproductsign}[1]{\sisetup{expproduct={#1}}}
-\newcommand*{\SIdecimalsign}[1]{\sisetup{decimalsymbol={#1}}}
-\newcommand*{\si@sis@savefont}[2]{%
- \@namedef{si@sis@#1}{#2}%
- \sisetup{#1=si@sis@#1}}
-\newcommand*{\SImathrm}[1]{\si@sis@savefont{mathrm}{#1}}
-\newcommand*{\SImathsf}[1]{\si@sis@savefont{mathsf}{#1}}
-\newcommand*{\SImathtt}[1]{\si@sis@savefont{mathtt}{#1}}
-\newcommand*{\SIdefaultMfam}[1]{\si@sis@savefont{mathrm}{#1}}
-\newcommand*{\SIdefaultNfam}[1]{\si@sis@savefont{mathnumrm}{#1}}
-\newcommand*{\SIdefaultTfam}[1]{\si@sis@savefont{textrm}{#1}}
-\si@newrobustcmd*{\ensureupmath}[1]{%
- \begingroup
- \sisetup{mode=maths,obeyitalic=false}%
- \si@out{#1}%
- \endgroup}
-\newcommand*{\degC}{\si@sym@celsius}
-\newcommand*{\arcdeg}{\si@sym@degree}
-\newcommand*{\degF}{\si@sym@degree F}
-\newcommand*{\SIstyle}[1]{\sisetup{locale=#1}}
-\newcommand*{\SIstyleToLang}[2]{\sisetup{loctolang=#1:#2}}
-\newcommand*{\AddToSIstyle}{%
- \si@switchfalse
- \@ifstar
- {\si@switchtrue
- \si@sis@addtolocale}
- {\si@sis@addtolocale}}
-\newcommand*{\si@sis@addtolocale}[2]{%
- \ifsi@switch
- \expandafter\let\csname si@loc@#1@extra\endcsname\relax
- \fi
- \addtolocale{#1}{#2}}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-sistyle.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-synchem.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-synchem.cfg
deleted file mode 100644
index 293072a53ff..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-synchem.cfg
+++ /dev/null
@@ -1,47 +0,0 @@
-%%
-%% This is file `si-synchem.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `synchem')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-synchem.cfg}
- [2010/02/22 v1.4c siunitx: Units for synthetic chemists]
-\requiresiconfigs{prefix}
-\newunit{\mmHg}{mmHg}
-\newunit{\molar}{\mole\per\cubic\deci\metre}
-\newunit{\Molar}{\textsc{m}}
-\newunit{\torr}{Torr}
-\newunit{\dalton}{Da}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-synchem.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-units.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-units.cfg
deleted file mode 100644
index f86e99ddd25..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-units.cfg
+++ /dev/null
@@ -1,74 +0,0 @@
-%%
-%% This is file `si-units.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `units')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\si@ifloaded{units}{\endinput}{}
-\ProvidesFile{si-units.cfg}
- [2010/02/22 v1.4c siunitx: Emulation of units]
-\si@emulating{units}{1998/08/04 v0.9b}
-\si@ifloaded{SIunits}
- {\si@emclash{units}{SIunits}\endinput}{}
-\si@ifloaded{sistyle}
- {\si@emclash{units}{sistyle}\endinput}{}
-\sisetup{per=fraction,fraction=nice,obeybold,inlinebold=maths,
- ,obeymode}
-\ifsi@old@tight
- \sisetup{valuesep=thin}
-\fi
-\ifsi@old@loose
- \sisetup{valuesep=space}
-\fi
-\ifsi@old@ugly
- \sisetup{fraction=ugly}
-\fi
-\si@newrobustcmd*{\unit}[2][]{%
- \ifmmode
- \SI{#1}{#2}%
- \else
- \SI[obeyfamily,obeyitalic]{#1}{#2}%
- \fi}
-\si@newrobustcmd*{\unitfrac}[3][]{%
- \begingroup
- \si@fam@mode%
- \ifmmode\else
- \sisetup{obeyfamily,obeyitalic}%
- \fi
- \si@ifnotmtarg{#1}
- {\num{#1}\ensuremath{\si@valuesep}}%
- \si@frac{#2}{#3}
- \endgroup}
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-units.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-unitsdef.cfg b/Master/texmf-dist/tex/latex/siunitx/config/si-unitsdef.cfg
deleted file mode 100644
index eba83cb0606..00000000000
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-unitsdef.cfg
+++ /dev/null
@@ -1,254 +0,0 @@
-%%
-%% This is file `si-unitsdef.cfg',
-%% generated with the docstrip utility.
-%%
-%% The original source files were:
-%%
-%% siunitx.dtx (with options: `unitsdef')
-%% ---------------------------------------------------------------
-%% 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
-%% ---------------------------------------------------------------
-%%
-\ProvidesFile{si-unitsdef.cfg}
- [2010/02/22 v1.4c siunitx:
- Emulation of unitsdef]
-\si@emulating{unitsdef}{2005/01/04 v0.2}
-\si@ifloaded{SIunits}
- {\si@emclash{unitsdef}{SIunits}\endinput}{}
-\si@ifloaded{sistyle}
- {\si@emclash{unitsdef}{sistyle}\endinput}{}
-\requiresiconfigs{units}
-\RequirePackage{textcomp}
-\RequirePackage[T1]{fontenc}
-\sisetup{mode=text,allowoptarg,prespace}
-\ifsi@old@noxspace
- \sisetup{xspace=false}
-\fi
-\ifsi@old@noabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@nofrequncyabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@nomolabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@novoltageabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@novolumeabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@noweightabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@noenergyabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@nolengthabbr
- \sisetup{noload=abbr}
-\fi
-\ifsi@old@notimeabbr
- \sisetup{noload=abbr}
-\fi
-\newcommand*{\unitvaluesep}{\,}
-\renewcommand*{\si@valuesep}{\text{\unitvaluesep}}
-\define@choicekey*+[si]{key}{valuesep}[\si@tempa]
- {space,thin,med,medium,thick,none}
- {\renewcommand*\unitvaluesep\@nameuse{si@fix@##1}%
- \si@log@debug{Option valuesep set to ##1}}
- {\si@log@debug{Option valuesep set to ##1}%
- \renewcommand*\unitvaluesep{##1}}
-\let\unitsignonly\si
-\si@newrobustcmd*{\ilu}[2][]{%
- \begingroup
- #1\unitvaluesep%
- \unit{#2}%
- \endgroup}
-\let\arc\ang
-\newcommand*{\unitSIdef}{\upshape}
-\newcommand*{\si@unitSIdef}{\unitSIdef\selectfont}
-\sisetup{textrm=si@unitSIdef}
-\let\per\relax
-\si@newrobustcmd*{\per}[2]{%
- \begingroup
- \si@xspacefalse
- \renewcommand*{\unitvaluesep}{}%
- \unitfrac{#1}{#2}%
- \endgroup}
-\newcommand*{\unittimes}{\ensuremath{\cdot}}
-\newcommand*{\unitsep}{\,}
-\renewcommand*{\si@unt@unithook}{\si@unt@litouttrue}
-\sisetup{unitsep=none}
-\newcommand*{\unitsuperscript}{\tothe}
-\newcommand*{\newnosepunit}{\newunit[valuesep=none]}
-\newcommand*{\renewnosepunit}{\renewunit[valuesep=none]}
-\newcommand*{\setTextOmega}[2]{%
- \renewcommand*{\si@textOmega}{%
- \begingroup
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setMathOmega}[1]{\sisetup{mathsOmega=#1}}
-\newcommand*{\setTextmu}[2]{%
- \renewcommand*{\si@textmu}{%
- \begingroup
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setMathmu}[1]{\sisetup{mathsmu=#1}}
-\newcommand*{\setTextCelsius}[2]{%
- \renewcommand*{\si@textcelsius}{%
- \begingroup
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setMathCelsius}[1]{\sisetup{mathscelsius=#1}}
-\newcommand*{\setMathDegree}[2]{%
- \renewcommand*{\si@textdegree}{%
- \begingroup%
- \edef\si@tempa{\sfdefault}%
- \ifx\f@family\si@tempa
- \expandafter#2%
- \else
- \expandafter#1%
- \fi
- \endgroup}}
-\newcommand*{\setTextDegree}[1]{\sisetup{textdegree=#1}}
-\ifsi@old@OHM
- \ifsi@old@ohm
- \si@log@inf{Both `ohm' and `OHM' options given\MessageBreak
- Using default behaviour for unitsdef}
- \expandafter\expandafter\expandafter\si@old@OHMfalse
- \fi
-\fi
-\ifsi@old@liter
- \ifsi@old@LITER
- \si@log@inf{Both `liter' and `LITER' options
- given\MessageBreak Using default behaviour for unitsdef}
- \else
- \renewunit{\liter}{l}
- \fi
-\fi
-\newunit{\ton}{t}
-\newunit{\days}{d}
-\newunit{\picometer}{\pico\meter}
-\newunit{\nanometer}{\nano\meter}
-\newunit{\micrometer}{\micro\meter}
-\newunit{\millimeter}{\milli\meter}
-\newunit{\centimeter}{\centi\meter}
-\newunit{\decimeter}{\deci\meter}
-\newunit{\kilometer}{\kilo\meter}
-\newunit{\femtoliter}{\femto\liter}
-\newunit{\picoliter}{\pico\liter}
-\newunit{\nanoliter}{\nano\liter}
-\newunit{\microliter}{\micro\liter}
-\newunit{\milliliter}{\milli\liter}
-\newunit{\centiliter}{\centi\liter}
-\newunit{\deciliter}{\deci\liter}
-\newunit{\hectoliter}{\hecto\liter}
-\newunit{\cubicmeter}{\meter\cubed}
-\newunit{\cubicmicrometer}{\micro\meter\cubed}
-\newunit{\cubicmillimeter}{\milli\meter\cubed}
-\newunit{\squaremeter}{\Square\meter}
-\newunit{\squarecentimeter}{\Square\centi\meter}
-\newunit{\squarekilometer}{\Square\kilo\meter}
-\newunit{\ar}{a}
-\newunit{\hectar}{\hecto\ar}
-\ifsi@old@noabbr
-\else
- \ifsi@old@novoltageabbr\else
- \newunit{\kv}{\kilo\volt}
- \newunit{\mv}{\milli\volt}
- \fi
-\fi
-\ifsi@old@noabbr\else
- \ifsi@old@notimeabbr\else
- \newunit{\sek}{\second}
- \fi
- \ifsi@old@noweightabbr\else
- \newunit{\fg}{\femto\gram}
- \fi
- \ifsi@old@novolumeabbr\else
- \newunit{\fl}{\femto\liter}
- \newunit{\pl}{\pico\liter}
- \newunit{\nl}{\nano\liter}
- \newunit{\micl}{\micro\liter}
- \newunit{\ml}{\milli\liter}
- \newunit{\cl}{\centi\liter}
- \newunit{\dl}{\deci\liter}
- \newunit{\hl}{\hecto\liter}
- \fi
-\fi
-\newunit{\calory}{cal}
-\newunit{\kilocalory}{\kilo\calory}
-\newunit{\uBar}{ba}
-\catcode`\-=11\relax
-\ifsi@old@redef-gensymb
- \expandafter\si@gensymbtrue
-\fi
-\catcode`\-=12\relax
-\ifsi@gensymb
- \RequirePackage{gensymb}
- \AtBeginDocument{
- \let\gensymbohm\ohm
- \let\gensymbcelsius\celsius
- \let\gensymbmicro\micro
- \let\gensymbdegree\degree
- \let\ohm\@undefined
- \let\celsius\@undefined
- \let\micro\@undefined
- \let\degree\@undefined
- \ifsi@old@OHM\else
- \newunit{\ohm}{\si@sym@Omega}
- \newunit{\celsius}{\si@sym@celsius}
- \newprefix{\micro}{\si@sym@mu}{-6}
- \newunit{\degree}{\si@sym@degree}
- \fi}
-\fi
-\requiresiconfigs{prefix,named,addn,accepted}
-\ifsi@old@noconfig\else
- \InputIfFileExists{unitsdef.cfg}
- {\si@log@inf{unitsdef config file loaded}}
- {\si@log@inf{unitsdef config file not found}}
-\fi
-%%
-%% Copyright (C) 2008-2010 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
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
-%%
-%%
-%% End of file `si-unitsdef.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/siunitx-abbreviations.cfg b/Master/texmf-dist/tex/latex/siunitx/config/siunitx-abbreviations.cfg
new file mode 100644
index 00000000000..d4d787aeb34
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/siunitx/config/siunitx-abbreviations.cfg
@@ -0,0 +1,92 @@
+%%
+%% This is file `siunitx-abbreviations.cfg',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% siunitx.dtx (with options: `config,abbreviations')
+%% ---------------------------------------------------------------
+%% 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
+%% ---------------------------------------------------------------
+%%
+\ProvidesExplFile {siunitx-abbreviations.cfg} {2010/05/23} {2.0}
+ {siunitx: Abbreviated units}
+\DeclareSIUnit \pA { \pico \ampere }
+\DeclareSIUnit \nA { \nano \ampere }
+\DeclareSIUnit \uA { \micro \ampere }
+\DeclareSIUnit \mA { \milli \ampere }
+\DeclareSIUnit \kA { \kilo \ampere }
+\DeclareSIUnit \Hz { \hertz }
+\DeclareSIUnit \mHz { \milli \hertz }
+\DeclareSIUnit \kHz { \kilo \hertz }
+\DeclareSIUnit \MHz { \mega \hertz }
+\DeclareSIUnit \GHz { \giga \hertz }
+\DeclareSIUnit \THz { \tera \hertz }
+\DeclareSIUnit \fmol { \femto \mole }
+\DeclareSIUnit \pmol { \pico \mole }
+\DeclareSIUnit \nmol { \nano \mole }
+\DeclareSIUnit \umol { \micro \mole }
+\DeclareSIUnit \mmol { \milli \mole }
+\DeclareSIUnit \kmol { \kilo \mole }
+\DeclareSIUnit \mV { \milli \volt }
+\DeclareSIUnit \kV { \kilo \volt }
+\DeclareSIUnit \ml { \milli \litre }
+\DeclareSIUnit \ul { \micro \litre }
+\DeclareSIUnit \mL { \milli \liter }
+\DeclareSIUnit \uL { \micro \liter }
+\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 }
+\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 = }
+\DeclareSIUnit \nm { \nano \metre }
+\DeclareSIUnit \pm { \pico \metre }
+\DeclareSIUnit \um { \micro \metre }
+\DeclareSIUnit \mm { \milli \metre }
+\DeclareSIUnit \cm { \centi \metre }
+\DeclareSIUnit \dm { \deci \metre }
+\DeclareSIUnit \km { \kilo \metre }
+\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 }
+%%
+%% Copyright (C) 2008-2010 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.
+%%
+%%
+%% End of file `siunitx-abbreviations.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/si-USA.cfg b/Master/texmf-dist/tex/latex/siunitx/config/siunitx-binary.cfg
index 2710d1fc42e..32707c3458b 100644
--- a/Master/texmf-dist/tex/latex/siunitx/config/si-USA.cfg
+++ b/Master/texmf-dist/tex/latex/siunitx/config/siunitx-binary.cfg
@@ -1,10 +1,10 @@
%%
-%% This is file `si-USA.cfg',
+%% This is file `siunitx-binary.cfg',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
-%% siunitx.dtx (with options: `USA')
+%% siunitx.dtx (with options: `config,binary')
%% ---------------------------------------------------------------
%% The siunitx package --- A comprehensive (SI) units package
%% Maintained by Joseph Wright
@@ -13,16 +13,18 @@
%% See http://www.latex-project.org/lppl.txt
%% ---------------------------------------------------------------
%%
-\ProvidesFile{si-USA.cfg}
- [2010/02/22 v1.4c siunitx: USA locale]
-\sisetup{
- unitsep=thin,
- expproduct=times,
- valuesep=thin,
- decimalsymbol=fullstop,
- digitsep=thin,
- sepfour=false,
- tophrase={{ to }}}
+\ProvidesExplFile {siunitx-binary.cfg} {2010/05/23} {2.0}
+ {siunitx: Binary units}
+\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 }
+\DeclareSIUnit \bit { bit }
+\DeclareSIUnit \byte { B }
%%
%% Copyright (C) 2008-2010 by
%% Joseph Wright <joseph.wright@morningstar2.co.uk>
@@ -39,11 +41,8 @@
%%
%% This work consists of the file siunitx.dtx
%% and the derived files siunitx.pdf,
-%% siunitx.sty
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
+%% siunitx.sty and
+%% siunitx.ins.
%%
%%
-%% End of file `si-USA.cfg'.
+%% End of file `siunitx-binary.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/config/siunitx-version-1.cfg b/Master/texmf-dist/tex/latex/siunitx/config/siunitx-version-1.cfg
new file mode 100644
index 00000000000..c7129987c98
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/siunitx/config/siunitx-version-1.cfg
@@ -0,0 +1,661 @@
+%%
+%% This is file `siunitx-version-1.cfg',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% siunitx.dtx (with options: `config,version-1')
+%% ---------------------------------------------------------------
+%% 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
+%% ---------------------------------------------------------------
+%%
+\ProvidesExplFile {siunitx-version-1.cfg} {2010/05/23} {2.0}
+ {siunitx: Version 1 settings}
+\keys_set:nn { siunitx } { load-configurations = abbreviations }
+\keys_define:nn { siunitx } {
+ addsign .choice: ,
+ addsign /
+ false .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 },
+ angelsep .choice: ,
+ angelsep /
+ cdot .meta:n =
+ { arc-separator = { } \cdot { } },
+ angelsep /
+ comma .meta:n = { arc-separator = { {,} } },
+ angelsep /
+ fullstop .meta:n = { arc-separator = { { . } } },
+ angelsep /
+ med .meta:n = { arc-separator = \: },
+ angelsep /
+ medium .meta:n = { arc-separator = \: },
+ angelsep /
+ none .meta:n = { arc-separator = },
+ angelsep /
+ period .meta:n = { arc-separator = { { . } } },
+ angelsep /
+ space .meta:n = { arc-separator = \text { ~ } },
+ angelsep /
+ stop .meta:n = { arc-separator = { { . } } },
+ angelsep /
+ thick .meta:n = { arc-separator = \; },
+ angelsep /
+ thin .meta:n = { arc-separator = \, },
+ angelsep /
+ tightcdot .meta:n =
+ { arc-separator = \bgroup \cdot \egroup },
+ angelsep /
+ tighttimes .meta:n =
+ { arc-separator = \bgroup \times \egroup },
+ angelsep /
+ times .meta:n = { arc-separator = \times },
+ angelsep /
+ 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 },
+ 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
+ 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 /
+ 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 = ,
+ 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 },
+ obeyitalic .meta:n = { detect-italic = #1 },
+ opbeyitalic .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
+ },
+ 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 /
+ 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-numbers = single,
+ product-units = single,
+ },
+ repeatunits /
+ power .meta:n =
+ {
+ multi-part-numbers = repeat,
+ product-units = power,
+ },
+ repeatunits /
+ true .meta:n =
+ {
+ multi-part-numbers = 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 .meta:n =
+ {
+ table-number-alignment = #1,
+ table-text-alignment = #1,
+ table-unit-alignment = #1
+ },
+ tabalignexp .code:n = ,
+ tabautofit .meta:n = { table-auto-round = #1 },
+ tabformat .meta:n = { table-format = #1 },
+ tabnumalign .meta:n = { table-number-alignment = #1 },
+ tabparseonly .meta:n = { table-parse-only = #1 },
+ tabparseonly .default:n = { true },
+ tabtextalign .meta:n = { table-text-numbers = #1 },
+ tabunitalign .meta:n = { 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 =
+ { unit-value-separator = { } \cdot { } },
+ valuesep /
+ comma .meta:n = { unit-value-separator = { {,} } },
+ valuesep /
+ fullstop .meta:n = { unit-value-separator = { { . } } },
+ valuesep /
+ med .meta:n = { unit-value-separator = \: },
+ valuesep /
+ medium .meta:n = { unit-value-separator = \: },
+ valuesep /
+ none .meta:n = { unit-value-separator = },
+ valuesep /
+ period .meta:n = { unit-value-separator = { { . } } },
+ valuesep /
+ space .meta:n = { unit-value-separator = \text { ~ } },
+ valuesep /
+ stop .meta:n = { unit-value-separator = { { . } } },
+ valuesep /
+ thick .meta:n = { unit-value-separator = \; },
+ valuesep /
+ thin .meta:n = { unit-value-separator = \, },
+ valuesep /
+ tightcdot .meta:n =
+ { unit-value-separator = \bgroup \cdot \egroup },
+ valuesep /
+ tighttimes .meta:n =
+ { unit-value-separator = \bgroup \times \egroup },
+ valuesep /
+ times .meta:n = { unit-value-separator = \times },
+ valuesep /
+ unknown .meta:n = { unit-value-separator = #1 },
+ xspace .meta:n = { use-xspace = #1 },
+ xpace .default:n = { true }
+}
+\cs_set_eq:NN \newunit \DeclareSIUnit
+\cs_set_eq:NN \renewunit \DeclareSIUnit
+\cs_set_eq:NN \provideunit \DeclareSIUnit
+\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} }
+}
+\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} }
+}
+\cs_set_eq:NN \newqualifier \DeclareSIQualifier
+\cs_set_eq:NN \renewqualifier \DeclareSIQualifier
+\cs_set_eq:NN \providequalifier \DeclareSIQualifier
+\DeclareSIPrePower \Square { 2 }
+\DeclareSIPrePower \ssquare { 2 }
+\DeclareSIUnit \BAR { \bar }
+\DeclareSIUnit \bbar { \bar }
+\DeclareSIUnit \Day { \day }
+\DeclareSIUnit \dday { \day }
+\DeclareSIUnit \Gray { \gray }
+\DeclareSIUnit \ggray { \gray }
+\DeclareSIUnit \atomicmass { \atomicmassunit }
+\DeclareSIUnit \arcmin { \arcminute }
+\DeclareSIUnit \arcsec { \arcsecond }
+\DeclareSIUnit \are { a }
+\DeclareSIUnit \curie { Ci }
+\DeclareSIUnit \gal { Gal }
+\DeclareSIUnit \millibar { \milli \bar }
+\DeclareSIUnit \rad { rad }
+\DeclareSIUnit \rem { rem }
+\DeclareSIUnit \roentgen { R }
+\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 }
+\DeclareSIUnit \parsec { pc }
+\DeclareSIUnit \lightyear { ly }
+\DeclareSIUnit \gmol { g \text { - } mol }
+\DeclareSIUnit \kgmol { kg \text { - } mol }
+\DeclareSIUnit \lbmol { lb \text { - } mol }
+\DeclareSIUnit \molar { \mole \per \cubic \deci \metre }
+\DeclareSIUnit \Molar { \textsc { m } }
+\DeclareSIUnit \torr { Torr }
+\DeclareSIUnit \gon { gon }
+%%
+%% Copyright (C) 2008-2010 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.
+%%
+%%
+%% End of file `siunitx-version-1.cfg'.
diff --git a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty
index 90b94d7132f..a407b5d22b6 100644
--- a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty
+++ b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty
@@ -13,3961 +13,5743 @@
%% See http://www.latex-project.org/lppl.txt
%% ---------------------------------------------------------------
%%
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{siunitx}
- [2010/02/22 v1.4c A comprehensive (SI) units package]
-\begingroup
- \@ifundefined{eTeXversion}
- {\PackageError{siunitx}
- {Not running under e-TeX}
- {This package requires e-TeX. Try compiling the document
- with\MessageBreak `elatex' instead of `latex'. When
- using pdfTeX, try `pdfelatex'\MessageBreak instead of
- `pdflatex'}%
- \endgroup\endinput}
- {\endgroup}
-\edef\si@catcodes{%
- \catcode\string`\string ` \the\catcode\string`\`\relax
- \catcode\string`\string = \the\catcode\string`\=\relax
- \catcode\string`\string ^ \the\catcode\string`\^\relax
- \catcode\string`\string _ \the\catcode\string`\_\relax
- \catcode\string`\string ~ \the\catcode\string`\~\relax
- \catcode\string`\string : \the\catcode\string`\:\relax
- \catcode\string`\string - \the\catcode\string`\-\relax
- \catcode\string`\string + \the\catcode\string`\+\relax
- \catcode\string`\string ; \the\catcode\string`\;\relax
- \catcode\string`\string , \the\catcode\string`\,\relax
- \catcode\string`\string . \the\catcode\string`\.\relax}
-\catcode\string`\` 12\relax
-\catcode`\= 12\relax
-\catcode`\^ 7\relax
-\catcode`\_ 8\relax
-\catcode`\~ \active\relax
-\@makeother{\:}
-\@makeother{\-}
-\@makeother{\+}
-\@makeother{\;}
-\@makeother{\,}
-\@makeother{\.}
-\RequirePackage{xkeyval}[2005/05/07]
-\RequirePackage{amstext,array,xspace}
-\newcommand*{\si@tempa}{}
-\newcommand*{\si@tempb}{}
-\newcommand*{\si@tempc}{}
-\newif\ifsi@switch
-\newbox\si@tempboxa
-\newbox\si@tempboxb
-\newbox\si@tempboxc
-\newbox\si@tempboxd
-\newtoks{\si@temptoks}
-\newcommand*{\si@blockpkgs}{SIunits,sistyle,siunits,SIstyle,%
- unitsdef,fancyunits}
-\newcommand*{\si@checkpkgs}{units,hepunits,fancynum}
-\newcommand*{\si@packagecheck}{%
- \begingroup
- \@for\si@tempa:=\si@blockpkgs\do{
- \@ifpackageloaded{\si@tempa}
- {\PackageError{siunitx}
- {Package `\si@tempa' incompatible}
- {The \si@tempa\space package and siunitx are
- incompatible.\MessageBreak Use the
- `emulate=\si@tempa' package option when loading
- siunitx}}
- {}}
- \@for\si@tempa:=\si@checkpkgs\do{%
- \@ifpackageloaded{\si@tempa}
- {\PackageWarning{siunitx}
- {Consider loading the siunitx package
- with\MessageBreak option `emulate=\si@tempa', rather
- than\MessageBreak loading both \si@tempa\space and
- siunitx}}
- {}}
- \endgroup}
-\si@packagecheck
-\AtBeginDocument{\si@packagecheck}
-\newcommand*{\si@ifdefinable}[1]{%
- \expandafter\expandafter\expandafter\@ifundefined%
- \expandafter\expandafter\expandafter%
- {\expandafter\@gobble\string#1}}
-\newcommand*{\si@addtolist}[2]{%
- \ifx\@empty#1\@empty
- \edef#1{#2}%
- \else
- \edef#1{#1,#2}%
- \fi}
-\newcommand*{\si@addtocsname}[2]{%
- \@ifundefined{#1}
- {\expandafter\gdef\csname #1\endcsname{#2}}
- {\si@temptoks\expandafter\expandafter\expandafter{%
- \csname #1\endcsname#2}%
- \expandafter\xdef\csname #1\endcsname{\the\si@temptoks}}}
-\begingroup
- \catcode`\Q=3
- \long\gdef\si@ifmtarg#1{%
- \si@xifmtarg#1QQ\@secondoftwo\@firstoftwo\@nil}
- \long\gdef\si@xifmtarg#1#2Q#3#4#5\@nil{#4}
- \long\gdef\si@ifnotmtarg#1{%
- \si@xifmtarg#1QQ\@firstofone\@gobble\@nil}
-\endgroup
-\@ifpackageloaded{etoolbox}
- {\let\si@newrobustcmd\newrobustcmd}
- {\protected\def\si@newrobustcmd{%
- \@ifstar
- {\let\l@ngrel@x\protected\si@newcommand}
- {\def\l@ngrel@x{\protected\long}\si@newcommand}}
- \newcommand*{\si@newcommand}[1]{\@testopt{\si@newcmd#1}0}
- \def\si@newcmd#1[#2]{%
- \@ifnextchar[%]
- {\si@xargdef#1[#2]}
- {\@argdef#1[#2]}}
- \long\def\si@xargdef#1[#2][#3]#4{%
- \@ifdefinable#1{%
- \expandafter\protected
- \expandafter\def
- \expandafter#1%
- \expandafter{%
- \expandafter\@testopt
- \csname\string#1\endcsname{#3}}%
- \expandafter\@yargdef
- \csname\string#1\endcsname\tw@{#2}{#4}}}}
-\newif\ifsi@debug
-\newif\ifsi@logmin
-\newif\ifsi@lognone
-\newcommand*{\si@log@err}[2]{%
- \ifsi@lognone\else
- \ifsi@logmin
- \PackageWarning{siunitx}{#1}%
- \else
- \PackageError{siunitx}{#1}{#2}%
- \fi
- \fi}
-\newcommand*{\si@log@warn}[1]{%
- \ifsi@lognone\else
- \ifsi@logmin\else
- \PackageWarning{siunitx}{#1}%
- \fi
- \fi}
-\newcommand*{\si@log@inf}[1]{%
- \ifsi@lognone\else
- \ifsi@logmin\else
- \PackageInfo{siunitx}{#1}%
- \fi
- \fi}
-\newcommand*{\si@log@debug}[1]{%
- \ifsi@lognone\else
- \ifsi@debug
- \PackageInfo{siunitx}{#1}%
- \fi
- \fi}
-\newcommand*{\si@str@ifchrstr}[2]{%
- \begingroup
- \si@switchfalse
- \renewcommand*{\si@tempa}{#1}%
- \protected@edef\si@tempb{#2}%
- \expandafter\si@str@chrstr\si@tempb\@empty\@empty\@empty
- \ifsi@switch
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@str@chrstr#1#2\@empty{%
- \renewcommand*{\si@tempc}{#1}%
- \ifx\si@tempa\si@tempc
- \expandafter\si@switchtrue
- \else
- \ifx\@empty#2\@empty\else
- \si@str@chrstr#2\@empty\@empty
- \fi
- \fi}
-\newcommand*{\si@str@ifonlychrs}[2]{%
- \begingroup
- \si@switchtrue
- \protected@edef\si@tempa{#1}%
- \renewcommand*{\si@tempb}{#2}%
- \expandafter\si@str@onlychrs\si@tempa\@empty\@empty\@empty
- \ifsi@switch
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@str@onlychrs#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@tempb}
- {}{\si@switchfalse}%
- \ifx\@empty#2\@empty\else
- \si@str@onlychrs#2\@empty\@empty
- \fi}
-\newcommand*{\sisetup}{\setkeys[si]{key}}
-\newcommand*{\si@opt@key}[2]{%
- \define@key[si]{key}{#1}
- {#2\si@log@debug{Option #1 set to ##1}}}
-\newcommand*{\si@opt@cmdkey}[3][]{%
- \define@cmdkey[si]{key}[si@]{#2}[#1]{#3}}
-\newcommand*{\si@opt@cmdkeys}[2][]{%
- \define@cmdkeys[si]{key}[si@]{#2}[#1]}
-\newcommand*{\si@opt@boolkey}[2][]{%
- \define@boolkey[si]{key}[si@]{#2}[true]
- {#1\si@log@debug{Option #2 set to ##1}}}
-\newcommand*{\si@opt@choicekey}[4][]{%
- \define@choicekey*+[si]{key}{#2}[\si@tempa]{#3}[#1]
- {#4\si@log@debug{Option #2 set to ##1}}
- {\si@log@warn{Unknown value `##1' for option #2}}}
-\newcommand*{\si@opt@xchoicekey}[3]{%
- \define@choicekey*+[si]{key}{#1}[\si@tempa]{#2}[#1]
- {\si@log@debug{Option #1 set to ##1}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@#1\endcsname}{\@nameuse{si@fix@##1}}}
- {\si@log@debug{Option #1 set to ##1}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@#1\endcsname}{##1}}
- \expandafter\newcommand\expandafter*\expandafter{%
- \csname si@#1\endcsname}%
- {\@nameuse{si@fix@#3}}}
-\newcommand*{\si@opt@compatkey}[2]{%
- \define@boolkey[si]{key}[si@old@]{#2}[true]
- {\si@log@debug{Emulating #1 package option\MessageBreak #2}%
- \sisetup{emulate=#1}%
- \si@log@debug{Option #2 set to ##1}}
- \AtEndOfPackage{\si@opt@disablekey{#2}
- {Compatibility option #2 only\MessageBreak
- available when loading siunitx package}}}
-\newcommand*{\si@opt@disablekey}[2]{%
- \key@ifundefined[si]{key}{#1}
- {}
- {\si@log@debug{Disabling key #1}%
- \si@opt@key{#1}{\si@log@warn{#2}}}}
-\si@opt@choicekey[normal]{log}{debug,verbose,normal,errors,none}
- {\si@debugfalse
- \si@logminfalse
- \si@lognonefalse
- \renewcommand*{\si@tempb}{none}%
- \ifx\si@tempa\si@tempb
- \si@lognonetrue
- \fi
- \renewcommand*{\si@tempb}{minimal}%
- \ifx\si@tempa\si@tempb
- \si@logmintrue
- \fi
- \renewcommand*{\si@tempb}{debug}%
- \ifx\si@tempa\si@tempb
- \si@debugtrue
- \fi
- \renewcommand*{\si@tempb}{verbose}%
- \ifx\si@tempa\si@tempb
- \si@debugtrue
- \fi}
-\si@opt@boolkey{debug}
-\si@opt@boolkey[%
- \ifsi@strict
- \sisetup{
- obeymode=false,
- obeybold=false,
- obeyitalic=false,
- mode=maths,
- repeatunits=true,
- trapambigerr=true,
- trapambigfrac=true,
- trapambigrange=true}
- \@for\si@tempa:=obeyall,obeymode,obeyitalic,mode,unitmode,%
- valuemode,textmode,obeybold,repeatunits,trapambigerr,%
- trapambigfrac,trapambigrange\do{%
- \begingroup
- \edef\si@tempb{\endgroup
- \noexpand\si@opt@disablekey{\si@tempa}
- {Option `\si@tempa' forbidden in strict mode}}%
- \si@tempb}
- \fi]{strict}
-\AtEndOfPackage{
- \si@opt@disablekey{strict}
- {Option `strict' only available when\MessageBreak
- loading package}}
-\newcommand*{\si@emulate}{}
-\si@opt@key{emulate}{\si@addtolist{\si@emulate}{#1}}
-\AtEndOfPackage{
- \si@opt@disablekey{emulate}
- {Option `emulate' only available when\MessageBreak
- loading package}}
-\si@opt@xchoicekey{unitsep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{thin}
-\si@opt@xchoicekey{unitspace}{space,thin,med,medium,thick,
- none}{thin}
-\si@opt@xchoicekey{errspace}{space,thin,med,medium,thick,
- none}{none}
-\si@opt@xchoicekey{valuesep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{thin}
-\si@opt@xchoicekey{digitsep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{thin}
-\si@opt@xchoicekey{decimalsymbol}{comma,stop,fullstop,period,
- cdot,tightcdot}{fullstop}
-\si@opt@xchoicekey{anglesep}
- {space,thin,med,medium,thick,none,comma,stop,fullstop,period,
- times,tighttimes,cdot,tightcdot}{none}
-\si@opt@boolkey{obeymode}
-\newif\ifsi@numtextmode
-\newif\ifsi@unittextmode
-\si@opt@choicekey[true]{textmode}{true,false}
- {\si@numtextmodefalse
- \si@unittextmodefalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@numtextmodetrue
- \si@unittextmodetrue
- \fi}
-\si@opt@choicekey{mode}{math,maths,text}
- {\si@numtextmodefalse
- \si@unittextmodefalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@numtextmodetrue
- \si@unittextmodetrue
- \fi}
-\si@opt@choicekey{valuemode}{math,maths,text}
- {\si@numtextmodefalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@numtextmodetrue
- \fi}
-\si@opt@choicekey{unitmode}{math,maths,text}
- {\si@unittextmodefalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@unittextmodetrue
- \fi}
-\si@opt@boolkey{obeyfamily}
-\si@opt@boolkey{obeybold}
-\newif\ifsi@inlinebtext
-\si@opt@choicekey{inlinebold}{text,maths,math}
- {\si@inlinebtextfalse
- \renewcommand*{\si@tempb}{text}%
- \ifx\si@tempa\si@tempb
- \si@inlinebtexttrue
- \fi}
-\si@opt@boolkey{obeyitalic}
-\si@opt@boolkey{detectdisplay}
-\si@opt@choicekey[true]{obeyall}{true,false}
- {\si@obeyboldfalse
- \si@obeyitalicfalse
- \si@obeymodefalse
- \si@obeyfamilyfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@obeyboldtrue
- \si@obeyitalictrue
- \si@obeymodetrue
- \si@obeyfamilytrue
- \fi}
-\si@opt@cmdkeys{valuemathsrm,valuemathssf,valuemathstt}
-\si@opt@cmdkeys{unitmathsrm,unitmathssf,unitmathstt}
-\si@opt@key{valuemathrm}{\sisetup{valuemathsrm=#1}}
-\si@opt@key{valuemathsf}{\sisetup{valuemathssf=#1}}
-\si@opt@key{valuemathtt}{\sisetup{valuemathstt=#1}}
-\si@opt@key{unitmathrm}{\sisetup{unitmathsrm=#1}}
-\si@opt@key{unitmathsf}{\sisetup{unitmathssf=#1}}
-\si@opt@key{unitmathtt}{\sisetup{unitmathstt=#1}}
-\si@opt@key{mathsrm}{\sisetup{valuemathsrm=#1,unitmathsrm=#1}}
-\si@opt@key{mathssf}{\sisetup{valuemathssf=#1,unitmathssf=#1}}
-\si@opt@key{mathstt}{\sisetup{valuemathstt=#1,unitmathstt=#1}}
-\si@opt@key{mathrm}{\sisetup{valuemathsrm=#1,unitmathsrm=#1}}
-\si@opt@key{mathsf}{\sisetup{valuemathssf=#1,unitmathssf=#1}}
-\si@opt@key{mathtt}{\sisetup{valuemathstt=#1,unitmathstt=#1}}
-\si@opt@cmdkeys{valuetextrm,valuetextsf,valuetexttt}
-\si@opt@cmdkeys{unittextrm,unittextsf,unittexttt}
-\si@opt@key{textrm}{\sisetup{unittextrm=#1,valuetextrm=#1}}
-\si@opt@key{textsf}{\sisetup{unittextsf=#1,valuetextsf=#1}}
-\si@opt@key{texttt}{\sisetup{unittexttt=#1,valuetexttt=#1}}
-\si@opt@cmdkeys{numdigits,numdecimal,numexp,numgobble,numsign,%
- numcloseerr,numopenerr,numaddn,numprod,numdiv}
-\newcommand*{\si@numextra}{%
- \si@numopenerr\si@numcloseerr\si@numaddn}
-\newcommand*{\si@numvalid}{\si@numgobble\si@numexp\si@numsign
- \si@numdecimal\si@numdigits\si@numextra\si@numprod\si@numdiv}
-\si@opt@boolkey{seperr}
-\si@opt@boolkey{trapambigerr}
-\si@opt@cmdkeys{openerr,closeerr}
-\si@opt@boolkey{sepfour}
-\si@opt@boolkey{retainplus}
-\si@opt@xchoicekey{expproduct}{times,tighttimes,
- cdot,tightcdot}{times}
-\si@opt@xchoicekey{expbase}{ten}{ten}
-\si@opt@boolkey{allowzeroexp}
-\si@opt@xchoicekey{prefixproduct}{times,tighttimes,cdot,
- tightcdot,none}{times}
-\si@opt@xchoicekey{prefixbase}{ten,two}{ten}
-\si@opt@boolkey{prefixsymbolic}
-\newif\ifsi@num@padlead
-\newif\ifsi@num@padtrail
-\si@opt@choicekey[all]{padnumber}
- {leading,lead,trailing,trail,all,both,true,none,false}
- {\si@num@padleadfalse
- \si@num@padtrailfalse
- \renewcommand*{\si@tempb}{leading}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \fi
- \renewcommand*{\si@tempb}{lead}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \fi
- \renewcommand*{\si@tempb}{trailing}%
- \ifx\si@tempa\si@tempb
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{trail}%
- \ifx\si@tempa\si@tempb
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{all}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \si@num@padtrailtrue
- \fi
- \renewcommand*{\si@tempb}{both}%
- \ifx\si@tempa\si@tempb
- \si@num@padleadtrue
- \si@num@padtrailtrue
- \fi}
-\newif\ifsi@num@signmant
-\newif\ifsi@num@signexp
-\si@opt@xchoicekey{sign}{plus,minus,pm,mp}{plus}
-\si@opt@choicekey[all]{addsign}
- {mantissa,exponent,mant,exp,all,both,true,none,false}
- {\si@num@signmantfalse
- \si@num@signexpfalse
- \renewcommand*{\si@tempb}{mantissa}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \fi
- \renewcommand*{\si@tempb}{mant}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \fi
- \renewcommand*{\si@tempb}{exponent}%
- \ifx\si@tempa\si@tempb
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{exp}%
- \ifx\si@tempa\si@tempb
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{all}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \si@num@signexptrue
- \fi
- \renewcommand*{\si@tempb}{both}%
- \ifx\si@tempa\si@tempb
- \si@num@signmanttrue
- \si@num@signexptrue
- \fi}
-\si@opt@boolkey{tightpm}
-\newcommand*{\si@pm}{%
- \ifsi@tightpm
- \si@fix@tightpm
- \else
- \si@fix@pm
- \fi}
-\newif\ifsi@ang@padsmall
-\newif\ifsi@ang@padlarge
-\si@opt@choicekey[all]{padangle}
- {small,large,all,both,true,none,false}
- {\si@ang@padsmallfalse
- \si@ang@padlargefalse
- \renewcommand*{\si@tempb}{small}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \fi
- \renewcommand*{\si@tempb}{large}%
- \ifx\si@tempa\si@tempb
- \si@ang@padlargetrue
- \fi
- \renewcommand*{\si@tempb}{all}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \si@ang@padlargetrue
- \fi
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \si@ang@padlargetrue
- \fi
- \renewcommand*{\si@tempb}{both}%
- \ifx\si@tempa\si@tempb
- \si@ang@padsmalltrue
- \si@ang@padlargetrue
- \fi}
-\newif\ifsi@ang@toarc
-\newif\ifsi@ang@todec
-\si@opt@choicekey[all]{angformat}
- {dec,decimal,arc,dms,unchanged,none}
- {\si@ang@toarcfalse
- \si@ang@todecfalse
- \renewcommand*{\si@tempb}{dec}%
- \ifx\si@tempa\si@tempb
- \si@ang@todectrue
- \fi
- \renewcommand*{\si@tempb}{decimal}%
- \ifx\si@tempa\si@tempb
- \si@ang@todectrue
- \fi
- \renewcommand*{\si@tempb}{arc}%
- \ifx\si@tempa\si@tempb
- \si@ang@toarctrue
- \fi
- \renewcommand*{\si@tempb}{dms}%
- \ifx\si@tempa\si@tempb
- \si@ang@toarctrue
- \fi}
-\si@opt@boolkey{astroang}
-\si@opt@boolkey{strictarc}
-\newif\ifsi@tab@fixed
-\si@opt@boolkey{tabparseonly}
-\si@opt@choicekey{tabnumalign}
- {centredecimal,centerdecimal,right,left,centre,center}
- {\si@tab@fixedtrue
- \def\si@tab@rfill@S{0.5}%
- \def\si@tab@lfill@S{0.5}%
- \renewcommand*{\si@tempb}{right}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@S{0}%
- \def\si@tab@lfill@S{1}%
- \fi
- \renewcommand*{\si@tempb}{left}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@S{1}%
- \def\si@tab@lfill@S{0}%
- \fi
- \renewcommand*{\si@tempb}{centredecimal}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@tab@fixedfalse
- \fi
- \renewcommand*{\si@tempb}{centerdecimal}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@tab@fixedfalse
- \fi}
-\si@opt@key{tabalign}{\sisetup{tabnumalign=#1,tabtextalign=#1,
- tabunitalign=#1}}
-\si@opt@boolkey{tabalignexp}
-\si@opt@boolkey[%
- \si@tabalignexpfalse
- \ifsi@tabexpalign
- \expandafter\si@tabalignexptrue
- \fi
- ]{tabexpalign}
-\newcount\si@tab@mantprecnt
-\newcount\si@tab@mantpostcnt
-\newcount\si@tab@expprecnt
-\newcount\si@tab@exppostcnt
-\newif\ifsi@tab@mantsign
-\newif\ifsi@tab@expsign
-\si@opt@cmdkey{tabformat}
- {\si@num@fixpm
- \renewcommand*{\si@num@arg}{tabformat data}%
- \renewcommand*{\si@num@exp}{}%
- \renewcommand*{\si@num@mant}{}%
- \si@tab@mantsignfalse
- \si@tab@expsignfalse
- \si@switchfalse
- \si@num@sepmantexp{#1}%
- \si@num@sepsign{mant}%
- \ifx\@empty\si@num@mantsign\@empty
- \ifsi@num@delplus
- \expandafter\expandafter\expandafter\si@tab@mantsigntrue
- \fi
- \else
- \expandafter\si@tab@mantsigntrue
- \fi
- \si@num@sepsign{exp}%
- \ifx\@empty\si@num@expsign\@empty
- \ifsi@num@delplus
- \expandafter\expandafter\expandafter\si@tab@expsigntrue
- \fi
- \else
- \expandafter\si@tab@expsigntrue
- \fi
- \si@opt@proctform{mant}%
- \si@opt@proctform{exp}%
- \ifnum\si@tab@mantpostcnt=\z@\relax
- \ifnum\si@tab@mantprecnt=\z@\relax
- \si@log@err{Empty mantissa argument for tabformat}
- {The argument `#1' contains no valid entry for
- a mantissa\MessageBreak It should be of the
- form `m.n', where m and n are integers}%
- \fi
- \fi
- \ifsi@tab@fixed\else
- \sisetup{tabnumalign=centre}%
- \fi
- \let\pm\si@num@pm
- \let\mp\si@num@mp}
-\newcommand*{\si@opt@proctform}[1]{%
- \renewcommand*{\si@num@predec}{}%
- \renewcommand*{\si@num@postdec}{}%
- \si@switchfalse
- \expandafter\si@ifnotmtarg\expandafter{%
- \csname si@num@#1\endcsname}
- {\expandafter\expandafter\expandafter\si@num@digits
- \csname si@num@#1\endcsname\@empty\@empty}%
- \csname si@tab@#1precnt\endcsname\z@\relax
- \csname si@tab@#1postcnt\endcsname\z@\relax
- \ifx\@empty\si@num@predec\@empty\else
- \csname si@tab@#1precnt\endcsname\si@num@predec\relax
- \fi
- \ifx\@empty\si@num@postdec\@empty\else
- \csname si@tab@#1postcnt\endcsname\si@num@postdec\relax
- \fi}
-\si@opt@choicekey{tabtextalign}{left,right,centre,center}
- {\def\si@tab@rfill@t{0.5}%
- \def\si@tab@lfill@t{0.5}%
- \renewcommand*{\si@tempb}{right}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@t{0}%
- \def\si@tab@lfill@t{1}%
- \fi
- \renewcommand*{\si@tempb}{left}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@t{1}%
- \def\si@tab@lfill@t{0}%
- \fi}
-\si@opt@choicekey{tabunitalign}{left,right,centre,center}
- {\def\si@tab@rfill@s{0.5}%
- \def\si@tab@lfill@s{0.5}%
- \renewcommand*{\si@tempb}{right}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@s{0}%
- \def\si@tab@lfill@s{1}%
- \fi
- \renewcommand*{\si@tempb}{left}%
- \ifx\si@tempa\si@tempb
- \def\si@tab@rfill@s{1}%
- \def\si@tab@lfill@s{0}%
- \fi}
-\si@opt@boolkey[%
- \ifsi@fixdp
- \expandafter\si@fixsffalse
- \fi]{fixdp}
-\newcount\si@num@dp
-\si@opt@key{dp}{%
- \si@str@ifonlychrs{#1}{0123456789}
- {\si@num@dp#1\relax
- \si@fixdptrue
- \si@fixsffalse}
- {\si@log@err{Invalid input for dp option}
- {The dp option must be given a positive integer}}}
-\si@opt@boolkey[%
- \ifsi@fixsf
- \expandafter\si@fixdpfalse
- \fi]{fixsf}
-\newcount\si@num@sf
-\si@opt@key{sf}{%
- \si@str@ifonlychrs{#1}{0123456789}
- {\si@num@sf#1\relax
- \ifnum\si@num@sf=\z@\relax
- \si@log@warn{Setting sf=0 disables function}%
- \si@fixsffalse
- \else
- \si@fixsftrue
- \si@fixdpfalse
- \fi}
- {\si@log@err{Invalid input for sf option}
- {The sf option must be given a positive integer}}}
-\si@opt@boolkey{tabautofit}
-\si@opt@boolkey{xspace}
-\si@opt@boolkey
- [\si@unt@numfalse
- \ifsi@prespace
- \si@unt@numtrue
- \fi]
- {prespace}
-\si@opt@boolkey{allowoptarg}
-\si@opt@boolkey{allowlitunits}
-\newif\ifsi@slash
-\newif\ifsi@frac
-\si@opt@boolkey{stickyper}
-\si@opt@choicekey[reciprocal]{per}
- {reciprocal,rp,power,slash,frac,fraction}
- {\si@slashfalse
- \si@fracfalse
- \let\si@frac\si@frc@frac
- \renewcommand*{\si@tempb}{slash}%
- \ifx\si@tempa\si@tempb
- \si@fractrue
- \si@slashtrue
- \let\si@frac\si@frc@slash
- \fi
- \renewcommand*{\si@tempb}{frac}%
- \ifx\si@tempa\si@tempb
- \si@fractrue
- \fi
- \renewcommand*{\si@tempb}{fraction}%
- \ifx\si@tempa\si@tempb
- \si@fractrue
- \fi}
-\si@opt@xchoicekey{slash}{slash}{slash}
-\newif\ifsi@repeatunits
-\newif\ifsi@addunitpower
-\si@opt@choicekey[true]{repeatunits}{true,false,power}
- {\si@repeatunitsfalse
- \si@addunitpowerfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@repeatunitstrue
- \fi
- \renewcommand*{\si@tempb}{power}%
- \ifx\si@tempa\si@tempb
- \si@addunitpowertrue
- \fi}
-\si@opt@boolkey{trapambigfrac}
-\si@opt@cmdkeys{closefrac,openfrac}
-\si@opt@choicekey[frac]{fraction}
- {frac,nicefrac,nice,sfrac,xfrac,uglyfrac,ugly}
- {\let\si@frac\si@frc@frac
- \renewcommand*{\si@tempb}{nicefrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@nice
- \fi
- \renewcommand*{\si@tempb}{uglyfrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@ugly
- \fi
- \renewcommand*{\si@tempb}{nice}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@nice
- \fi
- \renewcommand*{\si@tempb}{sfrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@sfrac
- \fi
- \renewcommand*{\si@tempb}{xfrac}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@sfrac
- \fi
- \renewcommand*{\si@tempb}{ugly}%
- \ifx\si@tempa\si@tempb
- \let\si@frac\si@frc@ugly
- \fi}
-\si@opt@cmdkeys{load,noload}
-\si@opt@key{alsoload}{\si@addtolist{\si@load}{#1}}
-\AtEndOfPackage{
- \si@opt@disablekey{load}
- {Configuration files can only be used\MessageBreak
- when loading package}
- \si@opt@disablekey{noload}
- {Configuration files can only be used\MessageBreak
- when loading package}}
-\AtEndOfPackage{
- \si@opt@key{alsoload}{%
- \@for\si@tempa:=#1\do{\si@loadfile{\si@tempa}}}}
-\si@opt@boolkey{colourunits}
-\si@opt@boolkey{colourvalues}
-\si@opt@choicekey[true]{colorunits}
- {true,false}
- {\si@colourunitsfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourunitstrue
- \fi}
-\si@opt@choicekey[true]{colorvalues}
- {true,false}
- {\si@colourvaluesfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourvaluestrue
- \fi}
-\si@opt@choicekey[true]{colorall}
- {true,false}
- {\si@colourvaluesfalse
- \si@colourunitsfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourunitstrue
- \si@colourvaluestrue
- \fi}
-\si@opt@choicekey[true]{colourall}
- {true,false}
- {\si@colourvaluesfalse
- \si@colourunitsfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colourunitstrue
- \si@colourvaluestrue
- \fi}
-\si@opt@cmdkeys{unitcolour,valuecolour}
-\si@opt@key{unitcolor}{\sisetup{unitcolour=#1}}
-\si@opt@key{valuecolor}{\sisetup{valuecolour=#1}}
-\si@opt@key{colour}{\sisetup{unitcolour=#1,valuecolour=#1}}
-\si@opt@key{color}{\sisetup{unitcolour=#1,valuecolour=#1}}
-\si@opt@boolkey{colourneg}
-\si@opt@choicekey[true]{colorneg}
- {true,false}
- {\si@colournegfalse
- \renewcommand*{\si@tempb}{true}%
- \ifx\si@tempa\si@tempb
- \si@colournegtrue
- \fi}
-\si@opt@cmdkeys{negcolour}
-\si@opt@key{negcolor}{\sisetup{negcolour=#1}}
-\si@opt@cmdkeys{textOmega,mathsOmega}
-\si@opt@key{mathOmega}{\sisetup{mathsOmega=#1}}
-\newcommand*{\si@mathsOmega}{\text{\ensuremath{\si@upOmega}}}
-\newcommand*{\si@textOmega}{\ensuremath{\si@upOmega}}
-\newcommand*\si@upOmega{}
-\AtBeginDocument{
- \ifdefined\upOmega
- \let\si@upOmega\upOmega
- \else
- \let\si@upOmega\Omega
- \fi
-}
-\si@opt@cmdkeys{textmu,mathsmu}
-\si@opt@key{mathmu}{\sisetup{mathsmu=#1}}
-\DeclareFontEncoding{TS1}{}{}
-\DeclareFontSubstitution{TS1}{cmr}{m}{n}
-\DeclareTextSymbol{\si@textmu}{TS1}{181}
-\DeclareTextSymbolDefault{\si@textmu}{TS1}
-\def\si@mathsmu{\text{\si@textmu}}
-\si@opt@cmdkeys{textdegree,mathsdegree,textminute,mathsminute,
- textsecond,mathssecond}
-\si@opt@key{mathdegree}{\sisetup{mathsdegree=#1}}
-\si@opt@key{mathminute}{\sisetup{mathsminute=#1}}
-\si@opt@key{mathsecond}{\sisetup{mathssecond=#1}}
-\newcommand*{\si@textdegree}{\ensuremath{{}^{\circ}}}
-\newcommand*{\si@mathsdegree}{{}^{\circ}}
-\newcommand*{\si@textminute}{\ensuremath{{}^{\prime}}}
-\newcommand*{\si@mathsminute}{{}^{\prime}}
-\newcommand*{\si@textsecond}{\ensuremath{{}^{\prime\prime}}}
-\newcommand*{\si@mathssecond}{{}^{\prime\prime}}
-\si@opt@cmdkeys{textcelsius,mathscelsius}
-\si@opt@key{mathcelsius}{\sisetup{mathscelsius=#1}}
-\newcommand*{\si@textcelsius}{%
- \si@textdegree\kern-\scriptspace C}
-\newcommand*{\si@mathscelsius}{%
- \si@mathsdegree\kern-\scriptspace C}
-\si@opt@cmdkeys{textringA,mathsringA}
-\si@opt@key{mathringA}{\sisetup{mathsringA=#1}}
-\newcommand*{\si@textringA}{\AA}
-\newcommand*{\si@mathsringA}{\text{\AA}}
-\si@opt@boolkey{redefsymbols}
-\AtBeginDocument{
- \si@opt@disablekey{redefsymbols}
- {Symbols can only be redefined\MessageBreak
- when loading siunitx}}
-\newlength\si@eVcorra
-\newlength\si@eVcorrb
-\si@opt@key{eVcorra}{\setlength\si@eVcorra{#1}}
-\si@opt@key{eVcorrb}{\setlength\si@eVcorrb{#1}}
-\si@opt@xchoicekey{tophrase}{to,dots,ndash,dash}{to}
-\si@opt@boolkey{trapambigrange}
-\si@opt@cmdkeys{openrange,closerange}
-\si@opt@key{locale}{%
- \si@loc@load{#1}%
- \si@loc@set{#1}}%
-\si@opt@key{loctolang}{\si@loc@ltol{#1}}
-\si@opt@compatkey{units}{ugly}
-\si@opt@compatkey{units}{nice}
-\si@opt@compatkey{units}{loose}
-\si@opt@compatkey{units}{tight}
-\si@opt@compatkey{unitsdef}{OHM}
-\si@opt@compatkey{unitsdef}{ohm}
-\si@opt@compatkey{unitsdef}{redef-gensymb}
-\newif\ifsi@gensymb
-\si@opt@compatkey{unitsdef}{LITER}
-\si@opt@compatkey{unitsdef}{liter}
-\si@opt@compatkey{unitsdef}{noxspace}
-\si@opt@compatkey{unitsdef}{noconfig}
-\si@opt@compatkey{unitsdef}{noabbr}
-\si@opt@compatkey{unitsdef}{noampereageabbr}
-\si@opt@compatkey{unitsdef}{nofrequncyabbr}
-\si@opt@compatkey{unitsdef}{nomolabbr}
-\si@opt@compatkey{unitsdef}{novoltageabbr}
-\si@opt@compatkey{unitsdef}{novolumeabbr}
-\si@opt@compatkey{unitsdef}{noweightabbr}
-\si@opt@compatkey{unitsdef}{noenergyabbr}
-\si@opt@compatkey{unitsdef}{nolengthabbr}
-\si@opt@compatkey{unitsdef}{notimeabbr}
-\si@opt@compatkey{SIunits}{cdot}
-\si@opt@compatkey{SIunits}{thickspace}
-\si@opt@compatkey{SIunits}{mediumspace}
-\si@opt@compatkey{SIunits}{thinspace}
-\si@opt@compatkey{SIunits}{thickqspace}
-\si@opt@compatkey{SIunits}{mediumqspace}
-\si@opt@compatkey{SIunits}{thinqspace}
-\si@opt@compatkey{SIunits}{amssymb}
-\si@opt@compatkey{SIunits}{squaren}
-\si@opt@compatkey{SIunits}{pstricks}
-\si@opt@compatkey{SIunits}{Gray}
-\si@opt@compatkey{SIunits}{italian}
-\si@opt@compatkey{SIunits}{textstyle}
-\si@opt@compatkey{SIunits}{binary}
-\si@opt@compatkey{SIunits}{noams}
-\si@opt@compatkey{SIunits}{derivedinbase}
-\si@opt@compatkey{SIunits}{derived}
-\si@opt@compatkey{hepunits}{noprefixcmds}
-\si@opt@compatkey{fancynum}{english}
-\si@opt@compatkey{fancynum}{french}
-\si@opt@compatkey{fancynum}{tight}
-\si@opt@compatkey{fancynum}{loose}
-\si@opt@compatkey{fancynum}{thinspaces}
-\si@opt@compatkey{fancynum}{commas}
-\si@opt@compatkey{fancynum}{plain}
-\si@opt@compatkey{fancyunits}{spaceqspace}
-\newcommand*{\si@fix@thin}{\,}
-\newcommand*{\si@fix@med}{\:}
-\newcommand*{\si@fix@medium}{\:}
-\newcommand*{\si@fix@thick}{\;}
-\newcommand*{\si@fix@space}{\text{ }}
-\newcommand*{\si@fix@cdot}{{}\cdot{}}
-\newcommand*{\si@fix@comma}{{,}}
-\newcommand*{\si@fix@stop}{{.}}
-\newcommand*{\si@fix@fullstop}{{.}}
-\newcommand*{\si@fix@period}{{.}}
-\newcommand*{\si@fix@times}{\times}
-\newcommand*{\si@fix@tighttimes}{\bgroup\times\egroup}
-\newcommand*{\si@fix@tightcdot}{\bgroup\cdot\egroup}
-\newcommand*{\si@fix@plus}{+}
-\newcommand*{\si@fix@minus}{-}
-\newcommand*{\si@fix@pm}{\pm}
-\newcommand*{\si@fix@tightpm}{\bgroup\pm\egroup}
-\newcommand*{\si@fix@mp}{\mp}
-\newcommand*{\si@fix@two}{2}
-\newcommand*{\si@fix@ten}{10}
-\newcommand*{\si@fix@slash}{/}
-\newcommand*{\si@fix@none}{}
-\newcommand*{\si@fix@to}{ to }
-\newcommand*{\si@fix@dash}{--}
-\newcommand*{\si@fix@dots}{\,\dots\,}
-\newcommand*{\si@symbol}[1]{%
- \expandafter\protected\expandafter\def
- \csname si@sym@#1\endcsname{%
- \ifmmode
- \expandafter\csname si@maths#1\expandafter\endcsname
- \else
- \expandafter\csname si@text#1\expandafter\endcsname
- \fi}}
-\si@symbol{Omega}
-\si@symbol{ringA}
-\si@symbol{mu}
-\si@symbol{degree}
-\si@symbol{minute}
-\si@symbol{second}
-\si@symbol{celsius}
-\AtBeginDocument{%
- \ifsi@redefsymbols
- \@ifpackageloaded{textcomp}
- {\si@log@debug{Redefining symbols using textcomp}%
- \renewcommand*{\si@textdegree}{\textdegree}%
- \renewcommand*{\si@mathsdegree}{\text{\textdegree}}%
- \@ifpackageloaded{mathptmx}{}
- {\renewcommand*{\si@textmu}{\textmu}%
- \renewcommand*{\si@textOmega}{\textohm}}%
- \renewcommand*{\si@tempa}{OT1}%
- \ifx\si@tempa\encodingdefault
- \renewcommand*{\si@mathsringA}{%
- \text{\capitalring{A}}}%
- \renewcommand*{\si@textringA}{\capitalring{A}}
- \fi}{}
- \@ifpackageloaded{upgreek}
- {\si@log@debug{Redefining symbols using upgreek}%
- \renewcommand*{\si@mathsOmega}{\Upomega}}{}
- \fi}
-\newcommand*{\si@frc@frac}[2]{%
- \ensuremath{\si@frc@hook\frac{%
- \expandafter\si@unt@out\expandafter{#1}}%
- {\expandafter\si@unt@out\expandafter{#2}}}}
-\let\si@frac\si@frc@frac
-\newcommand*{\si@frc@hook}{}
-\newcommand*{\si@frc@slash}[2]{%
- \expandafter\si@unt@out\expandafter{#1}%
- \si@out{\ensuremath{\si@slash}}%
- \expandafter\si@unt@out\expandafter{#2}}
-\newcommand*{\si@frc@nice}[2]{%
- \ensuremath{\si@frc@nicefrac{\expandafter\si@unt@out%
- \expandafter{#1}}{\expandafter\si@unt@out\expandafter
- {#2}}}}
-\newcommand*{\si@frc@sfrac}[2]{%
- \sfrac{\expandafter\si@unt@out\expandafter{#1}}%
- {\expandafter\si@unt@out\expandafter{#2}}}
-\AtBeginDocument{
- \@ifpackageloaded{xfrac}
- {}
- {\si@log@inf{xfrac package unavailable\MessageBreak
- using `fraction=sfrac' will fall back on\MessageBreak
- nicefrac-like method}%
- \renewcommand*{\si@frc@sfrac}[2]{%
- \si@log@warn{xfrac package unavailable}%
- \si@frc@nice{#1}{#2}}}}
-\newlength\si@frc@displen
-\newlength\si@frc@textlen
-\newlength\si@frc@suplen
-\newlength\si@frc@ssuplen
-\newcommand*{\si@frc@nicefrac}{%
- \ifmmode
- \expandafter\si@frc@mathsnf
- \else
- \expandafter\si@frc@textnf
- \fi}
-\newcommand*{\si@frc@mathsnf}[2]{%
- \begingroup
- \settoheight{\si@frc@displen}{\ensuremath{%
- \displaystyle{M}}}%
- \settoheight{\si@frc@textlen}{\ensuremath{%
- \textstyle{M}}}%
- \settoheight{\si@frc@suplen}{\ensuremath{%
- \scriptstyle{M}}}%
- \settoheight{\si@frc@ssuplen}{%
- \ensuremath{\scriptscriptstyle{M}}}%
- \addtolength{\si@frc@displen}{-\si@frc@ssuplen}%
- \addtolength{\si@frc@textlen}{-\si@frc@ssuplen}%
- \addtolength{\si@frc@suplen}{-\si@frc@ssuplen}%
- \mathchoice
- {\raisebox{\si@frc@displen}{\ensuremath{%
- \scriptstyle{#1}}}}%
- {\raisebox{\si@frc@textlen}{\ensuremath{%
- \scriptstyle{#1}}}}%
- {\raisebox{\si@frc@suplen}%
- {\ensuremath{\scriptscriptstyle{#1}}}}%
- {\raisebox{\si@frc@ssuplen}%
- {\ensuremath{\scriptscriptstyle{#1}}}}%
- \mkern-2mu\relax/\mkern-1mu\relax
- \bgroup
- \mathchoice
- {\scriptstyle}%
- {\scriptstyle}%
- {\scriptscriptstyle}%
- {\scriptscriptstyle}%
- {#2}%
- \egroup
- \endgroup}
-\newcommand*{\si@frc@textnf}[2]{%
- \begingroup
- \settoheight{\si@frc@textlen}{M}%
- \settoheight{\si@frc@ssuplen}{\fontsize\sf@size\z@\relax
- \selectfont{M}}%
- \addtolength{\si@frc@textlen}{-\si@frc@ssuplen}%
- \raisebox{\si@frc@textlen}{\fontsize\sf@size\z@\relax
- \selectfont{#1}}%
- \hspace{-0.25ex}/\hspace{-0.25ex}%
- \hbox{\fontsize\sf@size\z@\selectfont{#2}}%
- \endgroup}
-\newcommand*{\si@frc@ugly}[1]{%
- \renewcommand*{\si@tempa}{#1}%
- \ifmmode
- \expandafter\si@frc@frac
- \else
- \renewcommand*{\si@tempb}{1}%
- \ifx\si@tempa\si@tempb
- \setbox\si@tempboxa=\hbox{\ensuremath{\si@valuesep}}%
- \hskip-\wd\si@tempboxa\relax
- \renewcommand*{\si@tempa}{}%
- \fi
- \expandafter\si@frc@slash
- \fi
- {\si@tempa}}
-\g@addto@macro{\document}{%
- \ifdefined\mathsf
- \setbox\si@tempboxa=\hbox{%
- $\mathsf{\global\chardef\si@fam@sf=\fam}$}%
- \else
- \si@log@inf{\string\mathsf not found}%
- \global\chardef\si@fam@sf=99\relax
- \fi
- \ifdefined\mathtt
- \setbox\si@tempboxa=\hbox{%
- $\mathtt{\global\chardef\si@fam@tt=\fam}$}%
- \else
- \si@log@inf{\string\mathtt not found}%
- \global\chardef\si@fam@tt=99\relax
- \fi}
-\newcommand*\si@fam@detect@default{%
- \edef\si@tempa{\familydefault}%
- \edef\si@tempb{\sfdefault}%
- \ifx\si@tempa\si@tempb
- \@ifpackageloaded{cmbright}{}{\sisetup{ mathsrm = mathsf}}%
- \sisetup{ textrm = sffamily }%
- \fi
- \edef\si@tempb{\ttdefault}%
- \ifx\si@tempa\si@tempb
- \sisetup
+\RequirePackage{expl3}
+\ProvidesExplPackage {siunitx} {2010/05/23} {2.0}
+ {A comprehensive (SI) units package}
+\msg_set:nnnn { siunitx } { incompatible-package }
+ { Package~'#1'~incompatible. }
+ { The~#1~package~and~siunitx~are~incompatible. }
+\cs_set_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
+}
+\RequirePackage{ amstext , array , l3keys2e }
+\cs_set: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
+\bool_new:N \_l_siunitx_error_bool
+\cs_set_protected:Npn \_siunitx_error:nxx #1#2#3 {
+ \bool_set_true:N \_l_siunitx_error_bool
+ \msg_error:nnxx { siunitx } {#1} {#2} {#3}
+}
+\cs_set_protected:Npn \_siunitx_error:nx #1#2 {
+ \_siunitx_error:nxx {#1} {#2} { }
+}
+\cs_set_protected:Npn \_siunitx_error:n #1 {
+ \_siunitx_error:nxx {#1} { } { }
+}
+\cs_generate_variant:Nn \_siunitx_error:nx { nV }
+\AtBeginDocument {
+ \cs_if_free:cT { T@TS1 }
+ {
+ \DeclareFontEncoding { TS1 } { } { }
+ \DeclareFontSubstitution { TS1 } { cmr } { m } { n }
+ }
+}
+\DeclareTextSymbolDefault \_c_siunitx_minus_tl { TS1 }
+\DeclareTextSymbol \_c_siunitx_minus_tl { TS1 } { 61 }
+\DeclareTextSymbol \_c_siunitx_mu_tl { TS1 } { 181 }
+\DeclareTextSymbolDefault \_c_siunitx_mu_tl { TS1 }
+\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 } }
+}
+\cs_set_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_set_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 }
+\keys_define:nn { siunitx } {
+ unknown .code:n =
+ {
+ \msg_error:nnx { siunitx } { unknown-option }
+ { \exp_not:V \l_keys_key_tl }
+ }
+}
+\clist_new:N \_l_siunitx_option_deactivate_clist
+\cs_set_protected_nopar:Npn \_siunitx_option_deactivate:n #1 {
+ \clist_put_right:Nn \_l_siunitx_option_deactivate_clist {#1}
+}
+\cs_set_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
+}
+\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 }
+\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:Nnn \_siunitx_cs_if_tl:N { T , TF }
+ {
+ \exp_after:wN \_siunitx_cs_if_tl_aux:w
+ \token_to_meaning:N #1 MACRO \q_nil
+ {
+ \cs_if_exist:cTF { \cs_to_str:N #1 ~ }
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+ { \prg_return_false: }
+ }
+ \cs_set_nopar:Npn \_siunitx_cs_if_tl_aux:w #1 MACRO #2 \q_nil
+ { \tl_if_empty:nTF {#1} }
+ \prg_new_conditional:Nnn \_siunitx_cs_if_macro:N { T }
+ {
+ \exp_after:wN \_siunitx_cs_if_tl_aux:w
+ \token_to_meaning:N #1 MACRO \q_nil
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+}
+\cs_set_eq:NN \_siunitx_ensuremath:n \ensuremath
+\AtBeginDocument {
+ \@ifpackageloaded { tex4ht }
+ {
+ \cs_set_eq:NN \_siunitx_ensuremath:n \use:n
+ \keys_set:nn { siunitx } { mode = text }
+ }
+ { }
+}
+\cs_set_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 }
+}
+\cs_set_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 }
+}
+\tl_new:N \_l_siunitx_detect_inline_weight_tl
+\keys_define:nn { siunitx } {
+ detect-all .choice:,
+ detect-all .default:n = true,
+ detect-all / false .meta:n =
+ {
+ detect-family = false,
+ detect-italic = false,
+ detect-mode = false,
+ detect-weight = false
+ },
+ detect-all / true .meta:n =
+ {
+ detect-family = true,
+ detect-italic = true,
+ detect-mode = 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-weight .choice:,
+ detect-inline-weight .value_required:,
+ detect-inline-weight /
+ combined .code:n =
+ { \tl_set:Nn \_l_siunitx_detect_inline_weight_tl { combined } },
+ 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_italic_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-italic = true,
+ detect-mode = true,
+ detect-weight = true
+ },
+ detect-none / true .meta:n =
+ {
+ detect-family = false,
+ detect-italic = false,
+ detect-mode = false,
+ detect-weight = false
+ },
+ detect-weight .bool_set:N = \_l_siunitx_detect_weight_bool
+}
+\bool_new:N \_l_siunitx_font_set_bool
+\bool_new:N \_l_siunitx_font_math_mode_bool
+\tl_new:N \_l_siunitx_font_family_tl
+\cs_set_nopar:Npn \_siunitx_font_italic: { }
+\cs_set_nopar:Npn \_siunitx_font_weight: { }
+\cs_set_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_italic_bool
+ { \_siunitx_detect_font_italic: }
+ \bool_if:NT \_l_siunitx_detect_mode_bool
+ { \_siunitx_detect_font_mode: }
+ }
+}
+\cs_set_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_italic: { \upshape }
+ \tl_set:Nn \_l_siunitx_font_family_tl { rm }
+ \bool_set_true:N \_l_siunitx_font_math_mode_bool
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_weight: {
+ \mode_if_math:TF
+ {
+ \mode_if_inner:TF
+ {
+ \use:c
+ {
+ _siunitx_detect_font_weight_
+ \_l_siunitx_detect_inline_weight_tl
+ :
+ }
+ }
+ {
+ \bool_if:NTF \_l_siunitx_detect_display_math_bool
+ { \_siunitx_detect_font_weight_math: }
+ { \_siunitx_detect_font_weight_text: }
+ }
+ }
+ { \_siunitx_detect_font_weight_text: }
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_weight_combined: {
+ \_siunitx_detect_font_weight_math:
+ \_siunitx_detect_font_weight_text:
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_weight_math: {
+ \tl_if_eq:nVT { bold } \math@version
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ {
+ \boldmath
+ \bfseries
+ }
+ }
+ \tl_if_eq:nVT { light } \math@version
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ { \lseries }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_weight_text: {
+ \tl_set:Nx \_l_siunitx_tmpa_tl { \exp_args:NV \tl_head_i:n \f@series }
+ \tl_if_eq:nVT { b } \_l_siunitx_tmpa_tl
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ {
+ \boldmath
+ \bfseries
+ }
+ }
+ \tl_if_eq:nVT { l } \_l_siunitx_tmpa_tl
+ {
+ \cs_set:Npn \_siunitx_font_weight:
+ { \lseries }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_family: {
+ \_siunitx_detect_font_family_text:
+ \bool_if:NT \_l_siunitx_detect_display_math_bool
+ {
+ \mode_if_math:T
+ { \mode_if_inner:F { \_siunitx_detect_font_family_math: } }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_family_math: {
+ \tl_set:Nn \_l_siunitx_font_family_tl { rm }
+ \intexpr_compare:nNnT
+ { \int_use:N \fam } = { \int_use:N \_c_siunitx_mathsf_int }
+ { \tl_set:Nn \_l_siunitx_font_family_tl { sf } }
+ \intexpr_compare:nNnT
+ { \int_use:N \fam } = { \int_use:N \_c_siunitx_mathtt_int }
+ { \tl_set:Nn \_l_siunitx_font_family_tl { tt } }
+}
+\cs_set_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 } }
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_italic: {
+ \tl_if_eq:nVT { it } \f@shape
+ { \cs_set_nopar:Npn \_siunitx_font_italic: { \itshape } }
+}
+\cs_set_protected_nopar:Npn \_siunitx_detect_font_mode: {
+ \mode_if_math:F
+ { \bool_set_false:N \_l_siunitx_font_math_mode_bool }
+}
+\bool_new:N \_l_siunitx_number_math_mode_bool
+\bool_new:N \_l_siunitx_unit_math_mode_bool
+\cs_set:Npn \_siunitx_number_mathrm:n #1 { }
+\cs_set:Npn \_siunitx_number_mathsf:n #1 { }
+\cs_set:Npn \_siunitx_number_mathtt:n #1 { }
+\cs_set_nopar:Npn \_siunitx_number_textrm: { }
+\cs_set_nopar:Npn \_siunitx_number_textsf: { }
+\cs_set_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} }
+}
+\cs_set_nopar:Npn \_siunitx_unit_mathrm: { }
+\cs_set_nopar:Npn \_siunitx_unit_mathsf: { }
+\cs_set_nopar:Npn \_siunitx_unit_mathtt: { }
+\cs_set_nopar:Npn \_siunitx_unit_textrm: { }
+\cs_set_nopar:Npn \_siunitx_unit_textsf: { }
+\cs_set_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} }
+}
+\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,
+}
+\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
+ }
+ }
+}
+\tl_new:N \_l_siunitx_print_arg_tl
+\tl_new:N \_l_siunitx_print_type_tl
+\cs_set_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 }
+\cs_set_protected_nopar:Npn \_siunitx_print_aux: {
+ \text
+ {
+ \_siunitx_print_color:
+ \_siunitx_font_weight:
+ \_siunitx_font_italic:
+ \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: }
+ }
+}
+\cs_set_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: }
+}
+\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
+ }
+}
+\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_set_protected:Npn \_siunitx_print_text_sub_super:n { }
+\cs_set_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
+}
+\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 = /
+}
+\tl_new:N \_l_siunitx_number_arg_tl
+\tl_new:N \_l_siunitx_number_next_tl
+\tl_new:N \_l_siunitx_number_multi_tl
+\tl_new:N \_l_siunitx_number_denominator_tl
+\tl_new:N \_l_siunitx_number_numerator_tl
+\cs_set_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 }
+\cs_set_protected_nopar:Npn \_siunitx_number_preprocess_init: {
+ \bool_set_false:N \_l_siunitx_error_bool
+ \tl_clear:N \_l_siunitx_number_multi_tl
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_preprocess_product: {
+ \tl_map_function:NN \_l_siunitx_input_product_tl
+ \_siunitx_number_preprocess_product_aux:N
+}
+\cs_set_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_after:wN \_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:
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_preprocess_quotient: {
+ \tl_map_function:NN \_l_siunitx_input_quotient_tl
+ \_siunitx_number_preprocess_quotient_aux:N
+}
+\cs_set_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_after:wN \_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:
+ }
+}
+\tl_new:N \_c_siunitx_number_part_complex_tl
+\tl_set:Nn \_c_siunitx_number_part_complex_tl { complex }
+\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
+\prop_new:N \_l_siunitx_number_in_prop
+\tl_new:N \_l_siunitx_number_parsed_tl
+\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
+\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-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-decimal-markers = {.,},
+ input-digits = 0123456789,
+ input-exponent-markers = dDeE,
+ input-open-uncertainty = (, % )
+ input-protect-tokens = \mp\pi\pm,
+ input-signs = +-\mp\pm,
+ input-symbols = \pi,
+}
+\cs_set_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_set_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
+ \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}
+}
+\cs_set_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_set_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 }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_in_protect: {
+ \tl_map_function:NN \_l_siunitx_input_protect_tl
+ \_siunitx_number_in_protect_aux:N
+}
+\cs_set_protected:Npn \_siunitx_number_in_protect_aux:N #1 {
+ \cs_set_eq:NN #1 \scan_stop:
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_in_sign_replace:N #1 {
+ \tl_replace_all_in:Nnn #1 { -+ } { \mp }
+ \tl_replace_all_in:Nnn #1 { +- } { \pm }
+}
+\cs_set_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 }
+\cs_set_protected:Npn \_siunitx_number_in_parse_loop:N #1 { }
+\cs_set_protected:Npn \_siunitx_number_in_parse_more:N #1 { }
+\cs_set_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}
+ }
+ }
+ }
+ }
+}
+\cs_set_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
+ }
+ }
+}
+\cs_set_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}
+ }
+ }
+ }
+ }
+}
+\cs_set_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 #1
+ }
+ {
+ \tl_if_in:NnF \_l_siunitx_input_ignore_tl {#1}
+ { \_siunitx_number_in_parse_more:N #1 }
+ }
+ }
+ }
+ }
+}
+\cs_set_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}
+ }
+ }
+ }
+ }
+}
+\cs_set_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
+ }
+ }
+ }
+ }
+ }
+ }
+}
+\cs_set_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
+ }
+ }
+ }
+ }
+}
+\cs_set_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_set_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
+ }
+}
+\cs_set_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}
+ }
+}
+\cs_set_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}
+ \tl_if_eq:nnF {#1} { 0 }
+ { \bool_set_true:N \_l_siunitx_number_in_value_bool }
+ }
+ {
+ \tl_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} }
+ }
+ }
+}
+\cs_set_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 }
+ }
+}
+\cs_set_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
+ }
+ }
+ }
+}
+\cs_set_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_set_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
+ }
+}
+\cs_set_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
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_in_check:n #1 { }
+\cs_set_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_set_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:nV { misplaced-sign-token } \_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
+ }
+ }
+}
+\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
+\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
+\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,
+ 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-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,
+}
+\keys_set:nn { siunitx } {
+ add-decimal-zero = true,
+ add-integer-zero = true,
+ retain-unity-mantissa = true,
+ round-precision = 2,
+}
+\cs_set_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:
+ \_siunitx_number_process_uncertainty:
+ \prop_if_in:NnF \_l_siunitx_number_in_prop { uncertainty }
+ { \_siunitx_number_process_round: }
+ }
+}
+\cs_set_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_set_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
+ {
+ \intexpr_compare:nNnF
+ { \_l_siunitx_tmpa_tl } = { 0 }
+ { \bool_set_true:N \_l_siunitx_tmp_bool }
+ }
+}
+\cs_set_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_set_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_round_int } >
+ { \int_use:N \_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_set_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
+}
+\cs_set_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_set_protected_nopar:Npn
+ \_siunitx_number_process_figures_count_aux:n #1 {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:Nv \tl_head_i:n { _l_siunitx_round_ #1 _in_tl } }
+ \tl_set:cx { _l_siunitx_round_ #1 _in_tl }
+ { \exp_args:Nv \tl_tail:n { _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
+ {
+ \intexpr_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} }
+}
+\cs_set_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_set_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: }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_figures_integer: {
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_round_int } > { 0 }
+ { \tl_put_left:Nn \_l_siunitx_round_integer_out_tl { 0 } }
+ \intexpr_compare:nNnF
+ { \int_use:N \_l_siunitx_round_int } > { 1 }
+ {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:NV \tl_head_i:n \_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_round_int } = { 1 }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_tmp_int } > { 4 }
+ { \bool_set_true:N \_l_siunitx_round_bool }
+ }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_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
+ { \exp_args:NV \tl_tail:n \_l_siunitx_round_integer_in_tl }
+ \tl_if_empty:NF \_l_siunitx_round_integer_in_tl
+ { \_siunitx_number_process_figures_integer: }
+}
+\cs_set_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}
+}
+\tl_new:N \_c_siunitx_unity_tl
+\tl_set:Nn \_c_siunitx_unity_tl { 1 }
+\cs_set_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 }
+ }
+ }
+ }
+ }
+ }
+}
+\cs_set_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
+ {
+ \intexpr_while_do:nNnn
+ { \int_use:N \_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
+ }
+}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_number_process_places_aux_i:n #1 {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_process_precision_int } = { 0 }
+ { \prop_del:Nn \_l_siunitx_number_in_prop { #1 -decimal } }
+ {
+ \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 } }
+ \intexpr_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}
+ }
+ }
+ }
+}
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_places_aux_ii:n #1 {
+ \int_sub:Nn \_l_siunitx_round_int
+ { \_l_siunitx_process_precision_int }
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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}
+ }
+}
+\cs_set_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
+}
+\cs_set_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}
+ }
+}
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_places_integer:n #1 {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:NV \tl_head_i:n \_l_siunitx_round_integer_in_tl }
+ \tl_set:Nx \_l_siunitx_round_integer_in_tl
+ { \exp_args:NV \tl_tail:n \_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
+ \intexpr_compare:nNnT
+ { \int_use:N \_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
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_round: {
+ \tl_if_empty:NF \_l_siunitx_round_tl
+ {
+ \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
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_round_decimal: {
+ \intexpr_compare:nNnF
+ { \int_use:N \_l_siunitx_round_int } > { 1 }
+ { \_siunitx_number_process_round_decimal_aux: }
+ \tl_set:Nx \_l_siunitx_round_decimal_in_tl
+ { \exp_args:NV \tl_tail:n \_l_siunitx_round_decimal_in_tl }
+
+ \int_decr:N \_l_siunitx_round_int
+}
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_round_decimal_aux: {
+ \int_set:Nn \_l_siunitx_tmp_int
+ { \exp_args:NV \tl_head_i:n \_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_round_int } = { 1 }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_tmp_int } > { 4 }
+ { \bool_set_true:N \_l_siunitx_round_bool }
+ }
+ {
+ \intexpr_compare:nNnT
+ { \int_use:N \_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
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_round_tidy:n #1 {
+ \prop_put:NnV \_l_siunitx_number_in_prop { #1 -integer }
+ \_l_siunitx_round_integer_out_tl
+ \prop_put:NnV \_l_siunitx_number_in_prop { #1 -decimal }
+ \_l_siunitx_round_decimal_out_tl
+}
+\cs_set_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 } }
+ }
+}
+\cs_set_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
+ }
+ }
+ }
+}
+\tl_new:N \_c_siunitx_plus_tl
+\tl_set:Nn \_c_siunitx_plus_tl { + }
+\cs_set_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 }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_uncertainty: {
+ \clist_map_function:nN { mantissa , complex }
+ \_siunitx_number_process_uncertainty_aux:n
+}
+\cs_set_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} }
+ }
+}
+\cs_set_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
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_process_uncertainty_int }
+ > { \int_use:N \_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_set_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 }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_process_uncertainty_pad: {
+ \intexpr_while_do:nNnn
+ { \int_use:N \_l_siunitx_process_uncertainty_int }
+ < { \int_use:N \_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
+}
+\cs_set_protected_nopar:Npn
+ \_siunitx_number_process_uncertainty_separate: {
+ \tl_map_function:NN \_l_siunitx_tmpa_tl
+ \_siunitx_number_process_uncertainty_separate_aux:N
+}
+\cs_set_protected:Npn
+ \_siunitx_number_process_uncertainty_separate_aux:N #1 {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_process_uncertainty_int }
+ > { \int_use:N \_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
+}
+\cs_set_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
+}
+\cs_set_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_set_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_set_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 } }
+ }
+}
+\prop_new:N \_l_siunitx_number_out_prop
+\tl_new:N \_l_siunitx_group_sep_tl
+\tl_new:N \_l_siunitx_output_decimal_tl
+\bool_new:N \_l_siunitx_complex_after_bool
+\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-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 = (, % )
+}
+\cs_set_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_color:
+ \_siunitx_number_format_final:
+ }
+}
+\cs_set_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_set_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
+ \tl_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
+ }
+}
+\cs_set_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_set_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
+ {
+ \tl_if_eq:nVT { - } \_l_siunitx_tmpa_tl
+ {
+ \prop_put:NnV \_l_siunitx_number_out_prop { color }
+ \_l_siunitx_negative_color_tl
+ }
+ }
+}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_number_format_complex_aux:n #1 {
+ \prop_get:NnN \_l_siunitx_number_out_prop {#1} \_l_siunitx_tmpa_tl
+ \bool_if:NTF \_l_siunitx_complex_after_bool
+ {
+ \_siunitx_tl_put_right_math:NV \_l_siunitx_tmpa_tl
+ \_l_siunitx_output_complex_tl
+ }
+ {
+ \_siunitx_tl_put_left_math:NV \_l_siunitx_tmpa_tl
+ \_l_siunitx_output_complex_tl
+ }
+ \prop_put:NnV \_l_siunitx_number_out_prop {#1} \_l_siunitx_tmpa_tl
+}
+\cs_set_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_set_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
+}
+\cs_set_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 }
+ }
+}
+\cs_set_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
+ \tl_set_eq:NN \_l_siunitx_tmpb_tl \_l_siunitx_exponent_product_tl
+ \bool_if:NT \_l_siunitx_tight_bool
+ {
+ \tl_set:Nx \_l_siunitx_tmpb_tl
+ { { \exp_not:V \_l_siunitx_tmpb_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 }
+}
+\cs_set_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
+}
+\cs_set_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 }
+}
+\cs_set_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_set_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 } }
+ }
+ }
+}
+\cs_set_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_after:wN \_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_nil
+ { \_siunitx_number_format_copy:n {#1 - #2} }
+ { \_siunitx_number_format_group_four_aux:nn {#1} {#2} }
+ }
+}
+\cs_set_protected:Npn \_siunitx_number_format_group_four_aux:NNNNNNw
+ #1#2#3#4#5#6 \q_nil {
+ \quark_if_no_value:NTF #5
+}
+\cs_set_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
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_format_group_decimal: {
+ \tl_if_empty:NF \_l_siunitx_tmpa_tl
+ {
+ \exp_after:wN \_siunitx_number_format_group_decimal_aux:NNNN
+ \_l_siunitx_tmpa_tl { } { } { }
+ }
+}
+\cs_set_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
+ }
+ }
+ }
+}
+\cs_set_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_set_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_set_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_set_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
+ }
+}
+\cs_set_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 }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_format_join_uncert: {
+ \_siunitx_number_format_join_uncert:n { mantissa }
+ \_siunitx_number_format_join_uncert:n { complex }
+}
+\cs_set_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_set_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 { } } }
+ }
+}
+\cs_set_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 } }
+}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_number_format_sign_complex: {
+ \_siunitx_number_format_sign_complex:n { complex }
+ \_siunitx_number_format_sign_complex:n { complex-result }
+}
+\cs_set_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
+ }
+ }
+}
+\cs_set_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_set_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_set_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
+}
+\tl_new:N \_l_siunitx_number_out_tl
+\tl_new:N \_l_siunitx_number_out_saved_tl
+\tl_new:N \_l_siunitx_number_fraction_tl
+\bool_new:N \_l_siunitx_number_compound_bool
+\tl_new:N \_l_siunitx_quotient_mode_tl
+\cs_set_protected:Npn \_siunitx_fraction:nn { }
+\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
+}
+\cs_set_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 }
+\cs_set_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 } }
+ }
+}
+\cs_set_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
+ }
+}
+\cs_set_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 }
+\cs_set_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:
+ \prop_if_in:NnT \_l_siunitx_number_in_prop { exponent }
+ { \bool_set_true:N \_l_siunitx_brackets_bool }
+ \_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: }
+ }
+ }
+}
+\cs_set_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_set_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 }
+ {
+ \tl_set_eq:NN \_l_siunitx_tmpb_tl
+ \_l_siunitx_exponent_product_tl
+ \bool_if:NT \_l_siunitx_tight_bool
+ {
+ \tl_set:Nx \_l_siunitx_tmpb_tl
+ { { \exp_not:V \_l_siunitx_tmpb_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_set_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_set_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:
+}
+\cs_set_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:
+ }
+ }
+}
+\cs_set_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:
+}
+\cs_set_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
+ }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_number_output_quotient: {
+ \use:c
+ { _siunitx_number_output_quotient_ \_l_siunitx_quotient_mode_tl : }
+}
+\cs_set_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:
+}
+\cs_set_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:
+}
+\cs_set_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_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_set_protected_nopar:Npn \_siunitx_number_output_quotient_aux_ii: {
+ \_siunitx_number_process:
+ \_siunitx_number_format:
+}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_number_output_single_aux: {
+ \_siunitx_unit_output_pre_print:
+ \_siunitx_print:nV { number } \_l_siunitx_number_out_tl
+ \_siunitx_unit_output_print:
+}
+\bool_new:N \_l_siunitx_angle_degree_space_bool
+\bool_new:N \_l_siunitx_angle_minute_space_bool
+\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
+\prop_new:N \_l_siunitx_angle_degree_prop
+\prop_new:N \_l_siunitx_angle_minute_prop
+\prop_new:N \_l_siunitx_angle_second_prop
+\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 ,
+}
+\cs_set_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:nn { invalid-arc-format } { #1 ; #2 } }
+ { \_siunitx_angle_output_aux:nnn {#1} {#2} {#3} }
+ }
+}
+\cs_set_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} }
+ }
+}
+\cs_set_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
+}
+\cs_set_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_set_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_set_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_set_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}
+}
+\cs_set_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_set_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
+}
+\cs_set_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_set_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 } }
+ }
+}
+\cs_set_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_set_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_set_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
+ }
+}
+\cs_set_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_set_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: }
+ }
+}
+\cs_set_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_set_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_set_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_set_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_clear:N \_l_siunitx_angle_marker_box
+ \tex_hss:D
+ }
+ \box_use:N \_l_siunitx_angle_marker_box
+}
+\cs_set_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_clear:N \_l_siunitx_angle_marker_box
+ \tex_hss:D
+ }
+ \box_use:N \_l_siunitx_angle_marker_box
+ \skip_horizontal:N \scriptspace
+}
+\cs_set_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_set_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:
+ }
+}
+\tl_new:N \_l_siunitx_declare_list_tl
+\tl_set:Nn \_l_siunitx_declare_list_tl { \of \per \raiseto \tothe }
+\cs_set_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_set_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} }
+}
+\cs_set_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} }
+ }
+}
+\cs_set_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} }
+}
+\cs_set_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 }
+ {
+ \cs_if_exist:cTF
+ { _siunitx_ \_siunitx_unit_first_token:n {#2} _function:w }
+ {#2}
+ { \_siunitx_unit_parse_unit:Nn #1 {#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_set_protected:Npn \_siunitx_unit_first_token:n #1 {
+ \exp_after:wN \token_to_str:N \tl_head_i:w #1 \q_nil
+}
+\cs_set:cpn { _siunitx_ \token_to_str:N \per _literal:w } { / }
+\cs_set_protected:cpn { _siunitx_ \token_to_str:N \per _function:w } {
+ \bool_set_true:N \_l_siunitx_per_bool
+ \_siunitx_unit_parse_per:
+}
+\cs_set:cpn { _siunitx_ \token_to_str:N \raiseto _literal:w } #1#2 {
+ #2
+ \textsuperscript {#1}
+}
+\cs_set_protected:cpn { _siunitx_ \token_to_str:N \raiseto _function:w }
+ #1 {
+ \_siunitx_unit_parse_power_before:n {#1}
+}
+\cs_set:cpn { _siunitx_ \token_to_str:N \tothe _literal:w } #1 {
+ \textsuperscript {#1}
+}
+\cs_set_protected:cpn { _siunitx_ \token_to_str:N \tothe _function:w }
+ #1 {
+ \_siunitx_unit_parse_power_after:n {#1}
+}
+\cs_set_protected:cpn { _siunitx_ \token_to_str:N \of _literal:w } #1 {
+ \text { ~ } ( #1 )
+}
+\cs_set_protected:cpn { _siunitx_ \token_to_str:N \of _function:w } #1 {
+ \_siunitx_unit_parse_qualifier:n {#1}
+}
+\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
+}
+\AtBeginDocument {
+ \bool_if:NTF \_l_siunitx_create_free_bool
+ { \_siunitx_unit_create_functions: }
+ { \_siunitx_unit_create_empty_functions: }
+}
+\cs_set_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_set_protected_nopar:Npn
+ \_siunitx_unit_create_empty_functions_aux:N #1 {
+ \cs_if_free:NT #1 { \cs_set_protected_nopar:Npn #1 { \ERROR } }
+}
+\cs_set_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 } }
+}
+\cs_set_protected:Npn \_siunitx_unit_create:N #1 {
+ \cs_if_free:NT #1
+ {
+ \cs_set:Npx \_siunitx_tmp:w
+ {
+ \ProvideDocumentCommand \exp_not:N #1 { }
+ {
+ \bool_if:NT \_l_siunitx_create_prespace_bool
+ {
+ \exp_not:n
+ {
+ \_siunitx_ensuremath:n
+ { \_l_siunitx_number_unit_sep_tl }
+ }
+ }
+ \exp_not:n { \_siunitx_unit_in:nn {#1} { } }
+ \bool_if:NT \_l_siunitx_create_xspace_bool
+ { \exp_not:N \xspace }
+ }
+ }
+ \_siunitx_tmp:w
+ }
+}
+\cs_set_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 }
+ {
+ \exp_not:N \IfNoValueTF {####1}
+ { \exp_not:n { \_siunitx_unit_in:nn {#1} { } } }
+ {
+ \bool_if:NT \_l_siunitx_create_prespace_bool
+ {
+ \exp_not:n
+ {
+ \_siunitx_ensuremath:n
+ { \_l_siunitx_number_unit_sep_tl }
+ }
+ }
+ \SI {####1} { \exp_not:N #1 }
+ }
+ \bool_if:NT \_l_siunitx_create_xspace_bool
+ { \exp_not:N \xspace }
+ }
+ }
+ \_siunitx_tmp:w
+ }
+}
+\AtBeginDocument {
+ \tl_map_function:nN { \bar \color \ng \pm }
+ \_siunitx_protect_symbols:N
+}
+\cs_set_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 } }
+ }
+}
+\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
+}
+\cs_set_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 } {#1} }
+ { \_siunitx_unit_format_literal:n {#1} }
+ }
+ {
+ \bool_if:NT \_l_siunitx_per_auto_bool
+ {
+ \tl_set:Nn \_l_siunitx_per_mode_tl { symbol }
+ \mode_if_inner:F
+ {
+ \mode_if_math:T
+ {
+ \tl_set:Nn \_l_siunitx_per_mode_tl
+ { fraction }
+ }
+ }
+ }
+ \_siunitx_unit_parse:nn {#1} {#2}
+ \_siunitx_unit_format:
+ }
+ }
+ }
+ { \_siunitx_unit_format_literal:n {#1} }
+}
+\cs_generate_variant:Nn \_siunitx_unit_in:nn { Vn }
+\cs_set_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_set_protected:Npn \_siunitx_unit_if_literal_aux:N #1 {
+ \cs_set_eq:NN #1 \prg_do_nothing:
+}
+\int_new:N \_l_siunitx_unit_int
+\prop_new:N \_l_siunitx_unit_prop
+\bool_new:N \_l_siunitx_per_bool
+\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
+}
+\cs_set_protected:Npn \_siunitx_unit_parse:nn #1#2 {
+ \_siunitx_unit_parse_init:
+ \_siunitx_unit_parse_options:nn {#1} {#2}
+ #1
+ \cs_set_eq:NN \pm \_siunitx_pm:
+}
+\cs_set_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
+ \cs_set_eq:NN \_siunitx_pm: \pm
+ \tl_map_function:NN \_l_siunitx_declare_list_tl
+ \_siunitx_unit_parse_init_aux:N
+}
+\cs_set_protected:Npn \_siunitx_unit_parse_init_aux:N #1 {
+ \cs_set_eq:Nc #1 { _siunitx_ \token_to_str:N #1 _function:w }
+}
+\cs_set_protected_nopar:Npn \_siunitx_pm: { }
+\cs_set_protected:Npn \_siunitx_unit_parse_options:nn #1#2 {
+ \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}
+ }
+}
+\cs_set_protected:Npn \_siunitx_unit_parse_power_before:n #1 {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ { power- \intexpr_eval:n { \_l_siunitx_unit_int + 1 } }
+ \prop_put:NVn \_l_siunitx_unit_prop \_l_siunitx_tmpa_tl {#1}
+}
+\cs_set_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}
+}
+\cs_set_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_set_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}
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_parse_per: {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ { per- \intexpr_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_set_protected_nopar:Npn \_siunitx_unit_parse_per_error: {
+ \msg_error:nn { siunitx } { duplicate-sticky-per }
+}
+\cs_set_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}
+}
+\cs_set_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_set_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 }
+ }
+ }
+}
+\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
+\int_new:N \_l_siunitx_unit_denominator_int
+\int_new:N \_l_siunitx_unit_numerator_int
+\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
+\int_new:N \_l_siunitx_unit_prefix_gram_int
+\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_two_parts_bool
+\tl_new:N \_l_siunitx_qualifier_mode_tl
+\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
+ },
+ per-symbol .tl_set:N = \_l_siunitx_per_symbol_tl,
+ 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 } },
+}
+\keys_set:nn { siunitx } {
+ bracket-unit-denominator = true,
+ inter-unit-separator = \,,
+ per-mode = reciprocal,
+ per-symbol = /,
+ qualifier-mode = subscript
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format: {
+ \_siunitx_unit_format_init:
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_unit_int } = { 1 }
+ {
+ \tl_if_eq:VnT \_l_siunitx_per_mode_tl { symbol }
+ {
+ \prop_if_in:NnT \_l_siunitx_unit_prop { per-1 }
+ { \tl_clear:N \_l_siunitx_number_unit_separator_tl }
+ }
+ }
+ \intexpr_while_do:nNnn
+ { \int_use:N \_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: }
+ }
+}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_unit_format_add_aux:n #1 {
+ \tl_if_empty:cF { _l_siunitx_unit #1 _tl }
+ {
+ \tl_if_eq:nVTF { repeat } \_l_siunitx_per_mode_tl
+ {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ { per- \intexpr_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
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_fraction: {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_unit_denominator_int } > { 0 }
+ {
+ \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_set_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 } }
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_fraction_symbol: {
+ \_siunitx_unit_format_fraction_symbol_aux:
+ \intexpr_compare:nNnT
+ { \int_use:N \_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_set_protected_nopar:Npn \_siunitx_unit_format_fraction_symbol_aux: {
+}
+\cs_set_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 } }
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_init: {
+ \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
+}
+\char_make_active:N \~
+\cs_set_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_set_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 \~
+\cs_set_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_set_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 {
+ \AtBeginDocument
+ {
+ \@ifpackageloaded { inputenc }
+ {
+ \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:
+ }
+ }
+}
+\cs_set_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: }
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_power_aux: {
+ \tl_if_eq:nVTF { repeat } \_l_siunitx_per_mode_tl
+ { \_siunitx_unit_format_power_repeat: }
+ { \_siunitx_unit_format_power_per: }
+ \tl_if_eq:nVF { 1 } \_l_siunitx_tmpa_tl
+ {
+ \_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_set_protected:Npn \_siunitx_unit_format_power_aux:n #1 {
+ \bool_if:NTF \_l_siunitx_number_math_mode_bool
+ { \_siunitx_print:nn { number } {#1} }
+ {
+ \tl_set:Nn \_l_siunitx_tmpa_tl {#1}
+ \tl_replace_all_in:Nnn \_l_siunitx_tmpa_tl { - }
+ { \text { \_c_siunitx_minus_tl } }
+ \_siunitx_print:nV { number } \_l_siunitx_tmpa_tl
+ }
+}
+\cs_set_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
+ }
+}
+\cs_set_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_afer:wN \_siunitx_tmp:w \_l_siunitx_tmpa_tl \q_stop
+ }
+ { \tl_put_left:Nn \_l_siunitx_tmpa_tl { - } }
+ }
+ }
+}
+\cs_set_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
+ }
+}
+\cs_set_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_set_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
+ \intexpr_compare:nNnT
+ { \int_use:N \_l_siunitx_unit_prefix_base_int } = { 0 }
+ {
+ \int_set:Nn \_l_siunitx_unit_prefix_base_int
+ { \_l_siunitx_tmpa_tl }
+ }
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_unit_prefix_base_int }
+ = { \_l_siunitx_tmpa_tl }
+ { \_siunitx_unit_format_prefix_number_calc: }
+ { \msg_error:nn { siunitx } { prefix-base-mismatch } }
+}
+\cs_set_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
+ \tl_if_eq:nVT { \gram } \_l_siunitx_tmpb_tl
+ {
+ \tl_set:Nx \_l_siunitx_unit_prefix_current_tl
+ { \intexpr_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
+ {
+ \intexpr_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
+ {
+ \int_use:N \_l_siunitx_unit_prefix_int
+ - \_l_siunitx_unit_prefix_current_tl
+ }
+ }
+ {
+ \int_set:Nn \_l_siunitx_unit_prefix_int
+ {
+ \int_use:N \_l_siunitx_unit_prefix_int
+ + \_l_siunitx_unit_prefix_current_tl
+ }
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_prefix_symbol: {
+ \tl_set_eq:NN \_l_siunitx_unit_current_tl
+ \_l_siunitx_unit_prefix_current_tl
+}
+\cs_set_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_set_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_set_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:No \_l_siunitx_unit_current_tl
+ { \exp_after:wN @ \exp_after:wN { \_l_siunitx_tmpa_tl } }
+ }
+}
+\cs_set_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
+}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_unit_format_symbol_aux: {
+ \msg_error:nn { siunitx } { prefix-only }
+}
+\cs_set_protected_nopar:Npn \_siunitx_unit_format_symbol_aux_alt: {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_l_siunitx_unit_int } = { 1 }
+ {
+ \prop_del:Nn \_l_siunitx_unit_prop { prefix-1 }
+ \prop_if_empty:NF \_l_siunitx_unit_prop
+ { \msg_error:nn { siunitx } { prefix-only } }
+ }
+ { \msg_error:nn { siunitx } { prefix-only } }
+}
+\bool_new:N \_l_siunitx_multi_brackets_bool
+\bool_new:N \_l_siunitx_multi_repeat_bool
+\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
+\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,
+}
+\cs_set_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:
+ \_siunitx_unit_format_fraction_symbol_aux_alt:
+ \_siunitx_unit_in:nn {#1} {#2}
+ \intexpr_compare:nNnF
+ { \int_use:N\_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 { Vn }
+\cs_set_protected_nopar:Npn \_siunitx_unit_output_number_sep: {
+ \bool_if:NTF \_l_siunitx_number_unit_breaks_bool
+ { \allowbreak } { \nobreak }
+ \_siunitx_ensuremath:n { \_l_siunitx_number_unit_separator_tl }
+}
+\cs_set_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_set_protected_nopar:Npn \_siunitx_unit_output_print: {
+ \intexpr_compare:nNnF
+ { \int_use:N \_l_siunitx_unit_prefix_int } = { 0 }
+ {
+ \tl_set:Nx \_l_siunitx_tmpa_tl
+ {
+ \bool_if:NTF \_l_siunitx_tight_bool
+ { { \exp_not:V \_l_siunitx_exponent_product_tl } }
+ { { } \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
+ }
+}
+\tl_new:N \_l_siunitx_pre_unit_tl
+\int_new:N \_l_siunitx_number_product_int
+\cs_set_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}
+}
+\cs_set_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:
+ }
+}
+\cs_set_protected:Npn \_siunitx_combined_unit:nnn #1#2#3 {
+ \bool_if:NTF \_l_siunitx_product_power_bool
+ {
+ \_siunitx_combined_product_count:n {#1}
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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} }
+}
+\cs_set_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_set_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
+ }
+}
+\bool_new:N \_l_siunitx_list_brackets_bool
+\bool_new:N \_l_siunitx_list_repeat_bool
+\tl_new:N \_l_siunitx_list_current_tl
+\tl_new:N \_l_siunitx_list_tl
+\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,
+}
+\cs_set_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_set_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_set_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} }
+}
+\cs_set_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}
+ }
+}
+\bool_new:N \_l_siunitx_range_brackets_bool
+\bool_new:N \_l_siunitx_range_repeat_bool
+\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,
+}
+\cs_set_protected:Npn \_siunitx_range_numbers:nn #1#2 {
+ \_siunitx_range_numbers_aux:n {#1}
+ \text { \_l_siunitx_range_phrase_tl }
+ \_siunitx_range_numbers_aux:n {#2}
+}
+\cs_set_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:
+ }
+}
+\cs_set_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}
+ }
+}
+\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
+ }
+ { }
+}
+\cs_set_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 }
+\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
+\tl_new:N \_l_siunitx_number_valid_tl
+\bool_new:N \_l_siunitx_table_collect_pre_bool
+\bool_new:N \_l_siunitx_table_collect_post_bool
+\cs_set_protected:Npn \_siunitx_table_collect_begin:Nn #1#2 {
+ \keys_set:nn { siunitx } {#2}
+ \use:c { _siunitx_table_collect_begin_ #1 : }
+}
+\cs_set_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_set_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: }
+}
+\cs_set_protected:Npn \_siunitx_table_collect_braced:n #1 { }
+\cs_set_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} }
+ {
+ \bool_set_true:N \_l_siunitx_table_collect_post_bool
+ \tl_put_right:Nn \_l_siunitx_table_collect_post_tl {#1}
+ }
+ }
+ }
+}
+\cs_set_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:
+ {
+ \if_catcode:w \exp_not:N \l_peek_token \c_group_begin_token
+ \exp_after:wN \_siunitx_table_collect_braced:n
+ \else:
+ \exp_after:wN \_siunitx_table_collect_not_braced:N
+ \fi:
+ }
+ \peek_after:NN \peek_ignore_spaces_execute_branches:
+}
+\cs_set_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
+}
+\cs_set_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_set_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_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:
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_table_collect_next: { }
+\cs_set_protected_nopar:Npn \_siunitx_table_collect_newline: {
+ \_siunitx_table_print:
+ \cs_set_eq:NN \_siunitx_table_print: \prg_do_nothing:
+ \tabularnewline
+}
+\cs_set_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_set_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_set_protected:Npn \_siunitx_table_collect_not_braced_aux_ii:N #1 { }
+\cs_set_protected:Npn \_siunitx_table_collect_token:N #1 { }
+\cs_set_protected:Npn \_siunitx_table_collect_token_s:N #1 {
+ \tl_put_right:Nn \_l_siunitx_table_collect_tl {#1}
+}
+\cs_set_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 }
+ }
+}
+\skip_new:N \_c_siunitx_one_fill_skip
+\skip_set:Nn \_c_siunitx_one_fill_skip { \c_zero_skip plus 1 fill }
+\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_set_protected_nopar:Npn \_siunitx_table_colortbl_correction: {
+ \skip_horizontal:n { \_c_siunitx_table_correction_skip }
+ \tex_kern:D \c_zero_skip
+}
+\cs_set_protected_nopar:Npn \_siunitx_table_align_left:n #1 {
+ \_siunitx_table_colortbl_correction:
+ \skip_horizontal:n {#1}
+ \tex_kern:D \c_zero_skip
+}
+\cs_set_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:
+}
+\skip_new:N \_l_siunitx_table_unit_align_skip
+\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
+}
+\cs_set_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 }
+}
+\bool_new:N \_l_siunitx_table_center_decimal_bool
+\box_new:N \_l_siunitx_table_fill_box
+\dim_new:N \_l_siunitx_table_fill_dim
+\box_new:N \_l_siunitx_table_pre_box
+\box_new:N \_l_siunitx_table_post_box
+\box_new:N \_l_siunitx_table_result_box
+\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
+\dim_new:N \_l_siunitx_table_gap_dim
+\prop_new:N \_l_siunitx_table_model_prop
+\skip_new:N \_l_siunitx_table_number_align_skip
+\skip_new:N \_l_siunitx_table_text_align_skip
+\keys_define:nn { siunitx } {
+ table-align-text-post .bool_set:N
+ = \_l_siunitx_table_align_post_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 =
{
- mathsrm = mathtt,
- textrm = ttfamily
- }%
- \fi
-}
-\AtBeginDocument{\si@fam@detect@default}
-\newcommand*{\si@fam@ifbtext}[1]{%
- \if b\expandafter\@car\f@series\@nil
- #1\fi}
-\newcommand*{\si@fam@ifbmaths}[1]{%
- \renewcommand*{\si@tempa}{bold}%
- \ifx\math@version\si@tempa
- #1\fi}
-\newcommand*{\si@fam@ifbinline}{%
- \ifsi@inlinebtext
- \expandafter\si@fam@ifbtext
- \else
- \expandafter\si@fam@ifbmaths
- \fi}
-\newcommand*{\si@fam@ifitext}[1]{%
- \if n\expandafter\@car\f@series\@nil\else
- #1\fi}
-\newcommand*{\si@fam@mode}{%
- \ifsi@obeymode
- \ifmmode
- \sisetup{mode=maths}%
- \else
- \sisetup{mode=text}%
- \fi
- \fi}
-\AtBeginDocument{
- \@ifpackageloaded{color}
- {\let\si@fam@colourcmd\color}
- {\let\si@fam@colourcmd\@gobble}}
-\newif\ifsi@fam@set
-\newif\ifsi@textmode
-\newcommand*{\si@fam@set}{%
- \ifsi@out@num
- \ifsi@numtextmode
- \expandafter\expandafter\expandafter\si@textmodetrue
- \else
- \expandafter\expandafter\expandafter\si@textmodefalse
- \fi
- \else
- \ifsi@unittextmode
- \expandafter\expandafter\expandafter\si@textmodetrue
- \else
- \expandafter\expandafter\expandafter\si@textmodefalse
- \fi
- \fi
- \ifsi@fam@set\else
- \let\si@colourcmd\@gobble
- \ifsi@out@num
- \let\si@mathsrm\si@valuemathsrm
- \let\si@mathssf\si@valuemathssf
- \let\si@mathstt\si@valuemathstt
- \let\si@textrm\si@valuetextrm
- \let\si@textsf\si@valuetextsf
- \let\si@texttt\si@valuetexttt
- \ifsi@colourvalues
- \let\si@colourcmd\si@fam@colourcmd
- \fi
- \let\si@colour\si@valuecolour
- \else
- \let\si@mathsrm\si@unitmathsrm
- \let\si@mathssf\si@unitmathssf
- \let\si@mathstt\si@unitmathstt
- \let\si@textrm\si@unittextrm
- \let\si@textsf\si@unittextsf
- \let\si@texttt\si@unittexttt
- \ifsi@colourunits
- \let\si@colourcmd\si@fam@colourcmd
- \fi
- \let\si@colour\si@unitcolour
- \fi
- \fi
- \si@fam@settrue
- \edef\si@tempa{\sfdefault}%
- \edef\si@tempb{\ttdefault}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathsrm\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textrm\endcsname
- \ifsi@obeyfamily
- \si@log@debug{Font detection: checking font}%
- \ifmmode
- \ifinner
- \si@log@debug{Font detection: inline maths}%
- \si@fam@dettext
- \else
- \si@log@debug{Font detection: display maths}%
- \ifsi@detectdisplay
- \si@fam@detmaths
- \else
- \si@fam@dettext
- \fi
- \fi
- \else
- \si@log@debug{Font detection: text}%
- \si@fam@dettext
- \fi
- \else
- \si@log@debug{Font detection: inactive}%
- \fi
- \def\si@fam@bold{\unboldmath\mdseries}%
- \ifsi@obeybold
- \si@log@debug{Weight detection: checking weight}%
- \ifmmode
- \ifdim\displaywidth>0pt\relax
- \ifsi@detectdisplay
- \expandafter\si@fam@ifbmaths
- \else
- \expandafter\si@fam@ifbtext
- \fi
- \si@fam@setbold
- \else
- \si@fam@ifbinline\si@fam@setbold
- \fi
- \else
- \si@fam@ifbtext\si@fam@setbold
- \fi
- \fi
- \let\si@fam@italic\upshape
- \ifsi@obeyitalic
- \si@log@debug{Italic detection: checking italic}%
- \si@fam@ifitext
- {\let\si@fam@italic\relax
- \si@log@debug{Italic detection: italic}}%
- \fi}
-\newcommand*{\si@fam@detmaths}{%
- \ifnum\the\fam=\si@fam@sf
- \si@log@debug{Font detection: sf}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathssf\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textsf\endcsname
- \else
- \ifnum\the\fam=\si@fam@tt
- \si@log@debug{Font detection: tt}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathstt\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@texttt\endcsname
- \else
- \si@log@debug{Font detection: rm}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathsrm\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textrm\endcsname
- \fi
- \fi}
-\newcommand*{\si@fam@dettext}{%
- \ifx\f@family\si@tempa
- \si@log@debug{Font detection: sf}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathssf\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textsf\endcsname
- \else
- \ifx\f@family\si@tempb
- \si@log@debug{Font detection: tt}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathstt\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@texttt\endcsname
- \else
- \si@log@debug{Font detection: rm}%
- \expandafter\let\expandafter\si@fam@maths
- \csname\si@mathsrm\endcsname
- \expandafter\let\expandafter\si@fam@text
- \csname\si@textrm\endcsname
- \fi
- \fi}
-\newcommand*{\si@fam@setbold}{%
- \si@log@debug{Weight detection: bold weight}%
- \let\si@fam@bold\si@fam@boldify}
-\newcommand*{\si@fam@boldify}{\boldmath\bfseries}
-\si@newrobustcmd*{\num}[2][]{%
- \begingroup
- \sisetup{#1}%
- \si@fam@mode
- \si@num@intabfalse
- \si@log@debug{Processing \string\num\space input `#2'}%
- \expandafter\si@out@num\expandafter{\si@num{#2}}%
- \endgroup}
-\newif\ifsi@num@intab
-\newcommand*{\si@num}[1]{%
- \si@num@fixpm
- \begingroup
- \makeatletter
- \@makeother{\,}%
- \@makeother{\.}%
- \@makeother{\+}%
- \@makeother{\-}%
- \def~{}%
- \def\,{}%
- \catcode`\~=\active\relax
- \catcode`\^=\active\relax
- \catcode`\_=12\relax
- \everyeof{\noexpand}%
- \endlinechar\m@ne
- \protected@xdef\si@tempa{\scantokens{#1}}%
- \endgroup
- \si@ifnotmtarg{\si@tempa}
- {\si@num@ifvalid{\si@tempa}
- {\si@num@format{\si@tempa}}
- {\si@log@err{Invalid character `#1' in numerical input}%
- {Only characters from the list
- `\si@numvalid'\MessageBreak should be present in the
- argument of the \string\num\space macro\MessageBreak
- (or derivative such as an `s' column)}%
- {#1}}}}
-\newcommand*{\si@num@fixpm}{%
- \let\si@num@pm\pm
- \let\si@num@mp\mp
- \protected\def\pm{\si@num@pm}%
- \protected\def\mp{\si@num@mp}}
-\newcommand*{\si@num@ifvalid}[1]{%
- \begingroup
- \si@switchtrue
- \expandafter\si@num@valid#1\@empty\@empty
- \ifsi@switch
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@num@valid#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numvalid}
- {\ifx\@empty#2\@empty\else
- \si@num@valid#2\@empty\@empty\@empty
- \fi}
- {\si@switchfalse}}
-\newcommand*{\si@num@in}{}
-\newcommand*{\si@num@out}{}
-\newcommand*{\si@num@exp}{}
-\newcommand*{\si@num@expsign}{}
-\newcommand*{\si@num@mant}{}
-\newcommand*{\si@num@mantsign}{}
-\newcommand*{\si@num@err}{}
-\newcommand*{\si@num@xpart}{}
-\newcommand*{\si@num@ambig}{}
-\newcommand*{\si@tab@out}{}
-\newcommand*{\si@tab@expout}{}
-\newif\ifsi@num@erropen
-\newcommand*{\si@num@arg}{}
-\newcommand*{\si@num@format}[1]{%
- \protected@edef\si@num@arg{#1}%
- \si@log@debug{Formatting number `\si@num@arg'}%
- \renewcommand*{\si@num@in}{}%
- \renewcommand*{\si@num@exp}{}%
- \renewcommand*{\si@num@expsign}{}%
- \renewcommand*{\si@num@mant}{}%
- \renewcommand*{\si@num@mantsign}{}%
- \renewcommand*{\si@num@err}{}%
- \renewcommand*{\si@num@xpart}{}%
- \si@switchfalse
- \expandafter\si@num@findxpart\si@num@arg\@empty\@empty
- \si@switchfalse
- \si@num@sepmantexp{\si@num@in}%
- \si@num@sepsign{exp}%
- \si@num@sepsign{mant}%
- \ifx\@empty\si@num@exp\@empty
- \ifx\@empty\si@num@expsign\@empty\else
- \si@log@warn{Sign but no number for `\si@num@arg'}%
- \fi
- \let\si@num@expsign\@empty
- \fi
- \ifx\@empty\si@num@mant\@empty
- \ifx\@empty\si@num@mantsign\@empty\else
- \ifx\@empty\si@num@exp\@empty
- \si@log@warn{Sign but no number for `\si@num@arg'}%
- \let\si@num@mantsign\@empty
- \fi
- \fi
- \fi
- \renewcommand*{\si@tempa}{{-}}%
- \ifx\si@num@mantsign\si@tempa
- \ifsi@colourneg
- \expandafter\expandafter\expandafter\si@fam@colourcmd
- \else
- \expandafter\expandafter\expandafter\@gobble
- \fi
- \else
- \expandafter\@gobble
- \fi
- {\si@negcolour}%
- \si@num@procnum{exp}%
- \si@num@procnum{mant}%
- \si@str@ifonlychrs{\si@num@exp}{0\si@numdecimal}
- {\ifsi@allowzeroexp\else
- \renewcommand*{\si@num@exp}{}%
- \ifx\@empty\si@num@mant\@empty
- \renewcommand*{\si@num@mant}{1}%
- \fi
- \fi}{}%
- \ifx\@empty\si@num@exp\@empty\else
- \ifsi@trapambigerr
- \expandafter\expandafter\expandafter\si@num@ambigerrtrue
- \fi
- \fi
- \protected@edef\si@num@out{%
- \ensuremath{{\si@num@mantsign}}\si@num@mant}%
- \renewcommand*{\si@tempa}{num}%
- \ifsi@num@intab
- \protected@edef\si@tab@out{%
- \ensuremath{{\si@num@mantsign}}\si@num@predec}%
- \protected@edef\si@num@out{\si@num@postdec}%
- \renewcommand*{\si@tempa}{tab}%
- \fi
- \ifx\@empty\si@num@postdec\@empty\else
- \renewcommand*{\si@tempa}{num}%
- \fi
- \ifx\@empty\si@num@err\@empty\else
- \ifsi@seperr
- \ifsi@num@ambigerr
- \protected@edef\si@num@out{%
- \ensuremath{\si@openerr}\si@num@out}%
- \si@repeatunitsfalse
- \expandafter\si@num@erropentrue
- \else
- \ifsi@trapambigerr\else
- \ifx\@empty\si@num@exp\@empty\else
- \protected@edef\si@num@err{%
- \si@num@err\expandafter\@car\si@numexp\@nil
- \si@num@expsign\si@num@exp}%
- \ifsi@repeatunits\else
- \renewcommand*{\si@num@exp}{}%
- \renewcommand*{\si@num@expsign}{}%
- \fi
- \fi
- \fi
- \fi
- \else
- \expandafter\protected@edef\csname
- si@\si@tempa @out\endcsname{%
- \si@num@out\ensuremath{\si@errspace}\ensuremath
- {\si@openerr}\si@num@err\ensuremath{\si@closeerr}}%
- \renewcommand*{\si@num@err}{}%
- \fi
- \fi
- \renewcommand*{\si@tempa}{num@out}%
- \ifsi@num@erropen
- \renewcommand*{\si@tempa}{num@ambig}%
- \fi
- \ifsi@num@intab
- \renewcommand*{\si@tempa}{tab@expout}%
- \fi
- \ifx\@empty\si@num@exp\@empty
- \ifx\@empty\si@num@mant\@empty
- \si@log@err{Invalid number format `\si@num@arg'}
- {Something is wrong with the number format; does it
- contain \MessageBreak any numbers (from the list
- `\si@numdigits')?}%
- \renewcommand*\si@num@out{}%
- \fi
- \else
- \ifx\@empty\si@num@mant\@empty\else
- \expandafter\protected@edef\csname
- si@\si@tempa\endcsname{%
- \csname si@\si@tempa\endcsname\ensuremath{{}%
- \si@expproduct{}}}%
- \fi
- \expandafter\protected@edef\csname
- si@\si@tempa\endcsname{%
- \csname si@\si@tempa\endcsname\si@expbase
- \textsuperscript{\ensuremath{\si@num@expsign}%
- \si@num@exp}}%
- \fi
- \ifsi@num@intab\else
- \expandafter\si@num@out
- \fi
- \ifx\@empty\si@num@err\@empty\else
- \expandafter\si@num@procerr
- \fi
- \ifsi@num@erropen
- \expandafter\si@out@num\expandafter{%
- \ensuremath{\si@closeerr}}%
- \ifx\@empty\si@num@ambig\@empty\else
- \si@out@num{\si@num@ambig}%
- \renewcommand*{\si@num@ambig}{}%
- \fi
- \fi
- \si@num@erropenfalse
- \ifx\@empty\si@num@xpart\@empty\else
- \expandafter\si@num@sepxpart
- \fi}
-\def\si@num@findxpart#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numprod}
- {\si@switchtrue\si@seperrfalse}{}%
- \ifsi@switch
- \protected@edef\si@num@xpart{\si@num@xpart#1}%
- \else
- \protected@edef\si@num@in{\si@num@in#1}%
- \fi
- \ifx\@empty#2\@empty\else
- \si@num@findxpart#2\@empty
- \fi}
-\newcommand*{\si@num@sepmantexp}[1]{%
- \expandafter\si@num@mantexp#1\@empty\@empty}
-\def\si@num@mantexp#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numgobble}
- {\si@log@debug{Gobbling `#1' in \si@num@arg}}
- {\si@str@ifchrstr{#1}{\si@numexp}
- {\ifsi@switch
- \si@log@err{Duplicate exponent marker found}
- {Only a single exponent character \MessageBreak
- (from the list `\si@numexp')\MessageBreak may
- occur in a numerical argument}%
- \else
- \si@log@debug{Exponent marker `#1' found in
- `\si@num@arg'}%
- \fi
- \si@switchtrue}%
- {\ifsi@switch
- \expandafter\si@num@addexp
- \else
- \expandafter\si@num@addmnt
- \fi
- {#1}}}%
- \ifx\@empty#2\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@sepmantexp
- \fi
- {#2}}
-\newcommand*{\si@num@addmnt}[1]{%
- \si@num@addmntexp{#1}{mant}{mantissa}}
-\newcommand*{\si@num@addexp}[1]{%
- \si@num@addmntexp{#1}{exp}{exponent}}
-\newcommand*{\si@num@addmntexp}[3]{%
- \si@log@debug{Adding `#1' to #3 for `\si@num@arg'}%
- \expandafter\protected@edef\csname si@num@#2\endcsname{%
- \csname si@num@#2\endcsname#1}}
-\newcommand*{\si@num@sepsign}[1]{%
- \expandafter\ifx\expandafter\@empty
- \csname si@num@#1\endcsname\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@gensign
- \fi
- {#1}}
-\newcommand*{\si@num@gensign}[1]{%
- \expandafter\expandafter\expandafter\si@num@findsign
- \csname si@num@#1\endcsname\@empty\@empty
- \ifx\@empty\si@num@sign\@empty
- \ifx\@empty\si@num@value\@empty
- \expandafter\expandafter\expandafter\@gobble
- \else
- \expandafter\expandafter\expandafter\si@num@addsign
- \fi
- \else
- \expandafter\@gobble
- \fi
- {#1}%
- \expandafter\let\csname si@num@#1sign\endcsname\si@num@sign
- \expandafter\let\csname si@num@#1\endcsname\si@num@value}
-\newcommand*{\si@num@sign}{}
-\def\si@num@findsign#1#2#3\@empty{%
- \si@num@delplusfalse
- \si@str@ifchrstr{#1}{\si@numsign}{%
- \si@str@ifchrstr{#2}{\si@numsign}{%
- \if +#1%
- \if -#2%
- \si@log@debug{Found sign combination +- for
- `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{{\si@pm}}%
- \else
- \si@log@inf{Unknown sign combination `#1#2'}%
- \renewcommand*{\si@num@sign}{{#1#2}}%
- \fi
- \else
- \if -#1%
- \if +#2%
- \si@log@debug{Found sign combination -+ for
- `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{{\mp}}%
- \else
- \si@log@inf{Unknown sign combination `#1#2'}%
- \renewcommand*{\si@num@sign}{{#1#2}}%
- \fi
- \else
- \si@log@inf{Unknown sign combination `#1#2'}%
- \renewcommand*{\si@num@sign}{{#1#2}}%
- \fi
- \fi
- \protected@edef\si@num@value{#3}}%
- {\si@log@debug{Found single sign character `#1' for
- `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{{#1}}%
- \if +#1%
- \ifsi@retainplus\else
- \expandafter\expandafter\expandafter\si@num@killsign
- \fi
- \fi
- \protected@edef\si@num@value{#2#3}}}%
- {\si@log@debug{No sign found for `\si@num@arg'}%
- \renewcommand*{\si@num@sign}{}%
- \protected@edef\si@num@value{#1#2#3}}}
-\newif\ifsi@num@delplus
-\newcommand*{\si@num@killsign}{%
- \si@num@delplustrue
- \renewcommand*{\si@num@sign}{}}
-\newcommand*{\si@num@addsign}[1]{%
- \begingroup
- \renewcommand*{\si@tempa}{#1}%
- \renewcommand*{\si@tempb}{mant}%
- \ifx\si@tempa\si@tempb
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup
- {\ifsi@num@signmant
- \expandafter\si@num@asign
- \else
- \expandafter\@gobble
- \fi
- {mantissa}}
- {\ifsi@num@signexp
- \expandafter\si@num@asign
- \else
- \expandafter\@gobble
- \fi
- {exponent}}}
-\newcommand*{\si@num@asign}[1]{%
- \let\si@num@sign\si@sign
- \si@log@debug{Adding sign \si@sign\space to #1 for
- `\si@num@arg'}}
-\newcommand*{\si@num@procnum}[1]{%
- \expandafter\ifx\expandafter\@empty
- \csname si@num@#1\endcsname\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@finddigits
- \fi
- {#1}}
-\newcommand*{\si@num@predec}{}
-\newcommand*{\si@num@postdec}{}
-\newcommand*{\si@num@finddigits}[1]{%
- \renewcommand*{\si@num@predec}{}%
- \renewcommand*{\si@num@postdec}{}%
- \si@switchfalse
- \expandafter\expandafter\expandafter\si@num@digits
- \csname si@num@#1\endcsname\@empty\@empty
- \ifx\@empty\si@num@predec\@empty
- \ifsi@num@padlead
- \expandafter\expandafter\expandafter\si@num@addprezero
- \fi
- \fi
- \ifx\@empty\si@num@postdec\@empty
- \ifsi@num@padtrail
- \ifsi@switch
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter
- \si@num@addpostzero
- \fi
- \fi
- \fi
- \si@num@unsign{#1}%
- \ifx\@empty\si@num@predec\@empty
- \else
- \expandafter\si@num@nozero
- \fi
- \ifx\@empty\si@num@predec\@empty
- \ifx\@empty\si@num@postdec\@empty
- \expandafter\expandafter\expandafter\@gobble
- \else
- \expandafter\expandafter\expandafter\si@num@sepdigits
- \fi
- \else
- \expandafter\si@num@sepdigits
- \fi
- {#1}}
-\def\si@num@digits#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numdecimal}
- {\ifsi@switch
- \si@log@err{Duplicate decimal marker in `\si@num@arg'}
- {Only a single decimal marker (from the list
- `\si@numdecimal')\MessageBreak may occur in a
- numerical argument}%
- \else
- \si@log@debug{Found decimal marker `#1' in
- `\si@num@arg'}%
- \expandafter\si@switchtrue
- \fi}
- {\si@str@ifchrstr{#1}{\si@numsign}
- {\si@log@err{Misplaced sign character
- `#1' in `\si@num@arg'}
- {Sign characters `\si@numsign' can only
- occur\MessageBreak at the start of a number}}
- {\ifsi@switch
- \expandafter\si@num@post
- \else
- \expandafter\si@num@pre
- \fi
- {#1}}}%
- \ifx\@empty#2\@empty\else
- \si@num@digits#2\@empty\@empty
- \fi}
-\newcommand*{\si@num@pre}[1]{%
- \si@num@prepost{#1}{pre}{integer}}
-\newcommand*{\si@num@post}[1]{%
- \si@num@prepost{#1}{post}{decimal}}
-\newcommand*{\si@num@prepost}[3]{%
- \expandafter\protected@edef\csname si@num@#2dec\endcsname{%
- \csname si@num@#2dec\endcsname#1}%
- \si@log@debug{Adding `#1' to #3 part for `\si@num@arg'}}
-\newcommand*{\si@num@addprezero}{%
- \si@num@addpzero{pre}{leading}}
-\newcommand*{\si@num@addpostzero}{%
- \si@num@addpzero{post}{trailing}}
-\newcommand*{\si@num@addpzero}[2]{%
- \si@log@debug{Adding #2 zero for `\si@num@arg'}%
- \@namedef{si@num@#1dec}{0}}
-\newcommand*{\si@num@unsign}[1]{%
- \expandafter\ifx\expandafter\@empty
- \csname si@num@#1sign\endcsname\@empty
- \expandafter\@gobble
- \else
- \expandafter\si@num@nosign
- \fi
- {#1}}
-\newcommand*{\si@num@nosign}[1]{%
- \begingroup
- \si@switchtrue
- \si@str@ifonlychrs{\si@num@predec\si@num@postdec}{0}
- {\si@switchfalse}{}%
- \ifsi@switch
- \aftergroup\@gobble
- \else
- \aftergroup\@firstofone
- \fi
- \endgroup
- {\si@log@debug{Zero value: removing any sign}%
- \ifsi@ang@sign\else
- \@namedef{si@num@#1sign}{}%
- \fi}}
-\newcommand*{\si@num@nozero}{%
- \si@str@ifonlychrs{\si@num@predec}{0}
- {\renewcommand*{\si@num@predec}{0}}{}}
-\newcommand*{\si@num@decimalhook}{}
-\newcommand*{\si@num@sepdigits}[1]{%
- \begingroup
- \let\si@numextra\si@numaddn
- \protected@edef\si@tempa{\si@num@predec\si@num@postdec}%
- \si@num@ifextra{\si@tempa}
- {\aftergroup\@gobble}
- {\aftergroup\@firstofone}%
- \endgroup
- {\renewcommand*{\si@tempb}{mant}%
- \renewcommand*{\si@tempc}{#1}%
- \ifx\si@tempb\si@tempc
- \expandafter\si@num@checkerr
- \fi}%
- \protected@edef\si@tempa{\si@num@predec\si@num@postdec}%
- \expandafter\si@str@ifonlychrs\expandafter{\si@tempa}
- {0123456789}
- {\ifx\@empty\si@num@err\@empty
- \renewcommand*{\si@tempb}{mant}%
- \renewcommand*{\si@tempc}{#1}%
- \ifx\si@tempb\si@tempc
- \expandafter\expandafter\expandafter\si@num@fixlength
- \fi
- \fi}{}%
- \si@num@ifextra{\si@num@predec}{}
- {\expandafter\si@num@int\expandafter{\si@num@predec}}%
- \renewcommand*{\si@tempc}{}%
- \ifx\@empty\si@num@postdec\@empty\else
- \si@num@decimalhook
- \renewcommand*{\si@tempc}{%
- \ensuremath{{\si@decimalsymbol}}}%
- \si@num@ifextra{\si@num@postdec}{}
- {\expandafter\si@num@dec\expandafter{\si@num@postdec}}%
- \fi
- \expandafter\protected@edef\csname si@num@#1\endcsname
- {\si@num@predec\si@tempc\si@num@postdec}}
-\newcommand*{\si@num@ifextra}[1]{%
- \begingroup
- \si@switchfalse
- \expandafter\si@num@extra#1\@empty\@empty
- \ifsi@switch
- \si@log@debug{Found `extra' characters in `#1'}%
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\def\si@num@extra#1#2\@empty{%
- \ifx\@empty#1\@empty\else
- \si@str@ifchrstr{#1}{\si@numextra}{\si@switchtrue}{}%
- \ifx\@empty#2\@empty\else
- \si@num@extra#2\@empty\@empty
- \fi
- \fi}
-\newif\ifsi@num@ambigerr
-\newcommand*{\si@num@checkerr}{%
- \ifx\@empty\si@num@postdec\@empty
- \expandafter\si@num@preerr
- \else
- \expandafter\si@num@posterr
- \fi}
-\newcommand*{\si@num@preerr}{%
- \si@num@seperr{pre}%
- \ifx\@empty\si@tempb\@empty\else
- \expandafter\renewcommand\expandafter*\expandafter
- \si@num@err\expandafter{\si@tempb}%
- \fi}
-\newcommand*{\si@num@posterr}{%
- \si@num@seperr{post}%
- \ifx\@empty\si@tempb\@empty\else
- \ifsi@seperr
- \expandafter\expandafter\expandafter\si@num@psterr
- \else
- \let\si@num@err\si@tempb
- \fi
- \fi}
-\newcommand*{\si@num@psterr}{%
- \si@num@cntdigits{\si@tempb}%
- \si@tempcntb\si@tempcnta\relax
- \si@num@cntdigits{\si@num@postdec}%
- \ifnum\si@tempcnta<\si@tempcntb\relax
- \expandafter\si@num@largeerr
- \else
- \expandafter\si@num@smallerr
- \fi}
-\newcommand*{\si@num@seperr}[1]{%
- \si@switchfalse
- \renewcommand*{\si@tempa}{}%
- \renewcommand*{\si@tempb}{}%
- \expandafter\expandafter\expandafter\si@num@finderr
- \csname si@num@#1dec\endcsname\@empty\@empty
- \ifx\@empty\si@tempb\@empty\else
- \expandafter\let\csname si@num@#1dec\endcsname\si@tempa
- \fi}
-\def\si@num@finderr#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numopenerr}
- {\ifsi@switch
- \si@log@err{Invalid error in number}
- {The numerical argument \si@num@arg\space has two (or
- more)\MessageBreak error-opening characters}%
- \else
- \expandafter\si@switchtrue
- \fi}
- {\si@str@ifchrstr{#1}{\si@numcloseerr}
- {\ifsi@switch
- \ifx\@empty#2\@empty\else
- \si@log@err{Invalid error in number}
- {The numerical argument \si@num@arg\space has an
- error-closing before the last character}%
- \fi
- \else
- \si@log@err{Invalid error in number}
- {The numerical argument \si@num@arg\space has an
- error-closing character\MessageBreak but no
- error-opening one}%
- \fi}
- {\ifsi@switch
- \expandafter\si@num@addtmpb
- \else
- \expandafter\si@num@addtmpa
- \fi
- {#1}}}%
- \ifx\@empty#2\@empty\else
- \si@num@finderr#2\@empty
- \fi}
-\newcommand*{\si@num@addtmpa}[1]{\si@num@addtmp{a}{#1}}
-\newcommand*{\si@num@addtmpb}[1]{\si@num@addtmp{b}{#1}}
-\newcommand*{\si@num@addtmp}[2]{%
- \expandafter\protected@edef\csname si@temp#1\endcsname{%
- \csname si@temp#1\endcsname#2}}
-\newcommand*{\si@num@cntdigits}[1]{%
- \si@tempcnta\z@\relax
- \expandafter\si@num@cntdgt#1\@empty\@empty}
-\def\si@num@cntdgt#1#2\@empty{%
- \ifx\@empty#1\@empty\else
- \advance\si@tempcnta\@ne\relax
- \fi
- \ifx\@empty#2\@empty\else
- \expandafter\si@num@cntdgt#2\@empty
- \fi}
-\newcommand*{\si@num@smallerr}{%
- \si@tempcntb\si@tempcnta\relax
- \si@num@serr
- \protected@edef\si@num@err{%
- \ifsi@num@padlead0\fi\expandafter\@car\si@numdecimal\@nil
- \si@tempb}}
-\newcommand*{\si@num@serr}{%
- \si@num@cntdigits{\si@tempb}%
- \ifnum\si@tempcnta=\si@tempcntb\relax\else
- \protected@edef\si@tempb{0\si@tempb}%
- \expandafter\si@num@serr
- \fi}
-\newcommand*{\si@num@largeerr}{%
- \renewcommand*{\si@tempa}{}%
- \si@tempcntb\si@tempcnta\relax
- \si@num@lerr
- \protected@edef\si@num@err{%
- \si@tempa\expandafter\@car\si@numdecimal\@nil\si@tempb}}
-\newcommand*{\si@num@lerr}{%
- \si@num@cntdigits{\si@tempb}%
- \ifnum\si@tempcnta=\si@tempcntb\relax\else
- \expandafter\si@num@movedigit\si@tempb\@empty\@empty
- \si@num@lerr
- \fi}
-\def\si@num@movedigit#1#2\@empty{%
- \protected@edef\si@tempa{\si@tempa#1}%
- \protected@edef\si@tempb{#2}}
-\newcommand*{\si@num@fixlength}{%
- \ifsi@fixdp
- \expandafter\si@num@fixdp
- \else
- \ifsi@fixsf
- \expandafter\expandafter\expandafter\si@num@fixsf
- \fi
- \fi}
-\newcommand*{\si@num@fixdp}{%
- \si@num@cntdigits{\si@num@postdec}%
- \ifx\@empty\si@num@postdec\@empty
- \si@tempcnta\z@\relax
- \fi
- \ifnum\si@tempcnta>\si@num@dp\relax
- \expandafter\si@num@round
- \else
- \ifnum\si@tempcnta<\si@num@dp\relax
- \expandafter\expandafter\expandafter\si@num@pad
- \fi
- \fi}
-\newcommand*{\si@num@pad}{%
- \si@log@debug{Padding to \the\si@num@dp\space digits}%
- \loop\ifnum\si@tempcnta<\si@num@dp\si@num@pd\repeat}
-\newcommand*{\si@num@pd}{%
- \advance\si@tempcnta\@ne\relax
- \protected@edef\si@num@postdec{\si@num@postdec0}}
-\newcount\si@num@rndtarget
-\newcommand*{\si@num@prernd}{}
-\newcommand*{\si@num@postrnd}{}
-\newcommand*{\si@num@round}{%
- \si@log@debug{Rounding to \the\si@num@dp\space digits}%
- \si@num@rndtarget\si@num@dp\relax
- \si@num@rndstart}
-\newcommand*{\si@num@rndstart}{%
- \si@num@reverse{\si@num@postdec}%
- \si@num@reverse{\si@num@predec}%
- \let\si@num@prernd\si@num@predec
- \let\si@num@postrnd\si@num@postdec
- \renewcommand*{\si@num@predec}{}%
- \renewcommand*{\si@num@postdec}{}%
- \si@switchfalse
- \si@num@rnd}
-\newcommand*{\si@num@reverse}[1]{%
- \renewcommand*{\si@tempa}{}%
- \expandafter\si@num@rev#1\@empty\@empty
- \let#1\si@tempa}
-\def\si@num@rev#1#2\@empty{%
- \edef\si@tempa{#1\si@tempa}%
- \ifx\@empty#2\@empty\else
- \si@num@rev#2\@empty\@empty
- \fi}
-\newcommand*{\si@num@rnd}{%
- \ifx\@empty\si@num@postrnd\@empty
- \expandafter\si@num@rndpre
- \else
- \expandafter\si@num@rndpost
- \fi}
-\newcommand*{\si@num@rndpre}{%
- \expandafter\edef\expandafter\si@tempa\expandafter{%
- \expandafter\@car\si@num@prernd\@nil}%
- \expandafter\edef\expandafter\si@num@prernd\expandafter{%
- \expandafter\@cdr\si@num@prernd\@nil}%
- \si@tempcntb\si@tempa\relax
- \ifsi@switch
- \advance\si@tempcntb\@ne\relax
- \fi
- \si@switchfalse
- \ifnum\si@tempcntb=10\relax
- \si@tempcntb\z@\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@predec{\the\si@tempcntb\si@num@predec}%
- \ifx\@empty\si@num@prernd\@empty
- \ifsi@switch
- \edef\si@num@predec{1\si@num@predec}%
- \fi
- \else
- \expandafter\si@num@rnd
- \fi}
-\newcommand*{\si@num@rndpost}{%
- \expandafter\edef\expandafter\si@tempa\expandafter{%
- \expandafter\@car\si@num@postrnd\@nil}%
- \expandafter\edef\expandafter\si@num@postrnd\expandafter{%
- \expandafter\@cdr\si@num@postrnd\@nil}%
- \si@tempcntb\si@tempa\relax
- \ifsi@switch
- \advance\si@tempcntb\@ne\relax
- \fi
- \si@switchfalse
- \advance\si@num@rndtarget\@ne\relax
- \ifnum\si@tempcnta>\si@num@rndtarget\relax
- \advance\si@num@rndtarget\m@ne\relax
- \else
- \advance\si@num@rndtarget\m@ne\relax
- \ifnum\si@tempcnta>\si@num@rndtarget\relax
- \ifnum\si@tempcntb>4\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \else
- \ifnum\si@tempcntb=10\relax
- \si@tempcntb\z@\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@postdec{\the\si@tempcntb\si@num@postdec}%
- \fi
- \fi
- \advance\si@tempcnta\m@ne\relax
- \ifnum\si@tempcnta=\m@ne\relax
- \si@num@throw
- \fi
- \si@num@rnd}
-\newcommand*{\si@num@throw}{%
- \si@num@reverse{\si@num@postdec}%
- \edef\si@num@postdec{\expandafter\@cdr\si@num@postdec\@nil}%
- \si@num@reverse{\si@num@postdec}}
-\newcommand*{\si@num@fixsf}{%
- \si@num@cntdigits{\si@num@predec}%
- \ifx\@empty\si@num@predec\@empty
- \si@tempcnta\z@\relax
- \fi
- \ifnum\si@tempcnta=\@ne\relax
- \renewcommand*{\si@tempa}{0}%
- \ifx\si@num@predec\si@tempa
- \ifx\@empty\si@num@postdec\@empty\else
- \si@tempcnta\z@\relax
- \si@switchfalse
- \expandafter\si@num@cntpostsf\si@num@postdec
- \@empty\@empty
- \ifnum\si@tempcnta>\si@num@sf\relax
- \si@log@debug{Rounding to \the\si@num@sf\space
- figures}%
- \si@num@rndtarget\si@num@sf\relax
- \si@num@rndstart
- \fi
- \fi
- \else
- \si@num@cntprepost
- \fi
- \else
- \ifnum\si@tempcnta<\si@num@sf\relax
- \si@num@cntprepost
- \else
- \advance\si@tempcnta\m@ne\relax
- \si@switchfalse
- \ifnum\si@tempcnta>\si@num@sf\relax\else
- \ifx\@empty\si@num@postdec\@empty\else
- \edef\si@num@postdec{\expandafter\@car
- \si@num@postdec\@nil}%
- \ifnum\si@num@postdec>4\relax
- \expandafter\si@switchtrue
- \fi
- \fi
- \fi
- \advance\si@tempcnta\@ne\relax
- \renewcommand*{\si@num@postdec}{}%
- \si@num@reverse{\si@num@predec}%
- \let\si@num@prernd\si@num@predec
- \renewcommand*{\si@num@predec}{}%
- \si@num@sfpre
- \ifsi@switch
- \edef\si@num@predec{1\si@num@predec}%
- \fi
- \fi
- \fi}
-\def\si@num@cntpostsf#1#2\@empty{%
- \ifsi@switch
- \advance\si@tempcnta\@ne\relax
- \else
- \if 0#1\relax\else
- \si@tempcnta\@ne\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \fi
- \ifx\@empty#2\@empty\else
- \si@num@cntpostsf#2\@empty\@empty
- \fi}
-\newcommand*{\si@num@cntprepost}{%
- \si@tempcntb\si@tempcnta\relax
- \si@num@cntdigits{\si@num@postdec}%
- \advance\si@tempcnta\si@tempcntb\relax
- \ifnum\si@tempcnta>\si@num@sf
- \si@log@debug{Rounding to \the\si@num@sf\space figures}%
- \si@num@rndtarget\si@num@sf\relax
- \si@num@rndstart
- \ifsi@switch
- \si@num@throw
- \fi
- \fi}
-\newcommand*{\si@num@sfpre}{%
- \expandafter\edef\expandafter\si@tempa\expandafter{%
- \expandafter\@car\si@num@prernd\@nil}%
- \expandafter\edef\expandafter\si@num@prernd\expandafter{%
- \expandafter\@cdr\si@num@prernd\@nil}%
- \si@tempcntb\si@tempa\relax
- \ifsi@switch
- \advance\si@tempcntb\@ne\relax
- \fi
- \si@switchfalse
- \advance\si@num@sf\@ne\relax
- \ifnum\si@tempcnta>\si@num@sf\relax
- \advance\si@num@sf\m@ne\relax
- \edef\si@num@predec{0\si@num@predec}%
- \else
- \advance\si@num@sf\m@ne\relax
- \ifnum\si@tempcnta>\si@num@sf\relax
- \ifnum\si@tempcntb>4\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@predec{0\si@num@predec}%
- \else
- \ifnum\si@tempcntb=10\relax
- \si@tempcntb\z@\relax
- \expandafter\expandafter\expandafter\si@switchtrue
- \fi
- \edef\si@num@predec{\the\si@tempcntb\si@num@predec}%
- \fi
- \fi
- \advance\si@tempcnta\m@ne\relax
- \ifx\@empty\si@num@prernd\@empty\else
- \expandafter\si@num@sfpre
- \fi}
-\newcommand*{\si@num@int}[1]{%
- \renewcommand*{\si@num@predec}{}%
- \ifsi@sepfour
- \si@num@intfmt{}#1\@empty\@empty\@empty
- \else
- \si@num@iffive{#1}
- {\si@num@intfmt{}#1\@empty\@empty\@empty}
- {\renewcommand*{\si@num@predec}{#1}}%
- \fi}
-\newcommand*{\si@num@iffive}[1]{%
- \si@num@five#1\@empty\@empty\@empty\@empty\@empty\end}
-\def\si@num@five#1#2#3#4#5\end{%
- \ifx\@empty#5\@empty
- \expandafter\@secondoftwo
- \else
- \expandafter\@firstoftwo
- \fi}
-\newcommand*{\si@num@intfmt}[4]{%
- \ifx\@empty#2\@empty
- \si@num@intsep#1\relax
- \else
- \ifx\@empty#3\@empty
- \si@num@intsep\@empty\@empty#1#2\relax
- \else
- \ifx\@empty#4\@empty
- \si@num@intsep\@empty#1#2#3\relax
- \else
- \si@num@fiint{#1#2#3#4}%
- \fi
- \fi
- \fi}
-\def\si@num@fiint#1\fi\fi\fi{\fi\fi\fi\si@num@intfmt{#1}}
-\newcommand*{\si@num@intsep}[4]{%
- \protected@edef\si@num@predec{\si@num@predec#1#2#3}%
- \if\relax#4\relax\else
- \protected@edef\si@num@predec{%
- \si@num@predec\ensuremath{\noexpand\si@digitsep}}%
- \expandafter\si@num@intsep\expandafter#4%
- \fi}
-\newcommand*{\si@num@dec}[1]{%
- \renewcommand*{\si@num@postdec}{}%
- \ifsi@sepfour
- \si@num@decfmt#1\@empty\@empty\@empty\@empty
- \else
- \si@num@iffive{#1}
- {\si@num@decfmt#1\@empty\@empty\@empty\@empty}
- {\protected@edef\si@num@postdec{\si@num@postdec#1}}%
- \fi}
-\newcommand*{\si@num@decfmt}[4]{%
- \protected@edef\si@num@postdec{\si@num@postdec#1#2#3}%
- \ifx\@empty#4\@empty%
- \else
- \protected@edef\si@num@postdec{%
- \si@num@postdec\ensuremath{\noexpand\si@digitsep}}%
- \expandafter\si@num@decfmt\expandafter#4%
- \fi}
-\newcommand*{\si@num@procerr}{%
- \si@num@addunit
- \ensuremath{\si@pm}%
- \expandafter\si@num\expandafter{\si@num@err}}
-\newcommand*{\si@num@sepxpart}{%
- \si@num@addunit
- \ensuremath{{}\times{}}%
- \expandafter\expandafter\expandafter\si@num\expandafter
- \expandafter\expandafter{%
- \expandafter\@cdr\si@num@xpart\@nil}}
-\newcommand*{\si@num@addunit}{%
- \si@unt@numtrue
- \ifx\@empty\si@unt@unitarg\@empty\else
- \ifsi@repeatunits
- \begingroup
- \si@out@numfalse
- \si@fam@setfalse
- \si@fam@set
- \si@unt@printunit{\si@unt@unitarg}%
- \endgroup
- \fi
- \fi}
-\si@newrobustcmd*{\ang}[2][]{%
- \begingroup
- \sisetup{#1}%
- \si@fam@mode
- \si@log@debug{Processing \string\ang\space input `#2'}%
- \@makeother{\;}%
- \makeatletter
- \scantokens{\si@ang@parse#2;;;\@nil}}
-\def\si@ang@parse#1;#2;#3;#4\@nil{%
- \let\ifsi@ang@fixdp\ifsi@fixdp
- \si@fixdpfalse
- \si@ifmtarg{#4}
- {\si@log@debug{Angle argument contains no
- semi-colons:\MessageBreak decimal angle}%
- \si@ang@dec{#1}{}{}}
- {\si@log@debug{Angle argument contains
- semi-colons:\MessageBreak degree-minute-second angle}%
- \renewcommand*{\si@tempa}{#4}%
- \renewcommand*{\si@tempb}{;;}%
- \ifx\si@tempa\si@tempb\else
- \ifsi@strictarc
- \renewcommand*{\si@tempb}{;}%
- \ifx\si@tempa\si@tempb
- \si@log@err{Insufficient semi-colons in argument
- of \string\ang}{The argument of
- \string\ang\space must contain either no
- semi-colons or exactly two}%
- \else
- \si@log@err{Excess semi-colons in argument of
- \string\ang}{The argument of \string\ang\space
- must contain either no semi-colons or exactly
- two}%
- \fi
- \fi
- \fi
- \si@ang@arc{#1}{#2}{#3}}}
-\newcommand*{\si@ang@dec}{%
- \let\si@ang@fix\@gobble
- \ifsi@ang@toarc
- \expandafter\si@ang@dectoarc
- \else
- \sisetup{padangle=none,anglesep=none}\expandafter\si@ang@typeset
- \fi}
-\newcommand*{\si@ang@arc}{%
- \let\si@ang@fix\si@ang@arcfix
- \ifsi@ang@todec
- \expandafter\si@ang@arctodec
- \else
- \expandafter\si@ang@typeset
- \fi}
-\newif\ifsi@ang@fixdp
-\newcommand*{\si@ang@fix}[1]{}
-\newcommand*{\si@ang@arcfix}[1]{%
- \renewcommand*{\si@tempa}{second}%
- \renewcommand*{\si@tempb}{#1}%
- \ifx\si@tempa\si@tempb
- \ifsi@ang@fixdp
- \expandafter\expandafter\expandafter\si@fixdptrue
- \else
- \expandafter\expandafter\expandafter\si@fixdpfalse
- \fi
- \else
- \expandafter\si@fixdpfalse
- \fi}
-\newcommand*{\si@ang@ifnum}[1]{%
- \begingroup
- \renewcommand*{\si@numvalid}{0123456789,.+-}%
- \ifx\@empty#1\@empty
- \aftergroup\@firstoftwo
- \else
- \si@num@ifvalid{#1}
- {\aftergroup\@firstoftwo}
- {\aftergroup\@secondoftwo}%
- \fi
- \endgroup}
-\newcommand*{\si@ang@arctodec}[3]{%
- \let\si@ang@fix\@gobble
- \ifnum\si@num@dp>\thr@@\relax
- \si@num@dp\thr@@\relax
- \fi
- \si@fixdptrue
- \si@ang@ifnum{#1}
- {\si@ang@ifnum{#2}
- {\si@ang@ifnum{#3}
- {\si@tempdima\z@\relax
- \renewcommand*{\si@tempa}{+}%
- \ifx\@empty#1\@empty\else
- \si@tempdima #1pt\relax
- \fi
- \ifdim\si@tempdima<\z@\relax
- \renewcommand*{\si@tempa}{-}%
- \fi
- \ifx\@empty#2\@empty\else
- \si@tempdima\dimexpr\si@tempdima\si@tempa
- #2pt/60\relax
- \fi
- \ifdim\si@tempdima<\z@\relax
- \renewcommand*{\si@tempa}{-}%
- \else
- \fi
- \ifx\@empty#3\@empty\else
- \si@tempdima\dimexpr\si@tempdima\si@tempa
- #3pt/3600\relax
- \fi
- \sisetup{numdecimal=.}%
- \expandafter\si@ang@typeset\expandafter{%
- \strip@pt\si@tempdima}{}{}}
- {\si@ang@notnum{#1}{#2}{#3}}}
- {\si@ang@notnum{#1}{#2}{#3}}}
- {\si@ang@notnum{#1}{#2}{#3}}}
-\newcommand*{\si@ang@dectoarc}[1]{%
- \let\si@ang@fix\si@ang@arcfix
- \si@ang@fixdptrue
- \ifnum\si@num@dp>\@ne\relax
- \si@num@dp\@ne\relax
- \fi
- \si@ang@ifnum{#1}
- {\si@tempdima\z@\relax
- \ifx\@empty#1\@empty\else
- \si@tempdima #1pt\relax
- \fi
- \si@ang@sepint{deg}%
- \si@tempdima\dimexpr\si@tempdima *60\relax
- \si@ang@sepint{min}%
- \edef\si@tempa{\the\dimexpr\si@tempdima *60\relax}%
- \expandafter\newcommand\expandafter*\expandafter{%
- \expandafter\si@ang@arcsec\expandafter}\expandafter{%
- \expandafter\si@ang@strippt\si@tempa}%
- \si@tempdima\z@\relax
- \edef\si@tempa{\the\si@tempdima}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \expandafter\si@tempa\expandafter}\expandafter{%
- \expandafter\si@ang@strippt\si@tempa}%
- \ifx\si@tempa\si@ang@arcsec
- \renewcommand*{\si@ang@arcsec}{0}%
- \fi
- \renewcommand*{\si@tempa}{0}%
- \ifx\si@ang@arcdeg\si@tempa
- \si@temptoks{{}}%
- \else
- \si@temptoks{{\si@ang@arcdeg}}%
- \fi
- \ifx\si@ang@arcmin\si@tempa
- \si@temptoks\expandafter{\the\si@temptoks{}}%
- \else
- \si@temptoks\expandafter{\the\si@temptoks{%
- \si@ang@arcmin}}%
- \fi
- \ifx\si@ang@arcsec\si@tempa
- \si@temptoks\expandafter{\the\si@temptoks{}}%
- \else
- \si@temptoks\expandafter{\the\si@temptoks{%
- \si@ang@arcsec}}%
- \fi
- \expandafter\si@ang@typeset\the\si@temptoks}
- {\si@ang@notnum{#1}{}{}}}
-\newcommand*{\si@ang@sepint}[1]{%
- \expandafter\si@ang@sint\the\si@tempdima\@empty
- \expandafter\let\csname si@ang@arc#1\endcsname\si@tempa}
-\def\si@ang@sint#1.#2\@empty{%
- \renewcommand*{\si@tempa}{#1}%
- \si@tempdima 0.#2\relax}
-\begingroup
- \catcode`P=12
- \catcode`T=12
- \lowercase{
- \renewcommand*{\si@tempa}{%
- \def\si@ang@strippt##1PT{##1}}}
- \expandafter\endgroup
-\si@tempa
-\newcommand*{\si@ang@notnum}[3]{%
- \si@log@warn{Angle `#1;#2;#3' is not a pure
- number:\MessageBreak output will be as given}%
- \si@ang@typeset{#1}{#2}{#3}}
-\newif\ifsi@ang@sign
-\newcommand*{\si@ang@typeset}[3]{%
- \ifsi@ang@padlarge
- \newcommand*{\si@ang@degs}{0\si@sym@degree}%
- \newcommand*{\si@ang@mins}{0\si@sym@minute}%
- \newcommand*{\si@ang@secs}{0\si@sym@second}%
- \else
- \newcommand*{\si@ang@degs}{}%
- \newcommand*{\si@ang@mins}{}%
- \newcommand*{\si@ang@secs}{}%
- \fi
- \protected@edef\si@ang@decimalsymbol{\si@decimalsymbol}%
- \ifsi@astroang
- \let\si@ang@movesign\si@ang@astrosign
- \else
- \let\si@ang@movesign\@gobble
- \fi
- \newcommand*{\si@ang@secnum}{\si@ang@num{second}}%
- \newcommand*{\si@ang@minnum}{\si@ang@num{minute}}%
- \si@ifnotmtarg{#3}
- {\si@log@debug{Found seconds `#3'}%
- \si@ang@ifnum{#3}
- {\ifdim #3 pt=\z@\relax\else
- \si@ang@signtrue
- \fi}{}%
- \renewcommand*{\si@ang@secs}
- {\si@ang@secnum{#3}\si@sym@second}%
- \renewcommand*{\si@ang@mins}
- {\si@ang@pad{0\si@sym@minute}}%
- \renewcommand*{\si@ang@degs}
- {\si@ang@pad{0\si@sym@degree}}}%
- \si@ifnotmtarg{#2}
- {\si@log@debug{Found minutes `#2'}%
- \si@ang@ifnum{#2}
- {\ifdim #2 pt=\z@\relax\else
- \si@ang@signtrue
- \fi}{}%
- \renewcommand*{\si@ang@secnum}{%
- \si@ang@signlessnum{second}}%
- \renewcommand*{\si@ang@mins}
- {\si@ang@minnum{#2}\si@sym@minute}%
- \renewcommand*{\si@ang@degs}
- {\si@ang@pad{0\si@sym@degree}}}%
- \si@ifnotmtarg{#1}
- {\si@log@debug{Found degrees `#1'}%
- \renewcommand*{\si@ang@secnum}{%
- \si@ang@signlessnum{second}}%
- \renewcommand*{\si@ang@minnum}{%
- \si@ang@signlessnum{minute}}%
- \renewcommand*{\si@ang@degs}
- {\si@ang@num{degree}{#1}%
- \si@sym@degree}}%
- \si@out@num
- {\si@ang@degs\si@anglesep\si@ang@mins\si@anglesep
- \si@ang@secs}%
- \endgroup}
-\newcommand*{\si@ang@pad}[1]{\ifsi@ang@padsmall #1\fi}
-\newcommand*{\si@ang@num}[2]{%
- \begingroup
- \si@ang@fix{#1}%
- \si@ang@movesign{#1}%
- \si@num{#2}%
- \endgroup}
-\newcommand*{\si@ang@signlessnum}[2]{%
- \begingroup
- \si@ang@fix{#1}%
- \si@ang@movesign{#1}%
- \sisetup{addsign=none}%
- \si@num{#2}%
- \endgroup}
-\newcommand*{\si@ang@killdegree}{\let\si@sym@degree\relax}
-\newcommand*{\si@ang@killminute}{\let\si@sym@minute\relax}
-\newcommand*{\si@ang@killsecond}{\let\si@sym@second\relax}
-\newcommand*{\si@ang@astrosign}[1]{%
- \renewcommand*{\si@decimalsymbol}{%
- \setbox\si@tempboxa=\hbox{%
- \ensuremath{{\si@ang@decimalsymbol}}}%
- \si@tempdima\wd\si@tempboxa\relax
- \setbox\si@tempboxb=\hbox to\z@{%
- \hss\unhbox\si@tempboxa\hss}%
- \setbox\si@tempboxa=\hbox{%
- \csname si@sym@#1\endcsname\hskip-\scriptspace}%
- \si@tempdimb\wd\si@tempboxa\relax
- \setbox\si@tempboxc=\hbox to\z@{%
- \hss\unhbox\si@tempboxa\hss}%
- \setbox\si@tempboxd=\hbox{%
- \usebox\si@tempboxb\usebox\si@tempboxc}%
- \ifdim\si@tempdima>\si@tempdimb\relax
- \setbox\si@tempboxa=\hbox to\si@tempdima{%
- \hss\unhbox\si@tempboxd\hss}%
- \else
- \setbox\si@tempboxa=\hbox to\si@tempdimb{%
- \hss\unhbox\si@tempboxd\hss}%
- \fi
- \usebox\si@tempboxa%
- \ifdim\si@tempdima>\si@tempdimb\relax\else
- \hskip\scriptspace
- \fi}%
- \renewcommand*{\si@num@decimalhook}{\expandafter\aftergroup
- \csname si@ang@kill#1\endcsname}}%
-\@ifpackageloaded{cellspace}
- {\newcolumntype{C}[1]{>{\bcolumn #1\@nil}#1<{\ecolumn}}}
- {\AtBeginDocument{
- \@ifpackageloaded{cellspace}
- {\newcolumntype{C}[1]{>{\bcolumn #1\@nil}#1<{\ecolumn}}%
- \renewcommand*{\NC@rewrite@S}[1][]{%
- \edef\si@tempa{\the\@temptokena
- >{\noexpand\si@tab@begin@S[#1]}c%
- <{\noexpand\si@tab@end@S}}%
- \@temptokena\expandafter{\si@tempa}%
- \NC@find}}
- {}}}
-\edef\si@tempa{%
- \noexpand\NC@do S\noexpand\NC@do s\the\NC@list}
-\newcolumntype{S}{}
-\newcolumntype{s}{}
-\NC@list\expandafter{\si@tempa}
-\newcommand*{\si@tab@corr@colortbl}{\relax}
-\AtBeginDocument{
- \@ifpackageloaded{colortbl}{%
- \renewcommand*{\si@tab@corr@colortbl}{%
- \hskip\stretch{-0.5}\kern\z@
- }
- }{}
-}
-\renewcommand*{\NC@rewrite@S}[1][]{%
- \edef\si@tempa{\the\@temptokena
- >{\noexpand\si@tab@begin@S[#1]}c%
- <{\noexpand\si@tab@end@S}}%
- \@temptokena\expandafter{\si@tempa}%
- \NC@find}
-\renewcommand*{\NC@rewrite@s}[1][]{%
- \edef\si@tempa{\the\@temptokena
- >{\noexpand\si@tab@begin@s[#1]}c%
- <{\noexpand\si@tab@end@s}}%
- \@temptokena\expandafter{\si@tempa}%
- \NC@find}
-\newcommand*{\si@tab@begin@S}[1][]{%
- \si@log@debug{Processing S column cell contents}%
- \let\si@tab@gettok\si@tab@gettok@S
- \si@seperrfalse
- \renewcommand*{\si@num@sepxpart}{%
- \si@log@err{Multiple numbers not allowed in
- tables\MessageBreak Only the first number used}
- \@ehb}%
- \si@tab@begin[#1]}
-\newcommand*{\si@tab@begin@s}[1][]{%
- \si@log@debug{Processing s column cell contents}%
- \let\si@tab@gettok\si@tab@gettok@s
- \si@tab@begin[#1]}
-\newtoks\si@tab@toks
-\newtoks\si@tab@pretoks
-\newtoks\si@tab@posttoks
-\newcommand*{\si@tab@begin}[1][]{%
- \begingroup
- \sisetup{#1}%
- \si@tab@toks{}%
- \si@tab@pretoks{}%
- \si@tab@posttoks{}%
- \si@switchfalse
- \si@tab@gettok}
-\newcommand*{\si@tab@next}{}
-\newcommand*{\si@tab@gettok@S}[1]{%
- \ifx\tabularnewline#1\relax
- \let\si@tab@next\si@tab@newline@S
- \else
- \ifx\end#1\relax
- \let\si@tab@next\end
- \else
- \ifx\si@tab@end@S#1\relax
- \let\si@tab@next\si@tab@end@S
- \else
- \ifx\endtabular#1\relax
- \let\si@tab@next\endtabular
- \else
- \ifx\csname#1\relax
- \let\si@tab@next\csname
- \else
- \ifx\relax#1\relax
- \let\si@tab@next\relax
- \else
- \let\si@tab@next\si@tab@gettok@S
- \ifx\ignorespaces#1\relax
- \si@tab@othertok{#1}%
- \else
- \ifx\unskip#1\relax
- \si@tab@othertok{#1}%
- \else
- \si@str@ifchrstr{#1}{\si@numvalid}
- {\si@switchtrue
- \si@log@debug{Found numerical cell
- contents `#1'}%
- \si@tab@toks=\expandafter{%
- \the\si@tab@toks#1}}
- {\si@tab@ifonechar{#1}
- {\futurelet\si@tempa\si@tab@bracetest#1}%
- {\si@tab@othertok{#1}}}%
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \si@tab@next}
-\newcommand*{\si@tab@othertok}[1]{%
- \si@log@debug{Found other cell contents `\unexpanded{#1}'}%
- \ifsi@switch
- \si@log@debug{Adding to post-numeral part}%
- \si@tab@posttoks=\expandafter{\the\si@tab@posttoks#1}%
- \else
- \si@log@debug{Adding to pre-numeral part}%
- \si@tab@pretoks=\expandafter{\the\si@tab@pretoks#1}%
- \fi}
-\newcommand*{\si@tab@ifonechar}[1]{\si@tab@onechar#1\@empty}
-\def\si@tab@onechar#1#2\@empty{%
- \ifx\@empty#2\@empty
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi}
-\newcommand*{\si@tab@bracetest}{%
- \ifx\si@tempa\bgroup
- \expandafter\si@tab@othertok
- \else
- \expandafter\si@tab@exptest
- \fi}
-\newcommand*{\si@tab@exptest}[1]{%
- \edef\si@tempa{\si@tab@meaning{#1}}%
- \ifx\si@tempa\si@tab@macro
- \expandafter\si@tab@exptest@aux
- \else
- \expandafter\si@tab@othertok
- \fi
- {#1}%
-}
-\newcommand*{\si@tab@exptest@aux}[1]{%
- \ifcsname\expandafter\@gobble\string#1 \endcsname
- \si@tab@othertok{#1}%
- \else
- \si@log@debug{Expanding cell contents `\unexpanded{#1}'}%
- \the\si@tab@pretoks
- \si@tab@pretoks{}%
- \protected@edef\si@tab@next{\noexpand\si@tab@gettok@S#1}%
- \fi
-}
-\newcommand*{\si@tab@meaning}[1]{%
- \expandafter\si@tab@strip\meaning#1:->:->\@empty}
-\def\si@tab@strip#1:->#2:->#3\@empty{#1}
-\newcommand*{\si@tab@macro}{}
-\edef\si@tab@macro{\si@tab@meaning{\si@tab@macro}}
-\newcommand*{\si@tab@gettok@s}[1]{%
- \ifx\tabularnewline#1\relax
- \let\si@tab@next\si@tab@newline@s
- \else
- \ifx\end#1\relax
- \let\si@tab@next\end
- \else
- \ifx\si@tab@end@s#1\relax
- \let\si@tab@next\si@tab@end@s
- \else
- \ifx\endtabular#1\relax
- \let\si@tab@next\endtabular
- \else
- \ifx\csname#1\relax
- \let\si@tab@next\csname
- \else
- \ifx\relax#1\relax
- \let\si@tab@next\relax
- \else
- \let\si@tab@next\si@tab@gettok@s
- \ifx\ignorespaces#1\relax\else
- \ifx\unskip#1\relax\else
- \si@tab@toks=\expandafter{%
- \the\si@tab@toks#1}%
- \si@log@debug{Found cell contents `#1'}%
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \fi
- \si@tab@next}
-\newcommand*{\si@tab@end@S}{%
- \ifsi@switch
- \let\si@tab@lfill\si@tab@lfill@S
- \let\si@tab@rfill\si@tab@rfill@S
- \else
- \let\si@tab@rfill\si@tab@rfill@t
- \let\si@tab@lfill\si@tab@lfill@t
- \fi
- \si@tab@corr@colortbl
- \hskip\stretch{\si@tab@lfill}\kern\z@
- \ifsi@switch
- \the\si@tab@pretoks
- \si@tab@numout
- \the\si@tab@posttoks
- \else
- \the\si@tab@pretoks
- \fi
- \hskip\stretch{\si@tab@rfill}\kern\z@
- \si@tab@corr@colortbl
- \endgroup}
-\newcommand*{\si@tab@end@s}{%
- \si@tab@corr@colortbl
- \hskip\stretch{\si@tab@lfill@s}\kern\z@
- \ignorespaces
- \expandafter\si\expandafter{\the\si@tab@toks}%
- \unskip
- \hskip\stretch{\si@tab@rfill@s}\kern\z@
- \si@tab@corr@colortbl
- \endgroup}
-\newcommand*{\si@tab@newline@S}{%
- \si@tab@end@S
- \hfil\relax
- \let\si@tab@end\si@tab@end@S
- \renewcommand*{\si@tab@end@S}{\let\si@tab@end@S\si@tab@end}%
- \tabularnewline}
-\newcommand*{\si@tab@newline@s}{%
- \si@tab@end@s
- \hfil\relax
- \let\si@tab@end\si@tab@end@s
- \renewcommand*{\si@tab@end@s}{\let\si@tab@end@s\si@tab@end}%
- \tabularnewline}
-\newcount\si@tempcnta
-\newcount\si@tempcntb
-\newcommand*{\si@tab@numout}{%
- \si@num@intabtrue
- \ifsi@tabparseonly\else
- \ifsi@tab@fixed
- \ifsi@tabautofit
- \si@num@dp\si@tab@mantpostcnt\relax
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@fixdptrue
- \fi
- \fi
- \fi
- \expandafter\si@num\expandafter{\the\si@tab@toks}%
- \si@tab@format}
-\newbox\si@tab@prebox
-\newbox\si@tab@midbox
-\newbox\si@tab@postbox
-\newbox\si@tab@expbox
-\newcommand*{\si@tab@format}{%
- \ifsi@tabparseonly
- \expandafter\si@tab@outonly
- \else
- \ifsi@tab@fixed
- \expandafter\expandafter\expandafter\si@tab@fixed
- \else
- \expandafter\expandafter\expandafter\si@tab@unfixed
- \fi
- \fi
- \ifsi@colourvalues
- \si@fam@colourcmd{\si@valuecolour}%
- \fi
- \box\si@tab@prebox\box\si@tab@midbox\box\si@tab@postbox
- \box\si@tab@expbox}
-\newcommand*{\si@tab@outonly}{%
- \si@log@debug{Using non-aligned S column}%
- \setbox\si@tab@prebox=\hbox{}%
- \setbox\si@tab@midbox=\hbox{}%
- \setbox\si@tab@postbox=\hbox{}%
- \setbox\si@tab@expbox=\hbox{}%
- \protected@edef\si@tempa{%
- \si@tab@out
- \ifx\@empty\si@num@out\@empty\else
- \ensuremath{{\si@decimalsymbol}}%
- \fi
- \si@num@out
- \si@tab@expout}%
- \expandafter\si@out@num\expandafter{\si@tempa}}
-\newcommand*{\si@tab@unfixed}{%
- \si@log@debug{Using variable width S column}%
- \ifx\@empty\si@num@out\@empty
- \setbox\si@tab@midbox=\hbox
- {\phantom{\ensuremath{{\si@decimalsymbol}}}}%
- \else
- \setbox\si@tab@midbox=\hbox
- {\ensuremath{{\si@decimalsymbol}}}%
- \fi
- \protected@edef\si@num@out{\si@num@out\si@tab@expout}%
- \setbox\si@tab@prebox=\hbox{\si@out@num{\si@tab@out}}%
- \setbox\si@tab@postbox=\hbox{\si@out@num{\si@num@out}}%
- \ifdim\wd\si@tab@prebox>\wd\si@tab@postbox\relax
- \setbox\si@tab@postbox=\hbox to\wd\si@tab@prebox%
- {\unhbox\si@tab@postbox\hfill}%
- \else
- \setbox\si@tab@prebox=\hbox to\wd\si@tab@postbox%
- {\hfill\unhbox\si@tab@prebox}%
- \fi
- \setbox\si@tab@expbox=\hbox{}}
-\newdimen\si@tab@predim
-\newdimen\si@tab@postdim
-\newdimen\si@tab@expdim
-\newdimen\si@tempdima
-\newdimen\si@tempdimb
-\newcommand*{\si@tab@sp}{}
-\newcommand*{\si@tab@fixed}{%
- \si@log@debug{Using fixed-width S column}%
- \let\si@tab@sp\relax
- \setbox\si@tab@midbox=\hbox{}%
- \setbox\si@tab@expbox=\hbox{}%
- \setbox\si@tempboxa=\hbox{\si@out@num{1}}%
- \si@tempdima\wd\si@tempboxa\relax
- \si@tab@predim\the\si@tab@mantprecnt\si@tempdima\relax
- \si@tab@sepcorr{mantpre}{pre}%
- \si@tab@postdim\si@tab@mantpostcnt\si@tempdima\relax
- \setbox\si@tempboxa=\hbox{\ensuremath{{\si@decimalsymbol}}}%
- \ifnum\si@tab@mantpostcnt=\z@\relax\else
- \advance\si@tab@postdim\wd\si@tempboxa\relax
- \fi
- \si@tab@sepcorr{mantpost}{post}%
- \setbox\si@tempboxa=\hbox{\si@out@num{^{1}}}%
- \si@tempdima\wd\si@tempboxa\relax
- \ifnum\si@tab@expprecnt>\z@\relax
- \si@tab@expdim\si@tab@expprecnt\si@tempdima\relax
- \si@tab@sepcorr{exppre}{exp}%
- \fi
- \let\si@tab@sp\sp
- \ifnum\si@tab@exppostcnt>\z@\relax
- \advance\si@tab@expdim\si@tab@exppostcnt\si@tempdima\relax
- \setbox\si@tempboxa=\hbox{%
- \ensuremath{^{\si@decimalsymbol}}}%
- \advance\si@tab@expdim\wd\si@tempboxa\relax
- \si@tab@sepcorr{exppost}{exp}%
- \fi
- \setbox\si@tempboxa=\hbox{\ensuremath{-}}%
- \ifsi@tab@mantsign
- \advance\si@tab@predim\wd\si@tempboxa\relax
- \fi
- \setbox\si@tempboxa=\hbox{\ensuremath{^{-}}}%
- \ifsi@tab@expsign
- \advance\si@tab@expdim\wd\si@tempboxa\relax
- \fi
- \si@tempcnta\si@tab@expprecnt\relax
- \advance\si@tempcnta\si@tab@exppostcnt\relax
- \ifnum\si@tempcnta>\z@\relax
- \setbox\si@tempboxa=\hbox{\ensuremath{%
- {}\si@expproduct{}\si@expbase}}%
- \advance\si@tab@expdim\wd\si@tempboxa\relax
- \fi
- \ifsi@tabalignexp\else
- \advance\si@tab@postdim\si@tab@expdim\relax
- \fi
- \setbox\si@tab@prebox=\hbox to\si@tab@predim{\hss\hfill
- \si@out@num{\si@tab@out}}%
- \ifx\@empty\si@num@out\@empty
- \setbox\si@tab@postbox=\hbox to\si@tab@postdim{\hfil}%
- \else
- \ifsi@tabalignexp\else
- \protected@edef\si@num@out{\si@num@out\si@tab@expout}%
- \fi
- \setbox\si@tab@postbox=\hbox to\si@tab@postdim
- {\ensuremath{{\si@decimalsymbol}}\si@out@num
- {\si@num@out}\hfil}%
- \fi
- \ifx\@empty\si@tab@expout\@empty
- \ifsi@tabalignexp
- \setbox\si@tab@expbox=\hbox to\si@tab@expdim{\hfil}%
- \fi
- \else
- \ifsi@tabalignexp
- \setbox\si@tab@expbox=\hbox to\si@tab@expdim
- {\si@out@num{\si@tab@expout}\hfil}%
- \fi
- \fi}
-\newcommand*{\si@tab@sepcorr}[2]{%
- \expandafter\si@tempcnta\expandafter\the
- \csname si@tab@#1cnt\endcsname\relax
- \divide\si@tempcnta\thr@@\relax
- \ifsi@sepfour\else
- \expandafter\ifnum\expandafter\the
- \csname si@tab@#1cnt\endcsname=4\relax
- \si@tempcnta\z@\relax
- \fi
- \fi
- \setbox\si@tempboxa=\hbox{%
- \ensuremath{\si@tab@sp{\si@digitsep}}}%
- \expandafter\advance\csname si@tab@#2dim\endcsname
- \si@tempcnta\wd\si@tempboxa}
-\si@newrobustcmd*{\SI}[2][]{%
- \@ifnextchar[%]
- {\si@SI[#1]{#2}}
- {\si@SI[#1]{#2}[]}}
-\si@newrobustcmd*{\si}[2][]{\si@SI[#1]{}[]{#2}}
+ \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-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-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-text-post = true,
+ table-number-alignment = center-decimal-marker,
+ table-text-alignment = center,
+ table-figures-decimal = 2,
+ table-figures-integer = 3
+}
+\keys_define:nn { siunitx } {
+ table-alignment .meta:n =
+ {
+ table-number-alignment = #1,
+ table-text-alignment = #1,
+ table-unit-alignment = #1
+ }
+}
+\cs_set_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 { 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_mantissa_bool }
+ { \bool_set_false:N \_l_siunitx_table_sign_mantissa_bool }
+ \keys_set:nn { siunitx } { table-number-alignment = center }
+ },
+}
+\cs_set_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 }
+ }
+}
-\newcommand*{\newunit}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defunit[#1]{#2}{#3}}
- {\si@log@err{Unit \string#2 already defined!}\@eha}}
-\newcommand*{\renewunit}[3][]{%
- \si@ifdefinable{#2}
- {\si@log@err{Unit \string#2 undefined}\@ehc
- \si@unt@defunit[#1]{#2}{#3}}
- {\si@log@inf{Redefining unit \string#2}%
- \si@unt@defunit[#1]{#2}{#3}}}
-\newcommand*{\provideunit}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defunit[#1]{#2}{#3}}
- {}}
-\newcommand*{\newprefix}[4][]{%
- \si@ifdefinable{#2}
- {\si@unt@defprefix[#1]{#2}{#3}{#4}}
- {\si@log@err{Prefix \string#2 already defined!}\@eha}}
-\newcommand*{\renewprefix}[4][]{%
- \si@ifdefinable{#2}
- {\si@log@err{Prefix \string#2 undefined}\@ehc
- \si@unt@defprefix[#1]{#2}{#3}{#4}}
- {\si@log@inf{Redefining prefix \string#2}%
- \si@unt@defprefix[#1]{#2}{#3}{#4}}}
-\newcommand*{\provideprefix}[4][]{%
- \si@ifdefinable{#2}
- {\si@unt@defprefix[#1]{#2}{#3}{#4}}
- {}}
-\newcommand*{\newpower}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defpower[#1]{#2}{#3}}
- {\si@log@err{Power \string#2 already defined!}\@eha}}
-\newcommand*{\renewpower}[3][]{%
- \si@ifdefinable{#2}
- {\si@log@err{Power \string#2 undefined}\@ehc
- \si@unt@defpower[#1]{#2}{#3}}
- {\si@log@inf{Redefining power \string#2}%
- \si@unt@defpower[#1]{#2}{#3}}}
-\newcommand*{\providepower}[3][]{%
- \si@ifdefinable{#2}
- {\si@unt@defpower[#1]{#2}{#3}}
- {}}
-\newcommand*{\newqualifier}[2]{%
- \si@ifdefinable{#1}
- {\si@unt@defqual{#1}{#2}}
- {\si@log@err{Qualifier \string#1 already defined!}\@eha}}
-\newcommand*{\renewqualifier}[2]{%
- \si@ifdefinable{#1}
- {\si@log@err{Qualifier \string#1 undefined}\@ehc
- \si@unt@defqual{#1}{#2}}
- {\si@unt@defqual{#1}{#2}}}
-\newcommand*{\providequalifier}[2]{%
- \si@ifdefinable{#1}
- {\si@unt@defqual{#1}{#2}}
- {}}
-\newif\ifsi@unt@num
-\newcommand*{\si@unt@unitarg}{}
-\newcommand*{\si@unt@SIopts}{}
-\def\si@SI[#1]#2[#3]#4{%
- \begingroup
- \let\fg\SIfg
- \sisetup{#1}%
- \renewcommand*{\si@unt@SIopts}{#1}%
- \si@fam@mode
- \si@unt@numfalse
- \si@xspacefalse
- \si@ifnotmtarg{#3}
- {\si@log@debug{Prefix unit found}%
- \si@unt@printunit{#3}}%
- \si@ifnotmtarg{#4}
- {\renewcommand*{\si@unt@unitarg}{#4}}%
- \si@ifnotmtarg{#2}
- {\si@log@debug{Number found in \string\SI\space
- argument}%
- \ifsi@repeatunits\else
- \ifsi@trapambigerr
- \expandafter\expandafter\expandafter
- \si@num@ambigerrtrue
- \fi
- \fi
- \num{#2}%
- \si@unt@numtrue}%
- \si@ifnotmtarg{#4}
- {\si@ifmtarg{#2}
- {\si@unt@printunit{#4}}
- {\si@tempcnta\z@\relax
- \ifsi@addunitpower
- \si@unt@countx{#2}%
- \fi
- \ifnum\si@tempcnta>\z@\relax
- \advance\si@tempcnta\@ne\relax
- \edef\si@tempa{\noexpand\tothe{\si@tempcnta}}%
- \renewcommand*{\si@tempb}{#4}%
- \expandafter\expandafter\expandafter
- \si@unt@printunit\expandafter\expandafter
- \expandafter{%
- \expandafter\si@tempb\si@tempa}%
- \else
- \si@unt@printunit{#4}%
- \fi}}%
- \endgroup}
-\newcommand*{\si@unt@countx}[1]{%
- \si@tempcnta\z@\relax
- \expandafter\si@unt@cntx#1\@empty\@empty}
-\def\si@unt@cntx#1#2\@empty{%
- \si@str@ifchrstr{#1}{\si@numprod}
- {\advance\si@tempcnta\@ne\relax}
- {}%
- \ifx\@empty#2\@empty\else
- \si@unt@cntx#2\@empty\@empty
- \fi}
-\newif\ifsi@unt@littest
-\newcommand*{\si@unt@ifliteral}[1]{%
- \begingroup
- \si@unt@littesttrue
- \setbox\si@tempboxa=\hbox{\si@unt@out{#1}}%
- \ifdim\wd\si@tempboxa>\z@\relax
- \aftergroup\@firstoftwo
- \else
- \aftergroup\@secondoftwo
- \fi
- \endgroup}
-\newif\ifsi@unt@litout
-\newcommand*{\si@unt@printunit}[1]{%
- \si@unt@ifliteral{#1}
- {\ifsi@allowlitunits
- \expandafter\si@unt@litprint
- \else
- \expandafter\si@unt@nolitprint
- \fi
- {#1}}
- {\si@log@debug{Macro unit found:\MessageBreak
- processing to format output}%
- \si@unt@init
- \advance\si@unt@depthcnt\@ne\relax
- #1%
- \si@unt@final}}
-\newcommand*{\si@unt@litprint}[1]{%
- \si@log@debug{%
- Literal items found in unit argument:\MessageBreak outputting
- without further processing}%
- \si@unt@litouttrue
- \si@unt@addvaluesep
- \si@unt@out{#1}%
-}
-\newcommand*{\si@unt@nolitprint}[1]{%
- \si@log@err{Literal units disabled}{%
- You can the literal input `#1' for a unit\MessageBreak
- but the allowliteralunits option is off.
+\cs_set_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: }
+ }
+}
+\cs_set_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
+ {
+ \_siunitx_number_process:
+ \_siunitx_number_format:
+ \_siunitx_number_output_color:
+ }
+}
+\cs_set_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 }
+ \_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: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
+ }
+}
+\cs_set_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 } }
+ \hbox_set:Nn \_l_siunitx_table_post_box
+ { \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_clear: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_clear:N \_l_siunitx_table_pre_box
+ }
+ }
+}
+\cs_set_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_set_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
+}
+\cs_set_protected_nopar:Npn \_siunitx_table_print_S_reserved: {
+ \dim_zero:N \_l_siunitx_table_gap_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 }
+ \_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:
+ \intexpr_compare:nNnTF
+ {
+ \int_use:N \_l_siunitx_table_integer_int
+ + \int_use:N \_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 }
+ }
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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: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
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_table_print_S_reserved_ends: {
+ \hbox_set:Nn \_l_siunitx_tmp_box { \_l_siunitx_table_pre_tl }
+ \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 }
+ {
+ \tl_use:N \_l_siunitx_table_collect_post_tl
+ \tex_hfil:D
+ }
+}
+\cs_set_protected_nopar:Npn \_siunitx_table_print_S_model_create: {
+ \prop_clear:N \_l_siunitx_number_in_prop
+ \_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 }
+ \intexpr_compare:nNnF
+ {
+ \int_use:N \_l_siunitx_table_integer_int
+ + \int_use:N \_l_siunitx_table_decimal_int
+ }
+ = { 0 }
+ {
+ \prop_put:Nnn \_l_siunitx_number_in_prop { mantissa }
+ { true }
+ }
+ \intexpr_compare:nNnT
+ { \int_use:N \_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 } { - } }
+ \intexpr_compare:nNnT
+ { \int_use:N \_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:
+ \_siunitx_number_format:
+ \prop_set_eq:NN \_l_siunitx_table_model_prop
+ \_l_siunitx_number_out_prop
+}
+\cs_set_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 }
+ }
+}
+\cs_set_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 { }
+ \hbox_set_to_wd:Nnn \_l_siunitx_table_result_box
+ { \_l_siunitx_table_mantissa_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
+ \_siunitx_table_print_S_reserved_uncert:n { mantissa }
+}
+\cs_set_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
+ }
+}
+\cs_set_protected_nopar:Npn
+ \_siunitx_table_print_S_reserved_uncert:n #1 {
+ \bool_if:NT \_l_siunitx_uncert_sep_bool
+ {
+ \intexpr_compare:nNnTF
+ { \int_use:N \_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_set_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
+}
+\cs_set_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 }
+ }
+ \box_use:N \_l_siunitx_table_result_box
+}
+\cs_set_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
+}
+\cs_set_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: }
+ }
+ \box_use:N \_l_siunitx_table_result_box
+}
+\cs_set_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_set_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 }
+}
+\cs_set_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 }
+ }
+}
+\cs_set_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 }
+}
+\cs_set_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 }
+}
+\cs_set_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
+}
+\cs_set_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 }
+}
+\cs_set_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 }
+ }
+}
+\cs_set_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 }
+}
+\cs_set_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 }
+}
+\cs_set_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: }
+}
+\char_make_active:N \@
+\cs_set_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_set_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_set_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
+}
+\char_make_active:N \@
+\cs_set_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_set_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_set_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 }
+}
+\keys_define:nn { siunitx } {
+ redefine-symbols .bool_set:N = \_l_siunitx_redefine_symbols_bool,
+}
+\keys_set:nn { siunitx } {
+ redefine-symbols = true
+}
+\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 } }
+ }
+ \tl_if_eq:nVT { OT1 } \encodingdefault
+ {
+ \keys_set:nn { siunitx }
+ {
+ math-angstrom = \text { \capitalring { A } },
+ text-angstrom = \capitalring { A }
+ }
+ }
+ } { }
+ \@ifpackageloaded { upgreek }
+ {
+ \keys_set:nn { siunitx }
+ { math-ohm = \Upomega }
+ } { }
+ }
+}
+\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 } },
+}
+\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 },
+}
+\cs_set_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 } } }
+ }
+}
+\_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 }
+\clist_new:N \_l_siunitx_pgf_link_clist
+\cs_set_protected_nopar:Npn \_siunitx_pgf_link: {
+ \clist_clear:N \_l_siunitx_pgf_link_clist
+ \tl_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 }
+ }
+ \tl_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
+}
+\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.
+ }
+\cs_set_protected_nopar:Npn \DeclareBinaryPrefix #1#2#3 {
+ \_siunitx_declare_prefix:Nnnn #1 {#2} { 2 } {#3}
+}
+\cs_set_protected_nopar:Npn \DeclareSIPostPower #1#2 {
+ \_siunitx_declare_power_after:Nn #1 {#2}
+}
+\cs_set_protected_nopar:Npn \DeclareSIPrefix #1#2#3 {
+ \_siunitx_declare_prefix:Nnnn #1 {#2} { 10 } {#3}
+}
+\cs_set_protected_nopar:Npn \DeclareSIPrePower #1#2 {
+ \_siunitx_declare_power_before:Nn #1 {#2}
+}
+\cs_set_protected_nopar:Npn \DeclareSIQualifier #1#2 {
+ \_siunitx_declare_qualifier:Nn #1 {#2}
+}
+\cs_set_protected_nopar:Npn \DeclareSIUnit #1#2 {
+ \_siunitx_declare_unit:Nnn #1 {#2} { }
+}
+\cs_set_protected_nopar:Npn \DeclareSIUnitWithOptions #1#2#3 {
+ \_siunitx_declare_unit:Nnn #1 {#2} {#3}
+}
+\@onlypreamble \DeclareBinaryPrefix
+\@onlypreamble \DeclareSIPostPower
+\@onlypreamble \DeclareSIPrefix
+\@onlypreamble \DeclareSIPrePower
+\@onlypreamble \DeclareSIQualifier
+\@onlypreamble \DeclareSIUnit
+\@onlypreamble \DeclareSIUnitWithOptions
+\cs_set_protected_nopar:Npn \SendSettingsToPgf { \_siunitx_pgf_link: }
+\@onlypreamble \SendSettingsToPgf
+\NewDocumentCommand \ang { o > { \SplitArgument { 2 } { ; } } m } {
+ \group_begin:
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \_siunitx_angle_output:nnn #2
+ \group_end:
+}
+\NewDocumentCommand \num { o m } {
+ \group_begin:
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \_siunitx_number_output:n {#2}
+ \group_end:
+}
+\NewDocumentCommand \numlist { o > { \SplitList { ; } } m } {
+ \group_begin:
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \_siunitx_list_numbers:n {#2}
+ \group_end:
+}
+\NewDocumentCommand \numrange { o m m } {
+ \group_begin:
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \_siunitx_range_numbers:nn {#2} {#3}
+ \group_end:
+}
+\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:
+}
+\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:
+}
+\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:
+}
+\NewDocumentCommand \sisetup { m } {
+ \keys_set:nn { siunitx } {#1}
+}
+\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_set_protected_nopar:Npn \_siunitx_contents_add:N #1 {
+ \cs_set_nopar:Npn #1 { \token_to_str:N #1 }
+}
+\cs_set_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] }
+}
+\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 }
+\AtBeginDocument {
+ \@ifpackageloaded { hyperref }
+ { \pdfstringdefDisableCommands { \_siunitx_contents_bookmarks: } }
+ { }
+}
+\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 }
+\DeclareSIUnit \gram { g }
+\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 }
+\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 }
+\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 }
+\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 }
+\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 }
+\DeclareSIUnit \astronomicalunit { ua }
+\DeclareSIUnit \atomicmassunit { u }
+\DeclareSIUnit \electronvolt { eV }
+\DeclareSIUnit \dalton { Da }
+\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 } } }
+\DeclareSIUnit \elementarycharge { \text { \ensuremath { e } } }
+\group_begin:
+ \char_set_lccode:nn { `\@ } { `\_ }
+ \char_make_math_subscript:N \@
+\tl_to_lowercase:n {
+ \group_end:
+ \DeclareSIUnit \bohr { \text { \ensuremath { a @ { 0 } } } }
+ \DeclareSIUnit \hartree
+ { \text { \ensuremath { E @ { \textup { h } } } } }
+}
+\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 }
+\DeclareSIPrePower \square { 2 }
+\DeclareSIPostPower \squared { 2 }
+\DeclareSIPrePower \cubic { 3 }
+\DeclareSIPostPower \cubed { 3 }
+\NewDocumentCommand \requiresiconfigs { m } {
+ \keys_set:nn { siunitx } { load-configurations = version-1 }
+ \clist_map_function:nN {#1} \_siunitx_requireconfig:n
}
-\newcommand*{\si@unt@addvaluesep}{%
- \ifsi@unt@num
- \expandafter\si@unt@addvalsep
- \fi}
-\newcommand*{\si@unt@addvalsep}{%
- \ifsi@unt@litout
- \expandafter\si@unt@litvalsep
- \else
- \expandafter\si@unt@stackvalsep
- \fi}
-\newcommand*{\si@unt@stackvalsep}{%
- \protected@edef\si@unt@spstack{\si@valuesep}}
-\newcommand*{\si@unt@litvalsep}{%
- \nobreak\ensuremath{\si@valuesep}\nobreak}
-\newcommand*{\si@unt@spstack}{}
-\newcommand*{\si@unt@stacka}{}
-\newcommand*{\si@unt@stackb}{}
-\newcount\si@unt@unitcnta
-\newcount\si@unt@unitcntb
-\newcount\si@unt@depthcnt
-\newif\ifsi@unt@first
-\si@unt@depthcnt\m@ne\relax
-\newcommand*{\si@unt@init}{%
- \begingroup
- \si@unt@litoutfalse
- \si@unt@litprefixfalse
- \si@unt@firsttrue
- \si@unt@perfalse
- \si@unt@perseenfalse
- \si@unt@prepowerfalse
- \si@unt@depthcnt\z@\relax
- \si@unt@powerdim\z@\relax
- \si@unt@unitcnta\z@\relax
- \si@unt@unitcntb\z@\relax
- \si@unt@prefixcnt\z@\relax
- \renewcommand*{\si@unt@spstack}{}%
- \renewcommand*{\si@unt@stacka}{}%
- \renewcommand*{\si@unt@stackb}{}%
- \renewcommand*{\si@unt@spacestacka}{}%
- \renewcommand*{\si@unt@spacestackb}{}%
- \renewcommand*{\si@unt@lastadda}{space}%
- \renewcommand*{\si@unt@lastaddb}{space}}
-\newcommand*{\si@unt@final}{%
- \si@unt@third
- \si@unt@stackout
- \endgroup
- \ifsi@xspace
- \expandafter\expandafter\expandafter\xspace
- \fi}
-\newcommand*{\si@unt@defunit}[3][]{%
- \si@log@debug{Declaring unit \string#2 with \MessageBreak
- meaning \string#3}%
- \si@ifnotmtarg{#1}
- {\expandafter\@namedef\expandafter{%
- \expandafter\@gobble\string#2@opt@unt@si}{#1}}%
- \protected\def#2{%
- \ifsi@allowoptarg
- \expandafter\si@unt@withopt
- \else
- \expandafter\si@unt@noopt
- \fi
- {#2}{#3}}}
-\newcommand*{\si@unt@withopt}[2]{%
- \@ifnextchar[%]
- {\si@unt@opt{#1}{#2}}
- {\si@unt@opt{#1}{#2}[]}}
-\newcommand*{\si@unt@noopt}[2]{\si@unt@opt{#1}{#2}[]}
-\def\si@unt@opt#1#2[#3]{%
- \ifsi@unt@littest
- \expandafter\si@gobblethree
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\@gobbletwo
- \else
- \expandafter\expandafter\expandafter\si@unt@unit
- \fi
- \fi
- {#3}{#1}{#2}}
-\long\def\si@gobblethree #1#2#3{}
-\newif\ifsi@unt@litprefix
-\si@unt@litprefixtrue
-\newcommand*{\si@unt@defprefix}[4][]{%
- \si@log@debug{Declaring multiple \string#1 with\MessageBreak
- meaning \string#4}%
- \expandafter\expandafter\expandafter\def\expandafter
- \csname\expandafter\@gobble\string#2@opt@si\endcsname{#1}%
- \protected\def#2{%
- \ifsi@unt@littest
- \expandafter\si@gobblethree
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\@gobbletwo
- \else
- \ifsi@unt@litprefix
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\@gobbletwo
- \else
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@unt@prefix
- \fi
- \fi
- \fi
- {#2}{#3}{#4}}}
-\newcommand*{\si@unt@defpower}[3][]{%
- \si@log@debug{Declaring power \string#2 with\MessageBreak
- meaning \string#3}%
- \expandafter\expandafter\expandafter\def\expandafter
- \csname\expandafter\@gobble\string#2@opt@si\endcsname{#1}%
- \protected\def#2{%
- \ifsi@unt@littest
- \expandafter\@gobbletwo
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\si@unt@litpower
- \else
- \expandafter\expandafter\expandafter\si@unt@power
- \fi
- \fi
- {#2}{#3}}}
-\newcommand*{\si@unt@defqual}[2]{%
- \si@log@debug{Declaring qualifier \string#1 with\MessageBreak
- meaning \string#2}%
- \protected\def#1{%
- \ifsi@unt@littest
- \expandafter\@gobble
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\si@unt@litqual
- \else
- \expandafter\expandafter\expandafter\si@unt@qual
- \fi
- \fi
- {#2}}}
-\newcommand*{\si@unt@unithook}{}
-\newcommand*{\si@unt@unit}[3]{%
- \ifnum\si@unt@depthcnt=\m@ne\relax
- \expandafter\si@unt@init
- \fi
- \advance\si@unt@depthcnt\@ne\relax
- \si@log@debug{Unit processing: level \the\si@unt@depthcnt,
- \MessageBreak unit \string#2}%
- \si@unt@firstorsecond{#1}{#2}%
- \si@unt@ifliteral{#3}
- {\si@unt@addtostack{unit}{#3}%
- \ifsi@unt@prepower
- \expandafter\si@unt@stkpower
- \fi}
- {#3}%
- \advance\si@unt@depthcnt\m@ne\relax
- \ifnum\si@unt@depthcnt=\z@\relax
- \expandafter\si@unt@final
- \fi}
-\newcommand*{\si@unt@firstorsecond}[2]{%
- \ifsi@unt@first
- \expandafter\si@unt@first
- \else
- \expandafter\si@unt@second
- \fi
- {#1}{#2}}%
-\newcommand*{\si@unt@first}[2]{%
- \si@ifnotmtarg{#1}
- {\num{#1}%
- \si@unt@numtrue}%
- \si@unt@unithook
- \ifcsname\expandafter\@gobble\string#2@opt@unt@si\endcsname
- \expandafter\si@unt@setopts
- \else
- \expandafter\@gobble
- \fi
- {#2}%
- \si@unt@addvaluesep
- \si@unt@firstfalse}
-\newcommand*{\si@unt@setopts}[1]{%
- \expandafter\expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\si@temptoks\expandafter
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter{\expandafter%
- \csname\expandafter\@gobble\string#1@opt@unt@si%
- \endcsname}%
- \expandafter\sisetup\expandafter{\the\si@temptoks}%
- \si@log@debug{Applying options `\the\si@temptoks'
- for\MessageBreak unit \string#1}%
- \@ifundefined{si@unt@SIopts}{}
- {\ifx\@empty\si@unt@SIopts\@empty\else
- \expandafter\expandafter\si@unt@setSIopts
- \fi}}
-\newcommand*{\si@unt@setSIopts}{%
- \expandafter\si@temptoks\expandafter{\si@unt@SIopts}%
- \expandafter\sisetup\expandafter{\the\si@temptoks}}
-\newcommand*{\si@unt@second}[2]{%
- \si@ifnotmtarg{#1}
- {\si@log@warn{Optional argument to unit macro\MessageBreak
- allowed only for outer unit}}%
- \si@unt@third
- \si@unt@addtostack{space}{\ensuremath{\si@unitsep}}}
-\newcommand*{\si@unt@third}{%
- \ifsi@unt@prepower\else
- \expandafter\si@unt@stkpower
- \fi
- \renewcommand*{\si@tempa}{prefix}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \else
- \expandafter\si@unt@spacecheck
- \fi
- \ifsi@unt@per
- \expandafter\si@unt@perseentrue
- \fi}
-\newcommand*{\si@unt@spacecheck}{%
- \renewcommand*{\si@tempa}{space}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \else
- \expandafter\si@unt@reciptest
- \fi}
-\newcommand*{\si@unt@prefix}[3]{%
- \si@unt@firstorsecond{}{#1}%
- \ifsi@prefixsymbolic
- \expandafter\si@unt@addprefix
- \else
- \expandafter\si@unt@countprefix
- \fi
- {#1}{#2}{#3}}
-\newcommand*{\si@unt@addprefix}[3]{%
- \si@unt@addtostack{prefix}{#3}}
-\newcount\si@unt@prefixcnt
-\newcommand*{\si@unt@countprefix}[3]{%
- \renewcommand*{\si@tempa}{binary}%
- \expandafter\expandafter\expandafter\ifx\expandafter
- \csname\expandafter\@gobble\string#1@opt@si\endcsname
- \si@tempa
- \expandafter\sisetup
- \else
- \expandafter\@gobble
- \fi
- {prefixbase=two}%
- \si@tempcnta#2\relax
- \ifsi@unt@per
- \expandafter\si@unt@invprefix
- \fi
- \advance\si@unt@prefixcnt\si@tempcnta\relax}
-\newcommand*{\si@unt@invprefix}{%
- \si@tempcntb\si@tempcnta\relax
- \si@tempcnta -\si@tempcntb\relax}
-\newcommand*{\si@unt@litpower}[2]{\textsuperscript{#2}}
-\newif\ifsi@unt@prepower
-\newcommand*{\si@unt@power}[2]{%
- \renewcommand*{\si@tempa}{post}%
- \expandafter\expandafter\expandafter\ifx\expandafter
- \csname\expandafter\@gobble\string#1@opt@si\endcsname
- \si@tempa
- \expandafter\@gobbletwo
- \else
- \expandafter\si@unt@firstorsecond
- \fi
- {}{\power}%
- \si@unt@powerdim #2 pt\relax
- \ifsi@frac\else
- \ifsi@unt@per
- \expandafter\expandafter\expandafter\si@unt@invpower
- \fi
- \fi
- \renewcommand*{\si@tempa}{post}%
- \si@unt@prepowertrue
- \expandafter\expandafter\expandafter\ifx\expandafter
- \csname\expandafter\@gobble\string#1@opt@si\endcsname
- \si@tempa
- \expandafter\si@unt@stackpower
- \else
- \si@log@debug{Power \strip@pt\si@unt@powerdim\space saved
- to be added after\MessageBreak next unit}%
- \fi}
-\newdimen\si@unt@powerdim
-\newcommand*{\si@unt@stackpower}{%
- \si@unt@prepowerfalse
- \si@unt@stkpower
- \ifsi@stickyper\else
- \si@unt@perfalse
- \si@unt@perseenfalse
- \fi}
-\newcommand*{\si@unt@stkpower}{%
- \ifdim\si@unt@powerdim=\m@ne pt\relax
- \ifsi@frac\else
- \expandafter\expandafter\expandafter\si@unt@stkpwr
- \fi
- \else
- \expandafter\si@unt@stkpwr
- \fi}
-\newcommand*{\si@unt@stkpwr}{%
- \ifdim\si@unt@powerdim=\z@\relax\else
- \renewcommand*{\si@tempa}{unit}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname
- \si@tempa
- \si@unt@skpwr
- \else
- \renewcommand*{\si@tempa}{qual}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname
- \si@tempa
- \si@unt@skpwrqual
- \fi
- \fi
- \fi
- \si@unt@powerdim\z@\relax}
-\newcommand*{\si@unt@skpwr}{%
- \si@log@debug{Adding power
- \strip@pt\si@unt@powerdim\space to output stack}%
- \si@unt@addtostack{power}{^{\num[fixdp=false]{%
- \strip@pt\si@unt@powerdim}}}}
-\newcommand*{\si@unt@invpower}{%
- \si@tempdima\si@unt@powerdim\relax
- \si@unt@powerdim -\si@tempdima\relax
- \ifdim\si@unt@powerdim=\p@\relax
- \si@unt@powerdim\z@\relax
- \fi}
-\newcommand*{\si@unt@litqual}[1]{(#1)}
-\newcommand*{\si@unt@qual}[1]{%
- \ifsi@unt@first
- \si@log@err{Qualifier before units}
- {A unit qualifier can only be given after\MessageBreak
- one or more units. You tried to open a unit
- with\MessageBreak \string#1}%
- \fi
- \expandafter\let\expandafter\si@unt@spacestack
- \csname si@unt@spacestack\si@unt@checkstack\endcsname
- \expandafter\let\csname si@unt@spacestack\si@unt@checkstack
- \endcsname\@empty
- \renewcommand*{\si@tempa}{power}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \let\si@unt@skpwrqual\relax
- \else
- \let\si@unt@skpwrqual\si@unt@skpwr
- \fi
- \si@unt@addtostack{qual}{_{#1}}%
- \expandafter\let\csname si@unt@spacestack\si@unt@checkstack
- \endcsname\si@unt@spacestack}
-\newif\ifsi@unt@per
-\newif\ifsi@unt@perseen
-\si@newrobustcmd*{\si@per}{%
- \ifsi@unt@littest\else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter /%
- \else
- \ifsi@unt@litprefix
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter /%
- \else
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@unt@per
- \fi
- \fi
- \fi}
-\newcommand*{\si@unt@per}{%
- \si@unt@firstorsecond{}{\per}%
- \ifsi@unt@per
- \ifsi@stickyper\else
- \expandafter\expandafter\expandafter\si@unt@perfalse
- \fi
- \else
- \expandafter\si@unt@pertrue
- \fi}
-\let\per\si@per
-\newcommand*{\si@unt@reciptest}{%
- \ifsi@unt@per
- \ifsi@unt@perseen
- \expandafter\expandafter\expandafter\si@unt@recip
- \fi
- \fi}
-\newcommand*{\si@unt@recip}{%
- \si@unt@powerdim\m@ne pt\relax
- \si@unt@stackpower}
-\newcommand*{\si@unt@lastadda}{}
-\newcommand*{\si@unt@lastaddb}{}
-\newcommand*{\si@unt@addtostack}[2]{%
- \renewcommand*{\si@tempa}{#1}%
- \expandafter\ifx
- \csname si@unt@lastadd\si@unt@checkstack\endcsname\si@tempa
- \renewcommand*{\si@tempa}{prefix}%
- \expandafter\ifx\csname si@unt@lastadd\si@unt@checkstack
- \endcsname\si@tempa
- \si@log@warn{Two prefixes found: only first printed}%
- \fi
- \expandafter\@gobbletwo
- \else
- \expandafter\si@unt@preplussp
- \fi
- {#1}{#2}}
-\newcommand*{\si@unt@preplussp}[2]{%
- \renewcommand*{\si@tempa}{prefix+space}%
- \edef\si@tempb{%
- \csname si@unt@lastadd\si@unt@checkstack\endcsname+#1}%
- \ifx\si@tempa\si@tempb
- \expandafter\@gobbletwo
- \else
- \expandafter\si@unt@stack
- \fi
- {#1}{#2}}
-\newcommand*{\si@unt@stack}[2]{%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@unt@lastadd\si@unt@checkstack\endcsname}{#1}%
- \renewcommand*{\si@tempa}{#1}%
- \renewcommand*{\si@tempb}{unit}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@unt@inccnt
- \fi
- \renewcommand*{\si@tempb}{space}%
- \ifx\si@tempa\si@tempb
- \expandafter\si@unt@holdspace
- \else
- \expandafter\si@unt@addstack
- \fi
- {#2}}
-\newcommand*{\si@unt@inccnt}{%
- \expandafter\advance
- \csname si@unt@unitcnt\si@unt@checkstack\endcsname
- \@ne\relax}
-\newcommand*{\si@unt@spacestack}{}
-\newcommand*{\si@unt@spacestacka}{}
-\newcommand*{\si@unt@spacestackb}{}
-\newcommand*{\si@unt@holdspace}[1]{%
- \renewcommand*{\si@tempa}{b}%
- \edef\si@tempb{\si@unt@checkstack}%
- \ifx\si@tempa\si@tempb
- \ifx\@empty\si@unt@stackb\@empty
- \else
- \protected@edef\si@unt@spacestackb{#1}%
- \fi
- \else
- \protected@edef\si@unt@spacestacka{#1}%
- \fi}
-\newcommand*{\si@unt@addstack}[1]{%
- \expandafter\protected@edef
- \csname si@unt@stack\si@unt@checkstack\endcsname
- {\csname si@unt@stack\si@unt@checkstack\endcsname
- \csname si@unt@spacestack\si@unt@checkstack\endcsname#1}%
- \expandafter\renewcommand\expandafter*\expandafter{%
- \csname si@unt@spacestack\si@unt@checkstack\endcsname}{}}
-\newcommand*{\si@unt@stackout}{%
- \si@unt@litouttrue
- \ifsi@frac
- \expandafter\si@unt@fracout
- \else
- \expandafter\si@unt@normout
- \fi}
-\newcommand*{\si@unt@checkstack}{%
- \ifsi@frac
- \ifsi@unt@per
- \expandafter\expandafter\expandafter b%
- \else
- \expandafter\expandafter\expandafter a%
- \fi
- \else
- \expandafter a%
- \fi}
-\newcommand*{\si@unt@spaceout}{%
- \ensuremath{\si@unt@spstack}}
-\newcommand*{\si@unt@prefixout}{%
- \ifnum\si@unt@prefixcnt=\z@\relax\else
- \ifsi@unt@num
- \si@out{\ensuremath{{}\si@prefixproduct{}}}%
- \fi
- \si@unt@stackvalsep
- \let\si@expbase\si@prefixbase
- \num[fixdp=false]{e\the\si@unt@prefixcnt}%
- \fi}
-\newcommand*{\si@unt@normout}{%
- \si@unt@prefixout
- \si@unt@spaceout
- \expandafter\si@unt@out\expandafter{\si@unt@stacka}}
-\newcommand*{\si@unt@fracout}{%
- \si@unt@notambig
- \ifx\@empty\si@unt@stacka\@empty
- \ifx\@empty\si@unt@stackb\@empty
- \ifsi@unt@litout\else
- \si@log@err{Empty fractional unit}{The unit
- argument\MessageBreak given does not contain any
- symbols}%
- \fi
- \else
- \ifsi@slash
- \si@unt@prefixout
- \si@frac{}{\si@unt@stackb}%
- \else
- \si@unt@prefixout
- \si@unt@spaceout
- \si@frac{1}{\si@unt@stackb}%
- \fi
- \fi
- \else
- \ifx\@empty\si@unt@stackb\@empty
- \si@unt@normout
- \else
- \si@unt@prefixout
- \si@unt@spaceout
- \si@frac{\si@unt@stacka}{\si@unt@stackb}%
- \fi
- \fi}
-\newcommand*{\si@unt@notambig}{%
- \ifnum\si@unt@unitcntb>\@ne\relax
- \ifsi@slash
- \ifsi@trapambigfrac
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@unt@notabg
- \fi
- \fi
- \fi}
-\newcommand*{\si@unt@notabg}{%
- \protected@edef\si@unt@stackb{\si@openfrac\si@unt@stackb
- \si@closefrac}}
-\begingroup
- \catcode`\~=\active
- \catcode`\.=\active
- \gdef\si@unt@out#1{%
- \si@temptoks{#1}%
- \si@unt@fullstop
- \def.{\ensuremath{\si@unitsep}}%
- \def~{\ensuremath{\si@unitspace}}%
- \expandafter\protected@edef\expandafter\si@tempa
- \expandafter{\the\si@temptoks}%
- \begingroup
- \si@unt@nonlatin
- \makeatletter
- \endlinechar\m@ne
- \expandafter\si@out\expandafter{%
- \expandafter\scantokens\expandafter{\si@tempa}}%
- \endgroup}
-\endgroup
-\begingroup
- \catcode`\.=\active
- \catcode`\&=12\relax
- \begingroup
- \lccode`\.=`\.\relax
- \lccode`\&=`\.\relax
- \lowercase{\endgroup
- \gdef\si@unt@fullstop{%
- \si@temptoks\expandafter{\expandafter}\expandafter
- \si@unt@stp\the\si@temptoks&\@nil}
- \gdef\si@unt@stp#1&#2\@nil{%
- \edef\si@tempa{\the\si@temptoks}%
- \ifx\si@tempa\@empty
- \expandafter\@firstoftwo
- \else
- \expandafter\@secondoftwo
- \fi
- {\si@temptoks{#1}}
- {\si@temptoks\expandafter{\the\si@temptoks.#1}}%
- \si@ifmtarg{#2}
- {}
- {\si@unt@stp#2\@nil}}}
-\endgroup
-\newcommand*{\si@unt@nonlatin}{}
-\ifdefined\XeTeXrevision
- \renewcommand*{\si@unt@nonlatin}{%
- \catcode176=\active
- \catcode181=\active
- \catcode197=\active
- \si@unt@sym{176}{\si@sym@degree}%
- \si@unt@sym{181}{\si@sym@mu}%
- \si@unt@sym{197}{\si@sym@ringA}}%
-\fi
-\AtBeginDocument{
- \@ifpackageloaded{inputenc}
- {\@for\si@tempa:=latin1,latin5,latin9\do{
- \ifx\inputencodingname\si@tempa
- \renewcommand*{\si@unt@nonlatin}{%
- \catcode176=\active
- \catcode181=\active
- \catcode197=\active
- \si@unt@sym{176}{\si@sym@degree}%
- \si@unt@sym{181}{\si@sym@mu}%
- \si@unt@sym{197}{\si@sym@ringA}}%
- \fi}}
- {}}
-\newcommand*{\si@unt@sym}[1]{%
- \bgroup
- \uccode`\~#1%
- \uppercase{%
- \egroup
- \def~}}
-\newunit{\kilogram}{kg}
-\newunit{\metre}{m}
-\newunit{\meter}{\metre}
-\newunit{\mole}{mol}
-\AtBeginDocument{\provideunit{\second}{s}}
-\newunit{\ampere}{A}
-\newunit{\kelvin}{K}
-\newunit{\candela}{cd}
-\AtBeginDocument{
- \@ifundefined{Square}{%
- \newpower{\Square}{2}}{}}
-\newpower{\ssquare}{2}
-\newpower[post]{\squared}{2}
-\newpower{\cubic}{3}
-\newpower[post]{\cubed}{3}
-\newcommand*{\tothe}{\si@tothe{\tothe}}
-\newcommand*{\raiseto}{\si@tothe{\raiseto}}
-\newcommand*{\si@tothe}[2]{%
- \ifsi@unt@littest
- \expandafter\@gobbletwo
- \else
- \ifsi@unt@litout
- \expandafter\expandafter\expandafter\si@unt@litpower
- \else
- \expandafter\expandafter\expandafter\si@unt@power
- \fi
- \fi
- {#1}{#2}}
-\newcommand*{\tothe@opt@si}{post}
-\newcommand*{\raiseto@opt@si}{}
-\si@newrobustcmd*{\numrange}[3][]{%
- \begingroup
- \sisetup{#1}%
- \num{#2}%
- \text{\si@tophrase}%
- \num{#3}%
- \endgroup
-}
-\si@newrobustcmd*{\SIrange}[4][]{%
- \begingroup
- \sisetup{#1}%
- \ifsi@repeatunits
- \SI{#2}{#4}%
- \else
- \ifsi@trapambigrange
- \ensuremath{\si@openrange}%
- \fi
- \num{#2}%
- \fi
- \text{\si@tophrase}%
- \ifsi@repeatunits
- \SI{#3}{#4}%
- \else
- \ifsi@trapambigrange
- \num{#3}%
- \ensuremath{\si@closerange\si@valuesep}%
- \si{#4}%
- \else
- \SI{#3}{#4}%
- \fi
- \fi
- \endgroup
-}
-\newcommand*{\si@loc@load}[1]{%
- \let\si@loc@sisetup\sisetup
- \renewcommand*{\sisetup}[1]{%
- \expandafter\gdef\csname si@loc@#1\endcsname{##1}}%
- \si@loadfile{#1}%
- \let\sisetup\si@loc@sisetup}
-\newcommand*{\si@loc@set}[1]{%
- \ifcsname si@loc@#1\endcsname
- \si@log@inf{Setting locale to `#1'}%
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter\si@temptoks
- \expandafter\expandafter\expandafter\expandafter
- \expandafter\expandafter\expandafter{%
- \expandafter\csname si@loc@#1\endcsname}%
- \expandafter\sisetup\expandafter{\the\si@temptoks}%
- \ifcsname si@loc@#1@extra\endcsname
- \csname si@loc@#1@extra\endcsname
- \fi
- \else
- \ifcsname si@loc@#1@extra\endcsname
- \si@log@inf{Setting locale to `#1'}%
- \csname si@loc@#1@extra\endcsname
- \else
- \si@log@warn{Unknown locale `#1'}%
- \fi
- \fi}
-\newcommand*{\si@loc@ltol}[1]{%
- \def\si@tempa##1:##2\@nil{\si@loc@load{##1}}
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb:\@nil}
- \AtBeginDocument{
- \@ifpackageloaded{babel}
- {\def\si@tempa##1:##2:##3\@nil{%
- \expandafter\addto\expandafter{%
- \csname extras##2\endcsname}%
- {\si@loc@set{##1}}}%
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb::\@nil}%
- \expandafter\selectlanguage\expandafter{\languagename}}
- {\si@log@warn{babel not loaded \MessageBreak
- loctolang option ignored}}}}
-\AtBeginDocument{
- \@ifpackageloaded{babel}
- {\renewcommand*{\si@loc@ltol}[1]{%
- \def\si@tempa##1:##2\@nil{\si@loc@load{##1}}%
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb:\@nil}%
- \def\si@tempa##1:##2:##3\@nil{%
- \expandafter\addto\expandafter{%
- \csname extras##2\endcsname}%
- {\si@loc@set{##1}}}%
- \@for\si@tempb:=#1\do{%
- \expandafter\si@tempa\si@tempb::\@nil}}}
- {\renewcommand*{\si@loc@ltol}[1]{%
- \si@log@warn{babel not loaded \MessageBreak
- loctolang option ignored}}}}
-\newcommand*{\addtolocale}[2]{%
- \si@addtocsname{si@loc@#1@extra}{#2}}
-\begingroup
- \catcode`\^=\active
- \catcode`\-=\active
- \catcode`\_=\active
- \gdef\si@out#1{%
- \begingroup
- \catcode`\^=\active
- \catcode`\_=\active
- \makeatletter
- \endlinechar\m@ne
- \ifsi@fam@set\else
- \expandafter\si@fam@set
- \fi
- \text{%
- \si@colourcmd{\si@colour}%
- \si@fam@italic\si@fam@bold\si@fam@text
- \ifsi@textmode
- \expandafter\si@out@text
- \else
- \expandafter\si@out@maths
- \fi
- {\scantokens{#1}}}%
- \endgroup
- \check@mathfonts}
- \gdef\si@out@text#1{%
- \let^\si@out@sp
- \let_\si@out@sb
- \let\textsuperscript\si@out@sp
- \let\textsubscript\si@out@sb
- \catcode`\-=\active\relax
- \let-\si@out@minus
- #1}
- \gdef\si@out@maths#1{%
- \let^\sp
- \let_\sb
- \let\textsuperscript\sp
- \let\textsubscript\sb
- $\si@fam@maths{#1}$}
-\endgroup
-\newcommand*{\si@out@sp}[1]{\ensuremath{^{\text{#1}}}}
-\newcommand*{\si@out@sb}[1]{\ensuremath{_{\text{#1}}}}
-\newcommand*{\si@out@minus}{}
-\DeclareTextSymbolDefault{\si@out@minus}{TS1}
-\DeclareTextSymbol{\si@out@minus}{TS1}{61}
-\newif\ifsi@out@num
-\newcommand*{\si@out@num}[1]{%
- \begingroup
- \si@out@numtrue
- \si@out{#1}%
- \endgroup}
-\newcommand*{\si@extension}{cfg}
-\newcommand*{\si@fileprefix}{si-}
-\newcommand*{\si@ifl@aded}{}
-\let\si@ifl@aded\@ifl@aded
-\newcommand*{\si@ifloaded}[1]{%
- \si@ifl@aded\si@extension{\si@fileprefix#1}}
-\newcommand*{\si@loadfile}[1]{%
- \si@ifloaded{#1}{}
- {\si@InputIfFileExists{\si@fileprefix#1.\si@extension}
- {}
- {\si@log@err{Failed to load file
- \si@fileprefix#1.\si@extension}
- {The configuration file requested could not be
- found}}}}
-\newif\ifsi@outerinput\si@outerinputtrue
-\let\si@InputIfFileExists\InputIfFileExists
-\AtBeginDocument{
- \renewcommand*{\si@InputIfFileExists}{%
- \ifsi@outerinput
- \expandafter\si@outerinput
- \else
- \expandafter\InputIfFileExists
- \fi}}
-\newcommand*{\si@outerinput}[3]{%
- \makeatletter
- \nullfont
- \si@outerinputfalse
- \IfFileExists{#1}%
- {#2\@addtofilelist{#1}\@@input \@filef@und\normalsize}
- {#3}%
- \normalsize
- \makeatother}
-\newcommand*{\requiresiconfigs}[1]{%
- \@for\si@tempb:=#1\do{\si@loadfile{\si@tempb}}}
-\newcommand*{\si@loademfile}[1]{%
- \@ifpackageloaded{#1}
- {\si@log@err{Emulation clash for package `#1'}
- {You have asked for emulation of package
- `#1'\MessageBreak
- (perhaps by giving siunitx a back-compatibility
- option)\MessageBreak but the package is already
- loaded!}}
- {\si@loadfile{#1}}}
-\newcommand*{\si@emclash}[2]{%
- \si@log@err{Emulation clash: `#1' and `#2'}
- {You have asked for emulation of package `#1'\MessageBreak
- but have already loaded emulation of `#2'}}
-\newcommand*{\si@emulating}[2]{%
- \@namedef{ver@#1.sty}{#2 siunitx emulation of #1}%
- \let\si@tempa\si@blockpkgs
- \renewcommand*{\si@blockpkgs}{}%
- \@for\si@tempb:=\si@tempa\do{%
- \renewcommand*{\si@tempa}{#1}%
- \ifx\si@tempa\si@tempb\else
- \lowercase{\edef\si@tempa{#1}}%
- \lowercase{\edef\si@tempc{\si@tempb}}%
- \ifx\si@tempa\si@tempc
- \@namedef{ver@\si@tempc.sty}{#2 siunitx emulation of
- #1}%
- \else
- \si@addtolist{\si@blockpkgs}{\si@tempb}%
- \fi
- \fi}%
- \let\si@tempa\si@checkpkgs
- \renewcommand*{\si@checkpkgs}{}%
- \renewcommand*{\si@tempb}{#1}%
- \@for\si@tempc:=\si@tempa\do{%
- \ifx\si@tempb\si@tempc\else
- \si@addtolist{\si@checkpkgs}{\si@tempc}%
- \fi}}
-\sisetup{
- addsign=none,
- allowlitunits=true,
- allowzeroexp=false,
- angformat=unchanged,
- astroang=false,%(
- closeerr=),%(
- closefrac=),%(
- closerange=),
- colour=black,
- colourall=false,
- colourneg=false,
- decimalsymbol=fullstop,
- detectdisplay=true,
- digitsep=thin,
- dp=3,
- eVcorra=0.3ex,
- eVcorrb=0ex,
- errspace=none,
- fixdp=false,
- inlinebold=text,
- load=default,
- mathsrm=mathrm,
- mathssf=mathsf,
- mathstt=mathtt,
- mode=maths,
- negcolour=red,
- noload={},
- numaddn={},%(
- numcloseerr=),
- numdecimal={.,},
- numdigits=0123456789,
- numdiv=/,
- numexp=eEdD,
- numgobble={},
- numopenerr=(,%)
- numprod=x,
- numsign=+-\pm\mp,
- obeybold=false,
- obeyitalic=false,
- obeymode=false,
- openerr=(,%)
- openfrac=(,%)
- openrange=(,%
- padangle=small,
- padnumber=lead,
- per=reciprocal,
- prefixbase=ten,
- prefixproduct=times,
- prefixsymbolic=true,
- prespace=false,
- redefsymbols=true,
- repeatunits=true,
- retainplus=false,
- seperr=false,
- sepfour=false,
- sign=plus,
- slash=slash,
- stickyper=false,
- strictarc=true,
- tabalignexp=true,
- tabautofit=false,
- tabformat=3.2,
- tabnumalign=centredecimal,
- tabparseonly=false,
- tabtextalign=centre,
- tabunitalign=left,
- textrm=rmfamily,
- textsf=sffamily,
- texttt=ttfamily,
- tightpm=false,
- tophrase=to,
- trapambigerr=true,
- trapambigfrac=true,
- trapambigrange=true,
- unitsep=thin,
- valuesep=thin,
- xspace=false}
-\ProcessOptionsX[si]<key>
-\ifx\@empty\si@emulate\@empty\else
- \@for\si@tempa:=\si@emulate\do{%
- \expandafter\si@loademfile\expandafter{\si@tempa}}
-\fi
-\newcommand*{\si@expanddefault}[2]{%
- \expandafter\ifx\expandafter\@empty\csname si@#1\endcsname
- \@empty
- \else
- \renewcommand*{\si@tempb}{default}%
- \renewcommand*{\si@tempc}{}%
- \expandafter\@for\expandafter\si@tempa\expandafter
- :\expandafter=\csname si@#1\endcsname\do{%
- \ifx\si@tempa\si@tempb
- \si@addtolist{\si@tempc}{#2}%
- \else
- \si@addtolist{\si@tempc}{\si@tempa}%
- \fi}
- \expandafter\edef\csname si@#1\endcsname{\si@tempc}%
- \expandafter\si@addtolist\expandafter{%
- \csname si@no#1\endcsname}%
- {default}%
- \renewcommand*{\si@tempc}{}%
- \expandafter\@for\expandafter\si@tempa\expandafter
- :\expandafter=\csname si@#1\endcsname\do{%
- \si@switchfalse
- \expandafter\@for\expandafter\si@tempb\expandafter
- :\expandafter=\csname si@no#1\endcsname\do{%
- \ifx\si@tempa\si@tempb
- \si@switchtrue
- \fi
- \ifsi@switch\else
- \si@addtolist{\si@tempc}{\si@tempa}%
- \fi}}
- \@for\si@tempa:=\si@tempc\do{%
- \si@loadfile{\si@tempa}}%
- \fi}
-\si@expanddefault{load}{prefix,named,addn,prefixed,accepted,%
- physical,abbr}
-\IfFileExists{siunitx.cfg}
- {\si@log@inf{Local configuration file found}%
- \InputIfFileExists{siunitx.cfg}{}{}}
- {}
-\si@catcodes
+\cs_set_protected_nopar:Npn \_siunitx_requireconfig:n #1 {
+ \tl_if_eq:nnT {#1} { synchem }
+ { \keys_set:nn { siunitx } { load-configurations = chemistry } }
+}
+\keys_define:nn { siunitx } {
+ strict .code:n =
+ {
+ \keys_set:nn { siunitx }
+ {
+ bracket-numbers = true,
+ detect-italic = false,
+ detect-mode = 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-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_set_protected_nopar:Npn \_siunitx_strict_option:n #1 {
+ \clist_map_function:nN {#1} \_siunitx_strict_option_aux:n
+}
+\cs_set_protected_nopar:Npn \_siunitx_strict_option_aux:n #1 {
+ \keys_define:nn { siunitx }
+ { #1 .code:n =
+ { \msg_warning:nnx { _siunitx} { option-not-available } {#1} }
+ }
+}
+\keys_define:nn { siunitx } {
+ load-configurations .code:n =
+ { \_siunitx_load_configuration:n {#1} }
+}
+\cs_set_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_set_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 }
+\file_if_exist:nT { siunitx . \_c_siunitx_configuration_ext_tl }
+ {
+ \@onefilewithoptions { siunitx } [ ] [ ]
+ \_c_siunitx_configuration_ext_tl
+ }
+\ProcessKeysOptions { siunitx }
%%
%% Copyright (C) 2008-2010 by
%% Joseph Wright <joseph.wright@morningstar2.co.uk>
@@ -3984,11 +5766,8 @@
%%
%% This work consists of the file siunitx.dtx
%% and the derived files siunitx.pdf,
-%% siunitx.sty
-%% siunitx.bib,
-%% siunitx.ins,
-%% siunitx-bug.tex and
-%% various .cfg files.
+%% siunitx.sty and
+%% siunitx.ins.
%%
%%
%% End of file `siunitx.sty'.