diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/siunitx/siunitx.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/siunitx/siunitx.sty | 327 |
1 files changed, 282 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty index 3d5eb1260d7..b0d0bf5285b 100644 --- a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty +++ b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty @@ -15,7 +15,7 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{siunitx} - [2008/09/03 v1.0l A comprehensive (SI) units package] + [2008/09/28 v1.1 A comprehensive (SI) units package] \begingroup \@ifundefined{eTeXversion} {\PackageError{siunitx} @@ -30,6 +30,7 @@ \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 @@ -40,6 +41,7 @@ \catcode\string`\` 12\relax \catcode`\= 12\relax \catcode`\^ 7\relax +\catcode`\_ 8\relax \catcode`\~ \active\relax \@makeother{\:} \@makeother{\-} @@ -377,11 +379,11 @@ \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} + 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@numdecimal\si@numdigits\si@numextra\si@numprod\si@numdiv} \si@opt@boolkey{seperr} \si@opt@boolkey{trapambigerr} \si@opt@cmdkeys{openerr,closeerr} @@ -531,6 +533,7 @@ \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 @@ -639,15 +642,35 @@ \ifx\si@tempa\si@tempb \let\si@tab@lfill@s\relax \fi} -\si@opt@boolkey{fixdp} +\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@num@dp#1\relax - \si@fixdptrue} + {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 @@ -1240,6 +1263,7 @@ \def\,{}% \catcode`\~=\active\relax \catcode`\^=\active\relax + \catcode`\_=\active\relax \everyeof{\noexpand}% \endlinechar\m@ne \protected@xdef\si@tempa{\scantokens{#1}}% @@ -1700,8 +1724,10 @@ \expandafter\si@str@ifonlychrs\expandafter{\si@tempa} {0123456789} {\ifx\@empty\si@num@err\@empty - \ifsi@fixdp - \expandafter\expandafter\expandafter\si@num@fixdp + \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}{} @@ -1837,7 +1863,7 @@ \si@tempcntb\si@tempcnta\relax \si@num@lerr \protected@edef\si@num@err{% - \si@tempa\ensuremath{\si@decimalsymbol}\si@tempb}} + \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 @@ -1847,6 +1873,14 @@ \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 @@ -1865,10 +1899,14 @@ \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 @@ -1887,10 +1925,10 @@ \si@num@rev#2\@empty\@empty \fi} \newcommand*{\si@num@rnd}{% - \ifnum\si@tempcnta>\z@\relax - \expandafter\si@num@rndpost - \else + \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{% @@ -1924,12 +1962,12 @@ \advance\si@tempcntb\@ne\relax \fi \si@switchfalse - \advance\si@num@dp\@ne\relax - \ifnum\si@tempcnta>\si@num@dp\relax - \advance\si@num@dp\m@ne\relax + \advance\si@num@rndtarget\@ne\relax + \ifnum\si@tempcnta>\si@num@rndtarget\relax + \advance\si@num@rndtarget\m@ne\relax \else - \advance\si@num@dp\m@ne\relax - \ifnum\si@tempcnta>\si@num@dp\relax + \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 @@ -1942,7 +1980,120 @@ \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 @@ -2488,10 +2639,13 @@ \newcount\si@tempcntb \newcommand*{\si@tab@numout}{% \si@num@intabtrue - \ifsi@tab@fixed - \ifsi@tabautofit - \si@num@dp\si@tab@mantpostcnt\relax - \expandafter\expandafter\expandafter\si@fixdptrue + \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}% @@ -2501,17 +2655,35 @@ \newbox\si@tab@postbox \newbox\si@tab@expbox \newcommand*{\si@tab@format}{% - \ifsi@tab@fixed - \expandafter\si@tab@fixed + \ifsi@tabparseonly + \expandafter\si@tab@outonly \else - \expandafter\si@tab@unfixed + \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@prebox\box\si@tab@midbox\box\si@tab@postbox \box\si@tab@expbox} -\newcommand*\si@tab@unfixed{% +\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 @@ -2589,8 +2761,7 @@ \setbox\si@tab@prebox=\hbox to\si@tab@predim{\hss\hfill \expandafter\si@out@num\expandafter{\si@tab@out}}% \ifx\@empty\si@num@out\@empty - \setbox\si@tab@postbox=\hbox to\si@tab@postdim - {\expandafter\si@out@num\expandafter{\si@num@out}\hfil}% + \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}% @@ -2672,6 +2843,19 @@ \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}{} @@ -2792,8 +2976,8 @@ \renewcommand*{\si@unt@spstack}{}% \renewcommand*{\si@unt@stacka}{}% \renewcommand*{\si@unt@stackb}{}% - \renewcommand*{\si@unt@holdstacka}{}% - \renewcommand*{\si@unt@holdstackb}{}% + \renewcommand*{\si@unt@spacestacka}{}% + \renewcommand*{\si@unt@spacestackb}{}% \renewcommand*{\si@unt@lastadda}{space}% \renewcommand*{\si@unt@lastaddb}{space}} \newcommand*{\si@unt@final}{% @@ -2873,6 +3057,20 @@ \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 @@ -3034,19 +3232,50 @@ \expandafter\ifx \csname si@unt@lastadd\si@unt@checkstack\endcsname \si@tempa - \si@log@debug{Adding power - \strip@pt\si@unt@powerdim\space to output stack}% - \si@unt@addtostack{power}{^{\num[fixdp=false]{% - \strip@pt\si@unt@powerdim}}}% + \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}{% @@ -3122,28 +3351,27 @@ \expandafter\advance \csname si@unt@unitcnt\si@unt@checkstack\endcsname \@ne\relax} -\newcommand*{\si@unt@holdstacka}{} -\newcommand*{\si@unt@holdstackb}{} +\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 - \expandafter\protected@edef - \csname si@unt@holdstack\si@unt@checkstack\endcsname{#1}% + \protected@edef\si@unt@spacestackb{#1}% \fi \else - \expandafter\protected@edef - \csname si@unt@holdstack\si@unt@checkstack\endcsname{#1}% + \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@holdstack\si@unt@checkstack\endcsname#1}% + \csname si@unt@spacestack\si@unt@checkstack\endcsname#1}% \expandafter\renewcommand\expandafter*\expandafter{% - \csname si@unt@holdstack\si@unt@checkstack\endcsname}{}} + \csname si@unt@spacestack\si@unt@checkstack\endcsname}{}} \newcommand*{\si@unt@stackout}{% \si@unt@litouttrue \ifsi@frac @@ -3375,9 +3603,11 @@ \begingroup \catcode`\^=\active \catcode`\-=\active + \catcode`\_=\active \gdef\si@out#1{% \begingroup \catcode`\^=\active + \catcode`\_=\active \makeatletter \endlinechar\m@ne \ifsi@fam@set\else @@ -3396,16 +3626,21 @@ \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}{\ensuremath{-}} \newif\ifsi@out@num \newcommand*{\si@out@num}[1]{% @@ -3510,9 +3745,10 @@ negcolour=red, noload={}, numaddn={},%( - numcloseerr=),% + numcloseerr=), numdecimal={.,}, numdigits=0123456789, + numdiv=/, numexp=eEdD, numgobble={}, numopenerr=(,%) @@ -3543,6 +3779,7 @@ tabautofit=false, tabformat=3.2, tabnumalign=centredecimal, + tabparseonly=false, tabtextalign=centre, tabunitalign=left, textrm=rmfamily, |