summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/siunitx/siunitx-v2.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/siunitx/siunitx-v2.sty')
-rw-r--r--macros/latex/contrib/siunitx/siunitx-v2.sty7652
1 files changed, 7652 insertions, 0 deletions
diff --git a/macros/latex/contrib/siunitx/siunitx-v2.sty b/macros/latex/contrib/siunitx/siunitx-v2.sty
new file mode 100644
index 0000000000..260971dfcb
--- /dev/null
+++ b/macros/latex/contrib/siunitx/siunitx-v2.sty
@@ -0,0 +1,7652 @@
+%%
+%% This is file `siunitx-v2.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% siunitx-v2.dtx (with options: `package')
+%% ---------------------------------------------------------------
+%% 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
+%% ---------------------------------------------------------------
+%%
+\RequirePackage{expl3}[2020/01/12]
+\RequirePackage{xparse}
+\ProvidesExplPackage {siunitx} {2021-04-17} {2.8e}
+ {A comprehensive (SI) units package}
+\@ifpackagelater { expl3 } { 2020/01/12 }
+ { }
+ {
+ \PackageError { siunitx } { Support~package~expl3~too~old }
+ {
+ You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
+ 'l3packages'.\MessageBreak
+ Loading~siunitx~will~abort!
+ }
+ \tex_endinput:D
+ }
+\msg_new:nnnn { siunitx } { incompatible-package }
+ { Package~'#1'~incompatible. }
+ { The~#1~package~and~siunitx~are~incompatible. }
+\cs_new_protected: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 }
+\@ifl@t@r \fmtversion { 2020-10-01 }
+ { \cs_new_eq:NN \__siunitx_if_hooks:TF \use_i:nn }
+ { \cs_new_eq:NN \__siunitx_if_hooks:TF \use_ii:nn }
+\cs_new:Npn \__siunitx_tmp:w { }
+\cs_generate_variant:Nn \clist_map_function:nN { nc }
+\cs_generate_variant:Nn \tl_if_blank:nTF { V }
+\cs_generate_variant:Nn \tl_replace_all:Nnn { No, NV , Nx }
+\bool_new:N \l__siunitx_tmp_bool
+\box_new:N \l__siunitx_tmp_box
+\dim_new:N \l__siunitx_tmp_dim
+\int_new:N \l__siunitx_tmp_int
+\tl_new:N \l__siunitx_tmpa_tl
+\tl_new:N \l__siunitx_tmpb_tl
+\cs_new_protected:Npn \__siunitx_error:nxx #1#2#3 {
+ \bool_set_true:N \l__siunitx_error_bool
+ \msg_error:nnxx { siunitx } {#1} {#2} {#3}
+}
+\cs_new_protected:Npn \__siunitx_error:nx #1#2 {
+ \__siunitx_error:nxx {#1} {#2} { }
+}
+\cs_new_protected:Npn \__siunitx_error:n #1 {
+ \__siunitx_error:nxx {#1} { } { }
+}
+\bool_new:N \l__siunitx_error_bool
+\AtBeginDocument {
+ \cs_if_free:cT { T@TS1 }
+ { \RequirePackage { textcomp } }
+}
+\cs_new_protected:Npn \__siunitx_tl_put_left_math:Nn #1#2
+ { \tl_put_left:Nn #1 { \ensuremath {#2} } }
+\cs_generate_variant:Nn \__siunitx_tl_put_left_math:Nn { NV }
+\exp_args:NNx \seq_const_from_clist:Nn \c__siunitx_old_options_seq
+ {
+ \tl_to_str:n
+ {
+ addsign ,
+ allowlitunits ,
+ allowoptarg ,
+ allowzeroexp ,
+ alsoload ,
+ angformat ,
+ anglesep ,
+ astroang ,
+ closeerr ,
+ closrfrac ,
+ closerange ,
+ colour ,
+ colorall ,
+ colourall ,
+ colorneg ,
+ colourneg ,
+ colourunits ,
+ colourunits ,
+ colorvalues ,
+ colourvalues ,
+ decimalsymbol ,
+ debug ,
+ detectdisplay ,
+ digitsep ,
+ dp ,
+ emulate ,
+ errspace ,
+ eVcorra ,
+ eVcorrb ,
+ expbase ,
+ expproduct ,
+ fixdp ,
+ fixsf ,
+ fraction ,
+ inlinebold ,
+ loctolang ,
+ log ,
+ load ,
+ mathOmega ,
+ mathcelsius ,
+ mathdegree ,
+ mathminute ,
+ mathmu ,
+ mathringA ,
+ mathrm ,
+ mathsOmega ,
+ mathscelsius ,
+ mathsdegree ,
+ mathsecond ,
+ mathsf ,
+ mathsminute ,
+ mathsmu ,
+ mathsringA ,
+ mathsrm ,
+ mathssecond ,
+ mathssf ,
+ mathstt ,
+ mathtt ,
+ negcolor ,
+ negcolour ,
+ noload ,
+ numaddn ,
+ numcloseerr ,
+ numdecimal ,
+ numdigits ,
+ numdiv ,
+ numexp ,
+ numgobble ,
+ numopenerr ,
+ numprod ,
+ numsign ,
+ obeyall ,
+ obeybold ,
+ obeyfamily ,
+ obeymode ,
+ obeyitalic ,
+ openerr ,
+ openfrac ,
+ openrange ,
+ padangle ,
+ padnumber ,
+ per ,
+ prefixbase ,
+ prefixproduct ,
+ prefixsymbolic ,
+ prespace ,
+ redefsymbols ,
+ repeatunits ,
+ retainplus ,
+ seperr ,
+ sepfour ,
+ sf ,
+ sign ,
+ slash ,
+ stickyper ,
+ strictarc ,
+ tabalign ,
+ tabalignexp ,
+ tabautofit ,
+ tabexpalign ,
+ tabformat ,
+ tabnumalign ,
+ tabparseonly ,
+ tabtextalign ,
+ textOmega ,
+ textcelsius ,
+ textdegree ,
+ textminute ,
+ textmode ,
+ textmu ,
+ textringA ,
+ textrm ,
+ textsecond ,
+ textsf ,
+ texttt ,
+ tightpm ,
+ tophrase ,
+ trapamigerr ,
+ trapambigfrac ,
+ trapambigrange ,
+ unitcolor ,
+ unitcolour ,
+ unitmathrm ,
+ unitmathsf ,
+ unitmathsrm ,
+ unitmathssf ,
+ unitmathstt ,
+ unitmathtt ,
+ unitmode ,
+ unitsep ,
+ unitspace ,
+ valuecolor ,
+ valuecolour ,
+ valuemathrm ,
+ valuemathsf ,
+ valuemathsrm ,
+ valuemathssf ,
+ valuemathstt ,
+ valuemathtt ,
+ valuemode ,
+ valuesep ,
+ xspace
+ }
+ }
+\tl_new:N \l__siunitx_key_tl
+\keys_define:nn { siunitx } {
+ unknown .code:n =
+ {
+ \seq_if_in:NVTF \c__siunitx_old_options_seq \l_keys_key_tl
+ {
+ \msg_warning:nnx { siunitx } { version-1-option }
+ { \exp_not:V \l_keys_key_tl }
+ \tl_set:Nx \l__siunitx_key_tl
+ {
+ \keys_set:nn { siunitx }
+ {
+ \exp_not:V \l_keys_key_tl
+ \tl_if_blank:nF {#1} { = \exp_not:n {#1} }
+ }
+ }
+ \keys_set:nn { siunitx } { version-1-compatibility }
+ \tl_use:N \l__siunitx_key_tl
+ }
+ {
+ \msg_error:nnx { siunitx } { unknown-option }
+ { \exp_not:V \l_keys_key_tl }
+ }
+ }
+}
+\AtBeginDocument {
+ \keys_define:nn { siunitx } {
+ unknown .code:n =
+ {
+ \seq_if_in:NVTF \c__siunitx_old_options_seq \l_keys_key_tl
+ {
+ \msg_error:nnx { siunitx } { version-1-option }
+ { \exp_not:V \l_keys_key_tl }
+ }
+ {
+ \msg_error:nnx { siunitx } { unknown-option }
+ { \exp_not:V \l_keys_key_tl }
+ }
+ }
+}
+}
+\cs_new_protected:Npn \__siunitx_option_deactivate:n #1 {
+ \clist_put_right:Nn \l__siunitx_option_deactivate_clist {#1}
+}
+\cs_new_protected: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
+}
+\clist_new:N \l__siunitx_option_deactivate_clist
+\cs_new_protected:Npn \__siunitx_option_unchanged:Nnn #1#2#3
+ {
+ \str_if_eq:VnT #1 {#2}
+ { \tl_set:Nn #1 {#3} }
+ }
+\cs_generate_variant:Nn \tl_if_empty_p:n { f }
+\cs_generate_variant:Nn \tl_if_empty:nT { f }
+\cs_generate_variant:Nn \tl_if_in:NnTF { NV }
+\cs_generate_variant:Nn \tl_replace_all:Nnn { NnV }
+\prg_new_conditional:Npnn \__siunitx_cs_if_tl:N #1 { T, F , TF , p }
+ {
+ \bool_lazy_and:nnTF
+ {
+ \tl_if_empty_p:f
+ {
+ \cs_prefix_spec:N #1
+ \cs_argument_spec:N #1
+ }
+ }
+ { \bool_not_p:n { \cs_if_exist_p:c { \cs_to_str:N #1 ~ } } }
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\prg_new_conditional:Npnn \__siunitx_number_if_zero:n #1 { p , TF }
+ {
+ \tl_map_function:nN {#1} \__siunitx_number_if_zero_aux:n
+ \prg_return_true:
+ }
+\cs_generate_variant:Nn \__siunitx_number_if_zero_p:n { V }
+\cs_new:Npn \__siunitx_number_if_zero_aux:n #1
+ {
+ \token_if_eq_charcode:NNF #1 0
+ { \tl_map_break:n { \prg_return_false: \use_none:n } }
+ }
+\AtBeginDocument
+ {
+ \@ifpackageloaded { tex4ht }
+ {
+ \cs_set_eq:NN \__siunitx_print_text_super:n \textsuperscript
+ \__siunitx_option_unchanged:Nnn \l__siunitx_qualifier_mode_tl
+ { subscript } { brackets }
+ \keys_set:nn { siunitx } { mode = text }
+ }
+ { }
+ }
+\cs_new_eq:NN \__siunitx_ensure_ltr:n \use:n
+\AtBeginDocument
+ {
+ \@ifpackageloaded { bidi }
+ {
+ \sys_if_engine_xetex:T
+ { \cs_set_protected:Npn \__siunitx_ensure_ltr:n #1 { \LRE {#1} } }
+ }
+ { }
+ }
+\cs_new_protected:Npn \__siunitx_textsuperscript:n #1
+ {
+ \m@th
+ \ensuremath { ^ { \mbox { \fontsize \sf@size \z@ \selectfont #1 } } }
+ }
+\bool_new:N \l__siunitx_display_math_bool
+\tex_everydisplay:D \exp_after:wN
+ {
+ \tex_the:D \tex_everydisplay:D
+ \bool_set_true:N \l__siunitx_display_math_bool
+ }
+\cs_generate_variant:Nn \prop_get:NnNT { NV }
+\cs_generate_variant:Nn \prop_get:NnNF { NV }
+\cs_generate_variant:Nn \prop_get:NnNTF { NV }
+\cs_new_protected:Npn \__siunitx_set_math_fam:n #1 {
+ \group_begin:
+ \hbox_set:Nn \l__siunitx_tmp_box
+ {
+ \ensuremath
+ {
+ \use:c { math #1 }
+ {
+ \int_const:cn { c__siunitx_math #1 _int } { \fam }
+ }
+ }
+ }
+ \group_end:
+}
+\__siunitx_if_hooks:TF
+ {
+ \AddToHook { begindocument / end } [ siunitx ]
+ {
+ \__siunitx_set_math_fam:n { sf }
+ \__siunitx_set_math_fam:n { tt }
+ }
+ }
+ {
+ \tl_put_right:Nn \document
+ {
+ \__siunitx_set_math_fam:n { sf }
+ \__siunitx_set_math_fam:n { tt }
+ \ignorespaces
+ }
+ }
+\cs_new_protected:Npn \__siunitx_set_text_fam:n #1 {
+ \tl_const: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
+\tl_new:N \l__siunitx_detect_inline_family_tl
+\keys_define:nn { siunitx } {
+ detect-all .choice:,
+ detect-all .default:n = true,
+ detect-all / false .meta:n =
+ {
+ detect-family = false ,
+ detect-mode = false ,
+ detect-shape = false ,
+ detect-weight = false ,
+ },
+ detect-all / true .meta:n =
+ {
+ detect-family = true ,
+ detect-mode = true ,
+ detect-shape = true ,
+ detect-weight = true ,
+ },
+ detect-display-math .bool_set:N =
+ \l__siunitx_detect_display_math_bool,
+ detect-family .bool_set:N = \l__siunitx_detect_family_bool,
+ detect-inline-family .choice:,
+ detect-inline-family .value_required:n = true,
+ detect-inline-family /
+ math .code:n =
+ { \tl_set:Nn \l__siunitx_detect_inline_family_tl { math } },
+ detect-inline-family /
+ text .code:n =
+ { \tl_set:Nn \l__siunitx_detect_inline_family_tl { text } },
+ detect-inline-weight .choice:,
+ detect-inline-weight .value_required:n = true,
+ detect-inline-weight /
+ math .code:n =
+ { \tl_set:Nn \l__siunitx_detect_inline_weight_tl { math } },
+ detect-inline-weight /
+ text .code:n =
+ { \tl_set:Nn \l__siunitx_detect_inline_weight_tl { text } },
+ detect-italic .bool_set:N = \l__siunitx_detect_shape_bool,
+ detect-mode .bool_set:N = \l__siunitx_detect_mode_bool,
+ detect-none .choice:,
+ detect-none .default:n = true,
+ detect-none / false .meta:n =
+ {
+ detect-family = true,
+ detect-mode = true,
+ detect-shape = true,
+ detect-weight = true
+ },
+ detect-none / true .meta:n =
+ {
+ detect-family = false,
+ detect-mode = false,
+ detect-shape = false,
+ detect-weight = false
+ },
+ detect-shape .bool_set:N = \l__siunitx_detect_shape_bool,
+ detect-weight .bool_set:N = \l__siunitx_detect_weight_bool
+}
+\keys_set:nn { siunitx } {
+ detect-inline-family = text ,
+ detect-inline-weight = text ,
+}
+\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_new:Npn \__siunitx_font_shape: { }
+\cs_new:Npn \__siunitx_font_weight: { }
+\cs_new_protected:Npn \__siunitx_detect_font: {
+ \bool_if:NF \l__siunitx_font_set_bool
+ {
+ \__siunitx_detect_font_init:
+ \bool_if:NT \l__siunitx_detect_weight_bool
+ { \__siunitx_detect_font_weight: }
+ \bool_if:NT \l__siunitx_detect_family_bool
+ { \__siunitx_detect_font_family: }
+ \bool_if:NT \l__siunitx_detect_shape_bool
+ { \__siunitx_detect_font_shape: }
+ \bool_if:NT \l__siunitx_detect_mode_bool
+ { \__siunitx_detect_font_mode: }
+ }
+}
+\cs_new_protected:Npn \__siunitx_detect_font_init: {
+ \bool_set_true:N \l__siunitx_font_set_bool
+ \cs_set:Npn \__siunitx_font_weight:
+ {
+ \unboldmath
+ \mdseries
+ }
+ \cs_set:Npn \__siunitx_font_shape: { \upshape }
+ \tl_set:Nn \l__siunitx_font_family_tl { rm }
+ \bool_set_true:N \l__siunitx_font_math_mode_bool
+}
+\cs_new_protected:Npn \__siunitx_detect_font_weight: {
+ \mode_if_math:TF
+ {
+ \bool_if:NTF \l__siunitx_display_math_bool
+ {
+ \bool_if:NTF \l__siunitx_detect_display_math_bool
+ { \__siunitx_detect_font_weight_math: }
+ { \__siunitx_detect_font_weight_text: }
+ }
+ {
+ \use:c
+ {
+ __siunitx_detect_font_weight_
+ \l__siunitx_detect_inline_weight_tl
+ :
+ }
+ }
+ }
+ { \__siunitx_detect_font_weight_text: }
+}
+\cs_new_protected:Npn \__siunitx_detect_font_weight_math: {
+ \str_if_eq:VnT \math@version { bold }
+ {
+ \cs_set:Npn \__siunitx_font_weight:
+ {
+ \boldmath
+ \bfseries
+ }
+ }
+ \str_if_eq:VnT \math@version { light }
+ { \cs_set:Npn \__siunitx_font_weight: { \lseries } }
+}
+\cs_new_protected:Npn \__siunitx_detect_font_weight_text: {
+ \tl_set:Nx \l__siunitx_tmpa_tl { \tl_head:N \f@series }
+ \str_if_eq:VnT \l__siunitx_tmpa_tl { b }
+ {
+ \cs_set:Npn \__siunitx_font_weight:
+ {
+ \boldmath
+ \bfseries
+ }
+ }
+ \str_if_eq:VnT \l__siunitx_tmpa_tl { l }
+ { \cs_set:Npn \__siunitx_font_weight: { \lseries } }
+}
+\cs_new_protected:Npn \__siunitx_detect_font_family: {
+ \mode_if_math:TF
+ {
+ \bool_if:NTF \l__siunitx_display_math_bool
+ {
+ \bool_if:NTF \l__siunitx_detect_display_math_bool
+ { \__siunitx_detect_font_family_math: }
+ { \__siunitx_detect_font_family_text: }
+ }
+ {
+ \use:c
+ {
+ __siunitx_detect_font_family_
+ \l__siunitx_detect_inline_family_tl
+ :
+ }
+ }
+ }
+ { \__siunitx_detect_font_family_text: }
+}
+\cs_new_protected:Npn \__siunitx_detect_font_family_math: {
+ \tl_set:Nn \l__siunitx_font_family_tl { rm }
+ \int_compare:nNnT { \fam } = { \c__siunitx_mathsf_int }
+ { \tl_set:Nn \l__siunitx_font_family_tl { sf } }
+ \int_compare:nNnT { \fam } = { \c__siunitx_mathtt_int }
+ { \tl_set:Nn \l__siunitx_font_family_tl { tt } }
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_detect_font_shape:
+ {
+ \cs_if_exist:cT { \f@shape shape }
+ {
+ \cs_set:Npx \__siunitx_font_shape: { \exp_not:c { \f@shape shape } }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_detect_font_mode: {
+ \mode_if_math:F
+ {
+ \bool_set_false:N \l__siunitx_font_math_mode_bool
+ \bool_set_false:N \l__siunitx_number_math_mode_bool
+ \bool_set_false:N \l__siunitx_unit_math_mode_bool
+ }
+}
+\bool_new:N \l__siunitx_number_math_mode_bool
+\bool_new:N \l__siunitx_unit_math_mode_bool
+\cs_new:Npn \__siunitx_number_mathrm:n #1 { }
+\cs_new:Npn \__siunitx_number_mathsf:n #1 { }
+\cs_new:Npn \__siunitx_number_mathtt:n #1 { }
+\cs_new:Npn \__siunitx_number_textrm: { }
+\cs_new:Npn \__siunitx_number_textsf: { }
+\cs_new: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:Npn \__siunitx_number_mathrm:n ##1 { #1 {##1} } },
+ number-math-sf .code:n =
+ { \cs_set:Npn \__siunitx_number_mathsf:n ##1 { #1 {##1} } },
+ number-math-tt .code:n =
+ { \cs_set: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:Npn \__siunitx_number_textrm: {#1} },
+ number-text-sf .code:n =
+ { \cs_set:Npn \__siunitx_number_textsf: {#1} },
+ number-text-tt .code:n =
+ { \cs_set:Npn \__siunitx_number_texttt: {#1} }
+}
+\cs_new:Npn \__siunitx_unit_mathrm: { }
+\cs_new:Npn \__siunitx_unit_mathsf: { }
+\cs_new:Npn \__siunitx_unit_mathtt: { }
+\cs_new:Npn \__siunitx_unit_textrm: { }
+\cs_new:Npn \__siunitx_unit_textsf: { }
+\cs_new: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:Npn \__siunitx_unit_mathrm:n ##1 { #1 {##1} } },
+ unit-math-sf .code:n =
+ { \cs_set:Npn \__siunitx_unit_mathsf:n ##1 { #1 {##1} } },
+ unit-math-tt .code:n =
+ { \cs_set: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:Npn \__siunitx_unit_textrm: {#1} },
+ unit-text-sf .code:n =
+ { \cs_set:Npn \__siunitx_unit_textsf: {#1} },
+ unit-text-tt .code:n =
+ { \cs_set: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,
+ mode = math,
+ text-rm = \rmfamily,
+ text-sf = \sffamily,
+ text-tt = \ttfamily,
+}
+\AtBeginDocument {
+ \tl_set:Nx \l__siunitx_tmpa_tl { \familydefault }
+ \@ifpackageloaded { eulervm }
+ {
+ \cs_set:Npn \__siunitx_tmp:w #1 { \mathrm {#1} }
+ \cs_if_eq:NNT \__siunitx_number_mathrm:n \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { number-math-rm = \mathnormal } }
+ \cs_if_eq:NNT \__siunitx_unit_mathrm:n \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { unit-math-rm = \mathnormal } }
+ }
+ { }
+ \tl_if_eq:NNT \l__siunitx_tmpa_tl \c__siunitx_textsf_tl
+ {
+ \@ifpackageloaded { arev }
+ { }
+ {
+ \@ifpackageloaded { cmbright }
+ { }
+ {
+ \cs_set:Npn \__siunitx_tmp:w #1 { \mathrm {#1} }
+ \cs_if_eq:NNT \__siunitx_number_mathrm:n \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { number-math-rm = \mathsf } }
+ \cs_if_eq:NNT \__siunitx_unit_mathrm:n \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { unit-math-rm = \mathsf } }
+ }
+ }
+ \cs_set:Npn \__siunitx_tmp:w { \rmfamily }
+ \cs_if_eq:NNT \__siunitx_number_textrm: \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { number-text-rm = \sffamily } }
+ \cs_if_eq:NNT \__siunitx_unit_textrm: \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { unit-text-rm = \sffamily } }
+ }
+ \tl_if_eq:NNT \l__siunitx_tmpa_tl \c__siunitx_texttt_tl
+ {
+ \cs_set:Npn \__siunitx_tmp:w #1 { \mathrm {#1} }
+ \cs_if_eq:NNT \__siunitx_number_mathrm:n \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { number-math-rm = \mathtt } }
+ \cs_if_eq:NNT \__siunitx_unit_mathrm:n \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { unit-math-rm = \mathtt } }
+ \cs_set:Npn \__siunitx_tmp:w { \rmfamily }
+ \cs_if_eq:NNT \__siunitx_number_textrm: \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { number-text-rm = \ttfamily } }
+ \cs_if_eq:NNT \__siunitx_unit_textrm: \__siunitx_tmp:w
+ { \keys_set:nn { siunitx } { unit-text-rm = \ttfamily } }
+ }
+}
+\tl_new:N \l__siunitx_print_arg_tl
+\tl_new:N \l__siunitx_print_type_tl
+\cs_new_protected:Npn \__siunitx_print:nn #1#2 {
+ \group_begin:
+ \tl_set:Nn \l__siunitx_print_type_tl {#1}
+ \tl_set:Nn \l__siunitx_print_arg_tl {#2}
+ \__siunitx_detect_font:
+ \bool_if:NF \l__siunitx_detect_mode_bool
+ {
+ \bool_if:cTF { l__siunitx_ #1 _math_mode_bool }
+ { \bool_set_true:N \l__siunitx_font_math_mode_bool }
+ { \bool_set_false:N \l__siunitx_font_math_mode_bool }
+ }
+ \__siunitx_print_aux:
+ \group_end:
+}
+\cs_generate_variant:Nn \__siunitx_print:nn { nV }
+\cs_new_protected:Npn \__siunitx_print_aux:
+ {
+ \text
+ {
+ \__siunitx_ensure_ltr:n
+ {
+ \color@begingroup
+ \__siunitx_print_color:
+ \__siunitx_font_shape:
+ \__siunitx_font_weight:
+ \use:c
+ {
+ __siunitx_ \l__siunitx_print_type_tl _
+ text \l__siunitx_font_family_tl :
+ }
+ \bool_if:NTF \l__siunitx_font_math_mode_bool
+ { \__siunitx_print_math: }
+ { \__siunitx_print_text: }
+ \color@endgroup
+ }
+ }
+ }
+\cs_new_protected: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_new_eq:NN \__siunitx_textcolor:n \textcolor }
+ {
+ \cs_set_protected:Npn \__siunitx_print_color:
+ {
+ \tl_if_empty:cF { l__siunitx_ \l__siunitx_print_type_tl _color_tl }
+ {
+ \cs_gset_eq:NN \__siunitx_print_color: \scan_stop:
+ \msg_warning:nn { siunitx } { color-not-loaded }
+ }
+ }
+ \cs_new_protected:Npn \__siunitx_textcolor:n #1
+ {
+ \cs_gset_eq:NN \__siunitx_textcolor:n \use_none:n
+ \msg_warning:nn { siunitx } { color-not-loaded }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_print_math:
+ {
+ \cs_set_eq:NN \PrintSubscript \sb
+ \cs_set_eq:NN \PrintSuperscript \sp
+ \ensuremath
+ {
+ \use:c
+ {
+ __siunitx_ \l__siunitx_print_type_tl _
+ math \l__siunitx_font_family_tl :n
+ }
+ { \l__siunitx_print_arg_tl }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_print_text:
+ {
+ \tl_replace_all:Nnn \l__siunitx_print_arg_tl { - }
+ { \textminus }
+ \__siunitx_print_text_aux:
+ \tl_replace_all:Nnn \l__siunitx_print_arg_tl { \mp }
+ { \ensuremath { \mp } }
+ \tl_remove_all:Nn \l__siunitx_print_arg_tl { \mathord }
+ \cs_set_eq:NN \PrintSubscript \__siunitx_print_text_sub:n
+ \cs_set_eq:NN \PrintSuperscript \__siunitx_print_text_super:n
+ \__siunitx_print_text_aux:NnN
+ _ { math_subscript } \__siunitx_print_text_sub:n
+ _ { active } \__siunitx_print_text_sub:n
+ ^ { math_superscript } \__siunitx_print_text_super:n
+ ^ { active } \__siunitx_print_text_super:n
+ \q_recursion_tail ? ?
+ \q_recursion_stop
+ \l__siunitx_print_arg_tl
+ }
+\cs_new_protected:Npn \__siunitx_print_text_aux:
+ {
+ \tl_replace_all:Nnn \l__siunitx_print_arg_tl { \pm }
+ { \ensuremath { \pm } }
+ }
+\cs_new_protected:Npn \__siunitx_print_text_aux:NnN #1#2#3
+ {
+ \quark_if_recursion_tail_stop:N #1
+ \tl_set_rescan:Nnn \l__siunitx_tmpa_tl
+ { \use:c { char_set_catcode_ #2 :N } #1 }
+ {#1}
+ \tl_replace_all:NVn \l__siunitx_print_arg_tl \l__siunitx_tmpa_tl {#3}
+ \__siunitx_print_text_aux:NnN
+ }
+\AtBeginDocument
+ {
+ \@ifpackageloaded { textcomp }
+ {
+ \cs_set_protected:Npn \__siunitx_print_text_aux:
+ {
+ \tl_replace_all:Nnn \l__siunitx_print_arg_tl { \pm }
+ { \textpm }
+ }
+ }
+ { }
+ }
+\cs_new_protected:Npn \__siunitx_print_text_sub:n #1
+ {
+ \cs_set:Npn \__siunitx_print_text_sub_super:n ##1
+ {
+ \ensuremath
+ {
+ \sb { \text {#1} }
+ \sp { \text {##1} }
+ }
+ }
+ \cs_set_protected:Npn \__siunitx_peek_true:
+ {
+ \tex_afterassignment:D \__siunitx_print_text_sub_super:n
+ \cs_set_eq:NN \__siunitx_tmp:w
+ }
+ \cs_set_protected:Npn \__siunitx_peek_false:
+ { \ensuremath { \sb { \text {#1} } } }
+ \peek_after:Nw \__siunitx_print_text_sub_peek:
+ }
+\cs_new_protected:Npn \__siunitx_print_text_sub_peek:
+ {
+ \if_meaning:w \l_peek_token \__siunitx_print_text_super:n
+ \exp_after:wN \__siunitx_peek_true:
+ \else:
+ \exp_after:wN \__siunitx_peek_false:
+ \fi:
+ }
+\cs_new_protected:Npn \__siunitx_peek_true: { }
+\cs_new_protected:Npn \__siunitx_peek_false: { }
+\cs_new_protected:Npn \__siunitx_print_text_sub_super:n { }
+\cs_new_protected:Npn \__siunitx_print_text_super:n #1 {
+ \tl_set:Nn \l__siunitx_tmpa_tl {#1}
+ \tl_replace_all:Nnn \l__siunitx_tmpa_tl { - }
+ { \textminus }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:N \ensuremath
+ { \sp { \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_new_protected:Npn \__siunitx_number_preprocess:n #1 {
+ \__siunitx_number_preprocess_init:
+ \tl_set:Nn \l__siunitx_number_arg_tl {#1}
+ \__siunitx_number_preprocess_product:
+ \tl_if_empty:NT \l__siunitx_number_multi_tl
+ { \__siunitx_number_preprocess_quotient: }
+}
+\cs_generate_variant:Nn \__siunitx_number_preprocess:n { V }
+\cs_new_protected:Npn \__siunitx_number_preprocess_init: {
+ \bool_set_false:N \l__siunitx_error_bool
+ \tl_clear:N \l__siunitx_number_multi_tl
+}
+\cs_new_protected:Npn \__siunitx_number_preprocess_product: {
+ \tl_map_function:NN \l__siunitx_input_product_tl
+ \__siunitx_number_preprocess_product_aux:N
+}
+\cs_new_protected:Npn \__siunitx_number_preprocess_product_aux:N #1 {
+ \tl_if_in:NnT \l__siunitx_number_arg_tl {#1}
+ {
+ \cs_set:Npn \__siunitx_tmp:w ##1 #1 ##2 \q_stop
+ {
+ \tl_set:Nn \l__siunitx_number_arg_tl {##1}
+ \tl_set:Nn \l__siunitx_number_next_tl {##2}
+ \tl_set:Nn \l__siunitx_number_multi_tl { product }
+ }
+ \exp_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_new_protected:Npn \__siunitx_number_preprocess_quotient: {
+ \tl_map_function:NN \l__siunitx_input_quotient_tl
+ \__siunitx_number_preprocess_quotient_aux:N
+}
+\cs_new_protected:Npn \__siunitx_number_preprocess_quotient_aux:N #1 {
+ \tl_if_in:NnT \l__siunitx_number_arg_tl {#1}
+ {
+ \cs_set:Npn \__siunitx_tmp:w ##1 #1 ##2 \q_stop
+ {
+ \tl_set:Nn \l__siunitx_number_numerator_tl {##1}
+ \tl_set:Nn \l__siunitx_number_denominator_tl {##2}
+ \tl_set:Nn \l__siunitx_number_multi_tl { quotient }
+ }
+ \exp_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_const: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
+\int_new:N \l__siunitx_number_mantissa_length_int
+\tl_new:N \l__siunitx_number_uncert_tl
+\int_new:N \l__siunitx_number_uncert_length_int
+\tl_new:N \l__siunitx_input_uncert_sign_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-comparators .tl_set:N = \l__siunitx_input_comparator_tl ,
+ input-decimal-markers .tl_set:N = \l__siunitx_input_decimal_tl ,
+ input-digits .tl_set:N = \l__siunitx_input_digit_tl ,
+ input-exponent-markers .tl_set:N = \l__siunitx_input_exponent_tl ,
+ input-ignore .tl_set:N = \l__siunitx_input_ignore_tl ,
+ input-open-uncertainty .tl_set:N = \l__siunitx_input_uncert_open_tl ,
+ input-protect-tokens .tl_set:N = \l__siunitx_input_protect_tl ,
+ input-signs .tl_set:N = \l__siunitx_input_sign_tl ,
+ input-symbols .tl_set:N = \l__siunitx_input_symbol_tl ,
+ input-uncertainty-signs .code:n =
+ {
+ \tl_set:Nn \l__siunitx_input_uncert_sign_tl {#1}
+ \tl_map_inline:nn {#1}
+ {
+ \tl_if_in:NnF \l__siunitx_input_sign_tl {##1}
+ { \tl_put_right:Nn \l__siunitx_input_sign_tl {##1} }
+ }
+ } ,
+}
+\keys_set:nn { siunitx } { % (
+ input-close-uncertainty = ),
+ input-complex-roots = ij,
+ input-comparators = {<=>\approx\ge\geq\gg\le\leq\ll\sim},
+ input-decimal-markers = {.,},
+ input-digits = 0123456789,
+ input-exponent-markers = dDeE,
+ input-open-uncertainty = (, % )
+ input-protect-tokens = \approx\dots\ge\geq\gg\le\leq\ll\mp\pi\pm\sim,
+ input-signs = +-\mp\pm,
+ input-symbols = \dots\pi,
+ input-uncertainty-signs = \pm,
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse:n #1 {
+ \tl_if_empty:nF {#1}
+ {
+ \__siunitx_number_in_init:
+ \cs_set_eq:NN \__siunitx_number_in_parse_more:N
+ \__siunitx_number_in_parse_mantissa_aux:N
+ \__siunitx_number_in_parse_aux:n {#1}
+ }
+}
+\cs_generate_variant:Nn \__siunitx_number_in_parse:n { V }
+\group_begin:
+ \char_set_catcode_active:N \~
+ \char_set_catcode_space:N \ %
+ \cs_new_protected:Npn \__siunitx_number_in_parse_aux:n#1%
+ {%
+ \group_begin:
+ \__siunitx_number_in_protect:
+ \cs_set_eq:NN\,\prg_do_nothing:
+ \cs_set_eq:NN~\prg_do_nothing:
+ \tl_set_rescan:Nnx\l__siunitx_number_arg_tl
+ {%
+ \char_set_catcode_ignore:N\ %
+ \char_set_catcode_other:N\,%
+ \char_set_catcode_other:N\.%
+ }%
+ {#1}%
+ \exp_args:NNNV\group_end:
+ \tl_set:Nn\l__siunitx_number_arg_tl\l__siunitx_number_arg_tl
+ \__siunitx_number_in_sign_replace:N\l__siunitx_number_arg_tl
+ \__siunitx_number_in_parse_relation:N\l__siunitx_number_arg_tl
+ \tl_map_function:NN\l__siunitx_number_arg_tl
+ \__siunitx_number_in_parse_loop:N
+ \tl_if_empty:NF\l__siunitx_number_parsed_tl
+ {%
+ \bool_if:NTF\l__siunitx_number_in_uncert_bool
+ {\__siunitx_error:nx{invalid-number}{#1}}%
+ {%
+ \prop_put:NVn \l__siunitx_number_in_prop
+ \l__siunitx_number_part_tl {true}%
+ \bool_if:NTF\l__siunitx_number_in_decimal_bool
+ {%
+ \prop_put:NVV\l__siunitx_number_in_prop
+ \l__siunitx_number_part_decimal_tl
+ \l__siunitx_number_parsed_tl
+ }%
+ {%
+ \prop_put:NVV\l__siunitx_number_in_prop
+ \l__siunitx_number_part_integer_tl
+ \l__siunitx_number_parsed_tl
+ }%
+ }%
+ }%
+ \__siunitx_number_in_check:n {#1}%
+ }
+\group_end:
+\cs_new_protected:Npn \__siunitx_number_in_init: {
+ \cs_set_eq:NN \__siunitx_number_in_parse_loop:N
+ \__siunitx_number_in_parse_mantissa:N
+ \cs_set_eq:NN \__siunitx_number_in_check:n
+ \__siunitx_number_in_check_short:n
+ \tl_clear:N \l__siunitx_number_parsed_tl
+ \prop_clear:N \l__siunitx_number_in_prop
+ \bool_set_false:N \l__siunitx_error_bool
+ \bool_set_false:N \l__siunitx_number_in_complex_bool
+ \bool_set_false:N \l__siunitx_number_in_complex_root_bool
+ \bool_set_false:N \l__siunitx_number_in_exponent_bool
+ \bool_set_false:N \l__siunitx_number_in_uncert_bool
+ \__siunitx_number_in_init_part:n { mantissa }
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_number_in_protect: {
+ \tl_map_function:NN \l__siunitx_input_protect_tl
+ \__siunitx_number_in_protect_aux:N
+}
+\cs_new_protected:Npn \__siunitx_number_in_protect_aux:N #1 {
+ \cs_set_eq:NN #1 \scan_stop:
+}
+\cs_new_protected:Npn \__siunitx_number_in_sign_replace:N #1
+ {
+ \__siunitx_number_in_sign_replace_aux:N #1
+ \__siunitx_number_in_sign_replace_aux:NnN #1
+ { -+ } \mp
+ { +- } \pm
+ { << } \ll
+ { <= } \le
+ { >> } \gg
+ { >= } \ge
+ { ?? } \q_recursion_tail
+ \q_recursion_stop
+ }
+\group_begin:
+ \char_set_catcode_active:N -
+ \cs_new_protected:Npx \__siunitx_number_in_sign_replace_aux:N #1
+ { \tl_replace_all:Nnn #1 { \exp_not:N - } { \token_to_str:N - } }
+\group_end:
+\cs_new_protected:Npn \__siunitx_number_in_sign_replace_aux:NnN #1#2#3
+ {
+ \quark_if_recursion_tail_stop:N #3
+ \tl_replace_all:Nnn #1 {#2} {#3}
+ \__siunitx_number_in_sign_replace_aux:NnN #1
+ }
+\cs_new_protected:Npn \__siunitx_number_in_parse_error:nn #1#2 {
+ \__siunitx_error:nx {#1} { \exp_not:n {#2} }
+ \tl_map_break:
+}
+\cs_generate_variant:Nn \__siunitx_number_in_parse_error:nn { nV }
+\cs_new_protected:Npn \__siunitx_number_in_parse_loop:N #1 { }
+\cs_new_protected:Npn \__siunitx_number_in_parse_more:N #1 { }
+\cs_new_protected:Npn \__siunitx_number_in_parse_relation:N #1 {
+ \exp_after:wN \__siunitx_number_in_parse_relation:w #1 \q_stop #1
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_relation:w
+ #1#2 \q_stop #3 {
+ \tl_if_in:NnT \l__siunitx_input_comparator_tl {#1}
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { comparator } {#1}
+ \tl_set:Nn #3 {#2}
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_restricted:N #1 {
+ \tl_if_in:NnTF \l__siunitx_input_exponent_tl {#1}
+ {
+ \__siunitx_number_in_parse_error:nn
+ { 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:nn
+ { restricted-number } {#1}
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_complex:N #1 {
+ \tl_if_in:NnTF \l__siunitx_input_exponent_tl {#1}
+ {
+ \cs_set_eq:NN \__siunitx_number_in_parse_loop:N
+ \__siunitx_number_in_parse_mantissa:N
+ \__siunitx_number_in_exponent:N #1
+ }
+ {
+ \tl_if_in:NnF \l__siunitx_input_ignore_tl {#1}
+ {
+ \__siunitx_number_in_parse_error:nV
+ { misplaced-complex-root-token }
+ \l__siunitx_number_arg_tl
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_exponent:N #1 {
+ \tl_if_in:NnTF \l__siunitx_input_exponent_tl {#1}
+ {
+ \__siunitx_number_in_parse_error:nn
+ { 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:nn
+ { invalid-token-in-number } {#1}
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_mantissa:N #1 {
+ \tl_if_in:NnTF \l__siunitx_input_digit_tl {#1}
+ { \__siunitx_number_in_digit:n {#1} }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_decimal_tl {#1}
+ { \__siunitx_number_in_decimal:N #1 }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_sign_tl {#1}
+ { \__siunitx_number_in_sign:N #1 }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_symbol_tl {#1}
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { symbolic }
+ { true }
+ \__siunitx_number_in_digit:n {#1}
+ }
+ {
+ \tl_if_in:NnF \l__siunitx_input_ignore_tl {#1}
+ { \__siunitx_number_in_parse_more:N #1 }
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_mantissa_aux:N #1 {
+ \tl_if_in:NnTF \l__siunitx_input_exponent_tl {#1}
+ { \__siunitx_number_in_exponent:N #1 }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_uncert_open_tl {#1}
+ { \__siunitx_number_in_uncert_open:N #1 }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_uncert_close_tl {#1}
+ {
+ \__siunitx_number_in_parse_error:nn
+ { 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:nn
+ { invalid-token-in-number } {#1}
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_uncert:N #1 {
+ \tl_if_in:NnTF \l__siunitx_input_digit_tl {#1}
+ { \__siunitx_number_in_digit:n {#1} }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_decimal_tl {#1}
+ {
+ \__siunitx_number_in_parse_error:nV
+ { invalid-token-in-uncertainty }
+ \l__siunitx_number_arg_tl
+ }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_sign_tl {#1}
+ {
+ \__siunitx_number_in_parse_error:nV
+ { invalid-token-in-uncertainty }
+ \l__siunitx_number_arg_tl
+ }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_symbol_tl {#1}
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { symbolic }
+ { true }
+ \__siunitx_number_in_digit:n {#1}
+ }
+ {
+ \tl_if_in:NnF \l__siunitx_input_ignore_tl {#1}
+ {
+ \tl_if_in:NnTF \l__siunitx_input_uncert_close_tl
+ {#1}
+ { \__siunitx_number_in_uncert_close:N #1 }
+ {
+ \__siunitx_number_in_parse_error:nV
+ { invalid-token-in-uncertainty }
+ \l__siunitx_number_arg_tl
+ }
+ }
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_parse_uncert_after:N #1 {
+ \tl_if_in:NnTF \l__siunitx_input_exponent_tl {#1}
+ {
+ \cs_set_eq:NN \__siunitx_number_in_parse_loop:N
+ \__siunitx_number_in_parse_mantissa:N
+ \__siunitx_number_in_exponent:N #1
+ }
+ {
+ \tl_if_in:NnTF \l__siunitx_input_sign_tl {#1}
+ {
+ \cs_set_eq:NN \__siunitx_number_in_parse_loop:N
+ \__siunitx_number_in_parse_mantissa:N
+ \__siunitx_number_in_sign:N #1
+ }
+ {
+ \tl_if_in:NnF \l__siunitx_input_ignore_tl {#1}
+ {
+ \tl_if_in:NnTF \l__siunitx_input_complex_tl {#1}
+ {
+ \cs_set_eq:NN \__siunitx_number_in_parse_loop:N
+ \__siunitx_number_in_parse_mantissa:N
+ \__siunitx_number_in_complex:N #1
+ }
+ {
+ \__siunitx_number_in_parse_error:nV { invalid-number }
+ \l__siunitx_number_arg_tl
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_complex:N #1 {
+ \bool_set_false:N \l__siunitx_number_in_first_bool
+ \bool_if:NTF \l__siunitx_number_in_complex_root_bool
+ {
+ \__siunitx_number_in_parse_error:nn
+ { 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_remove: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:NnTF \l__siunitx_number_in_prop
+ { complex-sign }
+ { \bool_set_true:N \l__siunitx_number_in_sign_bool }
+ { \prop_remove:Nn \l__siunitx_number_in_prop { mantissa } }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_complex_aux:nn #1#2 {
+ \prop_get:NnNT \l__siunitx_number_in_prop {#1} \l__siunitx_tmpa_tl
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop {#1}
+ \prop_put:NnV \l__siunitx_number_in_prop {#2} \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_decimal:N #1 {
+ \bool_set_false:N \l__siunitx_number_in_first_bool
+ \bool_if:NTF \l__siunitx_number_in_decimal_bool
+ {
+ \__siunitx_number_in_parse_error:nn { duplicate-decimal-token }
+ {#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_new_protected:Npn \__siunitx_number_in_digit:n #1 {
+ \bool_set_false:N \l__siunitx_number_in_first_bool
+ \bool_if:NTF \l__siunitx_number_in_uncert_bool
+ { \tl_put_right:Nn \l__siunitx_number_parsed_tl {#1} }
+ {
+ \bool_if:NTF \l__siunitx_number_in_decimal_bool
+ {
+ \tl_put_right:Nn \l__siunitx_number_parsed_tl {#1}
+ \str_if_eq:nnF {#1} { 0 }
+ { \bool_set_true:N \l__siunitx_number_in_value_bool }
+ }
+ {
+ \str_if_eq:nnTF {#1} { 0 }
+ {
+ \prop_put:NVn \l__siunitx_number_in_prop
+ \l__siunitx_number_part_tl { true }
+ \prop_put:NVn \l__siunitx_number_in_prop
+ \l__siunitx_number_part_integer_tl { 0 }
+ }
+ { \bool_set_true:N \l__siunitx_number_in_value_bool }
+ \bool_if:NT \l__siunitx_number_in_value_bool
+ { \tl_put_right:Nn \l__siunitx_number_parsed_tl {#1} }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_exponent:N #1 {
+ \bool_if:NTF \l__siunitx_number_in_exponent_bool
+ {
+ \__siunitx_number_in_parse_error:nn { 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_new_protected:Npn \__siunitx_number_in_sign:N #1 {
+ \bool_if:NTF \l__siunitx_number_in_first_bool
+ {
+ \bool_set_false:N \l__siunitx_number_in_first_bool
+ \bool_set_true:N \l__siunitx_number_in_sign_bool
+ \prop_put:NVn \l__siunitx_number_in_prop
+ \l__siunitx_number_part_sign_tl {#1}
+ }
+ {
+ \bool_if:NTF \l__siunitx_number_in_exponent_bool
+ {
+ \__siunitx_number_in_parse_error:nn { misplaced-sign-token }
+ {#1}
+ }
+ {
+ \bool_if:NTF \l__siunitx_number_in_complex_bool
+ {
+ \__siunitx_number_in_parse_error:nn
+ { 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_new_protected:Npn \__siunitx_number_in_uncert_open:N #1 {
+ \bool_set_false:N \l__siunitx_number_in_first_bool
+ \cs_set_eq:NN \__siunitx_number_in_parse_loop:N
+ \__siunitx_number_in_parse_uncert:N
+ \bool_set_true:N \l__siunitx_number_in_uncert_bool
+ \tl_if_empty:NTF \l__siunitx_number_parsed_tl
+ {
+ \prop_if_in:NVF \l__siunitx_number_in_prop
+ \l__siunitx_number_part_integer_tl
+ {
+ \__siunitx_number_in_parse_error:nV { invalid-number }
+ \l__siunitx_number_arg_tl
+ }
+ }
+ { \__siunitx_number_in_store: }
+}
+\cs_new_protected:Npn \__siunitx_number_in_uncert_close:N #1 {
+ \bool_set_false:N \l__siunitx_number_in_uncert_bool
+ \tl_if_empty:NTF \l__siunitx_number_parsed_tl
+ {
+ \__siunitx_number_in_parse_error:nV { empty-uncertainty }
+ \l__siunitx_number_arg_tl
+ }
+ {
+ \prop_put:NVV \l__siunitx_number_in_prop
+ \l__siunitx_number_part_uncert_tl \l__siunitx_number_parsed_tl
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { uncertainty } { true }
+ \tl_clear:N \l__siunitx_number_parsed_tl
+ \cs_set_eq:NN \__siunitx_number_in_parse_loop:N
+ \__siunitx_number_in_parse_uncert_after:N
+ }
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_number_in_check:n #1 { }
+\cs_new_protected: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:NVNT \l__siunitx_number_in_prop
+ \l__siunitx_number_part_sign_tl \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_remove:NV \l__siunitx_number_in_prop
+ \l__siunitx_number_part_sign_tl
+ }
+ }
+}
+\cs_new_protected: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
+ \tl_if_in:NVTF \l__siunitx_input_uncert_sign_tl \l__siunitx_tmpa_tl
+ {
+ \prop_if_in:NnTF \l__siunitx_number_in_prop { uncertainty }
+ {
+ \__siunitx_error:nx { misplaced-sign-token }
+ { \exp_not:n {#1} }
+ }
+ { \__siunitx_number_in_complex_to_uncert:n {#1} }
+ }
+ {
+ \__siunitx_error:nx { misplaced-sign-token }
+ { \exp_not:n {#1} }
+ }
+ }
+ \prop_get:NnNT \l__siunitx_number_in_prop { mantissa-sign }
+ \l__siunitx_tmpa_tl
+ {
+ \prop_if_in:NnF \l__siunitx_number_in_prop { mantissa }
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { mantissa-sign }
+ \prop_put:NnV \l__siunitx_number_in_prop { complex-sign }
+ \l__siunitx_tmpa_tl
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_in_complex_to_uncert:n #1 {
+ \prop_remove:Nn \l__siunitx_number_in_prop { complex }
+ \prop_remove:Nn \l__siunitx_number_in_prop { complex-decimal-marker }
+ \prop_remove:Nn \l__siunitx_number_in_prop { complex-sign }
+ \prop_put:Nnn \l__siunitx_number_in_prop { uncertainty } { true }
+ \prop_get:NnNTF \l__siunitx_number_in_prop { complex-integer }
+ \l__siunitx_number_uncert_tl
+ {
+ \tl_if_single:NTF \l__siunitx_number_uncert_tl
+ {
+ \int_compare:nNnTF \l__siunitx_number_uncert_tl = 0
+ { \__siunitx_number_in_complex_to_uncert_dec:n {#1} }
+ { \__siunitx_number_in_complex_to_uncert_int: }
+ }
+ { \__siunitx_number_in_complex_to_uncert_int: }
+ }
+ { \__siunitx_number_in_complex_to_uncert_dec:n {#1} }
+ \prop_remove:Nn \l__siunitx_number_in_prop { complex-integer }
+ \prop_remove:Nn \l__siunitx_number_in_prop { complex-decimal }
+}
+\cs_new_protected:Npn \__siunitx_number_in_complex_to_uncert_int: {
+ \prop_get:NnNF \l__siunitx_number_in_prop { complex-decimal }
+ \l__siunitx_tmpa_tl
+ { \tl_clear:N \l__siunitx_tmpa_tl }
+ \prop_get:NnNF \l__siunitx_number_in_prop { mantissa-decimal }
+ \l__siunitx_tmpb_tl
+ { \tl_clear:N \l__siunitx_tmpb_tl }
+ \__siunitx_number_in_complex_to_uncert_pad:
+}
+\cs_new_protected:Npn \__siunitx_number_in_complex_to_uncert_dec:n
+ #1
+ {
+ \tl_clear:N \l__siunitx_number_uncert_tl
+ \prop_get:NnNTF \l__siunitx_number_in_prop { complex-decimal }
+ \l__siunitx_tmpa_tl
+ {
+ \prop_get:NnN \l__siunitx_number_in_prop { mantissa-decimal }
+ \l__siunitx_tmpb_tl
+ \quark_if_no_value:NT \l__siunitx_tmpb_tl
+ { \tl_clear:N \l__siunitx_tmpb_tl }
+ \tl_map_function:NN
+ \l__siunitx_tmpa_tl
+ \__siunitx_number_in_complex_to_uncert_dec_loop:N
+ \__siunitx_number_in_complex_to_uncert_pad:
+ }
+ { \__siunitx_error:nx { misplaced-sign-token } { \exp_not:n {#1} } }
+ }
+\cs_new_protected:Npn
+ \__siunitx_number_in_complex_to_uncert_dec_loop:N #1
+ {
+ \str_if_eq:nnTF {#1} { 0 }
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { \tl_tail:N \l__siunitx_tmpa_tl }
+ \tl_if_empty:NF \l__siunitx_tmpb_tl
+ {
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ { \tl_tail:N \l__siunitx_tmpb_tl }
+ }
+ }
+ { \tl_map_break: }
+ }
+\cs_new_protected:Npn \__siunitx_number_in_complex_to_uncert_pad:
+ {
+ \int_set:Nn \l__siunitx_number_uncert_length_int
+ { \tl_count:N \l__siunitx_tmpa_tl }
+ \int_set:Nn \l__siunitx_number_mantissa_length_int
+ { \tl_count:N \l__siunitx_tmpb_tl }
+ \int_compare:nNnTF
+ { \l__siunitx_number_mantissa_length_int }
+ > { \l__siunitx_number_uncert_length_int }
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:V \l__siunitx_tmpa_tl
+ \prg_replicate:nn
+ {
+ \l__siunitx_number_mantissa_length_int
+ - \l__siunitx_number_uncert_length_int
+ }
+ { 0 }
+ }
+ }
+ {
+ \prop_get:NnNF \l__siunitx_number_in_prop { mantissa-decimal }
+ \l__siunitx_tmpb_tl
+ { \tl_clear:N \l__siunitx_tmpb_tl }
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ {
+ \exp_not:V \l__siunitx_tmpb_tl
+ \prg_replicate:nn
+ {
+ \l__siunitx_number_uncert_length_int
+ - \l__siunitx_number_mantissa_length_int
+ }
+ { 0 }
+ }
+ \tl_if_empty:NF \l__siunitx_tmpb_tl
+ {
+ \prop_put:NnV \l__siunitx_number_in_prop { mantissa-decimal }
+ \l__siunitx_tmpb_tl
+ \prop_if_in:NnF \l__siunitx_number_in_prop
+ { mantissa-decimal-marker }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { mantissa-decimal-marker } { . }
+ }
+ }
+ }
+ \tl_put_right:NV \l__siunitx_number_uncert_tl \l__siunitx_tmpa_tl
+ \prop_put:NnV \l__siunitx_number_in_prop { mantissa-uncertainty }
+ \l__siunitx_number_uncert_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_discard_tl
+\tl_new:N \l__siunitx_round_even_bool
+\tl_new:N \l__siunitx_round_integer_in_tl
+\tl_new:N \l__siunitx_round_integer_out_tl
+\bool_new:N \l__siunitx_round_half_up_bool
+\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
+\bool_new:N \l__siunitx_process_fixed_bool
+\bool_new:N \l__siunitx_process_engineering_bool
+\bool_new:N \l__siunitx_process_scientific_bool
+\bool_new:N \l__siunitx_process_drop_exponent_bool
+\keys_define:nn { siunitx }
+ {
+ add-decimal-zero .bool_set:N = \l__siunitx_process_decimal_zero_bool,
+ add-integer-zero .bool_set:N = \l__siunitx_process_integer_zero_bool,
+ explicit-sign .tl_set:N = \l__siunitx_process_sign_tl,
+ fixed-exponent .int_set:N = \l__siunitx_process_fixed_int,
+ minimum-integer-digits .int_set:N =
+ \l__siunitx_process_integer_min_int,
+ retain-explicit-plus .bool_set:N = \l__siunitx_process_plus_bool,
+ omit-uncertainty .bool_set:N = \l__siunitx_omit_uncert_bool,
+ 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-half .choice:,
+ round-half / even .code:n =
+ { \bool_set_false:N \l__siunitx_round_half_up_bool },
+ round-half / up .code:n =
+ { \bool_set_true:N \l__siunitx_round_half_up_bool },
+ round-integer-to-decimal .bool_set:N =
+ \l__siunitx_process_int_to_dec_bool,
+ round-minimum .tl_set:N = \l__siunitx_process_round_min_tl,
+ round-mode .choice: ,
+ round-mode / figures .code:n =
+ { \tl_set:Nn \l__siunitx_round_tl { figures } },
+ round-mode / off .code:n = { \tl_clear:N \l__siunitx_round_tl },
+ round-mode / places .code:n =
+ { \tl_set:Nn \l__siunitx_round_tl { places } },
+ round-precision .int_set:N = \l__siunitx_process_precision_int,
+ scientific-notation .choice: ,
+ scientific-notation
+ / false .code:n =
+ {
+ \bool_set_false:N \l__siunitx_process_fixed_bool
+ \bool_set_false:N \l__siunitx_process_engineering_bool
+ \bool_set_false:N \l__siunitx_process_scientific_bool
+ },
+ scientific-notation
+ / engineering .code:n =
+ {
+ \bool_set_false:N \l__siunitx_process_fixed_bool
+ \bool_set_true:N \l__siunitx_process_engineering_bool
+ \bool_set_true:N \l__siunitx_process_scientific_bool
+ },
+ scientific-notation
+ / fixed .code:n =
+ {
+ \bool_set_true:N \l__siunitx_process_fixed_bool
+ \bool_set_false:N \l__siunitx_process_engineering_bool
+ \bool_set_false:N \l__siunitx_process_scientific_bool
+ },
+ scientific-notation
+ / true .code:n =
+ {
+ \bool_set_false:N \l__siunitx_process_fixed_bool
+ \bool_set_false:N \l__siunitx_process_engineering_bool
+ \bool_set_true:N \l__siunitx_process_scientific_bool
+ },
+ zero-decimal-to-integer .bool_set:N =
+ \l__siunitx_zero_decimal_to_integer_bool
+ }
+\keys_set:nn { siunitx }
+ {
+ add-decimal-zero = true,
+ add-integer-zero = true,
+ retain-unity-mantissa = true,
+ round-half = up,
+ round-minimum = 0,
+ round-precision = 2
+ }
+\cs_new_protected: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 }
+ {
+ \bool_if:NTF \l__siunitx_process_fixed_bool
+ { \__siunitx_number_process_fixed: }
+ {
+ \bool_if:NT \l__siunitx_process_scientific_bool
+ { \__siunitx_number_process_scientific: }
+ }
+ \__siunitx_number_process_exponent:
+ \__siunitx_number_process_uncertainty:
+ \bool_if:NT \l__siunitx_exp_to_prefix_bool
+ {
+ \tl_if_empty:NF \l__siunitx_unit_tl
+ { \__siunitx_number_exp_to_prefix: }
+ }
+ \prop_if_in:NnTF \l__siunitx_number_in_prop { uncertainty }
+ {
+ \bool_if:NT \l__siunitx_omit_uncert_bool
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { uncertainty }
+ \prop_remove:Nn \l__siunitx_number_in_prop { mantissa-uncertainty }
+ }
+ }
+ { \__siunitx_number_process_round: }
+ }
+ \__siunitx_number_process_zero_to_integer:
+ \__siunitx_number_process_integer_digits:
+ \bool_if:NT \l__siunitx_process_drop_exponent_bool
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent }
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent-integer }
+ }
+ }
+\cs_new_protected: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_remove:Nn \l__siunitx_number_in_prop { exponent }
+ \prop_remove:Nn \l__siunitx_number_in_prop
+ { exponent-integer }
+ \prop_remove:Nn \l__siunitx_number_in_prop
+ { exponent-decimal }
+ \prop_if_in:NnF \l__siunitx_number_in_prop { mantissa }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { mantissa } { true }
+ \prop_put:Nnn \l__siunitx_number_in_prop { mantissa-integer } { 1 }
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_exponent_aux:n #1 {
+ \prop_get:NnNT \l__siunitx_number_in_prop { exponent- #1 }
+ \l__siunitx_tmpa_tl
+ {
+ \int_compare:nNnF { \l__siunitx_tmpa_tl } = { 0 }
+ { \bool_set_true:N \l__siunitx_tmp_bool }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_figures:n #1
+ {
+ \int_compare:nNnTF \l__siunitx_process_precision_int > 0
+ {
+ \prop_if_in:NnT \l__siunitx_number_in_prop {#1}
+ { \__siunitx_number_process_figures_aux:n {#1} }
+ }
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -sign }
+ \prop_put:Nnn \l__siunitx_number_in_prop { #1 -integer } { 0 }
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal }
+ \bool_if:NF \l__siunitx_process_int_to_dec_bool
+ { \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal-marker } }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_figures_aux:n #1
+ {
+ \__siunitx_number_process_figures_init:n {#1}
+ \__siunitx_number_process_figures_count:n { integer }
+ \__siunitx_number_process_figures_count:n { decimal }
+ \bool_if:NTF \l__siunitx_round_bool
+ {
+ \bool_set_false:N \l__siunitx_round_bool
+ \int_compare:nNnTF
+ \l__siunitx_round_int > \l__siunitx_process_precision_int
+ {
+ \__siunitx_number_process_figures_round:
+ \__siunitx_number_process_round_tidy:n {#1}
+ }
+ { \__siunitx_number_process_figures_pad:n {#1} }
+ }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { #1 -integer } { 0 }
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_figures_init:n #1
+ {
+ \int_zero:N \l__siunitx_round_int
+ \bool_set_false:N \l__siunitx_round_bool
+ \bool_set_false:N \l__siunitx_round_even_bool
+ \prop_get:NnNF \l__siunitx_number_in_prop { #1 -decimal }
+ \l__siunitx_round_decimal_in_tl
+ { \tl_clear:N \l__siunitx_round_decimal_in_tl }
+ \prop_get:NnNF \l__siunitx_number_in_prop { #1 -integer }
+ \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
+ \tl_clear:N \l__siunitx_round_discard_tl
+ }
+\cs_new_protected:Npn \__siunitx_number_process_figures_count:n #1
+ {
+ \tl_if_empty:cF { l__siunitx_round_ #1 _in_tl }
+ {
+ \prop_if_in:NnF \l__siunitx_number_in_prop { #1 -uncertainty }
+ { \__siunitx_number_process_figures_count_aux:n {#1} }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_figures_count_aux:n #1
+ {
+ \int_set:Nn \l__siunitx_tmp_int
+ { \tl_head:v { l__siunitx_round_ #1 _in_tl } }
+ \tl_set:cx { l__siunitx_round_ #1 _in_tl }
+ { \tl_tail:v { l__siunitx_round_ #1 _in_tl } }
+ \tl_put_left:cV { l__siunitx_round_ #1 _out_tl } \l__siunitx_tmp_int
+ \bool_if:NF \l__siunitx_round_bool
+ {
+ \int_compare:nNnF \l__siunitx_tmp_int = 0
+ { \bool_set_true:N \l__siunitx_round_bool }
+ }
+ \bool_if:NT \l__siunitx_round_bool
+ { \int_incr:N \l__siunitx_round_int }
+ \tl_if_empty:cTF { l__siunitx_round_ #1 _in_tl }
+ {
+ \tl_set_eq:cc { l__siunitx_round_ #1 _in_tl }
+ { l__siunitx_round_ #1 _out_tl }
+ \tl_clear:c { l__siunitx_round_ #1 _out_tl }
+ }
+ { \__siunitx_number_process_figures_count_aux:n {#1} }
+ }
+\cs_new_protected: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 } }
+ }
+\cs_new_protected: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_new_protected:Npn \__siunitx_number_process_figures_integer:
+ {
+ \int_compare:nNnT \l__siunitx_round_int > 0
+ { \tl_put_left:Nn \l__siunitx_round_integer_out_tl { 0 } }
+ \int_compare:nNnF \l__siunitx_round_int > 1
+ {
+ \int_set:Nn \l__siunitx_tmp_int
+ { \tl_head:N \l__siunitx_round_integer_in_tl }
+ \__siunitx_number_process_round_up:
+ \int_compare:nNnTF \l__siunitx_round_int = 1
+ {
+ \int_compare:nNnT \l__siunitx_tmp_int > 4
+ { \bool_set_true:N \l__siunitx_round_bool }
+ }
+ {
+ \int_compare:nNnT \l__siunitx_tmp_int = { 10 }
+ {
+ \bool_set_true:N \l__siunitx_round_bool
+ \int_zero:N \l__siunitx_tmp_int
+ }
+ \tl_put_left:NV \l__siunitx_round_integer_out_tl
+ \l__siunitx_tmp_int
+ }
+ }
+ \int_decr:N \l__siunitx_round_int
+ \tl_set:Nx \l__siunitx_round_integer_in_tl
+ { \tl_tail:N \l__siunitx_round_integer_in_tl }
+ \tl_if_empty:NF \l__siunitx_round_integer_in_tl
+ { \__siunitx_number_process_figures_integer: }
+ }
+\cs_new_protected: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}
+}
+\cs_new_protected:Npn \__siunitx_number_process_fixed: {
+ \prop_if_in:NnF \l__siunitx_number_in_prop { complex }
+ {
+ \prop_get:NnNF \l__siunitx_number_in_prop { mantissa-integer }
+ \l__siunitx_tmpa_tl
+ { \tl_set:Nn \l__siunitx_tmpa_tl { 0 } }
+ \prop_get:NnNF \l__siunitx_number_in_prop { mantissa-decimal }
+ \l__siunitx_tmpb_tl
+ { \tl_clear:N \l__siunitx_tmpb_tl }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { { \l__siunitx_tmpa_tl } { \l__siunitx_tmpb_tl } }
+ \prop_get:NnNF \l__siunitx_number_in_prop { exponent-integer }
+ \l__siunitx_tmpb_tl
+ { \tl_set:Nn \l__siunitx_tmpb_tl { 0 } }
+ \group_begin:
+ \prop_get:NnNT \l__siunitx_number_in_prop { exponent-sign }
+ \l__siunitx_tmpa_tl
+ {
+ \tl_put_left:NV \l__siunitx_tmpb_tl \l__siunitx_tmpa_tl
+ }
+ \exp_args:NNNV \group_end:
+ \tl_set:Nn \l__siunitx_tmpb_tl \l__siunitx_tmpb_tl
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { \l__siunitx_tmpa_tl { \l__siunitx_tmpb_tl } }
+ \exp_after:wN \__siunitx_number_process_fixed_aux_i:nnn
+ \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_fixed_aux_i:nnn #1#2#3
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { exponent } { true }
+ \int_compare:nNnTF \l__siunitx_process_fixed_int > 0
+ {
+ \prop_put:NnV \l__siunitx_number_in_prop { exponent-integer }
+ \l__siunitx_process_fixed_int
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent-sign }
+ }
+ {
+ \prop_put:Nnx \l__siunitx_number_in_prop { exponent-integer }
+ { \int_eval:n { - \l__siunitx_process_fixed_int } }
+ \prop_put:Nnn \l__siunitx_number_in_prop { exponent-sign } { - }
+ }
+ \__siunitx_number_process_fixed_aux_ii:nnn {#1} {#2} {#3}
+ }
+\cs_new_protected:Npn \__siunitx_number_process_fixed_aux_ii:nnn #1#2#3
+ {
+ \bool_set_true:N \l__siunitx_tmp_bool
+ \tl_map_inline:nn {#1#2}
+ {
+ \str_if_eq:nnF {##1} { 0 }
+ {
+ \bool_set_false:N \l__siunitx_tmp_bool
+ \tl_map_break:
+ }
+ }
+ \bool_if:NF \l__siunitx_tmp_bool
+ { \__siunitx_number_process_fixed_aux_iii:nnn {#1} {#2} {#3} }
+ }
+\cs_new_protected:Npn
+ \__siunitx_number_process_fixed_aux_iii:nnn #1#2#3 {
+ \int_compare:nNnTF {#3} > { \l__siunitx_process_fixed_int }
+ { \__siunitx_number_process_fixed_large:nnn {#1} {#2} {#3} }
+ {
+ \int_compare:nNnTF {#3} < { \l__siunitx_process_fixed_int }
+ { \__siunitx_number_process_fixed_small:nnn {#1} {#2} {#3} }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { mantissa-integer } {#1}
+ \tl_if_empty:nTF {#2}
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop
+ { mantissa-decimal }
+ \prop_remove:Nn \l__siunitx_number_in_prop
+ { mantissa-decimal-marker }
+ }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { mantissa-decimal } {#2}
+ \prop_if_in:NnF \l__siunitx_number_in_prop
+ { mantissa-decimal-marker }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { mantissa-decimal-marker } { . }
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_fixed_large:nnn #1
+ {
+ \__siunitx_number_if_zero:nTF {#1}
+ { \__siunitx_number_process_fixed_large_aux:nnn { } }
+ { \__siunitx_number_process_fixed_large_aux:nnn {#1} }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_fixed_large_aux:nnn #1#2#3
+ {
+ \cs_set_protected:Npn
+ \__siunitx_number_process_fixed_large_aux:w ##1##2 \q_stop
+ {
+ \tl_if_empty:nTF {##2}
+ {
+ \int_compare:nNnTF
+ { #3 - 1 } = { \l__siunitx_process_fixed_int }
+ {
+ \__siunitx_number_process_fixed_aux_ii:nnn { #1 ##1 }
+ { } { #3 - 1 }
+ }
+ {
+ \__siunitx_number_process_fixed_aux_ii:nnn { #1 ##1 }
+ { 0 } { #3 - 1 }
+ }
+ }
+ {
+ \__siunitx_number_if_zero:nTF {#1}
+ {
+ \__siunitx_number_process_fixed_aux_ii:nnn {##1} {##2}
+ { #3 - 1 }
+ }
+ {
+ \__siunitx_number_process_fixed_aux_ii:nnn { #1 ##1 }
+ {##2} { #3 - 1 }
+ }
+ }
+ }
+ \tl_if_empty:nTF {#2}
+ { \__siunitx_number_process_fixed_aux_ii:nnn { #1 0 } { } { #3 - 1 } }
+ { \__siunitx_number_process_fixed_large_aux:w #2 \q_stop }
+}
+\cs_new_protected:Npn \__siunitx_number_process_fixed_large_aux:w
+ { }
+\cs_new_protected:Npn
+ \__siunitx_number_process_fixed_small:nnn #1#2#3 {
+ \cs_set_protected:Npn
+ \__siunitx_number_process_fixed_small_aux:w ##1##2 \q_stop ##3
+ {
+ \tl_if_empty:nTF {##2}
+ {
+ \tl_if_empty:nTF {##3}
+ {
+ \__siunitx_number_process_fixed_aux_ii:nnn { 0 }
+ { ##1 #2 } { #3 + 1 }
+ }
+ {
+ \__siunitx_number_process_fixed_aux_ii:nnn {##3}
+ { ##1 #2 } { #3 + 1 }
+ }
+ }
+ {
+ \__siunitx_number_process_fixed_small_aux:w ##2 \q_stop
+ { ##3 ##1 }
+ }
+ }
+ \__siunitx_number_process_fixed_small_aux:w #1 \q_stop { }
+}
+\cs_new_protected:Npn \__siunitx_number_process_fixed_small_aux:w
+ { }
+\cs_new_protected:Npn \__siunitx_number_process_integer_digits: {
+ \int_compare:nNnT \l__siunitx_process_integer_min_int > 0
+ {
+ \prop_get:NnNT \l__siunitx_number_in_prop { mantissa-integer }
+ \l__siunitx_tmpa_tl
+ {
+ \int_set:Nn \l__siunitx_tmp_int
+ {
+ \l__siunitx_process_integer_min_int
+ - \tl_count:N \l__siunitx_tmpa_tl
+ }
+ \int_compare:nNnT \l__siunitx_tmp_int > 0
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \prg_replicate:nn { \l__siunitx_tmp_int } { 0 }
+ \exp_not:V \l__siunitx_tmpa_tl
+ }
+ \prop_put:NnV \l__siunitx_number_in_prop
+ { mantissa-integer } \l__siunitx_tmpa_tl
+ }
+ }
+ }
+}
+\cs_new_protected: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:NnNT \l__siunitx_number_in_prop { mantissa-integer }
+ \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_remove:Nn \l__siunitx_number_in_prop
+ { mantissa }
+ \prop_remove:Nn \l__siunitx_number_in_prop
+ { mantissa-integer }
+ }
+ }
+ }
+ }
+ }
+}
+\tl_const:Nn \c__siunitx_unity_tl { 1 }
+\cs_new_protected:Npn \__siunitx_number_process_pad:n #1 {
+ \prop_get:NnNT \l__siunitx_number_in_prop { #1 -decimal }
+ \l__siunitx_tmpa_tl
+ {
+ \int_while_do:nNnn { \l__siunitx_round_int } > { 0 }
+ {
+ \tl_put_right:Nn \l__siunitx_tmpa_tl { 0 }
+ \int_decr:N \l__siunitx_round_int
+ }
+ \prop_put:NnV \l__siunitx_number_in_prop { #1 -decimal }
+ \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_places:n #1
+ {
+ \prop_if_in:NnT \l__siunitx_number_in_prop {#1}
+ {
+ \prop_if_in:NnF \l__siunitx_number_in_prop { #1 -uncertainty }
+ { \__siunitx_number_process_places_aux_i:n {#1} }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_places_aux_i:n #1
+ {
+ \int_compare:nNnTF \l__siunitx_process_precision_int = 0
+ { \__siunitx_number_process_places_none:n {#1} }
+ {
+ \prop_get:NnNT \l__siunitx_number_in_prop { #1 -decimal }
+ \l__siunitx_tmpa_tl
+ {
+ \tl_if_empty:NT \l__siunitx_tmpa_tl
+ { \tl_set:Nn \l__siunitx_tmpa_tl { 0 } }
+ \__siunitx_number_process_places_aux_i:TF
+ {
+ \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_count:N \l__siunitx_tmpa_tl }
+ \__siunitx_number_process_places_aux_ii:n {#1}
+ }
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_places_aux_i:TF
+ {
+ \bool_set_true:N \l__siunitx_tmp_bool
+ \tl_map_inline:Nn \l__siunitx_tmpa_tl
+ {
+ \int_compare:nNnF {##1} = 0
+ {
+ \bool_set_false:N \l__siunitx_tmp_bool
+ \tl_map_break:
+ }
+ }
+ \bool_if:NTF \l__siunitx_tmp_bool
+ }
+\cs_new_protected:Npn \__siunitx_number_process_places_none:n #1
+ {
+ \prop_get:NnNT \l__siunitx_number_in_prop { #1 -decimal } \l__siunitx_tmpa_tl
+ {
+ \int_compare:nNnTF { \tl_head:N \l__siunitx_tmpa_tl } > 4
+ {
+ \prop_get:NnNTF \l__siunitx_number_in_prop { #1 -integer }
+ \l__siunitx_tmpb_tl
+ {
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ { \int_eval:n { \l__siunitx_tmpb_tl + 1 } }
+ \bool_if:NF \l__siunitx_round_half_up_bool
+ {
+ \bool_lazy_and:nnT
+ {
+ \int_compare_p:nNn
+ { 0 \tl_head:N \l__siunitx_tmpa_tl } = 5
+ }
+ {
+ \int_compare_p:nNn
+ { 0 \tl_tail:N \l__siunitx_tmpa_tl } = 0
+ }
+ {
+ \int_if_odd:nT \l__siunitx_tmpb_tl
+ {
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ { \int_eval:n { \l__siunitx_tmpb_tl - 1 } }
+ }
+ }
+ }
+ }
+ { \tl_set:Nn \l__siunitx_tmpb_tl { 1 } }
+ \prop_put:NnV \l__siunitx_number_in_prop
+ { #1 -integer } \l__siunitx_tmpb_tl
+ }
+ {
+ \prop_if_in:NnF \l__siunitx_number_in_prop { #1 -integer }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { #1 -integer } { 0 }
+ }
+ }
+ }
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal }
+ \bool_if:NF \l__siunitx_process_int_to_dec_bool
+ { \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal-marker } }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_places_aux_ii:n #1
+ {
+ \int_sub:Nn \l__siunitx_round_int
+ { \l__siunitx_process_precision_int }
+ \int_compare:nNnTF \l__siunitx_round_int < 0
+ {
+ \int_set:Nn \l__siunitx_round_int { - \l__siunitx_round_int }
+ \__siunitx_number_process_pad:n {#1}
+ }
+ {
+ \__siunitx_number_process_places_init:n {#1}
+ \__siunitx_number_process_places_loop:n {#1}
+ \__siunitx_number_process_round_tidy:n {#1}
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_places_init:n #1
+ {
+ \prop_get:NnNF \l__siunitx_number_in_prop { #1 -integer }
+ \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
+ \tl_clear:N \l__siunitx_round_discard_tl
+ \bool_set_false:N \l__siunitx_round_bool
+ \bool_set_false:N \l__siunitx_round_even_bool
+ }
+\cs_new_protected: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_new_protected:Npn \__siunitx_number_process_places_integer:n #1
+ {
+ \int_set:Nn \l__siunitx_tmp_int
+ { \tl_head:N \l__siunitx_round_integer_in_tl }
+ \tl_set:Nx \l__siunitx_round_integer_in_tl
+ { \tl_tail:N \l__siunitx_round_integer_in_tl }
+ \__siunitx_number_process_round_up:
+ \bool_set_false:N \l__siunitx_round_bool
+ \int_compare:nNnT \l__siunitx_tmp_int = { 10 }
+ {
+ \int_zero:N \l__siunitx_tmp_int
+ \bool_set_true:N \l__siunitx_round_bool
+ }
+ \tl_put_left:NV \l__siunitx_round_integer_out_tl \l__siunitx_tmp_int
+ }
+\cs_new_protected:Npn \__siunitx_number_process_round:
+ {
+ \tl_if_empty:NF \l__siunitx_round_tl
+ {
+ \bool_if:NT \l__siunitx_process_int_to_dec_bool
+ {
+ \prop_if_in:NnF \l__siunitx_number_in_prop { mantissa-decimal }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { mantissa-decimal }
+ { 0 }
+ }
+ \prop_if_in:NnF \l__siunitx_number_in_prop
+ { mantissa-decimal-marker }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { mantissa-decimal-marker } { . }
+ }
+ }
+ \clist_map_function:nc { mantissa , complex }
+ { __siunitx_number_process_ \l__siunitx_round_tl :n }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_round_decimal:
+ {
+ \int_compare:nNnF \l__siunitx_round_int > 1
+ { \__siunitx_number_process_round_decimal_aux: }
+ \tl_put_right:Nx \l__siunitx_round_discard_tl
+ { \tl_head:N \l__siunitx_round_decimal_in_tl }
+ \tl_set:Nx \l__siunitx_round_decimal_in_tl
+ { \tl_tail:N \l__siunitx_round_decimal_in_tl }
+ \int_decr:N \l__siunitx_round_int
+ }
+\cs_new_protected:Npn \__siunitx_number_process_round_decimal_aux:
+ {
+ \int_set:Nn \l__siunitx_tmp_int
+ { \tl_head:N \l__siunitx_round_decimal_in_tl }
+ \__siunitx_number_process_round_up:
+ \int_compare:nNnTF \l__siunitx_round_int = 1
+ {
+ \int_compare:nNnT \l__siunitx_tmp_int > 4
+ {
+ \bool_set_true:N \l__siunitx_round_bool
+ \bool_if:NF \l__siunitx_round_half_up_bool
+ {
+ \int_compare:nNnT
+ { \l__siunitx_round_discard_tl \int_use:N \l__siunitx_tmp_int } = 5
+ { \bool_set_true:N \l__siunitx_round_even_bool }
+ }
+ }
+ }
+ {
+ \int_compare:nNnT \l__siunitx_tmp_int = { 10 }
+ {
+ \bool_set_true:N \l__siunitx_round_bool
+ \int_zero:N \l__siunitx_tmp_int
+ }
+ \tl_put_left:NV \l__siunitx_round_decimal_out_tl
+ \l__siunitx_tmp_int
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_round_up:
+ {
+ \bool_if:NT \l__siunitx_round_bool
+ {
+ \bool_if:NTF \l__siunitx_round_even_bool
+ {
+ \bool_set_false:N \l__siunitx_round_even_bool
+ \int_if_even:nF \l__siunitx_tmp_int
+ { \int_incr:N \l__siunitx_tmp_int }
+ }
+ { \int_incr:N \l__siunitx_tmp_int }
+ }
+ \bool_set_false:N \l__siunitx_round_bool
+ }
+\cs_new_protected:Npn \__siunitx_number_process_round_tidy:n #1
+ {
+ \bool_lazy_and:nnTF
+ { \__siunitx_number_if_zero_p:V \l__siunitx_round_integer_out_tl }
+ { \__siunitx_number_if_zero_p:V \l__siunitx_round_decimal_out_tl }
+ {
+ \str_if_eq:VnTF \l__siunitx_process_round_min_tl { 0 }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { #1 -integer } { 0 }
+ \prop_put:NnV \l__siunitx_number_in_prop { #1 -decimal }
+ \l__siunitx_round_decimal_out_tl
+ }
+ {
+ \exp_after:wN \__siunitx_number_process_round_tidy_aux:w
+ \l__siunitx_process_round_min_tl . . \q_stop {#1}
+ }
+ }
+ {
+ \prop_put:NnV \l__siunitx_number_in_prop { #1 -integer }
+ \l__siunitx_round_integer_out_tl
+ \tl_if_empty:NTF \l__siunitx_round_decimal_out_tl
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal }
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal-marker }
+ }
+ {
+ \prop_put:NnV \l__siunitx_number_in_prop { #1 -decimal }
+ \l__siunitx_round_decimal_out_tl
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_round_tidy_aux:w
+ #1 . #2 . #3 \q_stop #4
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { comparator } { < }
+ \prop_put:Nnn \l__siunitx_number_in_prop { #4 -integer } {#1}
+ \tl_if_empty:nTF {#2}
+ { \prop_remove:Nn \l__siunitx_number_in_prop { #4 -decimal } }
+ { \prop_put:Nnn \l__siunitx_number_in_prop { #4 -decimal } {#2} }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_scientific: {
+ \prop_if_in:NnF \l__siunitx_number_in_prop { complex }
+ {
+ \prop_get:NnNF \l__siunitx_number_in_prop { mantissa-integer }
+ \l__siunitx_tmpa_tl
+ { \tl_set:Nn \l__siunitx_tmpa_tl { 0 } }
+ \prop_get:NnNF \l__siunitx_number_in_prop { mantissa-decimal }
+ \l__siunitx_tmpb_tl
+ { \tl_clear:N \l__siunitx_tmpb_tl }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { { \l__siunitx_tmpa_tl } { \l__siunitx_tmpb_tl } }
+ \prop_get:NnNF \l__siunitx_number_in_prop { exponent-integer }
+ \l__siunitx_tmpb_tl
+ { \tl_set:Nn \l__siunitx_tmpb_tl { 0 } }
+ \group_begin:
+ \prop_get:NnNT \l__siunitx_number_in_prop { exponent-sign }
+ \l__siunitx_tmpa_tl
+ { \tl_put_left:NV \l__siunitx_tmpb_tl \l__siunitx_tmpa_tl }
+ \exp_args:NNNV \group_end:
+ \tl_set:Nn \l__siunitx_tmpb_tl \l__siunitx_tmpb_tl
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { \l__siunitx_tmpa_tl { \l__siunitx_tmpb_tl } }
+ \exp_after:wN \__siunitx_number_process_scientific_aux_i:nnn
+ \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_scientific_aux_i:nnn #1#2#3
+ {
+ \bool_set_true:N \l__siunitx_tmp_bool
+ \tl_map_inline:nn {#1#2}
+ {
+ \str_if_eq:nnF {##1} { 0 }
+ {
+ \bool_set_false:N \l__siunitx_tmp_bool
+ \tl_map_break:
+ }
+ }
+ \bool_if:NF \l__siunitx_tmp_bool
+ { \__siunitx_number_process_scientific_aux_ii:nnn {#1} {#2} {#3} }
+ }
+\cs_new_protected:Npn
+ \__siunitx_number_process_scientific_aux_ii:nnn #1#2#3 {
+ \int_compare:nNnTF { \tl_count:n {#1} } > 1
+ { \__siunitx_number_process_scientific_large:nnn {#1} {#2} {#3} }
+ {
+ \__siunitx_number_if_zero:nTF {#1}
+ {
+ \__siunitx_number_process_scientific_small:wn
+ #2 \q_stop {#3}
+ }
+ {
+ \bool_if:NTF \l__siunitx_process_engineering_bool
+ { \__siunitx_number_process_scientific_engineering:nnn }
+ { \__siunitx_number_process_scientific_store:nnn }
+ {#1} {#2} {#3}
+ }
+
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_scientific_large:nnn #1#2#3
+ {
+ \cs_set_protected:Npn \__siunitx_number_process_scientific_large_loop:nNN
+ ##1##2##3
+ {
+ \quark_if_recursion_tail_stop_do:Nn ##3
+ {
+ \__siunitx_number_process_scientific_aux_ii:nnn {##1} { ##2 #2 }
+ { #3 + 1 }
+ }
+ \__siunitx_number_process_scientific_large_loop:nNN { ##1 ##2 } ##3
+ }
+ \__siunitx_number_process_scientific_large_loop:nNN { } #1
+ \q_recursion_tail \q_recursion_stop
+ }
+\cs_new_protected:Npn
+ \__siunitx_number_process_scientific_small:wn #1#2 \q_stop #3
+ { \__siunitx_number_process_scientific_aux_ii:nnn {#1} {#2} { #3 - 1 } }
+\cs_new_protected:Npn
+ \__siunitx_number_process_scientific_store:nnn #1#2#3
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { mantissa-integer } {#1}
+ \tl_if_empty:nTF {#2}
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { mantissa-decimal }
+ \prop_remove:Nn \l__siunitx_number_in_prop
+ { mantissa-decimal-marker }
+ }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { mantissa-decimal } {#2}
+ \prop_if_in:NnF \l__siunitx_number_in_prop
+ { mantissa-decimal-marker }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop
+ { mantissa-decimal-marker } { . }
+ }
+ }
+ \int_compare:nNnTF {#3} = { 0 }
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent }
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent-sign }
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent-integer }
+ }
+ {
+ \prop_put:Nnn \l__siunitx_number_in_prop { exponent } { true }
+ \int_compare:nNnTF {#3} > { 0 }
+ {
+ \int_set:Nn \l__siunitx_tmp_int {#3}
+ \prop_put:NnV \l__siunitx_number_in_prop
+ { exponent-integer } \l__siunitx_tmp_int
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent-sign }
+ }
+ {
+ \int_set:Nn \l__siunitx_tmp_int { 0 - (#3) }
+ \prop_put:NnV \l__siunitx_number_in_prop
+ { exponent-integer } \l__siunitx_tmp_int
+ \prop_put:Nnn \l__siunitx_number_in_prop { exponent-sign }
+ { - }
+ }
+ }
+ }
+\cs_new_protected:Npn
+ \__siunitx_number_process_scientific_engineering:nnn #1#2#3
+ {
+ \use:c
+ {
+ __siunitx_number_process_scientific_engineering_
+ \int_compare:nNnTF {#3} < { 0 }
+ {
+ \int_case:nnF { \int_mod:nn { 0 - (#3) } { 3 } }
+ {
+ { 1 } { 2 }
+ { 2 } { 1 }
+ }
+ { 0 }
+ }
+ { \int_mod:nn {#3} { 3 } }
+ :nnn
+ }
+ {#1} {#2} {#3}
+ }
+\cs_new_eq:cN
+ { __siunitx_number_process_scientific_engineering_0:nnn }
+ \__siunitx_number_process_scientific_store:nnn
+\cs_new_protected:cpn
+ { __siunitx_number_process_scientific_engineering_1:nnn } #1#2#3
+ {
+ \tl_if_empty:nTF {#2}
+ {
+ \__siunitx_number_process_scientific_store:nnn { #1 0 } { }
+ { #3 - 1 }
+ }
+ {
+ \use:c
+ { __siunitx_number_process_scientific_engineering_1:nw }
+ {#1} #2 \q_stop {#3}
+ }
+ }
+\cs_new_protected:cpn
+ { __siunitx_number_process_scientific_engineering_1:nw }
+ #1#2#3 \q_stop #4
+ {
+ \__siunitx_number_process_scientific_store:nnn
+ {#1#2} {#3} { #4 - 1 }
+ }
+\cs_new_protected:cpn
+ { __siunitx_number_process_scientific_engineering_2:nnn } #1#2#3
+ {
+ \tl_if_empty:nTF {#2}
+ {
+ \__siunitx_number_process_scientific_store:nnn { #1 00 } { }
+ { #3 - 2 }
+ }
+ {
+ \use:c
+ { __siunitx_number_process_scientific_engineering_2_i:nw }
+ {#1} #2 \q_stop {#3}
+ }
+ }
+\cs_new_protected:cpn
+ { __siunitx_number_process_scientific_engineering_2_i:nw }
+ #1#2#3 \q_stop #4
+ {
+ \tl_if_empty:nTF {#3}
+ {
+ \__siunitx_number_process_scientific_store:nnn { #1#2 0 } { }
+ { #4 - 2 }
+ }
+ {
+ \use:c
+ { __siunitx_number_process_scientific_engineering_2_ii:nw }
+ {#1#2} #3 \q_stop {#4}
+ }
+ }
+\cs_new_protected:cpn
+ { __siunitx_number_process_scientific_engineering_2_ii:nw }
+ #1#2#3 \q_stop #4
+ {
+ \__siunitx_number_process_scientific_store:nnn { #1#2 } {#3}
+ { #4 - 2 }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_sign: {
+ \bool_if:NF \l__siunitx_process_plus_bool
+ {
+ \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
+ {
+ \__siunitx_number_process_sign_add:n { mantissa }
+ \prop_if_in:NnTF \l__siunitx_number_in_prop { complex }
+ { \__siunitx_number_process_sign_add:n { complex } }
+ }
+}
+\cs_new_protected: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
+ }
+ }
+ }
+}
+\cs_new_protected: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_remove:Nn \l__siunitx_number_in_prop { #1 -sign }
+ \prop_put:Nnn \l__siunitx_number_in_prop { #1 -had-sign } { true }
+ }
+}
+\tl_const:Nn \c__siunitx_plus_tl { + }
+\cs_new_protected:Npn \__siunitx_number_process_uncertainty: {
+ \clist_map_function:nN { mantissa , complex }
+ \__siunitx_number_process_uncertainty_aux:n
+}
+\cs_new_protected: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_new_protected:Npn
+ \__siunitx_number_process_uncertainty_decimal:n #1 {
+ \__siunitx_number_process_uncertainty_count:nn {#1} { decimal }
+ \__siunitx_number_process_uncertainty_count:nn {#1} { uncertainty }
+ \tl_clear:N \l__siunitx_uncertainty_decimal_tl
+ \tl_clear:N \l__siunitx_uncertainty_integer_tl
+ \int_compare:nNnTF
+ { \l__siunitx_process_uncertainty_int } >
+ { \l__siunitx_process_decimal_int }
+ { \__siunitx_number_process_uncertainty_separate: }
+ { \__siunitx_number_process_uncertainty_pad: }
+ \tl_if_empty:NF \l__siunitx_uncertainty_integer_tl
+ {
+ \prop_put:NnV \l__siunitx_number_in_prop
+ { #1 -uncertainty-integer }
+ \l__siunitx_uncertainty_integer_tl
+ }
+ \prop_put:NnV \l__siunitx_number_in_prop { #1 -uncertainty-decimal }
+ \l__siunitx_uncertainty_decimal_tl
+ \prop_get:NnN \l__siunitx_number_in_prop { #1 -decimal-marker }
+ \l__siunitx_tmpa_tl
+ \prop_put:NnV \l__siunitx_number_in_prop
+ { #1 -uncertainty-decimal-marker } \l__siunitx_tmpa_tl
+}
+\cs_new_protected: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_count:N \l__siunitx_tmpa_tl }
+}
+\cs_new_protected:Npn \__siunitx_number_process_uncertainty_pad: {
+ \int_while_do:nNnn
+ { \l__siunitx_process_uncertainty_int } <
+ { \l__siunitx_process_decimal_int }
+ {
+ \tl_put_right:Nn \l__siunitx_uncertainty_decimal_tl {0}
+ \int_incr:N \l__siunitx_process_uncertainty_int
+ }
+ \tl_put_right:NV \l__siunitx_uncertainty_decimal_tl
+ \l__siunitx_tmpa_tl
+}
+\cs_new_protected:Npn
+ \__siunitx_number_process_uncertainty_separate: {
+ \tl_map_function:NN \l__siunitx_tmpa_tl
+ \__siunitx_number_process_uncertainty_separate_aux:N
+}
+\cs_new_protected:Npn
+ \__siunitx_number_process_uncertainty_separate_aux:N #1 {
+ \int_compare:nNnTF
+ { \l__siunitx_process_uncertainty_int } >
+ { \l__siunitx_process_decimal_int }
+ { \tl_put_right:Nn \l__siunitx_uncertainty_integer_tl {#1} }
+ { \tl_put_right:Nn \l__siunitx_uncertainty_decimal_tl {#1} }
+ \int_decr:N \l__siunitx_process_uncertainty_int
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_number_process_zero_fill: {
+ \__siunitx_number_process_zero_fill_aux:n { integer }
+ \__siunitx_number_process_zero_fill_aux:n { decimal }
+}
+\cs_new:Npn \__siunitx_number_process_zero_fill_aux:n #1 {
+ \bool_if:cT { l__siunitx_process_ #1 _zero_bool }
+ {
+ \__siunitx_number_process_zero_fill_aux:nn { mantissa } {#1}
+ \__siunitx_number_process_zero_fill_aux:nn { complex } {#1}
+ \__siunitx_number_process_zero_fill_aux:nn { exponent } {#1}
+ }
+}
+\cs_new_protected: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 } }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_process_zero_to_integer:
+ {
+ \bool_if:NT \l__siunitx_zero_decimal_to_integer_bool
+ {
+ \__siunitx_number_process_zero_to_integer_aux:n { mantissa }
+ \__siunitx_number_process_zero_to_integer_aux:n { complex }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_process_zero_to_integer_aux:n #1
+ {
+ \prop_get:NnNT \l__siunitx_number_in_prop { #1 -decimal } \l__siunitx_tmpa_tl
+ {
+ \bool_set_true:N \l__siunitx_tmp_bool
+ \tl_map_inline:Nn \l__siunitx_tmpa_tl
+ {
+ \str_if_eq:nnF {##1} { 0 }
+ {
+ \bool_set_false:N \l__siunitx_tmp_bool
+ \tl_map_break:
+ }
+ }
+ \bool_if:NT \l__siunitx_tmp_bool
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal }
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -decimal-marker }
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_exp_to_prefix:
+ {
+ \prop_set_eq:NN \l__siunitx_unit_prop \l__siunitx_unit_saved_prop
+ \prop_get:NnNT \l__siunitx_number_in_prop { exponent-integer }
+ \l__siunitx_tmpa_tl
+ {
+ \prop_get:NnNT \l__siunitx_number_in_prop { exponent-sign }
+ \l__siunitx_tmpb_tl
+ { \tl_put_left:NV \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl }
+ \prop_if_in:NnT \l__siunitx_unit_prop { per-1 }
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { \int_eval:n { - \l__siunitx_tmpa_tl } }
+ }
+ \prop_get:NnNT \l__siunitx_unit_prop { prefix-1 } \l__siunitx_tmpb_tl
+ {
+ \prop_remove:Nn \l__siunitx_unit_prop { prefix-1 }
+ \prop_remove:Nn \l__siunitx_unit_prop { prefix-symbol-1 }
+ \prop_get:NVN \l__siunitx_prefix_forward_prop \l__siunitx_tmpb_tl
+ \l__siunitx_tmpb_tl
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { \int_eval:n { \l__siunitx_tmpa_tl + \l__siunitx_tmpb_tl } }
+ }
+ \prop_get:NnNT \l__siunitx_unit_prop { power-1 } \l__siunitx_tmpb_tl
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { \int_eval:n { \l__siunitx_tmpa_tl / \l__siunitx_tmpb_tl } }
+ }
+ \prop_get:NVNTF \l__siunitx_prefix_reverse_prop \l__siunitx_tmpa_tl
+ \l__siunitx_tmpb_tl
+ {
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent }
+ \use:c
+ {
+ __siunitx_ \exp_after:wN \token_to_str:N \l__siunitx_tmpb_tl
+ _function:w
+ }
+ \prop_get:NnN \l__siunitx_unit_prop { total-units } \l__siunitx_tmpa_tl
+ \int_set:Nn \l__siunitx_unit_int \l__siunitx_tmpa_tl
+ \cs_set_eq:NN \__siunitx_pm: \pm
+ \__siunitx_unit_format:
+ \cs_set_eq:NN \pm \__siunitx_pm:
+ }
+ {
+ \msg_error:nnx { siunitx } { non-convertible-exponent }
+ { \l__siunitx_tmpa_tl }
+ }
+ }
+ }
+\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
+\bool_new:N \l__siunitx_group_decimal_bool
+\bool_new:N \l__siunitx_group_integer_bool
+\keys_define:nn { siunitx } {
+ bracket-negative-numbers .bool_set:N =
+ \l__siunitx_negative_bracket_bool ,
+ bracket-numbers .bool_set:N = \l__siunitx_brackets_bool,
+ close-bracket .tl_set:N = \l__siunitx_bracket_close_tl,
+ complex-root-position .choice:,
+ complex-root-position
+ / after-number .code:n =
+ { \bool_set_true:N \l__siunitx_complex_after_bool } ,
+ complex-root-position
+ / before-number .code:n =
+ { \bool_set_false:N \l__siunitx_complex_after_bool } ,
+ copy-complex-root .bool_set:N =
+ \l__siunitx_output_complex_copy_bool,
+ copy-decimal-marker .bool_set:N =
+ \l__siunitx_output_decimal_copy_bool,
+ exponent-base .tl_set:N = \l__siunitx_exponent_base_tl,
+ exponent-product .tl_set:N =
+ \l__siunitx_exponent_product_tl,
+ group-decimal-digits .meta:n = { group-digits = decimal },
+ group-digits .choice: ,
+ group-digits /
+ decimal .code:n =
+ {
+ \bool_set_true:N \l__siunitx_group_decimal_bool
+ \bool_set_false:N \l__siunitx_group_integer_bool
+ },
+ group-digits /
+ false .code:n =
+ {
+ \bool_set_false:N \l__siunitx_group_decimal_bool
+ \bool_set_false:N \l__siunitx_group_integer_bool
+ },
+ group-digits /
+ integer .code:n =
+ {
+ \bool_set_false:N \l__siunitx_group_decimal_bool
+ \bool_set_true:N \l__siunitx_group_integer_bool
+ },
+ group-digits /
+ true .code:n =
+ {
+ \bool_set_true:N \l__siunitx_group_decimal_bool
+ \bool_set_true:N \l__siunitx_group_integer_bool
+ },
+ group-digits .default:n = true ,
+ group-four-digits .choice:,
+ group-four-digits /
+ false .meta:n = { group-minimum-digits = 5 },
+ group-four-digits /
+ true .meta:n = { group-minimum-digits = 4 },
+ group-four-digits .default:n = true,
+ group-integer-digits .meta:n = { group-digits = integer },
+ group-minimum-digits .int_set:N = \l__siunitx_group_min_int,
+ 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-exponent-marker .tl_set:N = \l__siunitx_output_exponent_tl,
+ 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-digits = true ,
+ group-minimum-digits = 5 ,
+ group-separator = \, ,
+ open-bracket = ( , % ) (
+ output-close-uncertainty = ) ,
+ output-complex-root = \ensuremath { \mathrm { i } } ,
+ output-decimal-marker = . ,
+ output-open-uncertainty = ( % )
+ }
+\cs_new_protected:Npn \__siunitx_number_format: {
+ \prop_if_empty:NF \l__siunitx_number_in_prop
+ {
+ \prop_clear:N \l__siunitx_number_out_prop
+ \__siunitx_number_format_reassemble:
+ \__siunitx_number_format_complex:
+ \__siunitx_number_format_sign:n { mantissa }
+ \__siunitx_number_format_sign:n { exponent }
+ \__siunitx_number_format_relation:
+ \__siunitx_number_format_color:
+ \__siunitx_number_format_final:
+ }
+}
+\cs_new_protected: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_remove:Nn \l__siunitx_number_out_prop { #1 -bracket }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_brackets_aux:n #1 {
+ \prop_get:NnNF \l__siunitx_number_out_prop { #1 -result }
+ \l__siunitx_tmpa_tl
+ {
+ \prop_get:NnN \l__siunitx_number_out_prop {#1} \l__siunitx_tmpa_tl
+ }
+ \tl_put_left:NV \l__siunitx_tmpa_tl \l__siunitx_bracket_open_tl
+ \tl_put_right:NV \l__siunitx_tmpa_tl \l__siunitx_bracket_close_tl
+ \str_if_eq:nnTF {#1} { result }
+ { \prop_put:NnV \l__siunitx_number_out_prop {#1} \l__siunitx_tmpa_tl }
+ {
+ \prop_put:NnV \l__siunitx_number_out_prop { #1 -result }
+ \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_color: {
+ \tl_if_empty:NF \l__siunitx_negative_color_tl
+ {
+ \__siunitx_number_format_color_aux:n { mantissa-sign }
+ \__siunitx_number_format_color_aux:n { sign }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_color_aux:n #1 {
+ \prop_get:NnNT \l__siunitx_number_in_prop {#1} \l__siunitx_tmpa_tl
+ {
+ \str_if_eq:VnT \l__siunitx_tmpa_tl { - }
+ {
+ \prop_put:NnV \l__siunitx_number_out_prop { color }
+ \l__siunitx_negative_color_tl
+ }
+ }
+}
+\cs_new_protected: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 }
+ }
+ }
+ {
+ \prop_put:NnV \l__siunitx_number_out_prop { complex }
+ \l__siunitx_output_complex_tl
+ }
+ \__siunitx_number_format_join_complex:
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_complex_aux:n #1 {
+ \bool_if:NTF \l__siunitx_output_complex_copy_bool
+ {
+ \prop_get:NnN \l__siunitx_number_in_prop { complex-root }
+ \l__siunitx_tmpa_tl
+ }
+ { \tl_set_eq:NN \l__siunitx_tmpa_tl \l__siunitx_output_complex_tl }
+ \prop_get:NnN \l__siunitx_number_out_prop {#1} \l__siunitx_tmpb_tl
+ \bool_if:NTF \l__siunitx_complex_after_bool
+ { \tl_put_right:NV \l__siunitx_tmpb_tl \l__siunitx_tmpa_tl }
+ { \tl_put_left:NV \l__siunitx_tmpb_tl \l__siunitx_tmpa_tl }
+ \prop_put:NnV \l__siunitx_number_out_prop {#1} \l__siunitx_tmpb_tl
+}
+\cs_new_protected:Npn \__siunitx_number_format_copy:n #1 {
+ \prop_get:NnN \l__siunitx_number_in_prop {#1} \l__siunitx_tmpa_tl
+ \prop_put:NnV \l__siunitx_number_out_prop {#1} \l__siunitx_tmpa_tl
+}
+\cs_new_protected: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_new_protected: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_remove:Nn \l__siunitx_number_out_prop { mantissa-bracket }
+ }
+ \prop_if_in:NnT \l__siunitx_number_out_prop { comparator }
+ {
+ \__siunitx_number_format_brackets:n { result }
+ \prop_get:NnN \l__siunitx_number_out_prop { comparator }
+ \l__siunitx_tmpa_tl
+ \prop_get:NnN \l__siunitx_number_out_prop { result }
+ \l__siunitx_tmpb_tl
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:N \mathord
+ \exp_not:V \l__siunitx_tmpa_tl
+ \exp_not:V \l__siunitx_tmpb_tl
+ }
+ \prop_put:NnV \l__siunitx_number_out_prop { result }
+ \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected: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_if_empty:NT \l__siunitx_output_exponent_tl
+ {
+ \tl_put_right:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:N \ensuremath
+ {
+ \bool_if:NTF \l__siunitx_tight_bool
+ { { \exp_not:V \l__siunitx_exponent_product_tl } }
+ { { } \exp_not:V \l__siunitx_exponent_product_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_new_protected:Npn \__siunitx_number_format_final_exponent: {
+ \prop_get:NnN \l__siunitx_number_out_prop { exponent }
+ \l__siunitx_tmpa_tl
+ \tl_if_empty:NTF \l__siunitx_output_exponent_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
+ }
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:V \l__siunitx_output_exponent_tl
+ \exp_not:N \mathord
+ \exp_not:V \l__siunitx_tmpa_tl
+ }
+ }
+ \prop_put:NnV \l__siunitx_number_out_prop { exponent-result }
+ \l__siunitx_tmpa_tl
+}
+\cs_new_protected:Npn
+ \__siunitx_number_format_final_exponent_only: {
+ \prop_get:NnNT \l__siunitx_number_in_prop { mantissa-sign }
+ \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_new_protected: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:NnNT \l__siunitx_number_in_prop { #1 -decimal-marker }
+ \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_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:NnNF \l__siunitx_number_out_prop { #1 -decimal }
+ \l__siunitx_tmpb_tl
+ { \tl_clear:N \l__siunitx_tmpb_tl }
+ \tl_put_right:NV \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl
+ \prop_put:NnV \l__siunitx_number_out_prop {#1} \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_group_aux:nn #1#2 {
+ \prop_if_in:NnT \l__siunitx_number_in_prop { #1 - #2 }
+ {
+ \bool_if:cTF { l__siunitx_group_ #2 _bool }
+ { \__siunitx_number_format_group:nn {#1} {#2} }
+ { \__siunitx_number_format_copy:n { #1 - #2 } }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_group:nn #1#2
+ {
+ \prop_get:NnN \l__siunitx_number_in_prop { #1 - #2 } \l__siunitx_tmpa_tl
+ \int_compare:nNnTF
+ { \tl_count:N \l__siunitx_tmpa_tl } < \l__siunitx_group_min_int
+ { \__siunitx_number_format_copy:n { #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_new_protected: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_new_protected:Npn \__siunitx_number_format_group_decimal_aux:NNNN
+ #1#2#3#4 {
+ \tl_if_empty:nTF {#2}
+ { \tl_put_right:Nn \l__siunitx_tmpb_tl {#1} }
+ {
+ \tl_if_empty:nTF {#3}
+ { \tl_put_right:Nn \l__siunitx_tmpb_tl { #1 #2 } }
+ {
+ \tl_put_right:Nn \l__siunitx_tmpb_tl { #1 #2 #3 }
+ \tl_if_empty:nF {#4}
+ {
+ \tl_put_right:NV \l__siunitx_tmpb_tl \l__siunitx_group_sep_tl
+ \__siunitx_number_format_group_decimal_aux:NNNN #4
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_group_integer: {
+ \tl_if_empty:NF \l__siunitx_tmpa_tl
+ {
+ \__siunitx_number_format_group_integer_setup:V \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_group_integer_setup:n #1 {
+ \__siunitx_number_format_group_integer_setup_aux:NNNN
+ { } #1 { } { } { }
+}
+\cs_generate_variant:Nn \__siunitx_number_format_group_integer_setup:n
+ { V }
+\cs_new_protected:Npn
+ \__siunitx_number_format_group_integer_setup_aux:NNNN #1#2#3#4 {
+ \tl_if_empty:nTF {#2}
+ { \__siunitx_number_format_group_integer_aux:NNNN #1 \q_nil }
+ {
+ \tl_if_empty:nTF {#3}
+ {
+ \__siunitx_number_format_group_integer_aux:NNNN { } { } #1#2
+ \q_nil
+ }
+ {
+ \tl_if_empty:nTF {#4}
+ {
+ \__siunitx_number_format_group_integer_aux:NNNN { } #1#2#3
+ \q_nil
+ }
+ {
+ \__siunitx_number_format_group_integer_setup_aux:NNNN
+ {#1#2#3#4}
+ }
+ }
+ }
+}
+\cs_new_protected:Npn
+ \__siunitx_number_format_group_integer_aux:NNNN #1#2#3#4 {
+ \tl_put_right:Nn \l__siunitx_tmpb_tl {#1#2#3}
+ \quark_if_nil:nF {#4}
+ {
+ \tl_put_right:NV \l__siunitx_tmpb_tl \l__siunitx_group_sep_tl
+ \__siunitx_number_format_group_integer_aux:NNNN #4
+ }
+}
+\cs_new_protected: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:NnNF \l__siunitx_number_out_prop { complex-result }
+ \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_new_protected:Npn \__siunitx_number_format_join_uncert: {
+ \__siunitx_number_format_join_uncert:n { mantissa }
+ \__siunitx_number_format_join_uncert:n { complex }
+}
+\cs_new_protected:Npn \__siunitx_number_format_join_uncert:n #1 {
+ \prop_get:NnNT \l__siunitx_number_out_prop {#1}
+ \l__siunitx_tmpa_tl
+ {
+ \prop_get:NnNTF \l__siunitx_number_out_prop { #1 -uncertainty }
+ \l__siunitx_tmpb_tl
+ {
+ \bool_if:NT \l__siunitx_uncert_sep_bool
+ { \__siunitx_number_format_join_uncert_pm: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 -result }
+ \l__siunitx_tmpa_tl
+ \prop_put:Nnn \l__siunitx_number_out_prop { #1 -bracket }
+ { true }
+ }
+ { \__siunitx_number_format_copy:nn {#1} { #1 -result } }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_join_uncert_pm:N #1
+ {
+ \bool_if:NTF \l__siunitx_tight_bool
+ { \tl_put_left:Nn #1 { \ensuremath { { \pm } } } }
+ { \tl_put_left:Nn #1 { \ensuremath { { } \pm { } } } }
+ }
+\cs_new_protected: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_new_protected:Npn \__siunitx_number_format_relation: {
+ \prop_get:NnNT \l__siunitx_number_in_prop { comparator }
+ \l__siunitx_tmpa_tl
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:N \ensuremath
+ { \exp_not:V \l__siunitx_tmpa_tl }
+ }
+ \prop_put:NnV \l__siunitx_number_out_prop { comparator }
+ \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_sign:n #1 {
+ \prop_if_in:NnT \l__siunitx_number_out_prop {#1}
+ {
+ \prop_get:NnNT \l__siunitx_number_in_prop { #1 -sign }
+ \l__siunitx_tmpa_tl
+ {
+ \bool_if:NTF \l__siunitx_negative_bracket_bool
+ {
+ \str_if_eq:VnTF \l__siunitx_tmpa_tl { - }
+ { \__siunitx_number_format_sign_negative_brackets:n {#1} }
+ { \__siunitx_number_format_sign_aux:n {#1} }
+ }
+ { \__siunitx_number_format_sign_aux:n {#1} }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_format_sign_aux:n #1 {
+ \tl_clear:N \l__siunitx_tmpb_tl
+ \tl_put_left: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:NnNT \l__siunitx_number_out_prop { #1 -result }
+ \l__siunitx_tmpa_tl
+ {
+ \tl_put_left:NV \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl
+ \prop_put:NnV \l__siunitx_number_out_prop { #1 -result }
+ \l__siunitx_tmpa_tl
+ }
+}
+\cs_new_protected:Npn
+ \__siunitx_number_format_sign_negative_brackets:n #1
+ {
+ \__siunitx_number_format_brackets_aux:n {#1}
+ \prop_get:NnNT \l__siunitx_number_out_prop { #1 }
+ \l__siunitx_tmpa_tl
+ {
+ \tl_put_left:NV \l__siunitx_tmpa_tl \l__siunitx_bracket_open_tl
+ \tl_put_right:NV \l__siunitx_tmpa_tl \l__siunitx_bracket_close_tl
+ \prop_put:NnV \l__siunitx_number_out_prop { #1 }
+ \l__siunitx_tmpa_tl
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_format_sign_complex: {
+ \__siunitx_number_format_sign_complex:n { complex }
+ \__siunitx_number_format_sign_complex:n { complex-result }
+}
+\cs_new_protected:Npn \__siunitx_number_format_sign_complex:n #1 {
+ \prop_if_in:NnT \l__siunitx_number_out_prop {#1}
+ {
+ \prop_get:NnNT \l__siunitx_number_in_prop { complex-sign }
+ \l__siunitx_tmpa_tl
+ {
+ \bool_if:NTF \l__siunitx_tight_bool
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { \exp_not:N \mathord \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
+ \tl_put_left: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_new_protected:Npn \__siunitx_number_format_uncertainty:n #1 {
+ \prop_if_in:NnTF \l__siunitx_number_in_prop { #1 -uncertainty }
+ {
+ \bool_if:NTF \l__siunitx_uncert_sep_bool
+ { \__siunitx_number_format_uncertainty_sep:n {#1} }
+ { \__siunitx_number_format_uncertainty_joined:n {#1} }
+ \__siunitx_number_format_join_uncert:
+ }
+ { \__siunitx_number_format_copy:nn {#1} { #1 -result } }
+}
+\cs_new_protected:Npn
+ \__siunitx_number_format_uncertainty_joined:n #1 {
+ \prop_get:NnN \l__siunitx_number_in_prop { #1 -uncertainty }
+ \l__siunitx_tmpa_tl
+ \prop_remove:Nn \l__siunitx_number_in_prop { #1 -uncertainty }
+ \tl_put_left:NV \l__siunitx_tmpa_tl \l__siunitx_output_uncert_open_tl
+ \tl_put_left:NV \l__siunitx_tmpa_tl \l__siunitx_uncert_sep_tl
+ \tl_put_right:NV \l__siunitx_tmpa_tl \l__siunitx_output_uncert_close_tl
+ \prop_get:NnN \l__siunitx_number_out_prop {#1} \l__siunitx_tmpb_tl
+ \tl_put_right:NV \l__siunitx_tmpb_tl \l__siunitx_tmpa_tl
+ \prop_put:NnV \l__siunitx_number_out_prop {#1} \l__siunitx_tmpb_tl
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_fraction:nn { }
+\keys_define:nn { siunitx } {
+ fraction-function .code:n =
+ { \cs_set_protected:Npn \__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_new_protected:Npn \__siunitx_number_output:n #1 {
+ \tl_clear:N \l__siunitx_unit_tl
+ \tl_clear:N \l__siunitx_preunit_tl
+ \__siunitx_combined_output:n {#1}
+}
+\cs_generate_variant:Nn \__siunitx_number_output:n { V }
+\cs_new_protected: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_new_protected: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_new_protected:Npn \__siunitx_number_output_parse:n #1 {
+ \__siunitx_number_preprocess:n {#1}
+ \bool_if:NF \l__siunitx_error_bool
+ {
+ \tl_if_empty:NTF \l__siunitx_number_multi_tl
+ { \__siunitx_number_output_parse_aux: }
+ {
+ \use:c
+ { __siunitx_number_output_ \l__siunitx_number_multi_tl : }
+ }
+ }
+}
+\cs_generate_variant:Nn \__siunitx_number_output_parse:n { V }
+\cs_new_protected:Npn \__siunitx_number_output_parse_aux: {
+ \__siunitx_number_in_parse:V \l__siunitx_number_arg_tl
+ \bool_if:NF \l__siunitx_error_bool
+ {
+ \__siunitx_number_process:
+ \__siunitx_number_format:
+ \__siunitx_number_output_color:
+ \bool_if:NTF \l__siunitx_brackets_bool
+ { \__siunitx_number_output_single: }
+ {
+ \prop_if_in:NnTF \l__siunitx_number_out_prop
+ { result-bracket }
+ { \__siunitx_number_output_parts: }
+ { \__siunitx_number_output_single: }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_output_parts: {
+ \bool_lazy_and:nnTF
+ { \tl_if_empty_p:N \l__siunitx_pre_unit_tl }
+ { \tl_if_empty_p:N \l__siunitx_unit_tl }
+ { \__siunitx_number_output_single: }
+ { \__siunitx_number_output_parts_aux: }
+}
+\cs_new_protected: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:NnNT \l__siunitx_number_out_prop { exponent-result }
+ \l__siunitx_tmpa_tl
+ {
+ \prop_if_in:NnT \l__siunitx_number_out_prop { mantissa-result }
+ {
+ \tl_put_left:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:N \ensuremath
+ {
+ \bool_if:NTF \l__siunitx_tight_bool
+ { { \exp_not:V \l__siunitx_exponent_product_tl } }
+ { { } \exp_not:V \l__siunitx_exponent_product_tl { } }
+ }
+ }
+ \prop_put:NnV \l__siunitx_number_out_prop { exponent }
+ \l__siunitx_tmpa_tl
+ }
+ \__siunitx_number_output_parts_print:n { exponent }
+ }
+ }
+ { \__siunitx_number_output_single: }
+}
+\cs_new_protected: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 } { \ensuremath { { \pm } } } }
+ { \__siunitx_print:nn { number } { \ensuremath { { } \pm { } } } }
+ \__siunitx_number_output_parts_print:n { #1 -uncertainty }
+ }
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_number_output_product: {
+ \bool_if:NTF \l__siunitx_product_brackets_bool
+ {
+ \bool_lazy_and:nnTF
+ { \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_new_protected:Npn \__siunitx_number_output_product_brackets: {
+ \__siunitx_unit_output_pre_print:
+ \__siunitx_print:nV { number } \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:nV { number } \l__siunitx_bracket_close_tl
+ \__siunitx_unit_output_print:
+}
+\cs_new_protected: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 }
+ { \ensuremath { \l__siunitx_output_product_tl } }
+ }
+ {
+ \__siunitx_print:nn { number }
+ { \ensuremath { { } \l__siunitx_output_product_tl { } } }
+ }
+ \__siunitx_number_output_parse:V \l__siunitx_number_next_tl
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_number_output_quotient: {
+ \use:c
+ { __siunitx_number_output_quotient_ \l__siunitx_quotient_mode_tl : }
+}
+\cs_new_protected: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_new_protected: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
+ \tl_put_right: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_new_protected:Npn \__siunitx_number_output_quotient_aux_i: {
+ \__siunitx_number_in_parse:V \l__siunitx_number_numerator_tl
+ \__siunitx_number_output_quotient_aux_ii:
+ \__siunitx_number_output_color:
+ \prop_if_in:NnT \l__siunitx_number_out_prop { complex }
+ {
+ \prop_if_in:NnT \l__siunitx_number_out_prop { mantissa }
+ {
+ \prop_put:Nnn \l__siunitx_number_out_prop
+ { result-bracket } { true }
+ \__siunitx_number_format_brackets:n { result }
+ }
+ }
+ \prop_get:NnN \l__siunitx_number_out_prop { result }
+ \l__siunitx_number_numerator_tl
+ \__siunitx_number_in_parse:V \l__siunitx_number_denominator_tl
+ \__siunitx_number_output_quotient_aux_ii:
+ \prop_if_in:NnT \l__siunitx_number_out_prop
+ { result-bracket-exponent }
+ {
+ \prop_put:Nnn \l__siunitx_number_out_prop { result-bracket }
+ { true }
+ }
+ \__siunitx_number_output_bracket:
+ \prop_get:NnN \l__siunitx_number_out_prop { result }
+ \l__siunitx_number_denominator_tl
+}
+\cs_new_protected:Npn \__siunitx_number_output_quotient_aux_ii: {
+ \__siunitx_number_process:
+ \__siunitx_number_format:
+}
+\cs_new_protected:Npn \__siunitx_number_output_single: {
+ \bool_lazy_and:nnF
+ { \tl_if_empty_p:N \l__siunitx_pre_unit_tl }
+ { \tl_if_empty_p:N \l__siunitx_unit_tl }
+ {
+ \prop_if_in:NnF \l__siunitx_number_out_prop { exponent }
+ { \__siunitx_number_format_brackets:n { result } }
+ }
+ \__siunitx_number_output_bracket:
+ \prop_get:NnN \l__siunitx_number_out_prop { result }
+ \l__siunitx_number_out_tl
+ \__siunitx_number_output_single_aux:
+}
+\cs_new_protected:Npn \__siunitx_number_output_single_aux: {
+ \__siunitx_unit_output_pre_print:
+ \quark_if_no_value:NTF \l__siunitx_number_out_tl
+ { \tl_clear:N \l__siunitx_number_unit_product_tl }
+ { \__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-product .tl_set:N =
+ \l__siunitx_angle_unit_product_tl ,
+ number-angle-separator .tl_set:N =
+ \l__siunitx_angle_unit_product_tl ,
+}
+\cs_new_protected:Npn \__siunitx_angle_output:nnn #1#2#3 {
+ \__siunitx_angle_init:
+ \IfNoValueTF {#2}
+ {
+ \bool_set_false:N \l__siunitx_angle_minute_zero_bool
+ \bool_set_false:N \l__siunitx_angle_second_zero_bool
+ \__siunitx_angle_output_aux:nnn {#1} { } { }
+ }
+ {
+ \IfNoValueTF {#3}
+ { \__siunitx_error:nx { invalid-arc-format } { #1 ; #2 } }
+ { \__siunitx_angle_output_aux:nnn {#1} {#2} {#3} }
+ }
+}
+\cs_new_protected:Npn \__siunitx_angle_output_aux:nnn #1#2#3 {
+ \tl_if_empty:nTF { #1#2#3 }
+ { \__siunitx_error:n { empty-arc } }
+ {
+ \bool_if:NTF \l__siunitx_number_parse_bool
+ { \__siunitx_angle_parse:nnn {#1} {#2} {#3} }
+ { \__siunitx_angle_direct:nnn {#1} {#2} {#3} }
+ }
+}
+\cs_new_protected: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_product_tl
+ \l__siunitx_angle_unit_product_tl
+ \cs_set_eq:NN \__siunitx_number_in_parse_more:N
+ \__siunitx_number_in_parse_restricted:N
+}
+\cs_new_protected:Npn \__siunitx_angle_direct:nnn #1 {
+ \tl_if_empty:nTF {#1}
+ {
+ \bool_if:NTF \l__siunitx_angle_degree_zero_bool
+ { \__siunitx_angle_direct_aux_i:nnn { 0 } }
+ { \__siunitx_angle_direct_aux_i:nnn { } }
+ }
+ { \__siunitx_angle_direct_aux_i:nnn {#1} }
+}
+\cs_new_protected:Npn \__siunitx_angle_direct_aux_i:nnn #1#2 {
+ \tl_if_empty:nTF {#2}
+ {
+ \bool_if:NTF \l__siunitx_angle_minute_zero_bool
+ { \__siunitx_angle_direct_aux_ii:nnn {#1} { 0 } }
+ { \__siunitx_angle_direct_aux_ii:nnn {#1} { } }
+ }
+ { \__siunitx_angle_direct_aux_ii:nnn {#1} {#2} }
+}
+\cs_new_protected:Npn \__siunitx_angle_direct_aux_ii:nnn #1#2#3 {
+ \tl_if_empty:nTF {#3}
+ {
+ \bool_if:NTF \l__siunitx_angle_second_zero_bool
+ { \__siunitx_angle_direct_aux_iii:nnn {#1} {#2} { 0 } }
+ { \__siunitx_angle_direct_aux_iii:nnn {#1} {#2} { } }
+ }
+ { \__siunitx_angle_direct_aux_iii:nnn {#1} {#2} {#3} }
+}
+\cs_new_protected:Npn \__siunitx_angle_direct_aux_iii:nnn #1#2#3 {
+ \tl_if_empty:nF {#1}
+ {
+ \tl_if_empty:nF {#2#3}
+ { \bool_set_true:N \l__siunitx_angle_degree_space_bool }
+ }
+ \tl_if_empty:nF {#2}
+ {
+ \tl_if_empty:nF {#3}
+ { \bool_set_true:N \l__siunitx_angle_minute_space_bool }
+ }
+ \__siunitx_angle_print_direct:nnn {#1} {#2} {#3}
+}
+\cs_new_protected:Npn \__siunitx_angle_parse:nnn #1#2#3 {
+ \__siunitx_angle_parse_aux:nn {#1} { degree }
+ \__siunitx_angle_parse_aux:nn {#2} { minute }
+ \__siunitx_angle_parse_aux:nn {#3} { second }
+ \__siunitx_angle_check_sign:
+ \__siunitx_angle_zero_fill:
+ \prop_if_empty:NF \l__siunitx_angle_degree_prop
+ {
+ \prop_if_empty:NF \l__siunitx_angle_minute_prop
+ { \bool_set_true:N \l__siunitx_angle_degree_space_bool }
+ \prop_if_empty:NF \l__siunitx_angle_second_prop
+ { \bool_set_true:N \l__siunitx_angle_degree_space_bool }
+ }
+ \prop_if_empty:NF \l__siunitx_angle_minute_prop
+ {
+ \prop_if_empty:NF \l__siunitx_angle_second_prop
+ { \bool_set_true:N \l__siunitx_angle_minute_space_bool }
+ }
+ \__siunitx_angle_print:
+}
+\cs_new_protected:Npn \__siunitx_angle_parse_aux:nn #1#2 {
+ \prop_clear:N \l__siunitx_number_in_prop
+ \tl_if_empty:nF {#1}
+ {
+ \__siunitx_number_in_init:
+ \__siunitx_number_in_parse_aux:n {#1}
+ }
+ \prop_get:NnNT \l__siunitx_number_in_prop { mantissa-sign-deleted }
+ \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_new_protected:Npn \__siunitx_angle_check_sign: {
+ \prop_if_empty:NTF \l__siunitx_angle_degree_prop
+ {
+ \prop_if_empty:NF \l__siunitx_angle_minute_prop
+ { \__siunitx_angle_check_sign_aux:n { second } }
+ }
+ {
+ \__siunitx_angle_check_sign_aux:n { minute }
+ \__siunitx_angle_check_sign_aux:n { second }
+ }
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_angle_zero_fill: {
+ \bool_lazy_and:nnT
+ { \l__siunitx_angle_second_zero_bool }
+ { \prop_if_empty_p:N \l__siunitx_angle_second_prop }
+ {
+ \prop_put:Nnn \l__siunitx_angle_second_prop { mantissa }
+ { true }
+ \prop_put:Nnn \l__siunitx_angle_second_prop { mantissa-integer }
+ { 0 }
+ }
+ \bool_lazy_and:nnT
+ { \l__siunitx_angle_minute_zero_bool }
+ { \prop_if_empty_p:N \l__siunitx_angle_minute_prop }
+ {
+ \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_lazy_and:nnT
+ { \l__siunitx_angle_degree_zero_bool }
+ { \prop_if_empty_p:N \l__siunitx_angle_degree_prop }
+ {
+ \prop_put:Nnn \l__siunitx_angle_degree_prop { mantissa }
+ { true }
+ \prop_put:Nnn \l__siunitx_angle_degree_prop { mantissa-integer }
+ { 0 }
+ \__siunitx_angle_sign_shuffle:nn { second } { degree }
+ \__siunitx_angle_sign_shuffle:nn { minute } { degree }
+ }
+}
+\cs_new_protected:Npn \__siunitx_angle_sign_shuffle:nn #1#2 {
+ \__siunitx_angle_sign_shuffle_aux:nnn {#1} {#2} { }
+ \__siunitx_angle_sign_shuffle_aux:nnn {#1} {#2} { -deleted }
+}
+\cs_new_protected: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_remove: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_new_protected:Npn \__siunitx_angle_print: {
+ \__siunitx_angle_print_aux:nn { degree } { \SIUnitSymbolDegree }
+ \bool_if:NT \l__siunitx_angle_degree_space_bool
+ {
+ \nobreak
+ \l__siunitx_angle_arc_separator_tl
+ }
+ \__siunitx_angle_print_aux:nn { minute } { \SIUnitSymbolArcminute }
+ \bool_if:NT \l__siunitx_angle_minute_space_bool
+ {
+ \nobreak
+ \l__siunitx_angle_arc_separator_tl
+ }
+ \__siunitx_angle_print_aux:nn { second } { \SIUnitSymbolArcsecond }
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_angle_print_astronomy: {
+ \prop_if_in:NnTF \l__siunitx_number_in_prop
+ { mantissa-decimal-marker }
+ { \__siunitx_angle_print_astronomy_aux: }
+ { \__siunitx_number_output_single: }
+}
+\cs_new_protected:Npn \__siunitx_angle_print_astronomy_aux: {
+ \prop_get:NnNF \l__siunitx_number_out_prop { mantissa-sign }
+ \l__siunitx_tmpa_tl
+ { \tl_clear:N \l__siunitx_tmpa_tl }
+ \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-integer }
+ \l__siunitx_tmpb_tl
+ {
+ \tl_put_right:NV \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl
+ \__siunitx_print:nV { number } \l__siunitx_tmpa_tl
+ }
+ \hbox_set:Nn \l__siunitx_angle_marker_box
+ {
+ \__siunitx_print:nn { number } { { \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:NnNT \l__siunitx_number_out_prop { mantissa-decimal }
+ \l__siunitx_tmpa_tl
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+}
+\cs_new_protected:Npn \__siunitx_angle_print_astronomy_aux:n #1 {
+ \dim_set:cn { l__siunitx_angle_ #1 _dim }
+ { \box_wd:c { l__siunitx_angle_ #1 _box } }
+ \hbox_set_to_wd:cnn { l__siunitx_angle_ #1 _box } { \c_zero_skip }
+ {
+ \tex_hss:D
+ \hbox_unpack:c { l__siunitx_angle_ #1_box }
+ \tex_hss:D
+ }
+}
+\cs_new_protected:Npn \__siunitx_angle_print_astronomy_marker: {
+ \hbox_set_to_wd:Nnn \l__siunitx_angle_marker_box
+ { \l__siunitx_angle_marker_dim }
+ {
+ \tex_hss:D
+ \hbox_unpack:N \l__siunitx_angle_marker_box
+ \tex_hss:D
+ }
+ \box_use:N \l__siunitx_angle_marker_box
+}
+\cs_new_protected:Npn \__siunitx_angle_print_astronomy_unit: {
+ \hbox_set_to_wd:Nnn \l__siunitx_angle_marker_box
+ { \l__siunitx_angle_unit_dim }
+ {
+ \tex_hss:D
+ \hbox_unpack:N \l__siunitx_angle_marker_box
+ \tex_hss:D
+ }
+ \box_use:N \l__siunitx_angle_marker_box
+ \skip_horizontal:N \scriptspace
+}
+\cs_new_protected:Npn \__siunitx_angle_print_direct:nnn #1#2#3 {
+ \__siunitx_angle_print_direct_aux:nn {#1} { \SIUnitSymbolDegree }
+ \bool_if:NT \l__siunitx_angle_degree_space_bool
+ {
+ \nobreak
+ \l__siunitx_angle_arc_separator_tl
+ }
+ \__siunitx_angle_print_direct_aux:nn {#2} { \SIUnitSymbolArcminute }
+ \bool_if:NT \l__siunitx_angle_minute_space_bool
+ {
+ \nobreak
+ \l__siunitx_angle_arc_separator_tl
+ }
+ \__siunitx_angle_print_direct_aux:nn {#3} { \SIUnitSymbolArcsecond }
+}
+\cs_new_protected: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 } { \ensuremath {#1} }
+ \__siunitx_unit_output_print:
+ }
+}
+\seq_new:N \l_siunitx_unit_symbolic_seq
+\seq_put_right:Nn \l_siunitx_unit_symbolic_seq { \of }
+\seq_put_right:Nn \l_siunitx_unit_symbolic_seq { \highlight }
+\seq_put_right:Nn \l_siunitx_unit_symbolic_seq { \per }
+\seq_put_right:Nn \l_siunitx_unit_symbolic_seq { \raiseto }
+\seq_put_right:Nn \l_siunitx_unit_symbolic_seq { \tothe }
+\cs_new_protected:Npn \__siunitx_declare_power_after:Nn #1#2 {
+ \seq_put_right:Nn \l_siunitx_unit_symbolic_seq {#1}
+ \cs_set:cpn { __siunitx_ \token_to_str:N #1 _literal:w }
+ { \__siunitx_textsuperscript:n {#2} }
+ \cs_set:cpn { __siunitx_ \token_to_str:N #1 _function:w }
+ { \__siunitx_unit_parse_power_after:n {#2} }
+}
+\cs_new_protected:Npn \__siunitx_declare_power_before:Nn #1#2 {
+ \seq_put_right:Nn \l_siunitx_unit_symbolic_seq {#1}
+ \cs_set:cpn { __siunitx_ \token_to_str:N #1 _literal:w } ##1
+ { ##1 \__siunitx_textsuperscript:n {#2} }
+ \cs_set:cpn { __siunitx_ \token_to_str:N #1 _function:w }
+ { \__siunitx_unit_parse_power_before:n {#2} }
+}
+\cs_new_protected:Npn \__siunitx_declare_prefix:Nnnn #1#2#3#4
+ {
+ \seq_put_right:Nn \l_siunitx_unit_symbolic_seq {#1}
+ \prop_put:Nnn \l__siunitx_prefix_forward_prop {#1} {#4}
+ \prop_put:Nnn \l__siunitx_prefix_reverse_prop {#4} {#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:Nn #1 {#2} }
+ { \__siunitx_unit_parse_prefix:nn {#3} {#4} }
+ }
+ }
+\prop_new:N \l__siunitx_prefix_forward_prop
+\prop_new:N \l__siunitx_prefix_reverse_prop
+\cs_new_protected:Npn \__siunitx_declare_qualifier:Nn #1#2 {
+ \seq_put_right:Nn \l_siunitx_unit_symbolic_seq {#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_new_protected:Npn \__siunitx_declare_unit:Nnn #1#2#3 {
+ \seq_put_right:Nn \l_siunitx_unit_symbolic_seq {#1}
+ \cs_set:cpn { __siunitx_ \token_to_str:N #1 _literal:w } {#2}
+ \cs_set_protected:cpn { __siunitx_ \token_to_str:N #1 _function:w }
+ {
+ \__siunitx_unit_if_literal:nTF {#2}
+ { \__siunitx_unit_parse_unit:Nn #1 {#2} }
+ {#2}
+ }
+ \tl_if_empty:nTF {#3}
+ { \cs_undefine:c { l__siunitx_ \token_to_str:N #1 _options_tl } }
+ {
+ \tl_clear_new:c { l__siunitx_ \token_to_str:N #1 _options_tl }
+ \tl_set:cn { l__siunitx_ \token_to_str:N #1 _options_tl } {#3}
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_first_token:n #1 {
+ \exp_last_unbraced:No \token_to_str:N { \tl_head:w #1 \q_stop }
+}
+\cs_new:cpn { __siunitx_ \token_to_str:N \per _literal:w } { / }
+\cs_new_protected:cpn { __siunitx_ \token_to_str:N \per _function:w } {
+ \bool_set_true:N \l__siunitx_per_bool
+ \__siunitx_unit_parse_per:
+}
+\cs_new:cpn { __siunitx_ \token_to_str:N \raiseto _literal:w } #1#2 {
+ #2
+ \__siunitx_textsuperscript:n {#1}
+}
+\cs_new_protected:cpn { __siunitx_ \token_to_str:N \raiseto _function:w }
+ #1 {
+ \__siunitx_unit_parse_power_before:n {#1}
+}
+\cs_new:cpn { __siunitx_ \token_to_str:N \tothe _literal:w } #1 {
+ \__siunitx_textsuperscript:n {#1}
+}
+\cs_new_protected:cpn { __siunitx_ \token_to_str:N \tothe _function:w }
+ #1 {
+ \__siunitx_unit_parse_power_after:n {#1}
+}
+\cs_new:cpn { __siunitx_ \token_to_str:N \of _literal:w } #1 {
+ \text { ~ } ( #1 )
+}
+\cs_new_protected:cpn { __siunitx_ \token_to_str:N \of _function:w } #1 {
+ \__siunitx_unit_parse_qualifier:n {#1}
+}
+\AtBeginDocument {
+ \cs_if_exist:NT \cancel
+ {
+ \cs_set_protected:Npn \__siunitx_cancel:n #1
+ { \__siunitx__real_cancel:n { \__siunitx_print:nn { unit } {#1} } }
+ \cs_set_eq:NN \__siunitx__real_cancel:n \cancel
+ \seq_put_right:Nn \l_siunitx_unit_symbolic_seq { \cancel }
+ \cs_new_protected:cpn
+ { __siunitx_ \token_to_str:N \cancel _function:w }
+ { \__siunitx_unit_parse_special:n { \__siunitx_cancel:n } }
+ }
+}
+\cs_new:cpn
+ { __siunitx_ \token_to_str:N \highlight _literal:w } #1
+ { \__siunitx_textcolor:n {#1} }
+\cs_new_protected:cpn
+ { __siunitx_ \token_to_str:N \highlight _function:w } #1
+ { \__siunitx_unit_parse_special:n { \__siunitx_textcolor: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 ,
+}
+\cs_new_protected:Npn \__siunitx_unit_create_empty_functions:
+ {
+ \__siunitx_unit_create_functions_aux_i:
+ \seq_map_function:NN \l_siunitx_unit_symbolic_seq
+ \__siunitx_unit_create_empty_functions_aux:N
+ \__siunitx_unit_create_functions_aux_ii:
+ }
+\cs_new_protected:Npn \__siunitx_unit_create_empty_functions_aux:N #1
+ {
+ \cs_if_free:NT #1
+ { \cs_set_protected:Npn #1 { \ERROR } }
+ }
+\cs_new_protected:Npn \__siunitx_unit_create_functions:
+ {
+ \__siunitx_unit_create_functions_aux_i:
+ \bool_if:NT \l__siunitx_create_overwrite_bool
+ { \seq_map_function:NN \l_siunitx_unit_symbolic_seq \cs_undefine:N }
+ \bool_if:NTF \l__siunitx_create_optional_bool
+ {
+ \seq_map_function:NN \l_siunitx_unit_symbolic_seq
+ \__siunitx_unit_create_with_arg:N
+ }
+ {
+ \seq_map_function:NN \l_siunitx_unit_symbolic_seq
+ \__siunitx_unit_create:N
+ }
+ \__siunitx_unit_create_functions_aux_ii:
+ \bool_if:NT \l__siunitx_create_xspace_bool
+ { \RequirePackage { xspace } }
+ }
+\cs_new_protected:Npn \__siunitx_unit_create_functions_aux_i:
+ {
+ \@ifpackageloaded { soulpos }
+ {
+ \@ifpackageloaded { soul }
+ { }
+ {
+ \cs_set_protected:Npn \__siunitx_unit_create_functions_aux_ii:
+ {
+ \cs_undefine:N \hl
+ \cs_undefine:N \ul
+ }
+ }
+ }
+ { }
+ }
+\cs_new_protected:Npn \__siunitx_unit_create_functions_aux_ii: { }
+\cs_new_protected:Npn \__siunitx_unit_create:N #1 {
+ \cs_if_free:NT #1
+ {
+ \cs_set:Npx \__siunitx_tmp:w
+ {
+ \ProvideDocumentCommand \exp_not:N #1 { }
+ {
+ \group_begin:
+ \exp_not:N \cs_if_free:NF
+ \exp_not:c
+ { l__siunitx_ \token_to_str:N #1 _options_tl }
+ {
+ \keys_set:nV { siunitx }
+ \exp_not:c
+ { l__siunitx_ \token_to_str:N #1 _options_tl }
+ }
+ \bool_if:NT \l__siunitx_create_prespace_bool
+ { \exp_not:N \l__siunitx_number_unit_product_tl }
+ \exp_not:n { \__siunitx_unit_output:nn {#1} { } }
+ \group_end:
+ \bool_if:NT \l__siunitx_create_xspace_bool
+ { \exp_not:N \xspace }
+ }
+ }
+ \__siunitx_tmp:w
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_create_with_arg:N #1 {
+ \cs_if_free:NT #1
+ {
+ \cs_set:Npx \__siunitx_tmp:w
+ {
+ \ProvideDocumentCommand \exp_not:N #1 { o }
+ {
+ \group_begin:
+ \exp_not:N \cs_if_free:NF
+ \exp_not:c
+ { l__siunitx_ \token_to_str:N #1 _options_tl }
+ {
+ \keys_set:nV { siunitx }
+ \exp_not:c
+ {
+ l__siunitx_ \token_to_str:N #1 _options_tl
+ }
+ }
+ \exp_not:N \IfNoValueTF {####1}
+ {
+ \bool_if:NT \l__siunitx_create_prespace_bool
+ { \exp_not:N \l__siunitx_number_unit_product_tl }
+ \exp_not:n { \__siunitx_unit_output:nn {#1} { } }
+ }
+ { \SI {####1} { \exp_not:N #1 } }
+ \group_end:
+ \bool_if:NT \l__siunitx_create_xspace_bool
+ { \exp_not:N \xspace }
+ }
+ }
+ \__siunitx_tmp:w
+ }
+}
+\AtBeginDocument {
+ \cs_if_eq:NNT \color \use_none:n
+ { \cs_set_protected:Npn \color #1 { } }
+ \cs_set:Npn \__siunitx_tmp:w #1 { }
+ \cs_if_eq:NNT \color \__siunitx_tmp:w
+ { \cs_set_protected:Npn \color #1 { } }
+ \tl_map_function:nN { \bar \color \ng \pm \array@row@rst }
+ \__siunitx_protect_symbols:N
+}
+\__siunitx_if_hooks:TF
+ {
+ \AddToHook { begindocument / end } [ siunitx ]
+ { \__siunitx_protect_symbols:N \fg }
+ }
+ {
+ \tl_put_right:Nn \document
+ {
+ \__siunitx_protect_symbols:N \fg
+ \ignorespaces
+ }
+ }
+\cs_new_protected:Npn \__siunitx_protect_symbols:N #1 {
+ \cs_if_exist:NT #1
+ {
+ \tl_if_empty:fT { \cs_prefix_spec:N #1 }
+ { \cs_set_protected: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_new_protected:Npn \__siunitx_unit_in:nn #1#2 {
+ \bool_if:NTF \l__siunitx_unit_parse_bool
+ {
+ \tl_if_empty:nF {#1}
+ {
+ \__siunitx_unit_if_literal:nTF {#1}
+ {
+ \tl_clear:N \l__siunitx_per_mode_tl
+ \bool_if:NTF \l__siunitx_unit_forbid_literal_bool
+ {
+ \msg_error:nnx { siunitx } { literal-unit }
+ { \exp_not:n {#1} }
+ }
+ {
+ \cs_set_eq:NN \__siunitx_pm: \pm
+ \__siunitx_unit_format_literal:n {#1}
+ \cs_set_eq:NN \pm \__siunitx_pm:
+ }
+ }
+ {
+ \cs_set_eq:NN \__siunitx_pm: \pm
+ \__siunitx_unit_parse:nn {#1} {#2}
+ \__siunitx_unit_format:
+ \prop_set_eq:NN \l__siunitx_unit_saved_prop \l__siunitx_unit_prop
+ \cs_set_eq:NN \pm \__siunitx_pm:
+ }
+ }
+ }
+ { \__siunitx_unit_format_literal:n {#1} }
+}
+\cs_generate_variant:Nn \__siunitx_unit_in:nn { V }
+\cs_new:Npn \__siunitx_pm: { }
+\cs_new_protected:Npn \__siunitx_unit_if_literal:nTF #1#2#3 {
+ \group_begin:
+ \seq_map_function:NN \l_siunitx_unit_symbolic_seq
+ \__siunitx_unit_if_literal_aux:N
+ \cs_set_eq:NN \of \use_none:n
+ \cs_set_eq:NN \highlight \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_blank:VTF \l__siunitx_tmpa_tl {#3} {#2}
+}
+\cs_new_protected:Npn \__siunitx_unit_if_literal_aux:N #1 {
+ \cs_set_eq:NN #1 \prg_do_nothing:
+}
+\int_new:N \l__siunitx_unit_int
+\prop_new:N \l__siunitx_unit_prop
+\prop_new:N \l__siunitx_unit_saved_prop
+\bool_new:N \l__siunitx_per_bool
+\keys_define:nn { siunitx }
+ {
+ exponent-to-prefix .bool_set:N = \l__siunitx_exp_to_prefix_bool ,
+ 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_new_protected:Npn \__siunitx_unit_parse:nn #1#2 {
+ \__siunitx_unit_parse_init:
+ \__siunitx_unit_parse_options:nn {#1} {#2}
+ #1
+}
+\cs_new_protected: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
+ \seq_map_inline:Nn \l_siunitx_unit_symbolic_seq
+ { \cs_set_eq:Nc ##1 { __siunitx_ \token_to_str:N ##1 _function:w } }
+ }
+\cs_new_protected:Npn \__siunitx_unit_parse_options:nn #1#2 {
+ \tl_if_single:nT {#1}
+ {
+ \cs_if_free:cF
+ { l__siunitx_ \__siunitx_unit_first_token:n {#1} _options_tl }
+ {
+ \keys_set:nv { siunitx }
+ { l__siunitx_ \__siunitx_unit_first_token:n {#1} _options_tl }
+ \keys_set:nn { siunitx } {#2}
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_parse_power_before:n #1 {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { power- \int_eval:n { \l__siunitx_unit_int + 1 } }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl {#1}
+}
+\cs_new_protected:Npn \__siunitx_unit_parse_power_after:n #1 {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { power- \int_use:N \l__siunitx_unit_int }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl {#1}
+}
+\cs_new_protected:Npn \__siunitx_unit_parse_prefix:Nn #1#2
+ {
+ \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}
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { prefix-symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl {#2}
+ }
+\cs_new_protected:Npn \__siunitx_unit_parse_prefix:nn #1#2
+ {
+ \__siunitx_unit_parse_prefix:Nn \ERROR {#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_new_protected:Npn \__siunitx_unit_parse_per: {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { per- \int_eval:n { \l__siunitx_unit_int + 1 } }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl { true }
+ \bool_if:NT \l__siunitx_sticky_per_bool
+ { \cs_set_eq:NN \per \__siunitx_unit_parse_per_error: }
+}
+\cs_new_protected:Npn \__siunitx_unit_parse_per_error: {
+ \msg_error:nn { siunitx } { duplicate-sticky-per }
+}
+\cs_new_protected:Npn \__siunitx_unit_parse_qualifier:n #1 {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_if_in:NVF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ { \msg_error:nn { siunitx } { qualifier-before-unit } }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { qualifier- \int_use:N \l__siunitx_unit_int }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl {#1}
+}
+\cs_new_protected:Npn \__siunitx_unit_parse_special:n #1 {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { special- \int_eval:n { \l__siunitx_unit_int + 1 } }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl {#1}
+}
+\cs_new_protected:Npn \__siunitx_unit_parse_unit:Nn #1#2 {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { prefix-symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_if_in:NVTF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_if_in:NVT \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ { \int_incr:N \l__siunitx_unit_int }
+ }
+ { \int_incr:N \l__siunitx_unit_int }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { unit- \int_use:N \l__siunitx_unit_int }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl {#1}
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpa_tl {#2}
+ \__siunitx_unit_parse_unit_per:
+}
+\cs_new_protected: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_omit_unit_space_bool
+\bool_new:N \l__siunitx_per_auto_bool
+\bool_new:N \l__siunitx_per_fraction_bool
+\tl_new:N \l__siunitx_per_mode_tl
+\bool_new:N \l__siunitx_power_number_bool
+\bool_new:N \l__siunitx_per_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-product .tl_set:N = \l__siunitx_unit_product_tl ,
+ inter-unit-separator .tl_set:N = \l__siunitx_unit_product_tl ,
+ literal-superscript-as-power
+ .bool_set:N = \l__siunitx_literal_power_bool,
+ per-mode .choice:,
+ per-mode / fraction .code:n =
+ {
+ \bool_set_false:N \l__siunitx_per_auto_bool
+ \bool_set_true:N \l__siunitx_per_fraction_bool
+ \bool_set_true:N \l__siunitx_per_two_parts_bool
+ \tl_set:Nn \l__siunitx_per_mode_tl { fraction }
+ },
+ per-mode / power .meta:n = { per-mode = reciprocal } ,
+ per-mode / power-positive-first .meta:n =
+ { per-mode = reciprocal-positive-first } ,
+ per-mode / reciprocal .code:n =
+ {
+ \bool_set_false:N \l__siunitx_per_auto_bool
+ \bool_set_false:N \l__siunitx_per_fraction_bool
+ \bool_set_false:N \l__siunitx_per_two_parts_bool
+ \tl_clear:N \l__siunitx_per_mode_tl
+ },
+ per-mode / reciprocal-positive-first .code:n =
+ {
+ \bool_set_false:N \l__siunitx_per_auto_bool
+ \bool_set_false:N \l__siunitx_per_fraction_bool
+ \bool_set_true:N \l__siunitx_per_two_parts_bool
+ \tl_clear:N \l__siunitx_per_mode_tl
+ },
+ per-mode / repeated-symbol .code:n =
+ {
+ \bool_set_false:N \l__siunitx_per_auto_bool
+ \bool_set_false:N \l__siunitx_per_fraction_bool
+ \bool_set_false:N \l__siunitx_per_two_parts_bool
+ \tl_set:Nn \l__siunitx_per_mode_tl { repeat }
+ },
+ per-mode / symbol .code:n =
+ {
+ \bool_set_false:N \l__siunitx_per_auto_bool
+ \bool_set_true:N \l__siunitx_per_fraction_bool
+ \bool_set_true:N \l__siunitx_per_two_parts_bool
+ \tl_set:Nn \l__siunitx_per_mode_tl { symbol }
+ },
+ per-mode / symbol-or-fraction .code:n =
+ {
+ \bool_set_true:N \l__siunitx_per_auto_bool
+ \bool_set_true:N \l__siunitx_per_fraction_bool
+ \bool_set_true:N \l__siunitx_per_two_parts_bool
+ \tl_set:Nn \l__siunitx_per_mode_tl { symbol }
+ },
+ per-symbol .tl_set:N = \l__siunitx_per_symbol_tl,
+ power-font .choice:,
+ power-font / number .code:n =
+ { \bool_set_true:N \l__siunitx_power_number_bool },
+ power-font / unit .code:n =
+ { \bool_set_false:N \l__siunitx_power_number_bool },
+ qualifier-mode .choice:,
+ qualifier-mode / brackets .code:n =
+ { \tl_set:Nn \l__siunitx_qualifier_mode_tl { brackets } },
+ qualifier-mode / phrase .code:n =
+ { \tl_set:Nn \l__siunitx_qualifier_mode_tl { phrase } },
+ qualifier-mode / space .code:n =
+ { \tl_set:Nn \l__siunitx_qualifier_mode_tl { space } },
+ qualifier-mode / subscript .code:n =
+ { \tl_set:Nn \l__siunitx_qualifier_mode_tl { subscript } },
+ qualifier-mode / text .code:n =
+ { \tl_set:Nn \l__siunitx_qualifier_mode_tl { text } },
+ qualifier-phrase .tl_set:N = \l__siunitx_qualifier_phrase_tl
+}
+\keys_set:nn { siunitx } {
+ bracket-unit-denominator = true,
+ inter-unit-product = \,,
+ literal-superscript-as-power = true,
+ per-mode = reciprocal,
+ per-symbol = /,
+ power-font = number,
+ qualifier-mode = subscript,
+ qualifier-phrase = { ~ of ~ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format: {
+ \prop_put:Nnx \l__siunitx_unit_prop { total-units }
+ { \int_use:N \l__siunitx_unit_int }
+ \__siunitx_unit_format_init:
+ \int_while_do:nNnn { \l__siunitx_unit_int } > { 0 }
+ {
+ \__siunitx_unit_format_prefix:
+ \__siunitx_unit_format_symbol:
+ \__siunitx_unit_format_qualifier:
+ \__siunitx_unit_format_power:
+ \__siunitx_unit_format_add:
+ \int_decr:N \l__siunitx_unit_int
+ }
+ \bool_if:NT \l__siunitx_per_two_parts_bool
+ {
+ \bool_if:NTF \l__siunitx_per_fraction_bool
+ { \__siunitx_unit_format_fraction: }
+ { \__siunitx_unit_format_sorted: }
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_add: {
+ \bool_if:NTF \l__siunitx_per_two_parts_bool
+ {
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ { per- \int_use:N \l__siunitx_unit_int }
+ \prop_if_in:NVTF \l__siunitx_unit_prop \l__siunitx_tmpb_tl
+ {
+ \__siunitx_unit_format_add_aux:n { _denominator }
+ \int_incr:N \l__siunitx_unit_denominator_int
+ }
+ {
+ \__siunitx_unit_format_add_aux:n { _numerator }
+ \int_incr:N \l__siunitx_unit_numerator_int
+ }
+ }
+ { \__siunitx_unit_format_add_aux:n { } }
+ \tl_clear:N \l__siunitx_unit_current_tl
+}
+\cs_new_protected:Npn \__siunitx_unit_format_add_aux:n #1 {
+ \tl_if_empty:cF { l__siunitx_unit #1 _tl }
+ {
+ \str_if_eq:VnTF \l__siunitx_per_mode_tl { repeat }
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { per- \int_eval:n { \l__siunitx_unit_int + 1 } }
+ \prop_if_in:NVF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ {
+ \tl_put_right:NV \l__siunitx_unit_current_tl
+ \l__siunitx_unit_product_tl
+ }
+ }
+ {
+ \tl_put_right:NV \l__siunitx_unit_current_tl
+ \l__siunitx_unit_product_tl
+ }
+ }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { special- \int_use:N \l__siunitx_unit_int }
+ \prop_get:NVNTF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ \l__siunitx_tmpa_tl
+ {
+ \tl_put_left:cx { l__siunitx_unit #1 _tl }
+ {
+ \exp_not:V \l__siunitx_tmpa_tl
+ { \exp_not:V \l__siunitx_unit_current_tl }
+ }
+ }
+ {
+ \tl_put_left:cV { l__siunitx_unit #1 _tl }
+ \l__siunitx_unit_current_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_fraction: {
+ \int_compare:nNnT { \l__siunitx_unit_numerator_int } = { 0 }
+ {
+ \str_if_eq:VnT \l__siunitx_per_mode_tl { symbol }
+ { \bool_set_true:N \l__siunitx_omit_unit_space_bool }
+ }
+ \int_compare:nNnTF { \l__siunitx_unit_denominator_int } > { 0 }
+ {
+ \bool_if:NTF \l__siunitx_per_auto_bool
+ { \__siunitx_unit_format_fraction_auto: }
+ {
+ \use:c
+ { __siunitx_unit_format_fraction_ \l__siunitx_per_mode_tl : }
+ }
+ }
+ { \tl_set_eq:NN \l__siunitx_unit_tl \l__siunitx_unit_numerator_tl }
+}
+\cs_new_protected: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_new_protected:Npn \__siunitx_unit_format_fraction_auto: {
+ \mode_if_math:TF
+ {
+ \group_begin:
+ \__siunitx_unit_format_fraction_fraction:
+ \exp_args:NNNV \group_end:
+ \tl_set:Nn \l__siunitx_tmpa_tl \l__siunitx_unit_tl
+ \group_begin:
+ \__siunitx_unit_format_fraction_symbol:
+ \exp_args:NNNV \group_end:
+ \tl_set:Nn \l__siunitx_tmpb_tl \l__siunitx_unit_tl
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ {
+ \__siunitx_print:nn { unit }
+ { \exp_not:V \l__siunitx_tmpb_tl }
+ }
+ \tl_set:Nx \l__siunitx_unit_tl
+ {
+ \exp_not:N \ensuremath {
+ \tex_mathchoice:D
+ { \exp_not:V \l__siunitx_tmpa_tl }
+ { \exp_not:V \l__siunitx_tmpb_tl }
+ { \exp_not:V \l__siunitx_tmpb_tl }
+ { \exp_not:V \l__siunitx_tmpb_tl }
+ }
+ }
+ }
+ { \__siunitx_unit_format_fraction_symbol: }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_fraction_symbol: {
+ \__siunitx_unit_format_fraction_symbol_aux:
+ \int_compare:nNnT { \l__siunitx_unit_denominator_int } > { 1 }
+ {
+ \bool_if:NT \l__siunitx_unit_denominator_bracket_bool
+ {
+ \tl_put_left:NV \l__siunitx_unit_denominator_tl \l__siunitx_bracket_open_tl
+ \tl_put_right:NV \l__siunitx_unit_denominator_tl \l__siunitx_bracket_close_tl
+ }
+ }
+ \tl_set_eq:NN \l__siunitx_unit_tl \l__siunitx_unit_numerator_tl
+ \tl_put_right:NV \l__siunitx_unit_tl \l__siunitx_per_symbol_tl
+ \tl_put_right:NV \l__siunitx_unit_tl \l__siunitx_unit_denominator_tl
+}
+\cs_new_protected:Npn
+ \__siunitx_unit_format_fraction_symbol_aux: { }
+\cs_new_protected: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_new_protected:Npn \__siunitx_unit_format_init: {
+ \bool_set_false:N \l__siunitx_omit_unit_space_bool
+ \tl_clear:N \l__siunitx_unit_tl
+ \tl_clear:N \l__siunitx_unit_current_tl
+ \tl_clear:N \l__siunitx_unit_denominator_tl
+ \int_zero:N \l__siunitx_unit_prefix_gram_int
+ \tl_clear:N \l__siunitx_unit_numerator_tl
+ \int_zero:N \l__siunitx_unit_prefix_base_int
+ \int_zero:N \l__siunitx_unit_prefix_int
+ \int_zero:N \l__siunitx_unit_denominator_int
+ \int_zero:N \l__siunitx_unit_numerator_int
+ \seq_map_inline:Nn \l_siunitx_unit_symbolic_seq
+ { \__siunitx_unit_print_literal_aux:N ##1 }
+}
+\group_begin:
+ \char_set_catcode_active:N \~
+ \cs_new_protected:Npn \__siunitx_unit_format_literal:n #1
+ {
+ \int_zero:N \l__siunitx_unit_prefix_int
+ \seq_map_inline:Nn \l_siunitx_unit_symbolic_seq
+ { \__siunitx_unit_print_literal_aux:N ##1 }
+ \tl_set:Nn \l__siunitx_unit_tl {#1}
+ \tl_replace_all:NnV \l__siunitx_unit_tl { . }
+ \l__siunitx_unit_product_tl
+ \tl_replace_all:NnV \l__siunitx_unit_tl { ~ }
+ \l__siunitx_unit_product_tl
+ \bool_if:NT \l__siunitx_literal_power_bool
+ {
+ \tl_replace_all:Nnn \l__siunitx_unit_tl { ^ }
+ { \__siunitx_unit_format_literal_power:n }
+ \tl_replace_all:Non \l__siunitx_unit_tl { \token_to_str:N ^ }
+ { \__siunitx_unit_format_literal_power:n }
+ }
+ \__siunitx_unit_format_literal_extras:
+ }
+\group_end:
+\cs_new_protected:Npn \__siunitx_unit_print_literal_aux:N #1
+ { \cs_set_eq:Nc #1 { __siunitx_ \token_to_str:N #1 _literal:w } }
+\cs_new_protected:Npn \__siunitx_unit_format_literal_power:n #1
+ { \PrintSuperscript { \__siunitx_unit_format_power_aux:n {#1} } }
+ %\end{macro}
+\cs_new_protected:Npn \__siunitx_unit_format_literal_extras:
+ {
+ \__siunitx_unit_format_literal_extras_aux:nN { 176 }
+ \SIUnitSymbolDegree
+ \__siunitx_unit_format_literal_extras_aux:nN { 181 }
+ \SIUnitSymbolMicro
+ \__siunitx_unit_format_literal_extras_aux:nN { 197 }
+ \SIUnitSymbolAngstrom
+ }
+\cs_new_protected:Npn \__siunitx_unit_format_literal_extras_aux:nN #1#2
+ {
+ \tl_replace_all:Nxn \l__siunitx_unit_tl
+ { \char_generate:nn { #1 } { 12 } }
+ {#2}
+ }
+\bool_lazy_or:nnF { \sys_if_engine_luatex_p: } { \sys_if_engine_xetex_p: }
+ {
+ \AtBeginDocument
+ {
+ \cs_if_exist:NTF \inputencodingname
+ {
+ \tl_set:Nn \l__siunitx_tmpa_tl { latin1 , latin5 , latin9 }
+ \clist_if_in:NVF \l__siunitx_tmpa_tl \inputencodingname
+ {
+ \cs_set_eq:NN \__siunitx_unit_format_literal_extras:
+ \scan_stop:
+ }
+ }
+ {
+ \cs_set_eq:NN \__siunitx_unit_format_literal_extras:
+ \scan_stop:
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_unit_format_power: {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { power- \int_use:N \l__siunitx_unit_int }
+ \prop_get:NVNTF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ \l__siunitx_tmpa_tl
+ { \__siunitx_unit_format_power_aux: }
+ {
+ \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:
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_power_aux: {
+ \str_if_eq:VnTF \l__siunitx_per_mode_tl { repeat }
+ { \__siunitx_unit_format_power_repeat: }
+ { \__siunitx_unit_format_power_per: }
+ \str_if_eq:VnF \l__siunitx_tmpa_tl { 1 }
+ {
+ \__siunitx_unit_format_power_brackets:
+ \tl_put_right:Nx \l__siunitx_unit_current_tl
+ {
+ \exp_not:N \PrintSuperscript
+ {
+ \__siunitx_unit_format_power_aux:n
+ {
+ \exp_after:wN \__siunitx_unit_format_power:w
+ \l__siunitx_tmpa_tl . . \q_stop
+ }
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_power_aux:n #1 {
+ \bool_if:NTF \l__siunitx_power_number_bool
+ { \__siunitx_unit_format_power_aux:nn { number } {#1} }
+ { \__siunitx_unit_format_power_aux:nn { unit } {#1} }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_power_aux:nn #1#2 {
+ \bool_if:cTF { l__siunitx_ #1 _math_mode_bool }
+ { \__siunitx_print:nn {#1} {#2} }
+ {
+ \tl_set:Nn \l__siunitx_tmpa_tl {#2}
+ \tl_replace_all:Nnn \l__siunitx_tmpa_tl { - }
+ { \text { \textminus } }
+ \__siunitx_print:nV {#1} \l__siunitx_tmpa_tl
+ }
+}
+\cs_new:Npn \__siunitx_unit_format_power:w #1 . #2 . #3 \q_stop
+ {
+ \exp_not:n {#1}
+ \tl_if_blank:nF {#2}
+ {
+ \exp_not:V \l__siunitx_output_decimal_tl
+ \exp_not:n {#2}
+ }
+ }
+\cs_new_protected: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
+ {
+ \tl_put_left:NV \l__siunitx_unit_current_tl \l__siunitx_bracket_open_tl
+ \tl_put_right:NV \l__siunitx_unit_current_tl \l__siunitx_bracket_close_tl
+ }
+}
+\cs_new_protected: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_after:wN \__siunitx_tmp:w \l__siunitx_tmpa_tl \q_stop
+ }
+ { \tl_put_left:Nn \l__siunitx_tmpa_tl { - } }
+ }
+ }
+}
+\cs_new_protected: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
+ {
+ \tl_put_left:NV \l__siunitx_unit_current_tl \l__siunitx_per_symbol_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_prefix: {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { prefix-symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_if_in:NVT \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ {
+ \prop_get:NVN \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ \l__siunitx_unit_prefix_current_tl
+ \bool_if:NTF \l__siunitx_prefix_symbols_bool
+ { \__siunitx_unit_format_prefix_symbol: }
+ { \__siunitx_unit_format_prefix_number: }
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_prefix_number: {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { prefix-base- \int_use:N \l__siunitx_unit_int }
+ \prop_get:NVN \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ \l__siunitx_tmpa_tl
+ \int_compare:nNnT { \l__siunitx_unit_prefix_base_int } = { 0 }
+ {
+ \int_set:Nn \l__siunitx_unit_prefix_base_int
+ { \l__siunitx_tmpa_tl }
+ }
+ \int_compare:nNnTF
+ { \l__siunitx_unit_prefix_base_int } = { \l__siunitx_tmpa_tl }
+ { \__siunitx_unit_format_prefix_number_calc: }
+ { \msg_error:nn { siunitx } { prefix-base-mismatch } }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_prefix_number_calc: {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { power- \int_use:N \l__siunitx_unit_int }
+ \prop_get:NVNF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ \l__siunitx_tmpa_tl
+ { \tl_set:Nn \l__siunitx_tmpa_tl { 1 } }
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ { unit- \int_use:N \l__siunitx_unit_int }
+ \prop_get:NVN \l__siunitx_unit_prop \l__siunitx_tmpb_tl
+ \l__siunitx_tmpb_tl
+ \str_if_eq:VnT \l__siunitx_tmpb_tl { \gram }
+ {
+ \tl_set:Nx \l__siunitx_unit_prefix_current_tl
+ { \int_eval:n { \l__siunitx_unit_prefix_current_tl - 3 } }
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ { symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_put:NVn \l__siunitx_unit_prop \l__siunitx_tmpb_tl { kg }
+ }
+ \tl_set:Nx \l__siunitx_unit_prefix_current_tl
+ {
+ \int_eval:n
+ { \l__siunitx_unit_prefix_current_tl * \l__siunitx_tmpa_tl }
+ }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { per- \int_use:N \l__siunitx_unit_int }
+ \prop_if_in:NVTF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ {
+ \int_set:Nn \l__siunitx_unit_prefix_int
+ {
+ \l__siunitx_unit_prefix_int
+ - \l__siunitx_unit_prefix_current_tl
+ }
+ }
+ {
+ \int_set:Nn \l__siunitx_unit_prefix_int
+ {
+ \l__siunitx_unit_prefix_int
+ + \l__siunitx_unit_prefix_current_tl
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_prefix_symbol: {
+ \tl_set_eq:NN \l__siunitx_unit_current_tl
+ \l__siunitx_unit_prefix_current_tl
+}
+\cs_new_protected:Npn \__siunitx_unit_format_qualifier: {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { qualifier- \int_use:N \l__siunitx_unit_int }
+ \prop_get:NVNT \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ \l__siunitx_tmpa_tl
+ {
+ \use:c
+ {
+ __siunitx_unit_format_qualifier_
+ \l__siunitx_qualifier_mode_tl :
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_qualifier_brackets: {
+ \tl_put_right:NV \l__siunitx_unit_current_tl \l__siunitx_bracket_open_tl
+ \tl_put_right:NV \l__siunitx_unit_current_tl \l__siunitx_tmpa_tl
+ \tl_put_right:NV \l__siunitx_unit_current_tl \l__siunitx_bracket_close_tl
+}
+\cs_new_protected:Npn \__siunitx_unit_format_qualifier_phrase:
+ {
+ \tl_put_right:NV \l__siunitx_unit_current_tl \l__siunitx_qualifier_phrase_tl
+ \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_set_catcode_active:N \~
+\cs_new_protected: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_set_catcode_space:N \~
+\cs_new_protected:Npn \__siunitx_unit_format_qualifier_subscript: {
+ \tl_put_right:Nx \l__siunitx_unit_current_tl
+ { \exp_not:N \PrintSubscript { \exp_not:V \l__siunitx_tmpa_tl } }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_qualifier_text: {
+ \tl_put_right:NV \l__siunitx_unit_current_tl \l__siunitx_tmpa_tl
+}
+\cs_new_protected:Npn \__siunitx_unit_format_sorted:
+ {
+ \tl_set:Nx \l__siunitx_unit_tl
+ {
+ \exp_not:V \l__siunitx_unit_numerator_tl
+ \bool_lazy_or:nnF
+ { \tl_if_empty_p:N \l__siunitx_unit_numerator_tl }
+ { \tl_if_empty_p:N \l__siunitx_unit_denominator_tl }
+ {
+ \exp_not:N \l__siunitx_unit_product_tl
+ }
+ \exp_not:V \l__siunitx_unit_denominator_tl
+ }
+ }
+\cs_new_protected:Npn \__siunitx_unit_format_symbol: {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { symbol- \int_use:N \l__siunitx_unit_int }
+ \prop_get:NVNTF \l__siunitx_unit_prop \l__siunitx_tmpa_tl
+ \l__siunitx_tmpa_tl
+ {
+ \tl_put_right:NV \l__siunitx_unit_current_tl \l__siunitx_tmpa_tl
+ }
+ { \__siunitx_unit_format_symbol_aux: }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_symbol_aux: {
+ \msg_error:nn { siunitx } { prefix-only }
+}
+\cs_new_protected:Npn \__siunitx_unit_format_symbol_aux_alt: {
+ \int_compare:nNnTF { \l__siunitx_unit_int } = { 1 }
+ {
+ \prop_remove:Nn \l__siunitx_unit_prop { prefix-1 }
+ \prop_remove:Nn \l__siunitx_unit_prop { prefix-symbol-1 }
+ \prop_remove:Nn \l__siunitx_unit_prop { prefix-base-1 }
+ \prop_remove:Nn \l__siunitx_unit_prop { total-units }
+ \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_product_repeat_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-product .tl_set:N =
+ \l__siunitx_number_unit_product_tl,
+ number-unit-separator .tl_set:N =
+ \l__siunitx_number_unit_product_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-product = \, ,
+ product-units = repeat
+}
+\cs_new_protected:Npn \__siunitx_unit_output:nn #1#2 {
+ \cs_set_eq:NN \__siunitx_unit_format_symbol_aux:
+ \__siunitx_unit_format_symbol_aux_alt:
+ \cs_set_eq:NN \__siunitx_unit_format_fraction_symbol_aux_ii:
+ \__siunitx_unit_format_fraction_symbol_aux_alt:
+ \__siunitx_unit_in:nn {#1} {#2}
+ \int_compare:nNnTF { \l__siunitx_unit_prefix_int } = { 0 }
+ {
+ \str_if_eq:VnT \l__siunitx_per_mode_tl { symbol }
+ {
+ \int_compare:nNnT { \l__siunitx_unit_numerator_int } = { 0 }
+ {
+ \bool_if:NT \l__siunitx_unit_parse_bool
+ { \__siunitx_print:nn { unit } { 1 } }
+ }
+ }
+ }
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \int_use:N \l__siunitx_unit_prefix_base_int
+ \exp_not:N \PrintSuperscript
+ { \int_use:N \l__siunitx_unit_prefix_int }
+ }
+ \__siunitx_print:nV { number } \l__siunitx_tmpa_tl
+ \__siunitx_unit_output_number_sep:
+ }
+ \__siunitx_print:nV { unit } \l__siunitx_unit_tl
+}
+\cs_generate_variant:Nn \__siunitx_unit_output:nn { V }
+\cs_new_protected:Npn \__siunitx_unit_output_number_sep: {
+ \bool_if:NTF \l__siunitx_number_unit_breaks_bool
+ { \penalty \binoppenalty } { \nobreak }
+ \bool_if:NTF \l__siunitx_per_auto_bool
+ {
+ \mode_if_math:TF
+ {
+ \tex_mathchoice:D
+ { \l__siunitx_number_unit_product_tl }
+ { \__siunitx_unit_output_number_sep_aux: }
+ { \__siunitx_unit_output_number_sep_aux: }
+ { \__siunitx_unit_output_number_sep_aux: }
+ }
+ { \__siunitx_unit_output_number_sep_aux: }
+ }
+ { \__siunitx_unit_output_number_sep_aux: }
+}
+\cs_new_protected:Npn \__siunitx_unit_output_number_sep_aux: {
+ \bool_if:NF \l__siunitx_omit_unit_space_bool
+ { \l__siunitx_number_unit_product_tl }
+}
+\cs_new_protected:Npn \__siunitx_unit_output_pre_print: {
+ \tl_if_empty:NF \l__siunitx_pre_unit_tl
+ {
+ \nobreak
+ \__siunitx_print:nV { unit } \l__siunitx_pre_unit_tl
+ }
+}
+\cs_new_protected:Npn \__siunitx_unit_output_print: {
+ \int_compare:nNnF { \l__siunitx_unit_prefix_int } = { 0 }
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \bool_if:NTF \l__siunitx_tight_bool
+ {
+ \exp_not:N \ensuremath
+ { { \exp_not:V \l__siunitx_exponent_product_tl } }
+ }
+ {
+ \exp_not:N \ensuremath
+ { { } \exp_not:V \l__siunitx_exponent_product_tl { } }
+ }
+ \int_use:N \l__siunitx_unit_prefix_base_int
+ ^ { \int_use:N \l__siunitx_unit_prefix_int }
+ }
+ \__siunitx_print:nV { number } \l__siunitx_tmpa_tl
+ }
+ \tl_if_empty:NF \l__siunitx_unit_tl
+ {
+ \__siunitx_unit_output_number_sep:
+ \__siunitx_print:nV { unit } \l__siunitx_unit_tl
+ }
+}
+\keys_define:nn { siunitx } {
+ preunit .tl_set:N = \l__siunitx_preunit_tl ,
+}
+\tl_new:N \l__siunitx_pre_unit_tl
+\int_new:N \l__siunitx_number_product_int
+\cs_new_protected:Npn \__siunitx_combined:nnnn #1#2#3#4 {
+ \IfNoValueTF {#3}
+ { \tl_clear:N \l__siunitx_pre_unit_tl }
+ {
+ \group_begin:
+ \__siunitx_unit_in:nn {#3} {#1}
+ \cs_set_eq:NN \l__siunitx_pre_unit_tl \l__siunitx_unit_tl
+ \exp_args:NNNo \group_end:
+ \tl_set: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_new_protected:Npn \__siunitx_combined_output:n #1 {
+ \bool_if:NTF \l__siunitx_number_parse_bool
+ {
+ \tl_clear:N \l__siunitx_number_out_tl
+ \bool_set_false:N \l__siunitx_number_compound_bool
+ \__siunitx_number_output_parse:n {#1}
+ }
+ {
+ \__siunitx_unit_output_pre_print:
+ \__siunitx_print:nn { number } { \ensuremath {#1} }
+ \__siunitx_unit_output_print:
+ }
+}
+\cs_new_protected:Npn \__siunitx_combined_unit:nnn #1#2#3 {
+ \bool_if:NTF \l__siunitx_product_power_bool
+ {
+ \__siunitx_combined_product_count:n {#1}
+ \int_compare:nNnTF { \l__siunitx_number_product_int } > { 0 }
+ {
+ \int_incr:N \l__siunitx_number_product_int
+ \tl_set:Nn \l__siunitx_tmpa_tl {#2}
+ \tl_set:Nx \l__siunitx_tmpb_tl
+ { \tothe { \exp_not:V \l__siunitx_number_product_int } }
+ \tl_put_right:NV \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl
+ \__siunitx_unit_in:Vn \l__siunitx_tmpa_tl {#3}
+ }
+ { \__siunitx_unit_in:nn {#2} {#3} }
+ }
+ { \__siunitx_unit_in:nn {#2} {#3} }
+}
+\cs_new_protected:Npn \__siunitx_combined_product_count:n #1 {
+ \int_zero:N \l__siunitx_number_product_int
+ \tl_set:Nn \l__siunitx_tmpa_tl {#1}
+ \tl_map_function:NN \l__siunitx_input_product_tl
+ \__siunitx_combined_product_count_aux:N
+}
+\cs_new_protected:Npn \__siunitx_combined_product_count_aux:N #1 {
+ \tl_if_in:NnT \l__siunitx_tmpa_tl {#1}
+ {
+ \int_incr:N \l__siunitx_number_product_int
+ \tl_remove_once: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-pair-separator .tl_set:N = \l__siunitx_list_separator_pair_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-pair-separator = { ~ and ~ } ,
+ list-separator = { , ~ } ,
+ list-units = repeat
+}
+\cs_new_protected:Npn \__siunitx_list_numbers:n #1
+ {
+ \tl_clear:N \l__siunitx_unit_tl
+ \tl_clear:N \l__siunitx_preunit_tl
+ \__siunitx_list_numbers_aux_i:n {#1}
+ }
+\cs_new_protected:Npn \__siunitx_list_numbers_aux_i:n #1
+ {
+ \bool_set_true:N \l__siunitx_list_first_bool
+ \tl_clear:N \l__siunitx_list_current_tl
+ \int_compare:nNnTF { \tl_count:n {#1} } > 2
+ {
+ \tl_map_function:nN {#1} \__siunitx_list_numbers_aux_ii:n
+ \l__siunitx_list_tl
+ \l__siunitx_list_separator_final_tl
+ \l__siunitx_list_current_tl
+ }
+ {
+ \int_compare:nNnTF { \tl_count:n {#1} } = 2
+ { \__siunitx_list_numbers_aux:nn #1 }
+ { \__siunitx_combined_output:n #1 }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_list_numbers_aux_ii:n #1
+ {
+ \tl_if_empty:NTF \l__siunitx_list_tl
+ { \tl_set_eq:NN \l__siunitx_list_tl \l__siunitx_list_current_tl }
+ {
+ \tl_put_right:NV \l__siunitx_list_tl \l__siunitx_list_separator_tl
+ \tl_put_right:NV \l__siunitx_list_tl \l__siunitx_list_current_tl
+ }
+ \tl_set:Nn \l__siunitx_list_current_tl { \__siunitx_combined_output:n {#1} }
+ }
+\cs_new_protected:Npn \__siunitx_list_numbers_aux:nn #1#2
+ {
+ \__siunitx_combined_output:n {#1}
+ \l__siunitx_list_separator_pair_tl
+ \__siunitx_combined_output:n {#2}
+ }
+\cs_new_protected:Npn \__siunitx_list_units:nnn #1#2#3
+ {
+ \__siunitx_unit_parse_options:nn {#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_process_fixed_bool
+ { \bool_set_true:N \l__siunitx_process_drop_exponent_bool }
+ \bool_if:NT \l__siunitx_list_brackets_bool
+ { \__siunitx_print:nV { number } \l__siunitx_bracket_open_tl }
+ \__siunitx_list_numbers:n {#1}
+ \bool_if:NT \l__siunitx_list_brackets_bool
+ { \__siunitx_print:nV { number } \l__siunitx_bracket_close_tl }
+ \__siunitx_range_exponent:
+ \__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_new_protected:Npn \__siunitx_range_numbers:nn #1#2
+ {
+ \__siunitx_range_numbers_aux:n {#1}
+ \l__siunitx_range_phrase_tl
+ \__siunitx_range_numbers_aux:n {#2}
+ }
+\cs_new_protected:Npn \__siunitx_range_numbers_aux:n #1
+ {
+ \bool_if:NTF \l__siunitx_number_parse_bool
+ {
+ \tl_clear:N \l__siunitx_number_out_tl
+ \tl_clear:N \l__siunitx_number_out_saved_tl
+ \bool_set_false:N \l__siunitx_number_compound_bool
+ \__siunitx_number_output_parse:n {#1}
+ \bool_if:NT \l__siunitx_number_compound_bool
+ { \msg_error:nnx { siunitx } { multi-part-range } {#1} }
+ }
+ {
+ \__siunitx_unit_output_pre_print:
+ \__siunitx_print:nn { number } {#1}
+ \__siunitx_unit_output_print:
+ }
+ }
+\cs_new_protected:Npn \__siunitx_range_unit:nnnn #1#2#3#4 {
+ \__siunitx_unit_parse_options:nn {#1} {#2}
+ \bool_if:NTF \l__siunitx_range_repeat_bool
+ {
+ \__siunitx_unit_in:nn {#1} {#2}
+ \__siunitx_range_numbers_aux:n {#3}
+ \l__siunitx_range_phrase_tl
+ \__siunitx_range_numbers_aux:n {#4}
+ }
+ {
+ \bool_if:NT \l__siunitx_process_fixed_bool
+ { \bool_set_true:N \l__siunitx_process_drop_exponent_bool }
+ \bool_if:NT \l__siunitx_range_brackets_bool
+ { \__siunitx_print:nV { number } \l__siunitx_bracket_open_tl }
+ \__siunitx_range_numbers:nn {#3} {#4}
+ \bool_if:NT \l__siunitx_range_brackets_bool
+ { \__siunitx_print:nV { number } \l__siunitx_bracket_close_tl }
+ \__siunitx_range_exponent:
+ \__siunitx_unit_output_number_sep:
+ \__siunitx_unit_output:nn {#1} {#2}
+ }
+}
+\cs_new_protected:Npn \__siunitx_range_exponent:
+ {
+ \bool_if:NT \l__siunitx_process_fixed_bool
+ {
+ \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:N \mathord \exp_not:o \l__siunitx_tmpa_tl }
+ }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:N \ensuremath { { } \exp_not:o \l__siunitx_tmpa_tl { } }
+ 10 \exp_not:N \PrintSuperscript
+ { \int_use:N \l__siunitx_process_fixed_int }
+ }
+ \__siunitx_print:nV { number } \l__siunitx_tmpa_tl
+ }
+ }
+\AtBeginDocument {
+ \@ifpackageloaded { cellspace }
+ {
+ \cs_if_exist:NT \NC@find@S
+ {
+ \newcolumntype { C } [1]
+ { > { \bcolumn #1 \@nil } #1 < { \ecolumn } }
+ \cs_set:Npn \__siunitx_tmp:w #1 \NC@do S #2 \q_stop
+ { \NC@list { #1 #2 } }
+ \exp_after:wN \__siunitx_tmp:w \tex_the:D \NC@list \q_stop
+ \cs_undefine:N \NC@find@S
+ \msg_new:nnn { siunitx } { moved-cellspace-column }
+ { Column~type~for~cellspace~package~moved~to~'#1'. }
+ \msg_warning:nnn { siunitx } { moved-cellspace-column } { C }
+ \ifcellspace@m
+ \def \env@matrix
+ {
+ \hskip -\arraycolsep
+ \let \@ifnextchar \new@ifnextchar
+ \array
+ {
+ * { \c@MaxMatrixCols }
+ { > { \bcolumn c \@nil $ } c < { $ \ecolumn } } @ { }
+ }
+ }
+ \fi
+ }
+ }
+ { }
+}
+\cs_new_protected:Npn \__siunitx_table_rewrite_create:N #1 {
+ \newcolumntype {#1} { }
+ \cs_set_protected:Npn
+ \__siunitx_table_rewrite_create_aux:w \NC@do ##1##2 \NC@do #1
+ { \NC@list { \NC@do ##1 \NC@do #1 ##2 } }
+ \exp_after:wN \__siunitx_table_rewrite_create_aux:w \tex_the:D \NC@list
+ \exp_args:NNc \renewcommand * { NC@rewrite@ #1 } [1] [ ]
+ {
+ \@temptokena \exp_after:wN
+ {
+ \tex_the:D \@temptokena
+ > { \__siunitx_table_collect_begin:Nn #1 {##1} }
+ c
+ < { \__siunitx_table_print: }
+ }
+ \NC@find
+ }
+}
+\AtBeginDocument
+ {
+ \@ifpackageloaded { mdwtab }
+ {
+ \cs_set_protected:Npn \__siunitx_table_rewrite_create:N #1
+ {
+ \newcolumntype {#1} [1] []
+ {
+ > { \__siunitx_table_collect_begin:Nn #1 {##1} }
+ c
+ < { \__siunitx_table_print: }
+ }
+ }
+ }
+ { }
+ }
+\cs_new_protected:Npn \__siunitx_table_rewrite_create_aux:w { }
+\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_math_bool
+\bool_new:N \l__siunitx_table_collect_pre_bool
+\bool_new:N \l__siunitx_table_collect_post_bool
+\cs_new_protected:Npn \__siunitx_table_collect_begin:Nn #1#2
+ {
+ \keys_set:nn { siunitx } {#2}
+ \__siunitx_table_collect_begin:Nw #1
+ }
+\cs_new_protected:Npn \__siunitx_table_collect_begin:Nw #1#2 \ignorespaces
+ { \use:c { __siunitx_table_collect_begin_ #1 : } #2 }
+\cs_new_protected:Npn \__siunitx_table_collect_begin_s: {
+ \cs_set_eq:NN \__siunitx_table_collect_token:N
+ \__siunitx_table_collect_token_s:N
+ \cs_set_eq:NN \__siunitx_table_print: \__siunitx_table_print_s:
+ \__siunitx_table_collect_init_s:
+ \__siunitx_table_collect_get:
+}
+\cs_new_protected: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_detect_font:
+ \bool_if:NTF \l__siunitx_number_parse_bool
+ { \__siunitx_table_collect_get: }
+ { \__siunitx_table_print_S_direct: }
+}
+\cs_new_protected:Npn \__siunitx_table_collect_braced:n #1 { }
+\cs_new_protected:Npn \__siunitx_table_collect_expand:N #1 {
+ \cs_if_eq:NNTF #1 \color
+ {
+ \bool_if:NTF \l__siunitx_table_collect_pre_bool
+ {
+ \tl_clear:N \l__siunitx_number_color_tl
+ \tl_clear:N \l__siunitx_unit_color_tl
+ \tl_put_right:Nn \l__siunitx_table_collect_pre_tl {#1}
+ }
+ {
+ \bool_set_true:N \l__siunitx_table_collect_post_bool
+ \tl_put_right:Nn \l__siunitx_table_collect_post_tl {#1}
+ }
+ }
+ {
+ \__siunitx_cs_if_tl:NTF #1
+ {
+ \tl_use:N \l__siunitx_table_collect_pre_tl
+ \tl_clear:N \l__siunitx_table_collect_pre_tl
+ \cs_set:Npn \__siunitx_table_collect_next:
+ { \exp_after:wN \__siunitx_table_collect_get: #1 }
+ }
+ {
+ \bool_if:NTF \l__siunitx_table_collect_pre_bool
+ {
+ \tl_put_right:Nn \l__siunitx_table_collect_pre_tl {#1}
+ \__siunitx_table_collect_expand_math:N #1
+ }
+ {
+ \bool_set_true:N \l__siunitx_table_collect_post_bool
+ \tl_put_right:Nn \l__siunitx_table_collect_post_tl {#1}
+ }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_table_collect_expand_math:N #1 {
+ \token_if_math_toggle:NTF #1
+ {
+ \bool_if:NTF \l__siunitx_table_math_bool
+ { \bool_set_false:N \l__siunitx_table_math_bool }
+ { \bool_set_true:N \l__siunitx_table_math_bool }
+ }
+ {
+ \cs_if_eq:NNTF #1 \( % \)
+ { \bool_set_true:N \l__siunitx_table_math_bool }
+ { % \(
+ \cs_if_eq:NNT #1 \)
+ { \bool_set_false:N \l__siunitx_table_math_bool }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_table_collect_get:
+ {
+ \cs_set_eq:NN \__siunitx_table_collect_next:
+ \__siunitx_table_collect_get:
+ \peek_catcode_ignore_spaces:NTF \c_group_begin_token
+ { \__siunitx_table_collect_braced:n }
+ { \__siunitx_table_collect_not_braced:N }
+ }
+\cs_new_protected:Npn \__siunitx_table_collect_init: {
+ \tl_clear:N \l__siunitx_table_collect_tl
+ \tl_clear:N \l__siunitx_table_collect_pre_tl
+ \tl_clear:N \l__siunitx_table_collect_post_tl
+ \bool_set_false:N \l__siunitx_table_collect_post_bool
+ \bool_set_false:N \l__siunitx_table_math_bool
+}
+\cs_new_protected:Npn \__siunitx_table_collect_init_s: {
+ \__siunitx_table_collect_init:
+ \bool_set_false:N \l__siunitx_table_collect_pre_bool
+ \cs_set_protected:Npn \__siunitx_table_collect_braced:n ##1
+ {
+ \tl_put_right:Nn \l__siunitx_table_collect_tl { {##1} }
+ \__siunitx_table_collect_next:
+ }
+}
+\cs_new_protected:Npn \__siunitx_table_collect_init_S: {
+ \__siunitx_number_in_init:
+ \tl_set:Nx \l__siunitx_number_valid_tl
+ {
+ \exp_not:V \l__siunitx_input_complex_tl
+ \exp_not:V \l__siunitx_input_decimal_tl
+ \exp_not:V \l__siunitx_input_digit_tl
+ \exp_not:V \l__siunitx_input_exponent_tl
+ \exp_not:V \l__siunitx_input_ignore_tl
+ \exp_not:V \l__siunitx_input_comparator_tl
+ \exp_not:V \l__siunitx_input_uncert_close_tl
+ \exp_not:V \l__siunitx_input_uncert_open_tl
+ \exp_not:V \l__siunitx_input_sign_tl
+ \exp_not:V \l__siunitx_input_symbol_tl
+ }
+ \bool_set_true:N \l__siunitx_table_collect_pre_bool
+ \cs_set_protected: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_new_protected:Npn \__siunitx_table_collect_next: { }
+\cs_new_protected:Npn \__siunitx_table_collect_newline: {
+ \__siunitx_table_print:
+ \cs_set_eq:NN \__siunitx_table_print: \prg_do_nothing:
+ \tabularnewline
+}
+\cs_new_protected:Npn \__siunitx_table_collect_end: {
+ \__siunitx_table_print:
+ \cs_set_eq:NN \__siunitx_table_print: \prg_do_nothing:
+ \end
+}
+\cs_new_protected:Npn \__siunitx_table_collect_not_braced:N #1
+ {
+ \token_if_eq_meaning:NNF #1 \tex_ignorespaces:D
+ {
+ \token_if_eq_meaning:NNF #1 \tex_unskip:D
+ { \__siunitx_table_collect_not_braced_aux_i:N #1 }
+ }
+ \__siunitx_table_collect_next:
+ }
+\AtBeginDocument
+ {
+ \@ifpackageloaded { mdwtab }
+ {
+ \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
+ {
+ \token_if_eq_meaning:NNF #1 \tab@setcr
+ {
+ \token_if_eq_meaning:NNF #1 \@maybe@unskip
+ { \__siunitx_table_collect_not_braced_aux_i:N #1 }
+ }
+ }
+ }
+ \__siunitx_table_collect_next:
+ }
+ }
+ { }
+ }
+\cs_new_protected:Npn \__siunitx_table_collect_not_braced_aux_i:N #1 {
+ \cs_set:Npn \__siunitx_table_collect_not_braced_aux_ii:N ##1
+ {
+ \token_if_eq_meaning:NNT #1 ##1
+ { \cs_set_eq:NN \__siunitx_table_collect_next: ##1 }
+ }
+ \tl_map_function:nN
+ { \cs:w \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:
+ }
+ {
+ \token_if_eq_meaning:NNTF #1 \end
+ {
+ \cs_set_eq:NN \__siunitx_table_collect_next:
+ \__siunitx_table_collect_end:
+ }
+ { \__siunitx_table_collect_token:N #1 }
+ }
+ }
+}
+\cs_new_protected:Npn \__siunitx_table_collect_not_braced_aux_ii:N #1 { }
+\cs_new_protected:Npn \__siunitx_table_collect_token:N #1 { }
+\cs_new_protected:Npn \__siunitx_table_collect_token_s:N #1 {
+ \tl_put_right:Nn \l__siunitx_table_collect_tl {#1}
+}
+\cs_new_protected:Npn \__siunitx_table_collect_token_S:N #1 {
+ \bool_if:NTF \l__siunitx_table_collect_post_bool
+ { \tl_put_right:Nn \l__siunitx_table_collect_post_tl {#1} }
+ {
+ \tl_if_in:NnTF \l__siunitx_number_valid_tl {#1}
+ {
+ \bool_set_false:N \l__siunitx_table_collect_pre_bool
+ \tl_put_right:Nn \l__siunitx_table_collect_tl {#1}
+ }
+ { \__siunitx_table_collect_expand:N #1 }
+ }
+}
+\skip_const:Nn \c__siunitx_one_fill_skip { 0pt plus 1fill }
+\AtBeginDocument
+ {
+ \@ifpackageloaded { colortbl }
+ {
+ \cs_new_protected:Npn \__siunitx_table_colortbl_correction:
+ {
+ \skip_horizontal:n { 0pt plus -0.5fill }
+ \tex_kern:D \c_zero_skip
+ }
+ }
+ { \cs_new_protected:Npn \__siunitx_table_colortbl_correction: { } }
+ }
+\cs_new_protected:Npn \__siunitx_table_align_left:n #1
+ {
+ \__siunitx_table_colortbl_correction:
+ \skip_horizontal:n {#1}
+ \tex_kern:D \c_zero_skip
+ }
+\cs_new_protected: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:
+ }
+\cs_new_eq:NN \__siunitx_table_column_begin:n \__siunitx_table_align_left:n
+\cs_new_eq:NN \__siunitx_table_column_end:n \__siunitx_table_align_right:n
+\keys_define:nn { siunitx }
+ {
+ table-column-width .code:n =
+ {
+ \dim_compare:nNnTF {#1} = { \c_zero_dim }
+ {
+ \cs_set_eq:NN \__siunitx_table_column_begin:n
+ \__siunitx_table_align_left:n
+ \cs_set_eq:NN \__siunitx_table_column_end:n
+ \__siunitx_table_align_right:n
+ }
+ {
+ \cs_set_protected:Npn \__siunitx_table_column_begin:n ##1
+ {
+ \__siunitx_table_colortbl_correction:
+ \tex_hbox:D to \dim_eval:n {#1}
+ \c_group_begin_token
+ \skip_horizontal:n {##1}
+ \tex_kern:D \c_zero_skip
+ }
+ \cs_set_protected:Npn \__siunitx_table_column_end:n ##1
+ {
+ \skip_horizontal:n { \c__siunitx_one_fill_skip - ##1 }
+ \tex_kern:D \c_zero_skip
+ \c_group_end_token
+ \__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
+ { 0pt plus 0.5fill }
+ },
+ 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
+ { 0pt plus 1fill }
+ }
+ }
+\keys_set:nn { siunitx } { table-unit-alignment = center }
+\cs_new_protected:Npn \__siunitx_table_print_s:
+ {
+ \__siunitx_table_column_begin:n { \l__siunitx_table_unit_align_skip }
+ \tl_if_empty:NF \l__siunitx_table_collect_tl
+ { \__siunitx_unit_output:Vn \l__siunitx_table_collect_tl { } }
+ \__siunitx_table_column_end:n { \l__siunitx_table_unit_align_skip }
+ }
+\prop_new:N \l__siunitx_table_model_prop
+\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_fill_pre_dim
+\dim_new:N \l__siunitx_table_fill_post_dim
+\dim_new:N \l__siunitx_table_fill_mid_dim
+\box_new:N \l__siunitx_table_pre_box
+\box_new:N \l__siunitx_table_post_box
+\box_new:N \l__siunitx_table_mantissa_box
+\box_new:N \l__siunitx_table_result_box
+\skip_new:N \l__siunitx_table_number_align_skip
+\skip_new:N \l__siunitx_table_text_align_skip
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_main: { }
+\cs_new_protected:Npn \__siunitx_table_print_S_parsed: { }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_store_fill:n #1 { }
+\keys_define:nn { siunitx }
+ {
+ table-align-comparator .choice:,
+ table-align-comparator /
+ false .code:n =
+ {
+ \cs_set_eq:NN \__siunitx_table_print_S_reserved_store_fill:n
+ \__siunitx_table_print_S_reserved_store_fill_pre:n
+ },
+ table-align-comparator /
+ true .code:n =
+ {
+ \cs_set_eq:NN \__siunitx_table_print_S_reserved_store_fill:n
+ \__siunitx_table_print_S_reserved_store_fill_mid:n
+ },
+ table-align-comparator .default:n = true,
+ table-align-exponent .bool_set:N =
+ \l__siunitx_table_align_exponent_bool,
+ table-align-text-pre .bool_set:N =
+ \l__siunitx_table_align_text_pre_bool,
+ table-align-text-post .bool_set:N =
+ \l__siunitx_table_align_text_post_bool,
+ table-align-uncertainty .bool_set:N = \l__siunitx_table_align_uncert_bool,
+ table-auto-round .bool_set:N = \l__siunitx_table_auto_round_bool,
+ table-number-alignment .choice:,
+ table-number-alignment /
+ center .code:n =
+ {
+ \skip_set:Nn \l__siunitx_table_number_align_skip
+ { 0pt plus 0.5fill }
+ \cs_set_eq:NN \__siunitx_table_print_S_direct_main:
+ \__siunitx_table_print_S_direct_reserved:
+ \cs_set_eq:NN \__siunitx_table_print_S_parsed:
+ \__siunitx_table_print_S_reserved:
+ },
+ table-number-alignment /
+ center-decimal-marker .code:n =
+ {
+ \skip_set:Nn \l__siunitx_table_number_align_skip
+ { 0pt plus 0.5fill }
+ \cs_set_eq:NN \__siunitx_table_print_S_direct_main:
+ \__siunitx_table_print_S_direct_centered:
+ \cs_set_eq:NN \__siunitx_table_print_S_parsed:
+ \__siunitx_table_print_S_centered:
+ },
+ table-number-alignment /
+ left .code:n =
+ {
+ \skip_zero:N \l__siunitx_table_number_align_skip
+ \cs_set_eq:NN \__siunitx_table_print_S_direct_main:
+ \__siunitx_table_print_S_direct_reserved:
+ \cs_set_eq:NN \__siunitx_table_print_S_parsed:
+ \__siunitx_table_print_S_reserved:
+ },
+ table-number-alignment /
+ right .code:n =
+ {
+ \skip_set:Nn \l__siunitx_table_number_align_skip
+ { 0pt plus 1fill }
+ \cs_set_eq:NN \__siunitx_table_print_S_direct_main:
+ \__siunitx_table_print_S_direct_reserved:
+ \cs_set_eq:NN \__siunitx_table_print_S_parsed:
+ \__siunitx_table_print_S_reserved:
+ },
+ table-omit-exponent .bool_set:N =
+ \l__siunitx_table_omit_exponent_bool,
+ table-text-alignment .choice:,
+ table-text-alignment /
+ center .code:n =
+ {
+ \skip_set:Nn \l__siunitx_table_text_align_skip
+ { 0pt plus 0.5fill }
+ },
+ table-text-alignment /
+ left .code:n =
+ { \skip_zero:N \l__siunitx_table_text_align_skip },
+ table-text-alignment /
+ right .code:n =
+ {
+ \skip_set:Nn \l__siunitx_table_text_align_skip
+ { 0pt plus 1fill }
+ },
+ table-comparator .choice:,
+ table-comparator /
+ false .code:n =
+ { \prop_remove:Nn \l__siunitx_table_model_prop { comparator } },
+ table-comparator /
+ true .code:n =
+ { \prop_put:Nnn \l__siunitx_table_model_prop { comparator } { > } },
+ table-comparator .default:n = true,
+ table-figures-decimal .code:n =
+ {
+ \int_compare:nNnTF {#1} = 0
+ {
+ \prop_remove:Nn \l__siunitx_table_model_prop { mantissa-decimal }
+ \prop_remove:Nn \l__siunitx_table_model_prop { mantissa-decimal-raw }
+ \prop_remove:Nn \l__siunitx_table_model_prop
+ { mantissa-decimal-marker }
+ \prop_if_in:NnTF \l__siunitx_table_model_prop { mantissa-integer }
+ {
+ \prop_put:Nnn \l__siunitx_table_model_prop { mantissa }
+ { true }
+ }
+ { \prop_remove:Nn \l__siunitx_table_model_prop { mantissa } }
+ }
+ {
+ \prop_put:Nnx \l__siunitx_table_model_prop { mantissa-decimal }
+ { \prg_replicate:nn {#1} { 8 } }
+ \prop_put:Nnn \l__siunitx_table_model_prop { mantissa-decimal-raw }
+ {#1}
+ \prop_put:Nnn \l__siunitx_table_model_prop { mantissa } { true }
+ \prop_put:NnV \l__siunitx_table_model_prop
+ { mantissa-decimal-marker } \l__siunitx_output_decimal_tl
+ }
+ },
+ table-figures-exponent .code:n =
+ {
+ \int_compare:nNnTF {#1} = 0
+ { \prop_remove:Nn \l__siunitx_table_model_prop { exponent-integer } }
+ {
+ \prop_put:Nnx \l__siunitx_table_model_prop { exponent-integer }
+ { \prg_replicate:nn {#1} { 8 } }
+ \prop_put:Nnn \l__siunitx_table_model_prop { exponent } { true }
+ }
+ },
+ table-figures-integer .code:n =
+ {
+ \int_compare:nNnTF {#1} = 0
+ {
+ \prop_remove:Nn \l__siunitx_table_model_prop { mantissa-integer }
+ \prop_if_in:NnTF \l__siunitx_table_model_prop { mantissa-decimal }
+ {
+ \prop_put:Nnn \l__siunitx_table_model_prop { mantissa }
+ { true }
+ }
+ { \prop_remove:Nn \l__siunitx_table_model_prop { mantissa } }
+ }
+ {
+ \prop_put:Nnx \l__siunitx_table_model_prop { mantissa-integer }
+ { \prg_replicate:nn {#1} { 8 } }
+ \prop_put:Nnn \l__siunitx_table_model_prop { mantissa } { true }
+ }
+ },
+ table-figures-uncertainty .code:n =
+ {
+ \int_compare:nNnTF {#1} = 0
+ { \prop_remove:Nn \l__siunitx_table_model_prop { mantissa-uncertainty } }
+ {
+ \prop_put:Nnx \l__siunitx_table_model_prop { mantissa-uncertainty }
+ { \prg_replicate:nn {#1} { 8 } }
+ }
+ },
+ 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 .choice:,
+ table-sign-exponent / true .code:n =
+ { \prop_put:Nnn \l__siunitx_table_model_prop { exponent-sign } { - } },
+ table-sign-exponent / false .code:n =
+ { \prop_remove:Nn \l__siunitx_table_model_prop { exponent-sign } },
+ table-sign-exponent .default:n = true,
+ table-sign-mantissa .choice:,
+ table-sign-mantissa / true .code:n =
+ { \prop_put:Nnn \l__siunitx_table_model_prop { mantissa-sign } { - } },
+ table-sign-mantissa / false .code:n =
+ { \prop_remove:Nn \l__siunitx_table_model_prop { mantissa-sign } },
+ table-sign-mantissa .default:n = true,
+ }
+\keys_define:nn { siunitx }
+ {
+ table-alignment .meta:n =
+ {
+ table-number-alignment = #1,
+ table-text-alignment = #1,
+ table-unit-alignment = #1
+ }
+ }
+\keys_define:nn { siunitx }
+ {
+ table-format .code:n =
+ {
+ \bool_set_eq:NN \l__siunitx_process_plus_saved_bool \l__siunitx_process_plus_bool
+ \bool_set_true:N \l__siunitx_process_plus_bool
+ \__siunitx_number_in_parse:n {#1}
+ \prop_set_eq:NN \l__siunitx_table_model_prop \l__siunitx_number_in_prop
+ \tl_clear:N \l__siunitx_tmpa_tl
+ \prop_get:NnNT \l__siunitx_number_in_prop { mantissa-integer }
+ \l__siunitx_tmpb_tl
+ {
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { table-figures-integer = \l__siunitx_tmpb_tl }
+ }
+ \prop_get:NnNT \l__siunitx_number_in_prop { mantissa-decimal }
+ \l__siunitx_tmpb_tl
+ {
+ \clist_put_right:Nx \l__siunitx_tmpa_tl
+ { table-figures-decimal = \l__siunitx_tmpb_tl }
+ }
+ \prop_get:NnNT \l__siunitx_number_in_prop { mantissa-uncertainty }
+ \l__siunitx_tmpb_tl
+ {
+ \clist_put_right:Nx \l__siunitx_tmpa_tl
+ { table-figures-uncertainty = \l__siunitx_tmpb_tl }
+ }
+ \prop_if_in:NnTF \l__siunitx_number_in_prop { mantissa-sign }
+ {
+ \clist_put_right:Nn \l__siunitx_tmpa_tl
+ { table-sign-mantissa =true }
+ }
+ {
+ \clist_put_right:Nn \l__siunitx_tmpa_tl
+ { table-sign-mantissa =false }
+ }
+ \prop_get:NnNT \l__siunitx_number_in_prop { exponent-integer }
+ \l__siunitx_tmpb_tl
+ {
+ \clist_put_right:Nx \l__siunitx_tmpa_tl
+ { table-figures-exponent = \l__siunitx_tmpb_tl }
+ }
+ \prop_if_in:NnTF \l__siunitx_number_in_prop { exponent-sign }
+ {
+ \clist_put_right:Nn \l__siunitx_tmpa_tl
+ { table-sign-exponent =true }
+ }
+ {
+ \clist_put_right:Nn \l__siunitx_tmpa_tl
+ { table-sign-exponent =false }
+ }
+ \clist_put_right:Nn \l__siunitx_tmpa_tl
+ { table-number-alignment = center }
+ \keys_set:nV { siunitx } \l__siunitx_tmpa_tl
+ \bool_set_eq:NN \l__siunitx_process_plus_bool \l__siunitx_process_plus_saved_bool
+ }
+ }
+\bool_new:N \l__siunitx_process_plus_saved_bool
+\cs_new_protected:Npn \__siunitx_table_print_S:
+ {
+ \bool_if:NTF \l__siunitx_table_collect_pre_bool
+ {
+ \__siunitx_table_column_begin:n { \l__siunitx_table_text_align_skip }
+ \l__siunitx_table_collect_pre_tl
+ \__siunitx_table_column_end:n { \l__siunitx_table_text_align_skip }
+ }
+ {
+ \__siunitx_table_column_begin:n { \l__siunitx_table_number_align_skip }
+ \bool_if:NTF \l__siunitx_table_parse_only_bool
+ { \__siunitx_table_print_S_no_alignment: }
+ { \__siunitx_table_print_S_alignment: }
+ \bool_if:NTF \l__siunitx_table_align_text_pre_bool
+ { \__siunitx_table_print_S_pre_aligned: }
+ { \__siunitx_table_print_S_pre_not_aligned: }
+ \box_use:N \l__siunitx_table_result_box
+ \bool_if:NTF \l__siunitx_table_align_text_post_bool
+ { \__siunitx_table_print_S_post_aligned: }
+ { \__siunitx_table_print_S_post_not_aligned: }
+ \__siunitx_table_column_end:n { \l__siunitx_table_number_align_skip }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_no_alignment:
+ {
+ \l__siunitx_table_collect_pre_tl
+ \__siunitx_number_output:V \l__siunitx_table_collect_tl
+ \l__siunitx_table_collect_post_tl
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_alignment:
+ { \__siunitx_table_print_S_parsed: }
+\cs_new_protected:Npn \__siunitx_table_print_S_parse:
+ {
+ \bool_set_false:N \l__siunitx_error_bool
+ \__siunitx_number_in_parse:V \l__siunitx_table_collect_tl
+ \bool_if:NF \l__siunitx_error_bool
+ {
+ \bool_if:NTF \l__siunitx_table_omit_exponent_bool
+ {
+ \bool_set_true:N \l__siunitx_process_fixed_bool
+ \__siunitx_number_process:
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent }
+ \prop_remove:Nn \l__siunitx_number_in_prop { exponent-integer }
+ }
+ { \__siunitx_number_process: }
+ \__siunitx_number_format:
+ \__siunitx_number_output_color:
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_measure:NN #1#2
+ {
+ \tl_if_empty:NTF #1
+ { \dim_zero:N #2 }
+ {
+ \group_begin:
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \__siunitx_print:nV { number } #1 }
+ \exp_args:NNNo \group_end:
+ \dim_set:Nn #2 { \dim_use:N \box_wd:N \l__siunitx_tmp_box }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_pre_aligned:
+ {
+ \box_use:N \l__siunitx_table_pre_box
+ \hbox_to_wd:nn { \l__siunitx_table_fill_pre_dim } { \tex_hfil:D }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_pre_not_aligned:
+ {
+ \hbox_to_wd:nn { \l__siunitx_table_fill_pre_dim } { \tex_hfil:D }
+ \box_use:N \l__siunitx_table_pre_box
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_post_aligned:
+ {
+ \hbox_to_wd:nn { \l__siunitx_table_fill_post_dim } { \tex_hfil:D }
+ \box_use:N \l__siunitx_table_post_box
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_post_not_aligned:
+ {
+ \box_use:N \l__siunitx_table_post_box
+ \hbox_to_wd:nn { \l__siunitx_table_fill_post_dim } { \tex_hfil:D }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered:
+ {
+ \__siunitx_table_print_S_centered_ends:
+ \bool_if:NT \l__siunitx_table_math_bool { \c_math_toggle_token }
+ \__siunitx_table_print_S_parse:
+ \bool_if:NF \l__siunitx_error_bool
+ {
+ \__siunitx_table_print_S_centered_measure:
+ \bool_if:NT \l__siunitx_table_math_bool { \c_math_toggle_token }
+ \dim_set:Nn \l__siunitx_table_fill_pre_dim
+ {
+ \l__siunitx_table_result_dim
+ - \l__siunitx_table_integer_dim
+ - \l__siunitx_table_marker_dim
+ }
+ \dim_compare:nNnTF \l__siunitx_table_integer_dim >
+ \l__siunitx_table_fill_pre_dim
+ { \__siunitx_table_print_S_centered_integer: }
+ { \__siunitx_table_print_S_centered_decimal: }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered_ends:
+ {
+ \hbox_set:Nn \l__siunitx_table_pre_box
+ {
+ {
+ \l__siunitx_table_collect_pre_tl
+ \bool_if:NT \l__siunitx_table_math_bool
+ {
+ \scan_stop:
+ \c_math_toggle_token
+ }
+ }
+ }
+ \dim_compare:nNnT
+ { \box_wd:N \l__siunitx_table_pre_box } = \c_zero_dim
+ {
+ \box_clear:N \l__siunitx_table_pre_box
+ \l__siunitx_table_collect_pre_tl
+ \bool_set_false:N \l__siunitx_font_set_bool
+ }
+ \hbox_set:Nn \l__siunitx_table_post_box
+ {
+ \bool_if:NT \l__siunitx_table_math_bool
+ {
+ \c_math_toggle_token
+ \scan_stop:
+ }
+ \l__siunitx_table_collect_post_tl
+ }
+ \dim_compare:nNnTF
+ { \box_wd:N \l__siunitx_table_pre_box } >
+ { \box_wd:N \l__siunitx_table_post_box }
+ {
+ \hbox_set_to_wd:Nnn \l__siunitx_table_post_box
+ { \box_wd:N \l__siunitx_table_pre_box }
+ {
+ \hbox_unpack:N \l__siunitx_table_post_box
+ \tex_hfil:D
+ }
+ }
+ {
+ \hbox_set_to_wd:Nnn \l__siunitx_table_pre_box
+ { \box_wd:N \l__siunitx_table_post_box }
+ {
+ \tex_hfil:D
+ \hbox_unpack:N \l__siunitx_table_pre_box
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered_measure:
+ {
+ \__siunitx_table_print_S_centered_measure_int_part:
+ \__siunitx_table_print_S_centered_measure_marker:
+ \__siunitx_table_print_S_centered_measure_result:
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered_measure_int_part:
+ {
+ \prop_get:NnNF \l__siunitx_number_out_prop { comparator } \l__siunitx_tmpa_tl
+ { \tl_clear:N \l__siunitx_tmpa_tl }
+ \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-sign }
+ \l__siunitx_tmpb_tl
+ { \tl_put_right:No \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl }
+ \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-integer }
+ \l__siunitx_tmpb_tl
+ { \tl_put_right:No \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl }
+ \__siunitx_table_print_S_measure:NN \l__siunitx_tmpa_tl
+ \l__siunitx_table_integer_dim
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered_measure_marker:
+ {
+ \__siunitx_table_print_S_measure:NN \l__siunitx_output_decimal_tl
+ \l__siunitx_table_marker_dim
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered_measure_result:
+ {
+ \prop_get:NnN \l__siunitx_number_out_prop { result } \l__siunitx_tmpa_tl
+ \hbox_set:Nn \l__siunitx_table_result_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \dim_set:Nn \l__siunitx_table_result_dim
+ { \box_wd:N \l__siunitx_table_result_box }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered_integer:
+ {
+ \dim_set:Nn \l__siunitx_table_fill_post_dim
+ { \l__siunitx_table_integer_dim - \l__siunitx_table_fill_pre_dim }
+ \dim_zero:N \l__siunitx_table_fill_pre_dim
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_centered_decimal:
+ {
+ \dim_sub:Nn \l__siunitx_table_fill_pre_dim
+ { \l__siunitx_table_integer_dim }
+ \dim_zero:N \l__siunitx_table_fill_post_dim
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved:
+ {
+ \__siunitx_table_print_S_reserved_init:
+ \__siunitx_table_print_S_reserved_ends:
+ \bool_if:NT \l__siunitx_table_auto_round_bool
+ { \__siunitx_table_print_S_reserved_round_auto: }
+ \__siunitx_table_print_S_parse:
+ \bool_if:NF \l__siunitx_error_bool
+ {
+ \bool_if:NT \l__siunitx_table_math_bool { \c_math_toggle_token }
+ \__siunitx_table_print_S_reserved_comparator:
+ \__siunitx_table_print_S_reserved_mantissa:
+ \__siunitx_table_print_S_reserved_exponent:
+ \bool_if:NT \l__siunitx_table_math_bool { \c_math_toggle_token }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_init:
+ {
+ \dim_zero:N \l__siunitx_table_fill_mid_dim
+ \dim_zero:N \l__siunitx_table_fill_post_dim
+ \prop_set_eq:NN \l__siunitx_number_in_prop \l__siunitx_table_model_prop
+ \__siunitx_number_process_sign:
+ \__siunitx_number_process_zero_fill:
+ \__siunitx_number_process_mantissa:
+ \prop_if_in:NnF \l__siunitx_number_in_prop { symbolic }
+ { \__siunitx_number_process_uncertainty: }
+ \__siunitx_number_format:
+ \prop_get:NnNT \l__siunitx_table_model_prop { mantissa-decimal-raw }
+ \l__siunitx_tmpa_tl
+ {
+ \prop_put:NnV \l__siunitx_number_out_prop { mantissa-decimal-raw }
+ \l__siunitx_tmpa_tl
+ }
+ \prop_set_eq:NN \l__siunitx_table_model_prop \l__siunitx_number_out_prop
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_ends:
+ {
+ \hbox_set:Nn \l__siunitx_table_pre_box
+ {
+ {
+ \l__siunitx_table_collect_pre_tl
+ \bool_if:NT \l__siunitx_table_math_bool
+ {
+ \scan_stop:
+ \c_math_toggle_token
+ }
+ }
+ }
+ \dim_compare:nNnT
+ { \box_wd:N \l__siunitx_table_pre_box } = \c_zero_dim
+ {
+ \box_clear:N \l__siunitx_table_pre_box
+ \l__siunitx_table_collect_pre_tl
+ \bool_set_false:N \l__siunitx_font_set_bool
+ }
+ \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
+ \hbox_unpack:N \l__siunitx_table_pre_box
+ }
+ \hbox_set:Nn \l__siunitx_tmp_box { \l__siunitx_table_post_tl }
+ \hbox_set_to_wd:Nnn \l__siunitx_table_post_box
+ { \box_wd:N \l__siunitx_tmp_box }
+ {
+ {
+ \bool_if:NT \l__siunitx_table_math_bool
+ {
+ \c_math_toggle_token
+ \scan_stop:
+ }
+ \l__siunitx_table_collect_post_tl
+ }
+ \tex_hfil:D
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_round_auto:
+ {
+ \prop_get:NnNTF \l__siunitx_table_model_prop { mantissa-decimal-raw }
+ \l__siunitx_tmpa_tl
+ { \int_set:Nn \l__siunitx_process_precision_int { \l__siunitx_tmpa_tl } }
+ { \int_zero:N \l__siunitx_process_precision_int }
+ \tl_set:Nn \l__siunitx_round_tl { places }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_comparator:
+ {
+ \prop_get:NnNTF \l__siunitx_table_model_prop { comparator }
+ \l__siunitx_tmpa_tl
+ {
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \prop_get:NnNTF \l__siunitx_number_out_prop { comparator }
+ \l__siunitx_tmpa_tl
+ {
+ \hbox_set_to_wd:Nnn \l__siunitx_table_result_box
+ { \box_wd:N \l__siunitx_tmp_box }
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ }
+ {
+ \dim_add:Nn \l__siunitx_table_fill_pre_dim
+ { \box_wd:N \l__siunitx_tmp_box }
+ \cs_set_eq:NN \__siunitx_table_print_S_reserved_store_fill:n
+ \__siunitx_table_print_S_reserved_store_fill_pre:n
+ }
+ }
+ {
+ \cs_set_eq:NN \__siunitx_table_print_S_reserved_store_fill:n
+ \__siunitx_table_print_S_reserved_store_fill_pre:n
+ \prop_if_in:NnT \l__siunitx_number_out_prop { comparator }
+ {
+ \msg_error:nnx { siunitx } { table-partial-number }
+ { a~comparator }
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_store_fill_pre:n
+ { \dim_add:Nn \l__siunitx_table_fill_pre_dim }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_store_fill_mid:n
+ { \dim_add:Nn \l__siunitx_table_fill_mid_dim }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_mantissa:
+ {
+ \prop_get:NnNTF \l__siunitx_table_model_prop { mantissa }
+ \l__siunitx_tmpa_tl
+ {
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \prop_get:NnNTF \l__siunitx_number_out_prop { mantissa }
+ \l__siunitx_tmpa_tl
+ {
+ \dim_set:Nn \l__siunitx_table_mantissa_dim
+ { \box_wd:N \l__siunitx_tmp_box }
+ \hbox_set:Nn \l__siunitx_table_mantissa_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \__siunitx_table_print_S_reserved_mantissa_parts:
+ }
+ {
+ \__siunitx_table_print_S_reserved_store_fill:n
+ { \box_wd:N \l__siunitx_tmp_box }
+ }
+ }
+ {
+ \prop_if_in:NnT \l__siunitx_number_out_prop { mantissa }
+ {
+ \msg_error:nnx { siunitx } { table-partial-number }
+ { a~mantissa }
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_mantissa_parts:
+ {
+ \__siunitx_table_print_S_reserved_mantissa_integer:
+ \hbox_set:Nn \l__siunitx_table_result_box
+ {
+ \hbox_unpack:N \l__siunitx_table_result_box
+ \hbox_to_wd:nn { \l__siunitx_table_fill_mid_dim } { \tex_hfil:D }
+ \hbox_unpack:N \l__siunitx_table_mantissa_box
+ }
+ \dim_set:Nn \l__siunitx_table_fill_mid_dim
+ {
+ \l__siunitx_table_mantissa_dim
+ - \box_wd:N \l__siunitx_table_mantissa_box
+ - \l__siunitx_table_integer_dim
+ }
+ \__siunitx_table_print_S_reserved_mantissa_uncert:
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_mantissa_integer:
+ {
+ \prop_get:NnNF \l__siunitx_table_model_prop { mantissa-sign }
+ \l__siunitx_tmpa_tl
+ { \tl_clear:N \l__siunitx_tmpa_tl }
+ \prop_get:NnNT \l__siunitx_table_model_prop { mantissa-integer }
+ \l__siunitx_tmpb_tl
+ { \tl_put_right:No \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl }
+ \__siunitx_table_print_S_measure:NN \l__siunitx_tmpa_tl
+ \l__siunitx_table_integer_dim
+ \prop_get:NnNF \l__siunitx_number_out_prop { mantissa-sign }
+ \l__siunitx_tmpa_tl
+ { \tl_clear:N \l__siunitx_tmpa_tl }
+ \prop_get:NnNT \l__siunitx_number_out_prop { mantissa-integer }
+ \l__siunitx_tmpb_tl
+ { \tl_put_right:No \l__siunitx_tmpa_tl \l__siunitx_tmpb_tl }
+ \tl_if_empty:NF \l__siunitx_tmpa_tl
+ {
+ \__siunitx_table_print_S_measure:NN \l__siunitx_tmpa_tl
+ \l__siunitx_tmp_dim
+ \dim_sub:Nn \l__siunitx_table_integer_dim { \l__siunitx_tmp_dim }
+ }
+ \__siunitx_table_print_S_reserved_store_fill:n
+ { \l__siunitx_table_integer_dim }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_mantissa_uncert:
+ {
+ \prop_get:NnNT \l__siunitx_table_model_prop { mantissa-uncertainty }
+ \l__siunitx_tmpa_tl
+ {
+ \__siunitx_number_format_join_uncert_pm:N \l__siunitx_tmpa_tl
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \prop_get:NnNTF \l__siunitx_number_out_prop { mantissa-uncertainty }
+ \l__siunitx_tmpa_tl
+ {
+ \dim_set:Nn \l__siunitx_table_uncert_dim
+ { \box_wd:N \l__siunitx_tmp_box }
+ \__siunitx_number_format_join_uncert_pm:N \l__siunitx_tmpa_tl
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \bool_if:NTF \l__siunitx_table_align_uncert_bool
+ { \__siunitx_table_print_S_reserved_mantissa_uncert_aligned: }
+ { \__siunitx_table_print_S_reserved_mantissa_uncert_not_aligned: }
+ }
+ {
+ \cs_set_eq:NN \__siunitx_table_print_S_reserved_store_fill:n
+ \__siunitx_table_print_S_reserved_store_fill_mid:n
+ \__siunitx_table_print_S_reserved_store_fill:n
+ { \box_wd:N \l__siunitx_tmp_box }
+ }
+ }
+ }
+\cs_new_protected:Npn
+ \__siunitx_table_print_S_reserved_mantissa_uncert_aligned:
+ {
+ \hbox_set:Nn \l__siunitx_table_result_box
+ {
+ \hbox_unpack:N \l__siunitx_table_result_box
+ \hbox_to_wd:nn { \l__siunitx_table_fill_mid_dim } { \tex_hfil:D }
+ \hbox_unpack:N \l__siunitx_tmp_box
+ }
+ \dim_set:Nn \l__siunitx_table_fill_mid_dim
+ { \l__siunitx_table_uncert_dim - \box_wd:N \l__siunitx_tmp_box }
+ }
+\cs_new_protected:Npn
+ \__siunitx_table_print_S_reserved_mantissa_uncert_not_aligned:
+ {
+ \hbox_set:Nn \l__siunitx_table_result_box
+ {
+ \hbox_unpack:N \l__siunitx_table_result_box
+ \hbox_unpack:N \l__siunitx_tmp_box
+ }
+ \dim_add:Nn \l__siunitx_table_fill_mid_dim
+ {
+ \l__siunitx_table_uncert_dim
+ - \box_wd:N \l__siunitx_tmp_box
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_exponent:
+ {
+ \prop_get:NnNTF \l__siunitx_table_model_prop { exponent-result }
+ \l__siunitx_tmpa_tl
+ {
+ \prop_if_in:NnT \l__siunitx_table_model_prop { mantissa }
+ { \__siunitx_table_print_S_reserved_exponent_product: }
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \prop_get:NnNTF \l__siunitx_number_out_prop { exponent-result }
+ \l__siunitx_tmpa_tl
+ {
+ \dim_set:Nn \l__siunitx_table_exponent_dim
+ { \box_wd:N \l__siunitx_tmp_box }
+ \tl_if_empty:NT \l__siunitx_output_exponent_tl
+ {
+ \prop_if_in:NnTF \l__siunitx_number_out_prop { mantissa }
+ { \__siunitx_table_print_S_reserved_exponent_product: }
+ { \__siunitx_table_print_S_reserved_exponent_product_correction: }
+ }
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \__siunitx_print:nV { number } \l__siunitx_tmpa_tl }
+ \bool_if:NTF \l__siunitx_table_align_exponent_bool
+ { \__siunitx_table_print_S_reserved_exponent_aligned: }
+ { \__siunitx_table_print_S_reserved_exponent_not_aligned: }
+ }
+ {
+ \dim_set:Nn \l__siunitx_table_fill_post_dim
+ { \l__siunitx_table_fill_mid_dim + \box_wd:N \l__siunitx_tmp_box }
+ }
+ }
+ {
+ \prop_if_in:NnT \l__siunitx_number_out_prop { exponent-result }
+ {
+ \msg_error:nnx { siunitx } { table-partial-number }
+ { an~exponent }
+ }
+ \dim_set_eq:NN \l__siunitx_table_fill_post_dim
+ \l__siunitx_table_fill_mid_dim
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_exponent_product:
+ {
+ \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:N \mathord \exp_not:o \l__siunitx_tmpb_tl }
+ }
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ {
+ \exp_not:N \ensuremath { { } \exp_not:o \l__siunitx_tmpb_tl { } }
+ \exp_not:o \l__siunitx_tmpa_tl
+ }
+ }
+\cs_new_protected:Npn
+ \__siunitx_table_print_S_reserved_exponent_product_correction:
+ {
+ \group_begin:
+ \tl_clear:N \l__siunitx_tmpa_tl
+ \__siunitx_table_print_S_reserved_exponent_product:
+ \tl_set:Nx \l__siunitx_tmpa_tl
+ { { } \exp_not:o \l__siunitx_tmpa_tl { } }
+ \__siunitx_table_print_S_measure:NN \l__siunitx_tmpa_tl \l__siunitx_tmp_dim
+ \exp_args:NNNo \group_end:
+ \dim_set:Nn \l__siunitx_tmp_dim { \dim_use:N \l__siunitx_tmp_dim }
+ \__siunitx_table_print_S_reserved_store_fill:n { \l__siunitx_tmp_dim }
+ \dim_sub:Nn \l__siunitx_table_exponent_dim { \l__siunitx_tmp_dim }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_reserved_exponent_aligned:
+ {
+ \hbox_set:Nn \l__siunitx_table_result_box
+ {
+ \hbox_unpack:N \l__siunitx_table_result_box
+ \hbox_to_wd:nn { \l__siunitx_table_fill_mid_dim } { \tex_hfil:D }
+ \hbox_unpack:N \l__siunitx_tmp_box
+ }
+ \dim_set:Nn \l__siunitx_table_fill_post_dim
+ {
+ \l__siunitx_table_exponent_dim
+ - \box_wd:N \l__siunitx_tmp_box
+ }
+ }
+\cs_new_protected:Npn
+ \__siunitx_table_print_S_reserved_exponent_not_aligned:
+ {
+ \hbox_set:Nn \l__siunitx_table_result_box
+ {
+ \hbox_unpack:N \l__siunitx_table_result_box
+ \hbox_unpack:N \l__siunitx_tmp_box
+ }
+ \dim_set:Nn \l__siunitx_table_fill_post_dim
+ {
+ \l__siunitx_table_fill_mid_dim
+ + \l__siunitx_table_exponent_dim
+ - \box_wd:N \l__siunitx_tmp_box
+ }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct:
+ {
+ \peek_catcode_ignore_spaces:NTF \c_group_begin_token
+ { \__siunitx_table_print_S_direct_text:n }
+ { \__siunitx_table_print_S_direct_main: }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_text:n #1
+ {
+ \__siunitx_table_column_begin:n { \l__siunitx_table_text_align_skip }
+ #1
+ \__siunitx_table_column_end:n { \l__siunitx_table_text_align_skip }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_centered:
+ {
+ \cs_set_eq:NN \__siunitx_table_print:
+ \__siunitx_table_print_S_direct_centered_end:
+ \hbox_set:Nn \l__siunitx_tmp_box
+ { \ensuremath { \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:Nw \l__siunitx_table_pre_box
+ \c_math_toggle_token
+ \tl_map_function:NN \l__siunitx_input_decimal_tl
+ \__siunitx_table_print_S_direct_centered_aux:N
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_centered_aux:N #1
+ {
+ \char_set_active_eq:NN #1 \__siunitx_table_print_S_direct_centered_begin:
+ \char_set_mathcode:nn { `#1 } { "8000 }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_centered_begin:
+ {
+ \c_math_toggle_token
+ \hbox_set_end:
+ \hbox_set:Nw \l__siunitx_table_post_box
+ \c_math_toggle_token
+ \l__siunitx_output_decimal_tl
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_centered_end:
+ {
+ \c_math_toggle_token
+ \hbox_set_end:
+ \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
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_reserved:
+ {
+ \cs_set_eq:NN \__siunitx_table_print:
+ \__siunitx_table_print_S_direct_reserved_end:
+ \prop_get:NnNF \l__siunitx_table_model_prop { mantissa-integer }
+ \l__siunitx_tmpa_tl
+ { \tl_clear:N \l__siunitx_tmpa_tl }
+ \hbox_set:Nn \l__siunitx_tmp_box
+ {
+ \ensuremath
+ {
+ \prop_get:NnNT \l__siunitx_table_model_prop { mantissa-sign }
+ \l__siunitx_tmpb_tl
+ { \l__siunitx_tmpb_tl }
+ \l__siunitx_tmpa_tl
+ }
+ }
+ \dim_set:Nn \l__siunitx_table_integer_dim
+ { \box_wd:N \l__siunitx_tmp_box }
+ \prop_get:NnNF \l__siunitx_table_model_prop { mantissa-decimal }
+ \l__siunitx_tmpa_tl
+ { \tl_clear:N \l__siunitx_tmpa_tl }
+ \hbox_set:Nn \l__siunitx_tmp_box
+ {
+ \ensuremath
+ {
+ \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 }
+ \tex_setbox:D \l__siunitx_table_pre_box \tex_hbox:D to \l__siunitx_table_integer_dim
+ \c_group_begin_token
+ \c_math_toggle_token
+ \tl_map_function:NN \l__siunitx_input_decimal_tl
+ \__siunitx_table_print_S_direct_reserved_aux:N
+ \tex_hfill:D
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_reserved_aux:N #1
+ {
+ \char_set_active_eq:NN #1 \__siunitx_table_print_S_direct_reserved_begin:
+ \char_set_mathcode:nn { `#1 } { "8000 }
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_reserved_begin:
+ {
+ \c_math_toggle_token
+ \c_group_end_token
+ \tex_setbox:D \l__siunitx_table_post_box \tex_hbox:D to \box_wd:N \l__siunitx_tmp_box
+ \c_group_begin_token
+ \c_math_toggle_token
+ \l__siunitx_output_decimal_tl
+ }
+\cs_new_protected:Npn \__siunitx_table_print_S_direct_reserved_end:
+ {
+ \c_math_toggle_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_set:nn { siunitx }
+ {
+ table-align-comparator = true,
+ table-align-exponent = true,
+ table-align-text-pre = true,
+ table-align-text-post = true,
+ table-align-uncertainty = true,
+ table-omit-exponent = false,
+ table-parse-only = false,
+ table-number-alignment = center-decimal-marker,
+ table-text-alignment = center,
+ table-figures-decimal = 2,
+ table-figures-integer = 3
+ }
+\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 { fourier }
+ {
+ \__siunitx_option_unchanged:Nnn \l__siunitx_ohm_text_tl
+ { \textohm }
+ { \text { \ensuremath { \l__siunitx_ohm_math_tl } } }
+ }
+ { }
+ \@ifpackageloaded { mathptmx }
+ {
+ \__siunitx_option_unchanged:Nnn \l__siunitx_ohm_text_tl
+ { \textohm }
+ { \text { \ensuremath { \l__siunitx_ohm_math_tl } } }
+ }
+ { }
+ \str_if_eq:VnT \encodingdefault { OT1 }
+ {
+ \__siunitx_option_unchanged:Nnn \l__siunitx_angstrom_math_tl
+ { \text { \AA } }
+ { \text { \capitalring { A } } }
+ \__siunitx_option_unchanged:Nnn \l__siunitx_angstrom_text_tl
+ { \AA }
+ { \capitalring { A } }
+ }
+ \@ifpackageloaded { unicode-math }
+ {
+ \exp_args:NNnx
+ \__siunitx_option_unchanged:Nnn \l__siunitx_ohm_math_tl
+ { \text { \ensuremath { \Omega } } }
+ { \char_generate:nn { "03A9 } { 12 } }
+ }
+ { }
+ \@ifpackageloaded { upgreek }
+ {
+ \__siunitx_option_unchanged:Nnn \l__siunitx_ohm_math_tl
+ { \text { \ensuremath { \Omega } } }
+ { \text { \ensuremath { \Upomega } } }
+ }
+ {
+ \cs_if_exist:NT \upOmega
+ {
+ \__siunitx_option_unchanged:Nnn \l__siunitx_ohm_math_tl
+ { \text { \ensuremath { \Omega } } }
+ { \text { \ensuremath { \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 = \text { \textdegree } \__siunitx_unit_mathrm:n { C } ,
+ math-degree = \text { \textdegree },
+ math-micro = \text { \textmu },
+ math-ohm = \text { \ensuremath { \Omega } },
+}
+\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 = \text { \textdegree } C,
+ text-degree = \text { \textdegree },
+ text-micro = \textmu ,
+ text-ohm = \textohm
+}
+\cs_new_protected:Npn \__siunitx_symbol_new:n #1
+ {
+ \cs_set_protected:cpn { SIUnitSymbol #1 }
+ {
+ \use:c
+ {
+ l__siunitx_
+ \str_foldcase:n {#1}
+ _
+ \mode_if_math:TF { math } { 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_new_protected:Npn \__siunitx_pgf_link: {
+ \clist_clear:N \l__siunitx_pgf_link_clist
+ \str_if_eq:VnT \l__siunitx_round_tl { figure }
+ {
+ \clist_put_right:Nn \l__siunitx_pgf_link_clist { fixed }
+ \clist_put_right:Nn \l__siunitx_pgf_link_clist
+ { fixed~zerofill = true }
+ }
+ \clist_put_right:Nx \l__siunitx_pgf_link_clist
+ { precision = \int_use:N \l__siunitx_process_precision_int }
+ \clist_put_right:Nx \l__siunitx_pgf_link_clist
+ {
+ set~decimal~separator =
+ { { \exp_not:V \l__siunitx_output_decimal_tl } }
+ }
+ \clist_put_right:Nx \l__siunitx_pgf_link_clist
+ { set~thousands~separator = { \exp_not:V \l__siunitx_group_sep_tl } }
+ \clist_put_right:Nx \l__siunitx_pgf_link_clist
+ {
+ min~exponent~for~1000~sep = \int_eval:n { \l__siunitx_group_min_int - 1 }
+ }
+ \bool_lazy_or:nnF
+ { \l__siunitx_group_decimal_bool } { \l__siunitx_group_integer_bool }
+ {
+ \clist_put_right:Nn \l__siunitx_pgf_link_clist
+ { min~exponent~for~1000~sep = 999 }
+ }
+ \bool_if:NTF \l__siunitx_process_integer_zero_bool
+ {
+ \clist_put_right:Nn \l__siunitx_pgf_link_clist
+ { skip~0. = false }
+ }
+ {
+ \clist_put_right:Nn \l__siunitx_pgf_link_clist
+ { skip~0. = true }
+ }
+ \str_if_eq:VnTF \l__siunitx_process_sign_tl { + }
+ {
+ \clist_put_right:Nn \l__siunitx_pgf_link_clist
+ { showpos = true }
+ }
+ {
+ \clist_put_right:Nn \l__siunitx_pgf_link_clist
+ { showpos = false }
+ }
+ \use:x
+ {
+ \exp_not:N \pgfqkeys
+ { /pgf/number~format }
+ { \exp_not:V \l__siunitx_pgf_link_clist }
+ }
+}
+\msg_new: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_new:nnnn { siunitx } { color-not-loaded }
+ { Package~"color"~not~loaded. }
+ { The~command~\token_to_str:N \color \ is~not~available. }
+\msg_new: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_new:nnnn { siunitx } { duplicate-decimal-token }
+ { Duplicate~decimal~marker~token~'#1'~in~input. }
+ { Only~one~decimal~marker~token~can~appear~in~a~single~number. }
+\msg_new:nnnn { siunitx } { duplicate-exponent-token }
+ { Duplicate~exponent~marker~token~'#1'~in~input. }
+ { Only~one~exponent~marker~token~can~appear~in~a~single~number. }
+\msg_new:nnnn { siunitx } { duplicate-quotient-token }
+ { Duplicate~quotient~token. }
+ { Only~one~quotient~token~can~appear~in~a~single~number. }
+\msg_new: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_new:nnnn { siunitx } { empty-arc }
+ { Empty~degree-minute-second~angle. }
+ { The~angle~given~does~not~contain~any~numbers. }
+\msg_new:nnnn { siunitx } { empty-uncertainty }
+ { Empty~uncertainty~given~in~'#1'. }
+ { The~number~given~contains~an~empty~uncertainty. }
+\msg_new:nnnn { siunitx } { ending-product-token }
+ { Misplaced~product~token. }
+ { A~number~cannot~end~with~a~product~token. }
+\msg_new:nnnn { siunitx } { ending-quotient-token }
+ { Misplaced~quotient~token. }
+ { A~number~cannot~end~with~a~quotient~token. }
+\msg_new: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_new: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_new: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_new: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_new: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_new:nnnn { siunitx } { literal-unit }
+ { Literal~units~disabled. }
+ {
+ You~gave~the~literal~input~'#1'~
+ but~literal~unit~output~is~disabled.
+ }
+\msg_new:nnnn { siunitx } { misplaced-sign-token }
+ { Misplaced~sign~token~'#1'. }
+ { Sign~tokens~can~only~come~at~the~beginning~of~a~number. }
+\msg_new: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_new: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\\
+ \ \ 'input-open-uncertainty'~and~'input-close-uncertainty'~
+ options.
+ }
+\msg_new: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_new:nnn { siunitx } { non-convertible-exponent }
+ { Exponent~'#1'~cannot~be~converted~into~a~symbolic~prefix. }
+\msg_new:nnn { siunitx } { option-not-available }
+ { Option~'#1'~not~available~in~strict~mode. }
+\msg_new:nnn { siunitx } { option-preamble-only }
+ { Option~'#1'~only~available~in~the~preamble. }
+\msg_new: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_new:nnn { siunitx } { prefix-only }
+ { Prefix~with~no~unit. }
+\msg_new:nnnn { siunitx } { qualifier-before-unit }
+ { Qualifier~before~unit. }
+ { Unit~qualifiers~have~to~follow~after~units,~not~before~them. }
+\msg_new:nnnn { siunitx } { restricted-number }
+ { Token~'#1'~forbidden~in~restricted~numerical~input. }
+ {
+ The~current~input~must~be~a~real~number~and~cannot~contain: \\
+ \ -~an~exponent; \\
+ \ -~an~uncertainty; \\
+ \ -~a~complex~part.
+ }
+\msg_new:nnnn { siunitx } { starting-product-token }
+ { Misplaced~product~token. }
+ { A~number~cannot~begin~with~a~product~token. }
+\msg_new:nnnn { siunitx } { starting-quotient-token }
+ { Misplaced~quotient~token. }
+ { A~number~cannot~begin~with~a~quotient~token. }
+\msg_new: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_new:nnnn { siunitx } { unknown-option }
+ { Unknown~option~'#1'. }
+ {
+ The~option~file~'#1'~is~not~known~by~siunitx:
+ perhaps~it~is~spelled~incorrectly.
+ }
+\msg_new:nnnn { siunitx } { version-1-option }
+ { Version~1~option~'#1'~detected. }
+ {
+ Use: \\
+ \ \ \token_to_str:N \usepackage [ version-1-compatibility ]
+ \iow_char:N \{ siunitx \token_to_str:N \iow_char:N \} \\
+ in~the~preamble~to~load~the~appropriate~code.
+ }
+\NewDocumentCommand \DeclareBinaryPrefix { m m m } {
+ \__siunitx_declare_prefix:Nnnn #1 {#2} { 2 } {#3}
+}
+\NewDocumentCommand \DeclareSIPostPower { m m } {
+ \__siunitx_declare_power_after:Nn #1 {#2}
+}
+\NewDocumentCommand \DeclareSIPrefix { m m m } {
+ \__siunitx_declare_prefix:Nnnn #1 {#2} { 10 } {#3}
+}
+\NewDocumentCommand \DeclareSIPrePower { m m } {
+ \__siunitx_declare_power_before:Nn #1 {#2}
+}
+\NewDocumentCommand \DeclareSIQualifier { m m } {
+ \__siunitx_declare_qualifier:Nn #1 {#2}
+}
+\NewDocumentCommand \DeclareSIUnit { O { } m m } {
+ \__siunitx_declare_unit:Nnn #2 {#3} {#1}
+}
+\NewDocumentCommand \DeclareSIUnitWithOptions { m m m } {
+ \__siunitx_declare_unit:Nnn #1 {#2} {#3}
+}
+\@onlypreamble \DeclareBinaryPrefix
+\@onlypreamble \DeclareSIPostPower
+\@onlypreamble \DeclareSIPrefix
+\@onlypreamble \DeclareSIPrePower
+\@onlypreamble \DeclareSIQualifier
+\@onlypreamble \DeclareSIUnit
+\@onlypreamble \DeclareSIUnitWithOptions
+\cs_new_protected:Npn \SendSettingsToPgf { \__siunitx_pgf_link: }
+\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 } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \__siunitx_number_output:n {#2}
+ \group_end:
+}
+\NewDocumentCommand \numlist { o > { \SplitList { ; } } m } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \__siunitx_list_numbers:n {#2}
+ \group_end:
+}
+\NewDocumentCommand \numrange { o m m } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \__siunitx_range_numbers:nn {#2} {#3}
+ \group_end:
+}
+\NewDocumentCommand \SIlist { o > { \SplitList { ; } } m m } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \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 } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \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 } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \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}
+}
+\NewDocumentCommand \tablenum { o m } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \IfNoValueF {#1}
+ { \keys_set:nn { siunitx } {#1} }
+ \bool_if:NTF \l__siunitx_number_parse_bool
+ {
+ \tl_set:Nn \l__siunitx_table_collect_tl {#2}
+ \bool_set_false:N \l__siunitx_table_collect_pre_bool
+ \__siunitx_table_print_S:
+ }
+ { \__siunitx_table_print_S_direct: #2 \__siunitx_table_print: }
+ \group_end:
+}
+\NewDocumentCommand \si { o m } {
+ \leavevmode
+ \group_begin:
+ \bool_set_false:N \l__siunitx_font_set_bool
+ \IfNoValueTF {#1}
+ { \__siunitx_unit_output:nn {#2} { } }
+ {
+ \keys_set:nn { siunitx } {#1}
+ \__siunitx_unit_output:nn {#2} {#1}
+ }
+ \group_end:
+}
+\cs_new_protected:Npn \__siunitx_contents_bookmarks:
+ {
+ \seq_map_inline:Nn \l_siunitx_unit_symbolic_seq
+ { \__siunitx_unit_print_literal_aux:N ##1 }
+ \cs_if_exist:NT \FB@fg
+ { \cs_set_eq:NN \fg \FB@fg }
+ \msg_redirect_name:nnn { xparse } { redefine-command } { none }
+ \cs_set_eq:NN \num \numInBookmark
+ \cs_set_eq:NN \numrange \numrangeInBookmark
+ \cs_set_eq:NN \si \siInBookmark
+ \cs_set_eq:NN \SI \SIInBookmark
+ \cs_set_eq:NN \SIrange \SIrangeInBookmark
+ \cs_set_eq:NN \si \siInBookmark
+ \cs_set_eq:NN \highlight \use_ii:nn
+ \cs_set_eq:NN \__siunitx_textsuperscript:n \use:n
+ \cs_set:Npn \SIUnitSymbolAngstrom { \AA }
+ \cs_set:Npn \SIUnitSymbolArcminute { ' }
+ \cs_set:Npn \SIUnitSymbolArcsecond { '' }
+ \cs_set:Npn \SIUnitSymbolCelsius { \textcelsius }
+ \cs_set:Npn \SIUnitSymbolDegree { \textdegree }
+ \cs_set:Npn \SIUnitSymbolMicro { \textmu }
+ \cs_set:Npn \SIUnitSymbolOhm { \textohm }
+ }
+\DeclareExpandableDocumentCommand \numInBookmark { o m } {#2}
+\DeclareExpandableDocumentCommand \numrangeInBookmark { o m m }
+ { #2 \l__siunitx_range_phrase_tl #3 }
+\DeclareExpandableDocumentCommand \SIInBookmark { o m o m }
+ { \IfNoValueF {#3} {#3} #2 ~ #4 }
+\DeclareExpandableDocumentCommand \SIlistInBookmark
+ { o m m } { \__siunitx_bookmark_SIlist_map:nn {#1} {#2} }
+\DeclareExpandableDocumentCommand \SIrangeInBookmark
+ { o m m m } { #2 ~ #4 \l__siunitx_range_phrase_tl #3 ~ #4 }
+\DeclareExpandableDocumentCommand \siInBookmark { o m } {#2}
+\cs_new:Npn \__siunitx_bookmark_SIlist_map:nn #1#2 {
+ \__siunitx_bookmark_SIlist_map_aux:nw {#2} #1 ; \q_recursion_tail ;
+ \q_recursion_tail ; \q_recursion_stop
+}
+\cs_new:Npn \__siunitx_bookmark_SIlist_map_aux:nw #1#2 ; #3 ; #4 {
+ #2 ~ #1
+ \quark_if_recursion_tail_stop:n {#3}
+ \quark_if_recursion_tail_stop_do:nn {#4}
+ {
+ \l__siunitx_list_separator_final_tl
+ #3 ~ #1
+ }
+ \l__siunitx_list_separator_tl
+ \__siunitx_bookmark_SIlist_map_aux:nw {#1} #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 }
+\DeclareSIUnit [ number-unit-product = ] \arcmin { \arcminute }
+\DeclareSIUnit [ number-unit-product = ]
+ \arcminute { \SIUnitSymbolArcminute }
+\DeclareSIUnit [ number-unit-product = ]
+ \arcsecond { \SIUnitSymbolArcsecond }
+\DeclareSIUnit \day { d }
+\DeclareSIUnit[ number-unit-product = ] \degree { \SIUnitSymbolDegree }
+\DeclareSIUnit \hectare { ha }
+\DeclareSIUnit \hour { h }
+\DeclareSIUnit \litre { l }
+\DeclareSIUnit \liter { L }
+\DeclareSIUnit \minute { min }
+\DeclareSIUnit \percent { \char 37 }
+\DeclareSIUnit \tonne { t }
+\DeclareSIUnit \astronomicalunit { au }
+\DeclareSIUnit \atomicmassunit { u }
+\DeclareSIUnit \electronvolt { eV }
+\DeclareSIUnit \dalton { Da }
+\group_begin:
+\cs_set_eq:NN \endgroup \group_end:
+\char_set_catcode_math_subscript:N \_
+\use:n
+ {
+ \endgroup
+ \DeclareSIUnit \clight { \text { \ensuremath { c _ { 0 } } } }
+ \DeclareSIUnit \electronmass
+ { \text { \ensuremath { m _ { \textup { e } } } } }
+ }
+\DeclareSIUnit \planckbar { \text { \ensuremath { \hbar } } }
+\DeclareSIUnit \elementarycharge { \text { \ensuremath { e } } }
+\group_begin:
+\cs_set_eq:NN \endgroup \group_end:
+\char_set_catcode_math_subscript:N \_
+\use:n
+ {
+ \endgroup
+ \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 }
+\keys_define:nn { siunitx } {
+ strict .code:n =
+ {
+ \keys_set:nn { siunitx }
+ {
+ bracket-numbers = true,
+ detect-family = false,
+ detect-mode = false,
+ detect-shape = false,
+ detect-weight = false,
+ multi-part-units = brackets,
+ parse-numbers = true,
+ parse-units = true,
+ product-units = repeat
+ }
+ \__siunitx_strict_option:n
+ {
+ bracket-numbers ,
+ detect-family ,
+ detect-italic ,
+ detect-mode ,
+ detect-shape ,
+ detect-weight ,
+ multi-part-units ,
+ parse-numbers ,
+ parse-units ,
+ product-units
+ }
+ \keys_define:nn { siunitx }
+ {
+ per-mode / repeated-symbol .code:n =
+ {
+ \msg_warning:nnx { siunitx } { option-not-available }
+ { per-mode~=~repeated-symbol }
+ }
+ }
+ }
+}
+\__siunitx_option_deactivate:n { strict }
+\cs_new_protected:Npn \__siunitx_strict_option:n #1 {
+ \clist_map_function:nN {#1} \__siunitx_strict_option_aux:n
+}
+\cs_new_protected: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 } {
+ locale .choice:,
+ locale /
+ DE .meta:n =
+ {
+ exponent-product = \ensuremath { \cdot } ,
+ inter-unit-product = \, ,
+ output-decimal-marker = { , }
+ },
+ locale /
+ FR .meta:n =
+ {
+ exponent-product = \ensuremath { \times } ,
+ inter-unit-product = \, ,
+ output-decimal-marker = { , }
+ },
+ locale /
+ UK .meta:n =
+ {
+ exponent-product = \ensuremath { \times } ,
+ inter-unit-product = \, ,
+ output-decimal-marker = .
+ },
+ locale /
+ US .meta:n = { locale = UK },
+ locale /
+ USA .meta:n = { locale = UK },
+ locale /
+ ZA .meta:n =
+ {
+ exponent-product = \ensuremath { \times } ,
+ inter-unit-product = \ensuremath { \cdot } ,
+ output-decimal-marker = { , }
+ },
+}
+\file_if_exist:nT { translator.sty }
+ {
+ \RequirePackage { translator }
+ \usedictionary { translator-basic-dictionary }
+ \providetranslation [ to = English ]
+ { to~(numerical~range) } { to }
+ \providetranslation [ to = French ]
+ { to~(numerical~range) } { \`a }
+ \providetranslation [ to = German ]
+ { to~(numerical~range) } { bis }
+ \providetranslation [ to = Spanish ]
+ { to~(numerical~range) } { a }
+ \sisetup
+ {
+ list-final-separator = { ~ \translate { and } ~ },
+ list-pair-separator = { ~ \translate { and } ~ },
+ range-phrase = { ~ \translate { to~(numerical~range) } ~ }
+ }
+ }
+\tl_const:Nn \c__siunitx_configuration_ext_tl { cfg }
+\keys_define:nn { siunitx }
+ {
+ abbreviations .choice:,
+ abbreviations /
+ true .code:n = { \__siunitx_load_abbreviations: },
+ abbreviations /
+ false .code:n =
+ { \cs_set_eq:NN \__siunitx_load_abbreviations: \prg_do_nothing: } ,
+ abbreviations .default:n = true ,
+ binary-units .choice:,
+ binary-units /
+ true .code:n = { \AtBeginDocument { \__siunitx_load_binary: } },
+ binary-units /
+ false .code:n =
+ { \cs_set_eq:NN \__siunitx_load_binary: \prg_do_nothing: } ,
+ binary-units .default:n = true
+ }
+\cs_new_protected:Npn \__siunitx_load_abbreviations:
+ {
+ \@onefilewithoptions { siunitx-abbreviations } [ ] [ ]
+ \c__siunitx_configuration_ext_tl
+ }
+\cs_new_protected:Npn \__siunitx_load_binary:
+ {
+ \@onefilewithoptions { siunitx-binary } [ ] [ ]
+ \c__siunitx_configuration_ext_tl
+ }
+\AtBeginDocument { \__siunitx_load_abbreviations: }
+\__siunitx_option_deactivate:n { abbreviations , binary }
+\keys_define:nn { siunitx }
+ {
+ version-1-compatibility .choice: ,
+ version-1-compatibility /
+ true .code:n =
+ {
+ \@onefilewithoptions { siunitx-version-1 } [ ] [ ]
+ \c__siunitx_configuration_ext_tl
+ },
+ version-1-compatibility /
+ false .code:n = { } ,
+ version-1-compatibility .default:n = true
+ }
+\__siunitx_option_deactivate:n { version-1-compatibility }
+\keys_define:nn { siunitx } {
+ load-configurations .code:n =
+ {
+ \clist_if_in:nnT {#1} { version-1 }
+ {
+ \@onefilewithoptions { siunitx-version-1 } [ ] [ ]
+ \c__siunitx_configuration_ext_tl
+ }
+ }
+}
+\__siunitx_option_deactivate:n { load-configurations }
+\file_if_exist:nT { siunitx . \c__siunitx_configuration_ext_tl }
+ {
+ \@onefilewithoptions { siunitx } [ ] [ ]
+ \c__siunitx_configuration_ext_tl
+ }
+\ProcessKeysOptions { siunitx }
+\AtBeginDocument {
+ \bool_if:NTF \l__siunitx_create_free_bool
+ { \__siunitx_unit_create_functions: }
+ { \__siunitx_unit_create_empty_functions: }
+}
+%% Copyright (C) 2008-2021 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-v2.sty'.