13

please, consider the following mwe:

\documentclass[margin=3mm]{standalone}
\usepackage{siunitx}
    \sisetup{input-symbols = {( - )},
             table-space-text-post=***,
             group-digits=integer,
             group-four-digits,
             group-separator={,}
             }

\begin{document}
\begin{tabular}{S[table-format=5.5]}
    \hline
  123.45678     \\
 1234.5678      \\
  (12.345)      \\
 (123.45)       \\
    \hline
\end{tabular}
\end{document}

which gives:

enter image description here

as you can see, results in the first three rows are as expected, but in the last two rows the comma should not appear. did i miss something or this is bug?

edit: recent siunitx version v2.7n, last revised 2018-04-27 (available in miktex from 2018.05.03) contain fix as package author Joseph Wright gives in his answer below the following result:

enter image description here

this update is an important step towards a complete solution to the presented problem. apparently distinguishing between input symbols ( from numbers is (very) difficult problem.

12

The issue is that internally the symbolic input was being stored as \ensuremath{<thing>}, which looks like two characters when we do spacing. As a temporary fix, add

\ExplSyntaxOn
\cs_set_protected:Npn \__siunitx_number_in_parse_mantissa:N #1 {
  \tl_if_in:NnTF \l__siunitx_input_digit_tl {#1}
    { \__siunitx_number_in_digit:n {#1} }
    {
      \tl_if_in:NnTF \l__siunitx_input_decimal_tl {#1}
        { \__siunitx_number_in_decimal:N #1 }
        {
          \tl_if_in:NnTF \l__siunitx_input_sign_tl {#1}
            { \__siunitx_number_in_sign:N #1 }
            {
              \tl_if_in:NnTF \l__siunitx_input_symbol_tl {#1}
                {
                  \prop_put:Nnn \l__siunitx_number_in_prop { symbolic }
                    { true }
                  \__siunitx_number_in_digit:n {#1}
                }
                {
                  \tl_if_in:NnF \l__siunitx_input_ignore_tl {#1}
                    { \__siunitx_number_in_parse_more:N #1 }
                }
            }
        }
    }
}
\ExplSyntaxOff

I'll adjust the master code shortly.

  • meanwhile i add to question one more row with (123.45) , which seems make additional trouble. your fix solve original question (comma in the third row disappear), but in last row in edited question not. please, look to question again. thank you very much! – Zarko Apr 27 '18 at 9:45
  • @Zarko Well yes, that is to be expected: a symbol is just a non-numeric 'digit' (I'm actually thinking of dropping the distinction: it's not actually that useful). If you are using brackets to mean something else, you need a different approach .... – Joseph Wright Apr 27 '18 at 9:50
  • i used brackets in some tables with statistic, mostly as help to asker here on site. in tables something like this tex.stackexchange.com/questions/428118/… (in it this is not problem). so far i didn't see a real case as is presented in my question. so, for now i can live with solution in your answer, but in future it will be fine to solve this somehow :) – Zarko Apr 27 '18 at 10:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.