This question is related to Alignment of table entries: the case of negative numbers, where the problem is how to align table column entries in the presence of negative numbers and/or statistical significance stars.
In my case I have the same issue, with the additional problem that I have different panels in my table (two in the example below), where each panel contains variables measured with a different scale.
Below there's a simplified working example.
In panel A
I have 2 decimals preceded by 1 digit, whereas in panel B
I have no decimals and 2 or 3 digits.
I know one option is to use \usepackage{dcolumn}
, but here I am not sure how to define the custom column type, since the digits vary according to the panel.
Thanks for any suggestion.
\documentclass{article}
\usepackage{booktabs, longtable}
\usepackage[left=1.7cm,right=1.7cm,top=1.3cm,bottom=1.3cm]{geometry}
\newcommand{\rowgroup}[1]{\hspace{-2em}#1} % for indentation
\usepackage{dcolumn}
\begin{document}
\begin{longtable}[c]{ @{\hspace*{\leftmargin}} lcccccc}
\caption {Example table} \label{tab:table_balance_AvsH} \\ \toprule
& \multicolumn{3}{c}{Period 1} & \multicolumn{3}{c}{Period 2} \\ \cmidrule(r){2-4} \cmidrule(r){5-7}
& Group 1 & Group 2 & Difference & Group 1 & Group 2 & Difference \\
& (1) & (2) & (3) & (4) & (5) & (6) \\ \midrule
\rowgroup{\textit{Panel A: outcome 1 (USD)}} \\ \addlinespace
t - 5 & 8.76 & 9.28 & -0.52 & 10.71 & 6.93 & 3.78 \\
t - 4 & 9.07 & 9.17 & -0.10 & 9.07 & 6.93 & 2.14 \\
t - 3 & 9.34 & 8.36 & 0.97 & 9.36 & 7.27 & 2.09 \\
t - 2 & 9.33 & 8.46 & 0.87 & 9.43 & 8.07 & 1.36 \\
t - 1 & 9.40 & 9.07 & 0.33 & 8.87 & 8.33 & 0.53 \\
\addlinespace
\rowgroup{\textit{Panel B: outcome 2 (Th. USD)}} \\ \addlinespace
t - 5 & 456 & 650 & -194\mbox{*} & 1,007 & 656 & 352 \\
t - 4 & 490 & 650 & -160\mbox{*} & 1,055 & 619 & 436\mbox{*} \\
t - 3 & -383 & 625 & -1008 & 1,060 & 663 & 398 \\
t - 2 & -467 & 653 & -1120 & 1,120 & 877 & 242 \\
t - 1 & 666 & 746 & -80 & 1,117 & 1,020 & 97 \\ \bottomrule
\end{longtable}
\end{document}
siunitx
package.siunitx
, as suggested by @Bernard.)longtable
, i.e., is there a chance that the real table will span more than 1 page?