我有以下表格代码:
\bgroup
\def\arraystretch{1.5}
\begin{table}[ht]
\textbf{\caption{My Table}} % title of Table
\centering % used for centering table
\begin{tabular}{ c|ccc }
\hline
Col1 & Col2 & Col3 & Col4\\[5pt]
\hline
\multirow{2}{*}{Merged Cell} & A12 & A13 & A14\\
\cmidrule(lr){2-4}
& A22 & A23 & A24 \\
\hline
\end{tabular}
\end{table}
\egroup
当我运行此代码时,我发现第一列和第二列之间的垂直线不连续。不知道为什么会这样。
答案1
Booktabs
在规则 (aboverulesep
和belowrulesep
) 周围添加垂直填充,这解释了不连续性。将这些设置为-0.2pt
(标准线厚度的一半) 可解决问题。
您还可以加载boldline
以模拟 booktabs 规则的可变厚度,但您失去了修剪 s 的可能性 \cmidrule
。
以下是两种解决方案的示例:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow, booktabs, caption, boldline, cellspace}
\captionsetup{font=bf}
\setlength\cellspacetoplimit{8pt}
\setlength\cellspacebottomlimit{\cellspacetoplimit}
\begin{document}
\bgroup
\aboverulesep = -0.2pt
\belowrulesep = -0.2pt
\def\arraystretch{1.5}
\begin{table}[!ht]
\caption{My Table} % title of Table
\centering % used for centering table
\begin{tabular}{ c|ccc }
\toprule
Col1 & Col2 & Col3 & Col4 \\[5pt]
\midrule
\multirow{2}{*}{Merged Cell} & A12 & A13 & A14 \\
\cmidrule(lr){2-4}
& A22 & A23 & A24 \\
\bottomrule
\end{tabular}
\end{table}
\egroup
\vskip 1cm
\begin{table}[!ht]
\caption{My Table} % title of Table
\centering % used for centering table
\begin{tabular}{ c|Sccc }
\hlineB{2}
Col1 & Col2 & Col3 & Col4 \\
\hlineB{1.5}
\multirow{2}{*}[-4.6pt]{Merged Cell} & A12 & A13 & A14 \\
\clineB{2-4}{1.5}
& A22 & A23 & A24 \\
\hlineB{2}
\end{tabular}
\end{table}
\end{document}