1

I have some serious issue with my table.

First, I would like to know how to put N in the middle of the two rows. Right now it looks like:

enter image description here

Second, if I compile my document right now, it says:

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

If I add \usepackage{dcolumn} it says:

 ! Missing } inserted.

Can someone help me?

My TeX looks like this:

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

I would appreciate all kind of help, thank you so much!

  • What are the commas before numbers for? – Bernard Dec 10 '14 at 18:48
  • 1
    You should always make a minimal example by removing every package such as tikz, babel, longtable, tabu that arev not relevant to the problem. If you had done that (as I just did) you would eventually get to deleting icomma when the code then runs without error with dcolumn – David Carlisle Dec 10 '14 at 18:59
3

\tabcolsep is a length that must be set with \setlength not redefined. Theicommapackage generated the main error anddcolumnis required forD`

I left in

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

although it's mostly in error as it removes the cell padding from the cell even if that column has the tabcolsep padding.

\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}
  • Thank you David. But how can I let N be in the middle of these two rows in top rule? It looks not that good to place the letter on the same line that the other ones – A. F. Dec 11 '14 at 3:33
  • @A.F. it's better where it is, but if you really want to move it or you could use the multirow package or simply use \raisebox{-.5\baselineskip}{N} – David Carlisle Dec 11 '14 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.