I basically need to create a regression table with coefficients on one line, and t-statistics in brackets on the second line. However, I have a problem when the t-statistics are negative. When I compile the code, I get a misplaced sign token error. Here is the code that I used:

\documentclass[12pt,a4paper,twoside]{article}
\usepackage[french,german,english]{babel}                      
\usepackage{array}
\usepackage{multirow}
\usepackage{amsmath, amssymb,mathrsfs}  
\usepackage{siunitx}
\sisetup{
input-symbols = {()},
group-digits  = false,
explicit-sign
}

\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{l S S}
&\multicolumn{1}{c}{Proportion taken}&\multicolumn{1}{c}{Decision category}\\

Coefficient   &      -0.116** &      0.711** \\
t-test & (-0.23094) & (3223.3)\\

\end{tabular}
\end{table}

\end{document}

If I change the -0.23094 to 0.23094, it works fine, but not when I include the sign.

up vote 2 down vote accepted

\sisetup{parse-numbers=false} turns off the number parser inside the table environment. Then the numbers will be printed in math mode 'as given'.

\documentclass[12pt,a4paper,twoside]{article}
\usepackage[T1]{fontenc}
\usepackage[french,german,english]{babel}                      
\usepackage{array}
\usepackage{multirow}
\usepackage{amsmath, amssymb,mathrsfs}  
\usepackage{siunitx}
\sisetup{
input-symbols = {()},
group-digits  = false,
explicit-sign
}

\begin{document}
\begin{table}[ht]
\centering
\sisetup{parse-numbers=false}
\begin{tabular}{l S S}
  &\multicolumn{1}{c}{Proportion taken}&\multicolumn{1}{c}{Decision category}\\
  Coefficient   &      -0.116** &      0.711** \\
  t-test & (-0.23094) & (3223.3)\\
\end{tabular}
\end{table}

\end{document}

enter image description here

It is the option input-symbols = {()} that causes the “misplaced sign token" error.

However, I recommend not to set parse-numbers = false to work around this issue because it disables siunitx’s rounding and digit-grouping features, and it changes the appearance of the asterisk (as you can see from esdd’s screenshots above).

Instead, you should do without including the parentheses in the input-symbol list. Here’s my suggestion:

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{
    detect-all,
    round-integer-to-decimal = true,
    group-digits             = true,
    group-minimum-digits     = 4,
    group-separator          = {\,},
    table-align-text-pre     = false,
    table-align-text-post    = false,
    input-signs              = + -,
    input-symbols            = {*} {**} {***},
    input-open-uncertainty   = ,
    input-close-uncertainty  = ,
    retain-explicit-plus
}

\begin{document}

\begin{center}
  \begin{tabular}
    {@{}
     l
     S[table-format=+1.5, table-space-text-pre={**}, table-space-text-post={-**}]
     S[table-format=-4.3, table-space-text-pre={**}, table-space-text-post={-**}]
     @{}
    }
    \toprule
                & {Proportion taken} & {Decision category} \\
    \midrule
    Coefficient & -0.116**           &    0.711**          \\
    $t$-test    & (-0.23094)         & (3223.3)            \\
    \bottomrule
  \end{tabular}
\end{center}

\end{document}

This compiles into the following:

LaTeX example table using siunitx

  • How do you get rid of the space between the numbers (e.g., there's a space between 0 and 9 and again between 3 and 2)? – Chernoff May 25 at 19:15
  • To get rid of the grouping space between digits, set group-digits = false. – Holger Gerhardt Aug 7 at 15:10

I would do as follows:

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{
  input-symbols         = {()},
  group-digits          = false,
  table-space-text-post = **,
  explicit-sign
}

\begin{document}

\begin{center}
  \begin{tabular}{l S[table-format = -1.5] S[table-format = 4.3]}
   \toprule
                & {Proportion taken} & {Decision category} \\
   \midrule
    Coefficient & -0.116**           &    0.711**          \\
    $t$-test    & -0.23094           & 3223.3              \\
   \bottomrule
  \end{tabular}
\end{center}

\end{document}

output

Notice the use of table-space-text-post = ** to get a proper vertical alignment.

Also, the centering via \multicolumn is unnecessary since an entry surrounded by {} in an S-column is automatically centered.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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