5

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}

4 Answers 4

6

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}
0
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}
3

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

1
  • @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
    Commented Apr 6, 2016 at 8:55
2

I recommend a table with booktabs in the spirit of booktabs (see other answers). However, If you actually want a tabular with vertical and horizontal rules and an empty corner, I recommend the environment {NiceTabular} of nicematrix : with that environment, you have a key corners to specify so-called "corners" and the rules won't be drawn in the corners.

\documentclass{scrartcl}
\usepackage{nicematrix}

\begin{document}

\begin{NiceTabular}{ccccc}[columns-width=7mm,vlines,corners=NW] % NW = north-west
\Hline
        & \Block{1-2}{Method 1} && \Block{1-2}{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{NiceTabular}

\end{document}

Remark: columns-width does not specify the width of the columns but the minimal width of the columns.

Output of the above code

You must log in to answer this question.

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