I am trying to align my columns on the decimal points. I'd like the column widths to be equal. I believe a possible answer is here, but I am really struggling to implement. Any thoughts?
Note: I need to have the asterisks in the same column. In other words, I cannot rely on -0.470&***
. I should be able to wrap asterisks in other code, however (e.g., -0.470^{***}
) if essential.
\documenttype{report}
\begin{document}
\begin{table}[ht]
\centering
\begin{tabular}{rllllll}
\hline
& 1 & 2 & 3 & 4 & 5 & 6 \\
\hline
1 & & & & & & \\
2 & 0.47*** & & & & & \\
3 & 0.28* & 0.24* & & & & \\
4 & 0.14 & -0.03 & -0.08 & & & \\
5 & -0.28* & -0.22 & -0.11 & -0.38*** & & \\
6 & 0.14 & -0.02 & 0.02 & 0.23* & -0.02 & \\
\hline
\end{tabular}
\end{table}
\end{document}
The closest I've come is:
\documentclass{report}
\usepackage{siunitx}
\usepackage{booktabs}
\newcolumntype{L}{@{}l@{}} % a left column with no intercolumn space on either side
\newcommand{\mc}[1]{\multicolumn{1}{c}{#1}} % shorthand macro for column headings
\begin{document}
\begin{table}[ht]
\centering
%\begin{tabular}{rllllll}
\begin{tabular}{LS@{}S@{}S@{}S@{}S@{}S@{}}
\hline
\mc{} & \mc{1} & \mc{2} & \mc{3} & \mc{4} & \mc{5} & \mc{6} \\
\hline
1 & & & & & & \\
2 & 0.47*** & & & & & \\
3 & 0.28* & 0.24* & & & & \\
4 & 0.14 & -0.03 & -0.08 & & & \\
5 & -0.28* & -0.22 & -0.11 & -0.38*** & & \\
6 & 0.14 & -0.02 & 0.02 & 0.23* & -0.02 & \\
\hline
\end{tabular}
\end{table}
\end{document}
But notice (a) the space between -0.28 and * and (b) varying column widths.