3

I am using the following code to create a table for a paper I am writing in Overleaf.

\usepackage{array}       
\usepackage{dcolumn}
\usepackage{booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}
\begin{table}
\begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}d{5.5}d{5.8}d{5.5}}
\toprule
\noalign{\vskip 0.2in}
&  \multicolumn{2}{c}{Fisher-Zou} &
 \multicolumn{1}{c}{Wilcox-Muska} \\
    \multicolumn{1}{c}{GROUP} & \multicolumn{1}{c}{p-value} & \multicolumn{1}{c}{CI's} & \multicolumn{1}{c}{CI's} \\
 \noalign{\vskip 0.2in}
 \midrule 
 \noalign{\vskip 0.2in} 
\multicolumn{1}{c}{females} \\
\noalign{\vskip 0.1in}
(A vs. B) & .0043 & .0083-.5788 & -.0671-.4987 \\
(A vs. C) & .0005 & .1630-.5764 & .0767-.4990 \\
(A vs. D) & .0096 & .0789-.6195 & .0062-.5262 \\
(A vs. E) & .6926 & -.2448-.1991 & -.1997-.1475 \\
\bottomrule
\end{tabular*}     
\end{table}

The problem is that the values do not centre under the subheadings p-value, CI's and CI's, which in turn do not position correctly under the headings Fisher-Zou (should encompass data columns 2 and 3)and Wilcox-Muska (the final data column).

Any suggestions please?

7
  • A quick hint: If you highlight the lines of LaTeX code and click on the {} "button" in the row above the editing window, they'll be shifted four spaces to the right and will be pretty-printed by the site software.
    – Mico
    Apr 29 '16 at 13:52
  • @Mico sorry, I was just in the process of editing to display the code properly when you posted your edit! Apr 29 '16 at 13:52
  • What means number .0083-.5788? Is the second part a tolerance of the first part of number?
    – Zarko
    Apr 29 '16 at 14:04
  • @Zarko it represents a confidence interval so 'between' .0083 and .5788 Apr 29 '16 at 14:06
  • Isn't than better to type them in stabdard columns? Like ...& .0083 & -.5788 & ... ?
    – Zarko
    Apr 29 '16 at 14:08
2

an alternative ... withtabularx and siunitx instead of D columns:

enter image description here

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}

\usepackage{siunitx}

    \begin{document}
\begin{table}
\begin{tabularx}{\textwidth}{X S[table-format=1.4]
                 *{2}{S[table-format=-2.4]@{\quad--\quad}S[table-format=0.4]@{\qquad}}
                  }
    \toprule
&  \multicolumn{3}{c}{Fisher-Zou} 
    &   \multicolumn{2}{c}{Wilcox-Muska}                \\
    \cmidrule(r){2-4}\cmidrule(l){5-6}
\multicolumn{1}{c}{GROUP} 
    &   {p-value} 
        &   \multicolumn{2}{c}{CI's} 
            &   \multicolumn{2}{c}{CI's}                \\
    \midrule
females   &   \multicolumn{5}{c}{}                      \\
    \addlinespace
(A vs. B) & .0043 &  .0083 & .5788  & -.0671 & .4987    \\
(A vs. C) & .0005 &  .1630 & .5764  &  .0767 & .4990    \\
(A vs. D) & .0096 &  .0789 & .6195  &  .0062 & .5262    \\
(A vs. E) & .6926 & -.2448 & .1991  & -.1997 & .1475    \\
    \bottomrule
\end{tabularx}
\end{table}
    \end{document}
3
  • I'm not sure whether "Fisher-Zou" should span columns 2, 3,and 4 or just columns 3 and 4. Let's see if the OP weighs in with more Information.
    – Mico
    Apr 29 '16 at 14:54
  • yep, with the added advantage that the p-value sits under the Fisher-Zou heading (the R package for Wilcox-Muska only computes intervals). Apr 29 '16 at 14:56
  • yes, sorry Mico I should have picked that up immediately, the Fisher-Zou is p-values and the first CI's. It will be good practice to use your code and see if I can get it looking like Zarko's solution. Looks like I can only mark one answer as acceptable or best? But I think both would work. Mico's Version could be described adequately in the caption. Apr 29 '16 at 14:58
2

When using the D column type, be careful to provide only one number containing a decimal marker per cell. Also, take care to distinguish between a typographic - ("minus") and -- ("en-dash") symbol.

I would suggest you organize the table as follows:

enter image description here

\documentclass{article}    
\usepackage{dcolumn,booktabs}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\begin{document}

\begin{table}
\centering
\begin{tabular}{@{} l d{1.4} *{2}{d{2.4}@{\,--\,}d{1.4}} @{}}
\toprule
\addlinespace
Group & \multicolumn{1}{c}{$p$-value}
 & \multicolumn{2}{c}{Fisher-Zou} 
 & \multicolumn{2}{c@{}}{Wilcox-Muska} \\
 && \multicolumn{2}{c}{CIs} & \multicolumn{2}{c@{}}{CIs} \\
\addlinespace
\midrule  
\addlinespace
Females \\
\addlinespace
(A vs.\ B) & 0.0043 &  0.0083 & 0.5788 & -0.0671& 0.4987 \\
(A vs.\ C) & 0.0005 &  0.1630 & 0.5764 &  0.0767& 0.4990 \\
(A vs.\ D) & 0.0096 &  0.0789 & 0.6195 &  0.0062& 0.5262 \\
(A vs.\ E) & 0.6926 & -0.2448 & 0.1991 & -0.1997& 0.1475 \\
\bottomrule
\end{tabular}     
\end{table}
\end{document}
1
  • thank you, that was exactly what I wanted. I'll work through your solution so that I understand how to format my tables correctly in the future. Apr 29 '16 at 14:18

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.