4

I have created following table

enter image description here

And I have a left vertical line that starts to early. Also it looks like the column with heading SE are wider (true??). I can't find anything in my code explaining this. What am I doing wrong?

\begin{tabular}{|c|c|c|c|c|}
\cline{2-5}
& \multicolumn{2}{c|}{Method 1} & \multicolumn{2}{ c| }{Method 2} \\
\hline
N & E & SE & E & SE    \\ 
\hline
10      & 3 & 1 & 0 & 1    \\
100     & 2 & 0 & 0 & 1 \\
1000    & 3 & 1 & 1 & 1\\
10000   & 3 & 1 & 1 &1 \\
\hline
\end{tabular}
Orongo
  • 447

3 Answers3

5

To remove the vertical bar, add \multicolumn{1}{c|}{} to the first cell. The reason for the different column widths is described in Table column widths disproportionate due to multicolumn cell being too long A workaround is shown below.

enter image description here

\documentclass{scrartcl}
\usepackage{array}
\begin{document}
\begin{tabular}{|c| *{4}{>{\centering\arraybackslash}p{0.7cm}|}}
\cline{2-5}
\multicolumn{1}{c|}{} & \multicolumn{2}{c|}{Method 1} & \multicolumn{2}{c|}{Method 2} \\
\hline
N & E & SE & E & SE    \\ 
\hline
10      & 3 & 1 & 0 & 1    \\
100     & 2 & 0 & 0 & 1 \\
1000    & 3 & 1 & 1 & 1\\
10000   & 3 & 1 & 1 & 1 \\
\hline
\end{tabular}
\end{document}

For good measure, here's a different way of laying out the table, without using vertical rules. \toprule, \cmidrule, \midrule and \bottomrule are provided by booktabs.

enter image description here

\documentclass{scrartcl}
\usepackage{array,booktabs}
\begin{document}
\begin{tabular}{c *{4}{>{\centering\arraybackslash}p{0.7cm}}}
\toprule
\multicolumn{1}{c}{} & \multicolumn{2}{c}{Method 1} & \multicolumn{2}{c}{Method 2} \\
\cmidrule(rl){2-3} \cmidrule(rl){4-5}
N & E & SE & E & SE    \\ 
\hline
10      & 3 & 1 & 0 & 1    \\
100     & 2 & 0 & 0 & 1 \\
1000    & 3 & 1 & 1 & 1\\
10000   & 3 & 1 & 1 & 1 \\
\bottomrule
\end{tabular}
\end{document}
Torbjørn T.
  • 206,688
3

I'd argue that all vertical lines in the table -- and not just the one in the top-left corner -- are undesired. For sure, the vertical lines aren't needed, as the following screenshot is meant to illustrate.

Do consider giving your table a more "open" look. Your readers will thank you, implicitly, by being more inclined to absorb the information contained in the table...

enter image description here

\documentclass[]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\caption{Original form}
\begin{tabular}{|c|c|c|c|c|}
\cline{2-5}
& \multicolumn{2}{c|}{Method 1} & \multicolumn{2}{ c| }{Method 2} \\
\hline
N & E & SE & E & SE    \\ 
\hline
10      & 3 & 1 & 0 & 1    \\
100     & 2 & 0 & 0 & 1 \\
1000    & 3 & 1 & 1 & 1\\
10000   & 3 & 1 & 1 &1 \\
\hline
\end{tabular}

\bigskip
\caption{No vertical lines}
\begin{tabular}{@{}rcccc@{}}
\toprule
\multicolumn{1}{c}{N} & \multicolumn{2}{c}{Method 1} & \multicolumn{2}{c}{Method 2} \\
\cmidrule(lr){2-3} \cmidrule(l){4-5}
 & E & SE & E & SE    \\ 
\midrule
10      & 3 & 1 & 0 & 1 \\
100     & 2 & 0 & 0 & 1 \\
1000    & 3 & 1 & 1 & 1 \\
10000   & 3 & 1 & 1 &1  \\
\bottomrule
\end{tabular}
\end{table}

\end{document}
Mico
  • 506,678
2

A small variant, loading the caption package for a sensible vertical skip between caption and table, and a supplementary empty column to ensure centring of the bi-column heads:

\documentclass{article}

\usepackage{array, booktabs, caption}

\begin{document}

\begin{table}
\centering
\caption{Some table}
\begin{tabular}{@{}cc@{\qquad}ccc@{\qquad}c@{\,}}
\addlinespace[-1ex]
\toprule%
& \multicolumn{2}{@{}c@{}}{Method 1} & & \multicolumn{2}{@{}c@{}}{Method 2} \\
\cmidrule{2-6}
N & E & SE & & E & SE \\
\midrule
10 & 3 & 1 & & 0 & 1 \\
100 & 2 & 0 & & 0 & 1 \\
1000 & 3 & 1 & & 1 & 1\\
10000 & 3 & 1 & & 1 &1 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

Bernard
  • 271,350
  • @Mico: Oh! yes. I forgot to add the final image of my answer (it was late last night…). I'll change that at once. Thank you for pointing it! – Bernard Apr 06 '16 at 08:55