1

I've searched online and on this forum. I haven't found an appropriate solution to my issue. I am trying to align the numbers in my table with their decimal point. I'm not exactly sure how to go about doing this.

I'd greatly appreciate any help!

\documentclass[12pt, a4paper]{report}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{tabularx,booktabs}

\oddsidemargin-1cm
\textwidth17cm
\def\COMP#1{\begin{tabular}{c}#1\end{tabular}}

\newcolumntype{L}{>{$}l<{$}}
\newcolumntype{C}{>{$}c<{$}} 
\newcolumntype{R}{>{$}r<{$}}

\begin{document}

\begin{table} [h!]
\centering
%\resizebox{\textwidth}{!} {%
\begin{tabular}{LCCCCCCCCC}
\toprule
\multicolumn{1}{l}{} &
\multicolumn{3}{c}{2007 - 2011}    &
\multicolumn{3}{c}{2007 - 2012}    &
\multicolumn{3}{c}{2007 - 2013}    \\ 
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
\cmidrule(lr){8-10}

&
\multicolumn{1}{c}{\COMP{Coeff.}} &
\multicolumn{1}{c}{\COMP{C.S.E.} }&
\multicolumn{1}{c}{\COMP{S.E}} &
\multicolumn{1}{c}{\COMP{Coeff.}} &
\multicolumn{1}{c}{\COMP{C.S.E.}} &
\multicolumn{1}{c}{\COMP{S.E.}} &
\multicolumn{1}{c}{\COMP{Coeff.}} &
\multicolumn{1}{c}{\COMP{C.S.E}} &
\multicolumn{1}{c}{\COMP{S.E.}}     \\
\midrule
Black &-0.029 & 0.004^* & 0.096 & 0.018 & 0.007 & 0.092 & 0.019 & 0.016 & 0.092 \\
Male & 0.043 & 0.003^{**} & 0.136 & 0.030 & 0.008 & 0.135 & -0.048 & 0.019 & 0.122 \\
Female & -0.009 & 0.006 & 0.131 & 0.019 & 0.008 & 0.123 & -0.007 & 0.016 & 0.142 \\ 
\\
Asian & 0.021 & 0.002^* & 0.129 & 0.006 & 0.006 & 0.119 & -0.065 & 0.002^{**} & 0.121 \\
Male & -0.056 & 0.005^* & 0.192 & 0.144 & 0.004^{**} & 0.175 & -0.124 & 0.010^* & 0.170 \\
Female & 0.095 & 0.001^{***} & 0.171 & -0.097 & 0.007^{**} & 0.159 & -0.049 & 0.004^{**} & 0.175 \\
\\
Hispanic & -0.111 & 0.001^{***} & 0.049^* & -0.161 & 0.001^{***} & 0.049^{***} & -0.181 & 0.002^{***} & 0.048^{***} \\
Male & -0.136 & 0.001^{***} & 0.066^{**} & -0.169 & 0.001^{***} & 0.067^{**} & -0.223 & 0.001^{***} & 0.064^{***} \\
Female & -0.065 & 0.002^{**} & 0.076 & -0.138 & 0.001^{***} & 0.073^* & -0.130 & 0.001^{***} & 0.076^* \\
\\
W. Female & 0.023 & 0.001^{**} & 0.049 & 0.035 & 0.001^{**} & 0.049 & -0.059 & 0.001^{***} & 0.049 \\
\bottomrule

\end{tabular}
\caption{Triple Differences Estimates}\label{beta}
\end{table}

Image of table.

3
  • 1
    Welcome to TeX SX! What are the L and C column types?
    – Bernard
    Commented Mar 17, 2019 at 23:42
  • Apologies, forgot to add a section of code. It's been edited!
    – Aaron
    Commented Mar 17, 2019 at 23:44
  • look at the siunitx package
    – JPi
    Commented Mar 17, 2019 at 23:55

1 Answer 1

2

AS mentioned in a comment, this is best done with siunitx. I took the opportunity to add some improvements. Just one observation: don't use mathmode to obtain italic text – the interletter spacing is not good.

\documentclass[12pt, a4paper]{report}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{tabularx, booktabs, siunitx, caption}

\oddsidemargin-1cm
\textwidth17cm
\def\COMP#1{\begin{tabular}{c}#1\end{tabular}}
%
\let\ts = \textsuperscript

\begin{document}

\begin{table} [h!]
\centering
\caption{Triple Differences Estimates}\label{beta}
\setlength{\tabcolsep}{4pt}
\setlength{\defaultaddspace}{1.5ex}
 \sisetup{table-format=1.3, table-number-alignment=center}
\begin{tabular}{ >{\itshape}l*{3}{S[table-format=-1.3]S[table-space-text-post=$ ^{***}$]S[table-space-text-post=$^{***}$]} }
\toprule
\multicolumn{1}{l}{} &
\multicolumn{3}{c}{2007 - 2011} &
\multicolumn{3}{c}{2007 - 2012} &
\multicolumn{3}{c}{2007 - 2013} \\
\cmidrule(lr{1em}){2-4}
\cmidrule(lr{1em}){5-7}
\cmidrule(lr{1em}){8-10}
&
{Coeff.} &
{C.S.E.} &
{S.E} &
{Coeff.} &
{C.S.E.} &
{S.E.} &
{Coeff.} &
{C.S.E} &
{S.E.} \\
\midrule
Black &-0.029 & 0.004{\ts*} & 0.096 & 0.018 & 0.007 & 0.092 & 0.019 & 0.016 & 0.092 \\
Male & 0.043 & 0.003{\ts{**}} & 0.136 & 0.030 & 0.008 & 0.135 & -0.048 & 0.019 & 0.122 \\
Female & -0.009 & 0.006 & 0.131 & 0.019 & 0.008 & 0.123 & -0.007 & 0.016 & 0.142 \\
\addlinespace
Asian & 0.021 & 0.002{\ts{*}} & 0.129 & 0.006 & 0.006 & 0.119 & -0.065 & 0.002{\ts{**}} & 0.121 \\
Male & -0.056 & 0.005{\ts{*}} & 0.192 & 0.144 & 0.004{\ts{**}} & 0.175 & -0.124 & 0.010{\ts{*}} & 0.170 \\
Female & 0.095 & 0.001{\ts{***}} & 0.171 & -0.097 & 0.007{\ts{**}} & 0.159 & -0.049 & 0.004{\ts{**}} & 0.175 \\
\addlinespace
Hispanic & -0.111 & 0.001{\ts{***}} & 0.049{\ts{*}} & -0.161 & 0.001{\ts{***}} & 0.049{\ts{***}} & -0.181 & 0.002{\ts{***}} & 0.048{\ts{***}} \\
Male & -0.136 & 0.001{\ts{***}} & 0.066{\ts{**}} & -0.169 & 0.001{\ts{***}} & 0.067{\ts{**}} & -0.223 & 0.001{\ts{***}} & 0.064{\ts{***}} \\
Female & -0.065 & 0.002{\ts{**}} & 0.076 & -0.138 & 0.001{\ts{***}} & 0.073{\ts{*}} & -0.130 & 0.001{\ts{***}} & 0.076{\ts{*}} \\
\addlinespace
W. Female & 0.023 & 0.001{\ts{**}} & 0.049 & 0.035 & 0.001{\ts{**}} & 0.049 & -0.059 & 0.001{\ts{***}} & 0.049 \\
\bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .