[Tex/LaTex] Very wide columns with dcolumn package

dcolumntables

I want the the following table to be perfectly centered within the margin, with an approximately even spacing between each column.

 \documentclass[a4paper,11pt]{article}
  \usepackage{color,amsmath,amsfonts,amssymb}
     \usepackage[english]{babel}
  \usepackage{colortbl}
  \usepackage{booktabs,dcolumn,caption}
  \usepackage{expdlist}  %expanded list environment
  \usepackage{longtable} %multipage table
  \usepackage{setspace} %for \singlespacing
  \usepackage{adjustbox} %center tables
  \usepackage{icomma}

  \usepackage[margin=1in]{geometry}
  \usepackage{setspace}
  \setstretch{1}


 \captionsetup{labelsep=newline,singlelinecheck=false} % optional
 \newcolumntype{d}[1]{D{.}{.}{#1}} % "decimal" column type


 \setlength{\LTleft}{0pt}
 \setlength{\LTright}{0pt} %full margins

 \oddsidemargin 0.5cm %
 \evensidemargin 0.5cm %
 \textwidth 15cm %
 \topmargin  -0.2in  %
 \textheight 23.5cm %
 \headheight 15pt %


 \doublerulesep2pt

 \begin{document}


 \footnotesize

 \begin{longtable}{@{} l @{\extracolsep{\fill}} *{2}{d{5}} @{}}
 \caption{Pearson correlations} \\
 \toprule
 & \multicolumn{1}{l}{$(del1,del2)$}
 & \multicolumn{1}{l}{$(del1,del3)$} \\
 \midrule
 \endfirsthead
 \multicolumn{2}{@{}l}{\emph{(continued)}} \\
 \toprule
 & \multicolumn{1}{l}{$(del1,del2)$}
 & \multicolumn{1}{l}{$(del1,del3)$} \\
 \midrule
 \endhead
 \midrule[\heavyrulewidth]
 \multicolumn{3}{r@{}}{\emph{(continued)}}
 \endfoot
 \bottomrule
 \endlastfoot
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 Hello                & -0.032(Q>0.671) & 0.036(Q>0.620) \\
 \end{longtable}
 %\vspace{-0.8cm}

 {\noindent ....}
 \clearpage



 \end{document}

Best Answer

I'm not totally clear on what is required. It looks like you have four data columns: two of the data itself and two of some form of error (or similar). I'd therefore use that structure, with the repeated part using @ from the array package:

\documentclass{article}
\usepackage{array,booktabs,caption,dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}} % "decimal" column type
\makeatletter
\newcommand*{\colspacing}{\hskip \col@sep}
\makeatother
\begin{document}
\begin{table}
  \caption{Pearson correlations} 
  \centering
  \begin{tabular}
    {
      l      % 'Entry' row
      d{2.3} % First data column
      @{\colspacing $(Q > {}$}d{1.3}@{$)$\colspacing} % First 'Q' column
      d{1.3} % Second data column
      @{\colspacing $(Q > {}$}d{1.3}@{$)$\colspacing} % First 'Q' column
    }
    \toprule 
    & \multicolumn{2}{l}{$(del1,del2)$}
    & \multicolumn{2}{l}{$(del1,del3)$} \\
    \midrule
    Hello & -0.032 & 0.671 & 0.036 & 0.620 \\
    Hello & -0.032 & 0.671 & 0.036 & 0.620 \\
    Hello & -0.032 & 0.671 & 0.036 & 0.620 \\
    Hello & -0.032 & 0.671 & 0.036 & 0.620 \\
    Hello & -0.032 & 0.671 & 0.036 & 0.620 \\
    \bottomrule
  \end{tabular}
\end{table}
\end{document}

For the first data column, I've reserved space for two 'digits' before the decimal marker to allow for the negative sign. The other spacings are easy: simply the number of actual digits.

enter image description here

Related Question