不想要的表格线

不想要的表格线

我已经创建了下表

在此处输入图片描述

并且我的左侧垂直线开始得太早了。此外,看起来带有 SE 标题的列更宽(真的吗??)。我在我的代码中找不到任何解释这一点的东西。我做错了什么?

\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}

答案1

要删除垂直条,请将其添加\multicolumn{1}{c|}{}到第一个单元格。列宽不同的原因在由于多列单元格太长,导致表格列宽不成比例下面显示了一种解决方法。

在此处输入图片描述

\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}

为了保险起见,这里采用了另一种布置表格的方式,不使用垂直线。\toprule\cmidrule\midrule\bottomrule提供booktabs

在此处输入图片描述

\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}

答案2

我认为全部表格中的垂直线(不仅仅是左上角的垂直线)是不需要的。当然,垂直线是不需要的,如下面截图所示。

请考虑让您的表格看起来更“开放”。您的读者会更愿意吸收表格中包含的信息,从而暗中感谢您……

在此处输入图片描述

\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

一个小的变体,加载caption包以在标题和表格之间进行合理的垂直跳跃,以及补充空列以确保双列标题居中:

\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}

在此处输入图片描述

相关内容