2

I am having some trouble with the siunitx package and its S column. I am trying to create a regression table where the regression coefficients and the t-statistics are aligned on the decimal using the S column from siunitx. The problem I am encountering is the fact that the numbers in the table seem to have the math font, whereas I would prefer to have the same font as the rest of the text (Times). The result is the following: enter image description here

I've tried several different solutions, including the use of the detect-all, detect-weight, and detect-family options but none seem to work for me. A minimum working example is provided below. Hope someone can help me, all help is appreciated!

MWE:

\documentclass[a4paper, 12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{times}
\sisetup{detect-all=true}
\usepackage{rotating}

\begin{document}
\begin{sidewaystable}[htbp]
\centering
\sisetup{input-symbols = {()}, parse-numbers=false}
\caption{Regression\label{tab1}}
\begin{tabular*}{\textwidth}{lSSSSSS}
\toprule
                    & \multicolumn{6}{c}{Dependent Variable: Alpha Post}\\
                    &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}&\multicolumn{1}{c}{(5)}&\multicolumn{1}{c}{(6)}\\
\midrule
Variable 1  & -0.0115  &          &                 & -0.0107   & -0.0302*      & -0.0121         \\
                           & (-1.38)  &          &                 & (-0.97)   & (-1.75)             & (-0.21)         \\
\addlinespace
Variable 2 &          & -0.00101 &                 & -0.000283 & -0.000841           & -0.000408         \\
                           &          & (-1.57)  &                 & (-0.35)   & (-0.95)             & (-0.19)         \\
\bottomrule
\multicolumn{7}{l}{\footnotesize \textit{t}-statistics in parentheses}\\
\multicolumn{7}{l}{\footnotesize * \(p<.10\), ** \(p<.05\), *** \(p<.01\)}\\
\end{tabular*}
\end{sidewaystable}

\end{document}

Edit: Using the advice from Mico I changed my times and amsmath packages to newtxtext and newtxmath respectively and it seems to have solved the issue. Solution

3
  • 2
    Note that the times package is a deprecated text-only font package. I suggest you load the newtxtext and newtxmath packages.
    – Mico
    Apr 5 '18 at 16:41
  • @Mico Thanks for the comment, was unaware of the fact that the times package was deprecated. Changing my times and amsmath packages to newtxtext and newtxmath respectively seems to have solved the issue. Thank you very much!
    – Oxbowerce
    Apr 5 '18 at 16:54
  • I sugest to use the package mathptmx if you want a roman-like font option that supports math.
    – J Leon V.
    Apr 5 '18 at 17:04
3

In addition to loading a suitable Times Roman math font, you should provide the @{\extracolsep{\fill}} directive to make sure that the columns fully span the width of the tabular* environment. Providing a bit more structure to the header would also be helpful.

enter image description here

\documentclass[a4paper, 12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{booktabs}
\usepackage{siunitx,tabularx,rotating}
\usepackage{newtxtext,newtxmath}

\begin{document}
\begin{sidewaystable}
\setlength\tabcolsep{0pt} % make LaTeX figure out inter-col. whitespace
\sisetup{input-symbols = {()}, parse-numbers=false}
\caption{Regression\label{tab1}}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{6}{S[table-format=-2.6]} @{}}
\toprule
& \multicolumn{6}{c}{Dependent Variable: Alpha Post}\\
\cmidrule{2-7}
&{(1)}&{(2)}&{(3)}&{(4)}&{(5)}&{(6)}\\
\midrule
Variable 1 & -0.0115 & & & -0.0107 & -0.0302* & -0.0121 \\
           & (-1.38) & & & (-0.97) & (-1.75) & (-0.21) \\
\addlinespace
Variable 2 & & -0.00101 & & -0.000283 & -0.000841 & -0.000408 \\
           & & (-1.57) & & (-0.35) & (-0.95) & (-0.19) \\
\bottomrule
\multicolumn{7}{l}{\footnotesize \textit{t}-statistics in parentheses}\\
\multicolumn{7}{l}{\footnotesize * \(p<.10\), ** \(p<.05\), *** \(p<.01\)}\\
\end{tabular*}
\end{sidewaystable}

\end{document}

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.