7

In the following table, why does the double line before the diff column not go through? I guess all the multicolumn{1} are wrong? How can I fix it?

\begin{table}
\centering
\begin{tabular}{|l||c|c|c|c|c|c||r|}\hline

\multicolumn{1}{|c||}{} &
\multicolumn{3}{c|}{Model 1} &
\multicolumn{3}{c|}{Model 2}  &
\multicolumn{1}{||r|}{}\\

\multicolumn{1}{|c||}{Task} &
\multicolumn{1}{c}{(a)} &
\multicolumn{1}{c}{(b)} &
\multicolumn{1}{c|}{(c)} &
\multicolumn{1}{c}{(a)} &
\multicolumn{1}{c}{(b)} &
\multicolumn{1}{c}{(c)} &
\multicolumn{1}{||r|}{diff}\\\hline

Foo     & 1 & 2 & 3 & A & B & C & + \\
Bar     & 1 & 2 & 3 & A & B & C & + \\\hline

\end{tabular}
\caption{whatever}\label{tab:whatever}
\end{table}

fugly table

Moriambar
  • 11,466
Frank
  • 7,175

3 Answers3

7

A \multicolumn overwrites the right line setting of its cell(s) defined by the tabular header, except of the first cell, there it overwrites the right and left line setting.

\begin{tabular}{|l||c|c|c|c|c|c||r|}\hline

\multicolumn{1}{|c||}{} &
\multicolumn{3}{c|}{Model 1} &
\multicolumn{3}{c||}{Model 2}  &
\multicolumn{1}{r|}{}\\

\multicolumn{1}{|c||}{Task} &
\multicolumn{1}{c}{(a)} &
\multicolumn{1}{c}{(b)} &
\multicolumn{1}{c|}{(c)} &
\multicolumn{1}{c}{(a)} &
\multicolumn{1}{c}{(b)} &
\multicolumn{1}{c||}{(c)} &
\multicolumn{1}{r|}{diff}\\\hline

Foo     & 1 & 2 & 3 & A & B & C & + \\
Bar     & 1 & 2 & 3 & A & B & C & + \\\hline

\end{tabular}
David Carlisle
  • 757,742
5

This is not an answer to your question (others did that). However, I think you can make a better looking table by following the advice in the booktabs package.

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{lccccccc}
\toprule
&\multicolumn{3}{c}{Model 1}&\multicolumn{3}{c}{Model 2}&\\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}
Tack & (a) & (b) & (c) & (a) & (b) & (c) & diff\\
\midrule
Foo & 1 & 2 & 3 & A & B & C & $+$\\
Bar & 1 & 2 & 3 & A & B & C & $+$\\
\bottomrule
\end{tabular}
\end{document}

alt text

Moriambar
  • 11,466
TH.
  • 62,639
0

One way to solve your problem is to change some of your code as the following lines.

\multicolumn{1}{|c||}{} &
\multicolumn{3}{c|}{Model 1} &
\multicolumn{3}{c||}{Model 2}  &
\\

and

\multicolumn{1}{c||}{(c)} &
\multicolumn{1}{r|}{diff}\\\hline
S. Boonto
  • 1,074