9

enter image description here

I'm trying to make a table like the one above but with 5 variables under Females and Males instead of 2. Also under Treatment, I have more than those 3, but it's not that important. My codes keep running into problems at \cline. Doesn't that mean the horizontal lines span column 2 to 6 and 8 to 12 since 7 is a blank column?

\begin{table}[h]
\begin{tabular}{lcccccccccc}
\hline
\multicolumn{5}{c}{Females} & & \multicolumn{5}{c}{Males} \\
\cline{2-6} \cline{8-12} 
Treatment & V1 & V2 & V3 & V4  & V5 & & V1 & V2 & V3 & V4  & V5 \\
Placebo & 0.21 & 163 & 3 & 4 & 5 & & 0.22 & 164 & 3 & 4 & 5 \\
ACE Inhibitor & 0.13 & 142 & 3 & 4 & 5 & & 0.15 & 144 & 3 & 4 & 5 \\  
Hydralazine & 0.17 & 143 & 3 & 4 & 5 & & 0.16 & 140 & 3 & 4 & 5 \\
\begin{tabular}
\end{table}

1 Answer 1

9

You seem to be using a dummy column in order to separate the two parts: you need to specify it in the argument to \begin{tabular}.

\documentclass{article}

\begin{document}

\begin{tabular}{lccccc c ccccc}
\hline
 & \multicolumn{5}{c}{Females} && \multicolumn{5}{c}{Males} \\
\cline{2-6} \cline{8-12}
Treatment     & V1   & V2  & V3 & V4 & V5 && V1   & V2  & V3 & V4 & V5 \\
Placebo       & 0.21 & 163 & 3  & 4  & 5  && 0.22 & 164 & 3  & 4  & 5  \\
ACE Inhibitor & 0.13 & 142 & 3  & 4  & 5  && 0.15 & 144 & 3  & 4  & 5  \\
Hydralazine   & 0.17 & 143 & 3  & 4  & 5  && 0.16 & 140 & 3  & 4  & 5  \\
\end{tabular}

\end{document}

enter image description here

There are better methods, though.

\documentclass{article}

\usepackage{booktabs}

\begin{document}

\begin{tabular}{l ccccc ccccc}
\toprule
 & \multicolumn{5}{c}{Females} & \multicolumn{5}{c}{Males} \\
\cmidrule(lr){2-6} \cmidrule(lr){7-11}
Treatment     & V1   & V2  & V3 & V4 & V5 & V1   & V2  & V3 & V4 & V5 \\
\midrule
Placebo       & 0.21 & 163 & 3  & 4  & 5  & 0.22 & 164 & 3  & 4  & 5  \\
ACE Inhibitor & 0.13 & 142 & 3  & 4  & 5  & 0.15 & 144 & 3  & 4  & 5  \\
Hydralazine   & 0.17 & 143 & 3  & 4  & 5  & 0.16 & 140 & 3  & 4  & 5  \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

2
  • Ohhh that's why it didn't work out. Thank you! I decided to use the second method. Much better.
    – pineapple
    Jun 10, 2016 at 10:29
  • Quick question. I tried to caption this table but it doesn't let me. The message says "\caption outside float. See caption package for explanation." Is there any way I can caption this?
    – pineapple
    Jun 10, 2016 at 11:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .