Dezimalspaltenausrichtung in Tabellen

Dezimalspaltenausrichtung in Tabellen

Ich habe ein ernstes Problem mit meinem Tisch.

Zunächst möchte ich wissen, wie ich N in die Mitte der beiden Zeilen setze. Im Moment sieht es so aus:

Bildbeschreibung hier eingeben

Zweitens, wenn ich mein Dokument jetzt kompiliere, heißt es:

 Package array Error: Illegal pream-token (D): `c' used.

Wenn ich \usepackage{dcolumn} hinzufüge, heißt es:

 ! Missing } inserted.

Kann mir jemand helfen?

Mein TeX sieht folgendermaßen aus:

\documentclass[a4paper,11pt,oneside]{article} 
\usepackage[english,danish]{babel} 
\usepackage{fixltx2e} 
\usepackage{layout}
\renewcommand{\danishhyphenmins}{22} 
\usepackage[protrusion=true,expansion=true]{microtype} 
\addto\captionsdanish{
\renewcommand\appendixname{Appendiks}
\renewcommand\contentsname{Indhold}
\renewcommand\refname{Litteratur}
\renewcommand\listfigurename{Figur}}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{icomma}
\usepackage{amsmath,amssymb,bm,mathtools}
\usepackage[pdftex]{graphicx}
\usepackage{float}
\usepackage[left=3.0cm,right=3.0cm,top=3.0cm,bottom=3.0cm]{geometry}
\usepackage{setspace}
\setstretch{1.6}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\usepackage{tabu}
\usepackage[round, colon, sort, authoryear]{natbib}
\setlength{\bibsep}{0.0pt}
\setlength{\bibhang}{2em}
\bibpunct{(}{)}{;}{a}{}{}
\setcitestyle{notesep={: }}
\def\citeapos#1{\citeauthor{#1}'s (\citeyear{#1})}
\usepackage{csquotes}
\MakeOuterQuote{"}
\usepackage{tikz}
\usepackage{pgf}
\usetikzlibrary{shapes,arrows,positioning,calc, matrix} 
\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}
\usepackage{titletoc}
\usepackage{longtable}
\usepackage{array}
\usepackage{multirow,tabularx,caption,subcaption,booktabs,threeparttable}
%KOLONNEL%
\newcommand{\sym}[1]{{}^{#1}} % correct?
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro
\newcommand\narrowtab[2]{%  %% macro to hide depth of its argument from outer tabular
 \ensuremath{\smash{\begin{tabular}[t]{@{}>{\raggedright\arraybackslash}p{#1}@{}}%
     #2 \end{tabular}}}}

\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}

\usepackage{pdfpages}
\includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}
\usepackage{fancyvrb}

\begin{document}
\begin{table}[H]
\caption{??????}\label{tabel2}
\begin{threeparttable}
\renewcommand\arraystretch{1.0}
\renewcommand\tabcolsep{1pt}  
\begin{tabular*}{\textwidth}{@{} p{1.6in} @{\extracolsep{\fill}} *{5}{D{,}{,}{2.4}} @{}}
\toprule
& \mc{X2} & \mc{X3} & \mc{X4} \\
& \mc{($\Delta$02--06)} & \mc{($\Delta$02--06)} & \mc{($\Delta$02--06)} & \mc{N} \\
\midrule
All$^{\pm}$ & 
,56\sym{***} (,16) & ,49\sym{***} (,17) & ,11 (,48) & ,87\sym{***} (,30) \\
\narrowtab{1in}{S} & \\
\ \ \ $\Delta$02--03 &
-,01 (,02) & -,01 (,02) & ,02 (,04) & -,02 (,02) \\
\ \ \ $\Delta$03--04 &
-,05 (,04) & -,04 (,04) & -,10\sym{*} (,07) & -,04 (,05) \\
\narrowtab{1in}{V} & \\
\ \ \ $\Delta$02--03 &
-,01 (,02) & -,01 (,02) & ,02 (,04) & -,02 (,02) \\
\ \ \ $\Delta$03--04 &
-,05 (,04) & -,04 (,04) & -,10\sym{*} (,07) & -,04 (,05) \\
\bottomrule
\end{tabular*}
\end{threeparttable}
\end{table}
\end{document}

Ich würde mich über jede Art von Hilfe freuen, vielen Dank!

Antwort1

\tabcolsepist eine Länge, die festgelegt werden muss und \setlengthnicht neu definiert werden darf. Theicomma package generated the main error anddcolumn is required forD`

Ich verließ in

\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro

Allerdings handelt es sich dabei meistens um einen Fehler, da die Zellenpolsterung aus der Zelle entfernt wird, selbst wenn diese Spalte über die Tabcolsep-Polsterung verfügt.

\documentclass[a4paper,11pt,oneside]{article} 

\usepackage{fixltx2e} 
\usepackage{layout,dcolumn}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage{amsmath,amssymb,bm,mathtools}

\usepackage{float}
\usepackage[left=3.0cm,right=3.0cm,top=3.0cm,bottom=3.0cm]{geometry}
\usepackage{setspace}
\setstretch{1.6}

\usepackage{multirow,tabularx,caption,subcaption,booktabs,threeparttable}
%KOLONNEL%
\newcommand{\sym}[1]{{}^{#1}} % correct?
\newcommand\mc[1]{\multicolumn{1}{@{}c@{}}{#1}} % handy shortcut macro
\newcommand\narrowtab[2]{%  %% macro to hide depth of its argument from outer tabular
 \ensuremath{\smash{\begin{tabular}[t]{@{}>{\raggedright\arraybackslash}p{#1}@{}}%
     #2 \end{tabular}}}}

\def\sym#1{\relax\ifmmode^{#1}\else\(^{#1}\)\fi}

\usepackage{pdfpages}
\includepdfset{pagecommand=\thispagestyle{plain}}
\renewcommand{\TPTnoteSettings}{\footnotesize}
\renewcommand{\TPTnoteLabel}[1]{#1}
\usepackage{fancyvrb}

\begin{document}
\begin{table}[H]
\caption{??????}\label{tabel2}
\begin{threeparttable}
\renewcommand\arraystretch{1.0}
\setlength\tabcolsep{1pt}  
\begin{tabular*}{\textwidth}{@{} p{1.6in} @{\extracolsep{\fill}} *{5}{D{,}{,}{2.4}} @{}}
\toprule
& \mc{X2} & \mc{X3} & \mc{X4} &\mc{N}\\
& \mc{($\Delta$02--06)} & \mc{($\Delta$02--06)} & \mc{($\Delta$02--06)} &  \\
\midrule
%All$^{\pm}$ & 
a&
,56\sym{***} (16) & ,49\sym{***} (,17) & ,11 (,48) & ,87\sym{***} (,30) \\
\narrowtab{1in}{S} & \\
\ \ \ $\Delta$02--03 &
-,01 (,02) & -,01 (,02) & ,02 (,04) & -,02 (,02) \\
\ \ \ $\Delta$03--04 &
-,05 (,04) & -,04 (,04) & -,10\sym{*} (,07) & -,04 (,05) \\
\narrowtab{1in}{V} & \\
\ \ \ $\Delta$02--03 &
-,01 (,02) & -,01 (,02) & ,02 (,04) & -,02 (,02) \\
\ \ \ $\Delta$03--04 &
-,05 (,04) & -,04 (,04) & -,10\sym{*} (,07) & -,04 (,05) \\
\bottomrule
\end{tabular*}
\end{threeparttable}
\end{table}
\end{document}

verwandte Informationen