8

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.

3 Answers 3

3

\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

4

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

2
  • 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, 2018 at 19:15
  • 1
    To get rid of the grouping space between digits, set group-digits = false. Aug 7, 2018 at 15:10
0

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.

You must log in to answer this question.

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