is it possible to customize the space inserted before and after the plus-or-minus symbol using siunitx?

My problem is the following: when used in math mode, a space is inserted before and after the plus-or-minus symbol, which is fine. But the same space is missing when using in text mode, which I don't find aesthetic. How can I change this behavior? I don't think I've seen a command to do this in the documentation.

enter image description here

Here is a MWE:

\sisetup{mode = match, separate-uncertainty = true}


(18.0\:±\:0.2)%The spacing I would like to have around ±

$\qty{18.0+-0.2}{\kilo\gram}$%To compare with the math mode

1 Answer 1


The issue is that in v3 I work harder to use 'real' text mode symbols, but they of course don't space correctly in 'math like' situations. I've logged and issue and will creat a release shortly. For the present, you can use

\cs_gset_protected:Npn \__siunitx_print_text_replace:n #1
      \tl_if_head_eq_meaning:nNTF {#1} \mathchoice
        { \__siunitx_print_text_replace:Nnnnn #1 }
          \tl_set:Nn \l__siunitx_print_tmp_tl {#1}
          \tl_if_empty:NF \l_siunitx_unit_font_tl
            { \exp_after:wN \cs_set_eq:NN \l_siunitx_unit_font_tl \use:n }
          \cs_set:Npn \mathord ##1
              \str_case:nnF {##1}
                  { \cdot }  { \exp_not:N \textperiodcentered }
                  { \pm }    { \exp_not:N \textpm }
                  { \times } { \exp_not:N \texttimes }
                { ##1 }
          \cs_set:Npn \pm { \: \exp_not:N \textpm \: }
            { \mp \ge \le \gg \ll }
            { \cs_set:Npn ##1 { \exp_not:N \ensuremath { \exp_not:N ##1 } } }
          \cs_set:Npn \cdot { \: \exp_not:N \textperiodcentered \: }
          \cs_set:Npn \times { \: \exp_not:N \texttimes \: }
          \protected@edef \l__siunitx_print_tmp_tl { \l__siunitx_print_tmp_tl }
          \__siunitx_print_text_replace:N \l__siunitx_print_tmp_tl
          \__siunitx_print_text_replace_aux:n { \tl_use:N \l__siunitx_print_tmp_tl }

The idea here is that if \mathord applies, we filter out \cdot/\pm/\times and just replace with the text mode version. Without the \mathord, the definitions are adjusted such that spaces are added explicitly to maintain the spacing.

  • I suspect longer-term I'll need more flexibility here, but that's not an urgent fix
    – Joseph Wright
    Commented Feb 2, 2022 at 12:57
  • Hello, thank you for your diligence, your solution works. I do have one remark though: for cases such as \qty{+-5.0}{\percent} a redundant space appears in front of the ± (and perhaps the space between the ± and the number is also superfluous if one considers that it should be formatted as \qty{-5.0}{\percent} or \qty[retain-explicit-plus]{+5.0}{\percent}).
    – Bastien
    Commented Feb 2, 2022 at 16:29
  • 1
    @Bastien Hmm, yes: I'll have to extend the logic for adding \mathord a little - I'll think about that this evening. Should all be fixed in a version out tomorrow.
    – Joseph Wright
    Commented Feb 2, 2022 at 17:27
  • 1
    @Bastien I have a plan: release shortly
    – Joseph Wright
    Commented Feb 3, 2022 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .