alinhamento de coluna decimal em tabelas

alinhamento de coluna decimal em tabelas

Eu tenho um problema sério com minha mesa.

Primeiramente, gostaria de saber como colocar N no meio das duas linhas. Neste momento parece:

insira a descrição da imagem aqui

Segundo, se eu compilar meu documento agora, ele dirá:

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

Se eu adicionar \usepackage{dcolumn}, diz:

 ! Missing } inserted.

Alguém pode me ajudar?

Meu TeX está assim:

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

Eu apreciaria todo tipo de ajuda, muito obrigado!

Responder1

\tabcolsepé um comprimento que deve ser definido e \setlengthnão redefinido. Theicomma package generated the main error anddcoluna is required forD`

eu deixei em

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

embora seja principalmente um erro, pois remove o preenchimento da célula, mesmo que essa coluna tenha o preenchimento tabcolsep.

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

informação relacionada