表格中的小数列对齐

表格中的小数列对齐

我的桌子出现了严重问题。

首先,我想知道如何将 N 放在两行的中间。现在它看起来像:

在此处输入图片描述

其次,如果我现在编译我的文档,它会显示:

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

如果我添加\usepackage{dcolumn} 它会说:

 ! Missing } inserted.

有人能帮我吗?

我的 TeX 看起来像这样:

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

我将不胜感激各种帮助,非常感谢!

答案1

\tabcolsep是必须设置的长度,而不是\setlength重新定义。icomma dcolumnThepackage generated the main error andis required for D`

我离开了

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

尽管这主要是错误的,因为它会从单元格中删除单元格填充,即使该列具有 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}

相关内容