From cb57b9d1a6ccf3d7991bb0d0347c0ab1b95061dd Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Thu, 3 Oct 2024 15:35:07 +0100 Subject: [PATCH] Switch from \ifmmode ... \fi to \TextOrMath --- siunitx-compound.dtx | 28 ++++++++++++++-------------- siunitx-emulation.dtx | 30 ++++++++++++++++-------------- siunitx-locale.dtx | 16 ++++++++-------- testfiles/siunitx-compound.lvt | 2 +- 4 files changed, 39 insertions(+), 37 deletions(-) diff --git a/siunitx-compound.dtx b/siunitx-compound.dtx index f6f2c115..053b1cc6 100644 --- a/siunitx-compound.dtx +++ b/siunitx-compound.dtx @@ -1340,41 +1340,41 @@ compound-exponents = individual , compound-final-separator = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { and } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , compound-independent-prefix = false , compound-open-boundary = , compound-open-bracket = ( , % ) compound-pair-separator = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { and } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , compound-separator = - { , \ifmmode \ \else \space \fi } , + { , \TextOrMath { \space } { \ } } , compound-separator-mode = text , compound-units = repeat , % ( list-close-bracket = ) , list-exponents = individual , list-final-separator = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { and } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , list-independent-prefix = false , list-open-bracket = ( , % ) list-pair-separator = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { and } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , list-separator = - { , \ifmmode \ \else \space \fi } , + { , \TextOrMath { \space } { \ } } , list-units = repeat , % ( product-close-bracket = ) , product-exponents = individual , @@ -1383,9 +1383,9 @@ product-open-bracket = ( , % ) product-phrase = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { by } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , product-symbol = \times , product-units = repeat , % ( @@ -1396,9 +1396,9 @@ range-open-phrase = , range-phrase = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { to } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , range-units = repeat } diff --git a/siunitx-emulation.dtx b/siunitx-emulation.dtx index 8ff0aa57..aa2de2a8 100644 --- a/siunitx-emulation.dtx +++ b/siunitx-emulation.dtx @@ -1006,20 +1006,22 @@ } \cs_new_protected:Npx \SIUnitSymbolOhm { - \exp_not:N \ifmmode - \cs_if_exist:NTF \upOmega - { \exp_not:N \upOmega } - { \exp_not:N \Omega } - \exp_not:N \else - \siunitx_print_text:n - { - \bool_lazy_or:nnTF - { \sys_if_engine_luatex_p: } - { \sys_if_engine_xetex_p: } - { \@@_non_latin:n { "03A9 } } - { \exp_not:N \textohm } - } - \exp_not:N \fi + \exp_not:N \TextOrMath + { + \siunitx_print_text:n + { + \bool_lazy_or:nnTF + { \sys_if_engine_luatex_p: } + { \sys_if_engine_xetex_p: } + { \@@_non_latin:n { "03A9 } } + { \exp_not:N \textohm } + } + } + { + \cs_if_exist:NTF \upOmega + { \exp_not:N \upOmega } + { \exp_not:N \Omega } + } } } % \end{macrocode} diff --git a/siunitx-locale.dtx b/siunitx-locale.dtx index 457eeaeb..0aba22ac 100644 --- a/siunitx-locale.dtx +++ b/siunitx-locale.dtx @@ -173,15 +173,15 @@ { list-final-separator = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { \GetTranslation { and } } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , list-pair-separator = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { \GetTranslation { and } } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } , range-open-phrase = { @@ -196,16 +196,16 @@ { from~(numerical~range) } } { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { \GetTranslation { from~(numerical~range) } } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } } , range-phrase = { - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } \text { \GetTranslation { to~(numerical~range) } } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } } } diff --git a/testfiles/siunitx-compound.lvt b/testfiles/siunitx-compound.lvt index 1c9630c7..7146cda4 100644 --- a/testfiles/siunitx-compound.lvt +++ b/testfiles/siunitx-compound.lvt @@ -295,7 +295,7 @@ range-open-phrase = { \text { from } - \ifmmode \ \else \space \fi + \TextOrMath { \space } { \ } } } \test:nn { 1 } { 2 }