I am trying to create a table containing a correlation matrix. I marked the significant numbers bold and insignificant are just normal. Anyhow, all boldifyed numbers are aligned differently than the "normal" ones. I tried to put the content in multicolumn{1}{c}[} But even then the numbers are not "correctly" aligned. Is there a way to fix that? Additionally, I tried to put a star after the significant numbers but the star is like a "multiplying" star (centered and not "exponent").
\documentclass[a4paper, 12pt]{article}
\usepackage[left=4cm, right=3cm, top=3cm, bottom=4cm]{geometry}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage[labelsep=newline,% line break after label
justification=raggedright,
singlelinecheck=off,
font=sc]{caption}
\usepackage{subcaption}
\usepackage{siunitx}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{table}[htp!]
\setlength\tabcolsep{0.1pt} % default value: 6.0pt
\caption{Pearson and Spearman Rank Correlation Matrix}
\label{tab:PSCorrelation}
\scriptsize
\begin{threeparttable}
\begin{tabular*}{\textwidth}%
{ @{\extracolsep{\fill}} l *{11}{d{2.3}} }
\toprule
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} & \mc{(5)} & \mc{(6)} & \mc{(7)} & \mc{(8)} & \mc{(9)} & \mc{(10)} & \mc{(11)} \\ [0.5ex]
\midrule
(1) (D)SUE1
& & \textbf{\hphantom{-}0.877} & \textbf{\hphantom{-}0.257} & -0.005 & \textbf{$-$0.095} & \textbf{$-$0.101} & \textbf{$-$0.093} & 0.000 & \textbf{$-$0.061} & \textbf{\hphantom{-}0.089} & -0.001 \\
(2) (D)SUE2
& \textbf{\hphantom{-}0.858} & & \textbf{\hphantom{-}0.286} & -0.008 & \textbf{$-$0.093} & \textbf{$-$0.101} & \textbf{$-$0.088} & -0.004 & \textbf{$-$0.062} & \textbf{\hphantom{-}0.095} & -0.005 \\
(3) (D)SUE3
& \textbf{\hphantom{-}0.256} & \textbf{\hphantom{-}0.295} & & 0.010 & 0.008 & \textbf{$-$0.144} & \textbf{$-$0.076} & 0.006 & \textbf{$-$0.043} & \textbf{\hphantom{-}0.165} & \textbf{$-$0.083} \\
(4) $\Delta$SPOT
& -0.011 & \textbf{$-$0.023} & -0.009 & & \textbf{\hphantom{-}0.177} & \textbf{$-$0.126} & \textbf{$-$0.160} & -0.000 & 0.017 & \textbf{\hphantom{-}0.023} & \textbf{$-$0.253} \\
(5) $\Delta$SLOPE
& \textbf{$-$0.031} & \textbf{$-$0.024} & 0.013 & \textbf{\hphantom{-}0.274} & & -0.006 & -0.004 & 0.016 & \textbf{\hphantom{-}0.081} & \textbf{$-$0.028} & \textbf{$-$0.086} \\
(6) $\Delta$LEVERAGE
& \textbf{$-$0.106} & \textbf{$-$0.102} & \textbf{$-$0.110} & \textbf{$-$0.163} & \textbf{$-$0.051} & & \textbf{\hphantom{-}0.259} & 0.006 & \textbf{\hphantom{-}0.030} & \textbf{$-$0.094} & \textbf{\hphantom{-}0.101} \\
(7) $\Delta$VOLA
& \textbf{$-$0.123} & \textbf{$-$0.119} & \textbf{$-$0.036} & \textbf{$-$0.230} & \textbf{$-$0.079} & \textbf{\hphantom{-}0.316} & & 0.010 & -0.011 & \textbf{$-$0.051} & \textbf{\hphantom{-}0.195} \\
(8) UPGRADE
& \textbf{\hphantom{-}0.022} & 0.015 & 0.004 & -0.002 & \textbf{\hphantom{-}0.024} & 0.011 & \textbf{\hphantom{-}0.024} & & \textbf{$-$0.029} & \textbf{\hphantom{-}0.018} & \textbf{$-$0.018} \\
(9) DOWNGRADE
& \textbf{$-$0.057} & \textbf{$-$0.053} & \textbf{$-$0.035} & 0.009 & \textbf{\hphantom{-}0.064} & \textbf{\hphantom{-}0.048} & \textbf{\hphantom{-}0.033} & \textbf{$-$0.022} & & \textbf{$-$0.024} & 0.000 \\
(10) BHAR
& \textbf{\hphantom{-}0.073} & \textbf{\hphantom{-}0.067} & \textbf{\hphantom{-}0.155} & \textbf{\hphantom{-}0.037} & 0.007 & \textbf{$-$0.065} & \textbf{$-$0.095} & 0.015 & -0.016 & & \textbf{$-$0.207} \\
(11) CASC
& -0.011 & -0.004 & \textbf{$-$0.030} & \textbf{$-$0.111} & \textbf{$-$0.047} & \textbf{\hphantom{-}0.071} & \textbf{\hphantom{-}0.099} & 0.002 & 0.008 & \textbf{$-$0.340} & \\ [1ex]
\bottomrule
\end{tabular*}
\begin{tablenotes}
\item[a] A subtable-specific footnote
\end{tablenotes}
\end{threeparttable}
\end{table}
\begin{table}[htp!]
\setlength\tabcolsep{0.1pt} % default value: 6.0pt
\caption{Pearson and Spearman Rank Correlation Matrix}
\label{tab:PSCorrelation}
\scriptsize
\begin{threeparttable}
\begin{tabular*}{\textwidth}%
{ @{\extracolsep{\fill}} l *{11}{d{2.3}} }
\toprule
& \mc{(1)} & \mc{(2)} & \mc{(3)} & \mc{(4)} & \mc{(5)} & \mc{(6)} & \mc{(7)} & \mc{(8)} & \mc{(9)} & \mc{(10)} & \mc{(11)} \\ [0.5ex]
\midrule
(1) (D)SUE1
& & \mc{\textbf{\hphantom{-}0.877}} & \mc{\textbf{\hphantom{-}0.257}} & -0.005 & \mc{\textbf{$-$0.095}} & \mc{\textbf{$-$0.101}} & \mc{\textbf{$-$0.093}} & 0.000 & \mc{\textbf{$-$0.061}} & \mc{\textbf{\hphantom{-}0.089}} & -0.001 \\
(2) (D)SUE2
& \mc{\textbf{\hphantom{-}0.858}} & & \mc{\textbf{\hphantom{-}0.286}} & -0.008 & \mc{\textbf{$-$0.093}} & \mc{\textbf{$-$0.101}} & \mc{\textbf{$-$0.088}} & -0.004 & \mc{\textbf{$-$0.062}} & \mc{\textbf{\hphantom{-}0.095}} & -0.005 \\
(3) (D)SUE3
& \mc{\textbf{\hphantom{-}0.256}} & \mc{\textbf{\hphantom{-}0.295}} & & 0.010 & 0.008 & \mc{\textbf{$-$0.144}} & \mc{\textbf{$-$0.076}} & 0.006 & \mc{\textbf{$-$0.043}} & \mc{\textbf{\hphantom{-}0.165}} & \mc{\textbf{$-$0.083}} \\
(4) $\Delta$SPOT
& -0.011 & \mc{\textbf{$-$0.023}} & -0.009 & & \mc{\textbf{\hphantom{-}0.177}} & \mc{\textbf{$-$0.126}} & \mc{\textbf{$-$0.160}} & -0.000 & 0.017 & \mc{\textbf{\hphantom{-}0.023}} & \mc{\textbf{$-$0.253}} \\
(5) $\Delta$SLOPE
& \mc{\textbf{$-$0.031}} & \mc{\textbf{$-$0.024}} & 0.013 & \mc{\textbf{\hphantom{-}0.274}} & & -0.006 & -0.004 & 0.016 & \mc{\textbf{\hphantom{-}0.081}} & \mc{\textbf{$-$0.028}} & \mc{\textbf{$-$0.086}} \\
(6) $\Delta$LEVERAGE
& \mc{\textbf{$-$0.106}} & \mc{\textbf{$-$0.102}} & \mc{\textbf{$-$0.110}} & \mc{\textbf{$-$0.163}} & \mc{\textbf{$-$0.051}} & & \mc{\textbf{\hphantom{-}0.259}} & 0.006 & \mc{\textbf{\hphantom{-}0.030}} & \mc{\textbf{$-$0.094}} & \mc{\textbf{\hphantom{-}0.101}} \\
(7) $\Delta$VOLA
& \mc{\textbf{$-$0.123}} & \mc{\textbf{$-$0.119}} & \mc{\textbf{$-$0.036}} & \mc{\textbf{$-$0.230}} & \mc{\textbf{$-$0.079}} & \mc{\textbf{\hphantom{-}0.316}} & & 0.010 & -0.011 & \mc{\textbf{$-$0.051}} & \mc{\textbf{\hphantom{-}0.195}} \\
(8) UPGRADE
& \mc{\textbf{\hphantom{-}0.022}} & 0.015 & 0.004 & -0.002 & \mc{\textbf{\hphantom{-}0.024}} & 0.011 & \mc{\textbf{\hphantom{-}0.024}} & & \mc{\textbf{$-$0.029}} & \mc{\textbf{\hphantom{-}0.018}} & \mc{\textbf{$-$0.018}} \\
(9) DOWNGRADE
& \mc{\textbf{$-$0.057}} & \mc{\textbf{$-$0.053}} & \mc{\textbf{$-$0.035}} & 0.009 & \mc{\textbf{\hphantom{-}0.064}} & \mc{\textbf{\hphantom{-}0.048}} & \mc{\textbf{\hphantom{-}0.033}} & \mc{\textbf{$-$0.022}} & & \mc{\textbf{$-$0.024}} & 0.000 \\
(10) BHAR
& \mc{\textbf{\hphantom{-}0.073}} & \mc{\textbf{\hphantom{-}0.067}} & \mc{\textbf{\hphantom{-}0.155}} & \mc{\textbf{\hphantom{-}0.037}} & 0.007 & \mc{\textbf{$-$0.065}} & \mc{\textbf{$-$0.095}} & 0.015 & -0.016 & & \mc{\textbf{$-$0.207}} \\
(11) CASC
& -0.011 & -0.004 & \mc{\textbf{$-$0.030}} & \mc{\textbf{$-$0.111}} & \mc{\textbf{$-$0.047}} & \mc{\textbf{\hphantom{-}0.071}} & \mc{\textbf{\hphantom{-}0.099}} & 0.002 & 0.008 & \mc{\textbf{$-$0.340}} & \\ [1ex]
\bottomrule
\end{tabular*}
\begin{tablenotes}
\item[a] A subtable-specific footnote
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
EDIT: I have also tried the siunitx package, but the result is the same.
\begin{table}[htp!]
\sisetup{group-separator={}}
\caption{Pearson and Spearman Rank Correlation Matrix}
\begin{threeparttable}
\scriptsize
\begin{tabular*}{\textwidth}
{
@{\extracolsep{\fill}}
l
*{12]}{S[table-format=-1.3]}
@{}
}
/toprule
& {(1)} & {(2)} & {(3} & {(4)} & {(5)} & {(6)} & {(7)} & {(8)} & {(9)} & & {(10)} & {(11)}\\
\midrule
(1) (D)SUE1
& & \textbf{\hphantom{-}0.877} & \textbf{\hphantom{-}0.257} & -0.005 & \textbf{$-$0.095} & \textbf{$-$0.101} & \textbf{$-$0.093} & 0.000 & \textbf{$-$0.061} & \textbf{\hphantom{-}0.089} & -0.001 \\
(2) (D)SUE2
& \textbf{\hphantom{-}0.858} & & \textbf{\hphantom{-}0.286} & -0.008 & \textbf{$-$0.093} & \textbf{$-$0.101} & \textbf{$-$0.088} & -0.004 & \textbf{$-$0.062} & \textbf{\hphantom{-}0.095} & -0.005 \\
(3) (D)SUE3
& \textbf{\hphantom{-}0.256} & \textbf{\hphantom{-}0.295} & & 0.010 & 0.008 & \textbf{$-$0.144} & \textbf{$-$0.076} & 0.006 & \textbf{$-$0.043} & \textbf{\hphantom{-}0.165} & \textbf{$-$0.083} \\
(4) $\Delta$SPOT
& -0.011 & \textbf{$-$0.023} & -0.009 & & \textbf{\hphantom{-}0.177} & \textbf{$-$0.126} & \textbf{$-$0.160} & -0.000 & 0.017 & \textbf{\hphantom{-}0.023} & \textbf{$-$0.253} \\
(5) $\Delta$SLOPE
& \textbf{$-$0.031} & \textbf{$-$0.024} & 0.013 & \textbf{\hphantom{-}0.274} & & -0.006 & -0.004 & 0.016 & \textbf{\hphantom{-}0.081} & \textbf{$-$0.028} & \textbf{$-$0.086} \\
(6) $\Delta$LEVERAGE
& \textbf{$-$0.106} & \textbf{$-$0.102} & \textbf{$-$0.110} & \textbf{$-$0.163} & \textbf{$-$0.051} & & \textbf{\hphantom{-}0.259} & 0.006 & \textbf{\hphantom{-}0.030} & \textbf{$-$0.094} & \textbf{\hphantom{-}0.101} \\
(7) $\Delta$VOLA
& \textbf{$-$0.123} & \textbf{$-$0.119} & \textbf{$-$0.036} & \textbf{$-$0.230} & \textbf{$-$0.079} & \textbf{\hphantom{-}0.316} & & 0.010 & -0.011 & \textbf{$-$0.051} & \textbf{\hphantom{-}0.195} \\
(8) UPGRADE
& \textbf{\hphantom{-}0.022} & 0.015 & 0.004 & -0.002 & \textbf{\hphantom{-}0.024} & 0.011 & \textbf{\hphantom{-}0.024} & & \textbf{$-$0.029} & \textbf{\hphantom{-}0.018} & \textbf{$-$0.018} \\
(9) DOWNGRADE
& \textbf{$-$0.057} & \textbf{$-$0.053} & \textbf{$-$0.035} & 0.009 & \textbf{\hphantom{-}0.064} & \textbf{\hphantom{-}0.048} & \textbf{\hphantom{-}0.033} & \textbf{$-$0.022} & & \textbf{$-$0.024} & 0.000 \\
(10) BHAR
& \textbf{\hphantom{-}0.073} & \textbf{\hphantom{-}0.067} & \textbf{\hphantom{-}0.155} & \textbf{\hphantom{-}0.037} & 0.007 & \textbf{$-$0.065} & \textbf{$-$0.095} & 0.015 & -0.016 & & \textbf{$-$0.207} \\
(11) CASC
& -0.011 & -0.004 & \textbf{$-$0.030} & \textbf{$-$0.111} & \textbf{$-$0.047} & \textbf{\hphantom{-}0.071} & \textbf{\hphantom{-}0.099} & 0.002 & 0.008 & \textbf{$-$0.340} & \\ [1ex]
\bottomrule
\end{tabular*}
\begin{tablenotes}
\item[a] A subtable-specific footnote
\end{tablenotes}
\end{threeparttable}
\end{table}
The columns are not "shifted" anymore, but still not properly aligned.
edit2: I tried the solution from siunitx: aligning numbers by decimal points in tables doesn't work for bolded or italicized numbers, but it does not change anything.
edit3: I have found the solution for my question; I added
\usepackage{etoolbox}
\robustify\bfseries \sisetup{
detect-weight = true , locale = DE , }
\robustify\bfseries
in the table environment which aligns the numeric values in the table created with siunitx correctly. Still I do not have a solution for the table created with the dcolumn package.
\scriptsize.) – barbara beeton Aug 12 '14 at 20:59\obeyspaces. Then you can (for example) underline significant values. – RicoRally Nov 09 '14 at 11:35siunitxsolution was edited into the question (and found elsewhere on-site). Thedcolumnsolution is at Decimals in table don't align with dcolumn when bolded. I'm voting to close as a duplicate of thedcolumnsolution. – Paul Gessler Mar 24 '15 at 00:56