0

I'm looking to create a table in which I align the entries by the dot. For the first column of entry values, this alignment takes place nicely. However, for the second column, the negative value surrounded by square-brackets is shifted so that the dots do not align. Any suggestions how to solve this?

\begin{table}[htbp!]
\centering
\begin{tabular}{*{1}{l}*{3}{S[table-format=1.2]}}
\toprule
\toprule
        & {$\alpha$} & {$\beta$} & {$R^{2}$}\\
        \midrule
                        Credit Spread & 0.00  & 0.13  & 0.00\\
 &\hbox{[$0.26$]}  & \hbox{[$-5.56$]}  & \\
  \addlinespace 

       \bottomrule
   \end{tabular}
   \end{table}
  • Welcome to TeX.SX! Why are you using these hboxes? To disable the effects of the S column? – TeXnician Aug 29 '18 at 11:20
  • 2
    (1) welcome, (2) it is custom here to post full minimal examples, not sniplets like this. Full minimal examples can then be copied as is and tested. (3) Why are you using those \hbox in the first place? They of course messes things us and the S parser cannot see the dot. Can you explain what exactly you are trying to do? I've never seen that syntax before. – daleif Aug 29 '18 at 11:21
1

Here is what I'm assuming you are trying to do

\documentclass[a4paper]{memoir}

\usepackage{siunitx}

\begin{document}

\begin{table}[htbp!]
  \centering

  \sisetup{
    parse-numbers=false,
  }

  \newcommand\mc[1]{\multicolumn{1}{c}{#1}}
  \begin{tabular}{
      l
      S[table-format=2.3] % space for []'s
      S[table-format=-2.3] % 
      S[table-format=1.3] % 
    }
    \toprule
    & \mc{$\alpha$} & \mc{$\beta$} & \mc{$R^{2}$}
    \\
    \midrule
    Credit Spread & 0.00       & 0.13      & 0.00
    \\
    & [0.26]     & [-5.56]   & 
    \\
    \addlinespace 

    \bottomrule
  \end{tabular}
\end{table}


\end{document}
1

You need to reserve space for the brackets:

\documentclass{article}
\usepackage{siunitx,booktabs}

\begin{document}

\begin{table}[htp]
\centering

\caption{Whatever}

\sisetup{
  table-space-text-pre=[,
  table-space-text-post=],
}

\begin{tabular}{
  l
  S[table-format=1.2]
  S[table-format=-1.2]
  S[table-format=1.2]
}
\toprule
        & {$\alpha$} & {$\beta$} & {$R^{2}$}\\
\midrule
Credit Spread &  0.00  &   0.13  & 0.00 \\
              & [0.26] & [-5.56] &      \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

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.