Wie richte ich Tabelleninhalte nach Dezimalstellen aus?

Wie richte ich Tabelleninhalte nach Dezimalstellen aus?

Ich habe online und in diesem Forum gesucht. Ich habe keine passende Lösung für mein Problem gefunden. Ich versuche, die Zahlen in meiner Tabelle mit ihrem Dezimalpunkt auszurichten. Ich bin mir nicht ganz sicher, wie ich das machen soll.

Ich wäre für jede Hilfe sehr dankbar!

\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}

Bild der Tabelle.

Antwort1

Wie in einem Kommentar erwähnt, funktioniert dies am besten mit siunitx. Ich habe die Gelegenheit genutzt, einige Verbesserungen hinzuzufügen. Nur eine Anmerkung: Verwenden Sie den Mathematikmodus nicht, um kursiven Text zu erhalten – der Abstand zwischen den Buchstaben ist nicht gut.

\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} 

Bildbeschreibung hier eingeben

verwandte Informationen