\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}
\usepackage{multicol}
\begin{document}
\begin{table}[h]
\caption{Title} \label{tab:addlabel}%
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{A} &\multirow{2}{*}{B} & \multirow{2}{*}{C} & \multirow{2}{*}{D} & \multicolumn{4}{c}{E} & \multirow{2}{*}{F} & \multirow{2}{*}{G} & \multirow{2}{*}{H} \\
\cline{5-8}
& & & & M & N&O&P & & & \\
\cline{1-11}
\end{tabular}%
\end{table}%
\end{document}
答案1
使用“经典”tabular
表,您可以按照@koleygr 评论中的建议解决您的问题,即对于多列单元格写入,\multicolumn{4}{c|}{E}
因为它覆盖了列规范中定义的右垂直线。
但是,您可以使用tabularray
包,其中 formultirow
和multicolumn
宏分别使用命令SetCell[r=...]{<align>}...
和SetCell[c=...]{<align>}...
。两者都不会干扰表格行,您可以在表格前言中定义表格行:
\documentclass{article}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage{tabularray}
\begin{document}
\begin{table}[h]
\caption{Title}
\centering
\label{tab:addlabel}%
\begin{tblr}{hlines, vlines, % table's horizontal and vertical lines
colspec = {*{11}{c}}
}
\SetCell[r=2]{c} A & \SetCell[r=2]{c} B & \SetCell[r=2]{c} C & \SetCell[r=2]{c} D
& \SetCell[c=4]{c} E
& & & & \SetCell[r=2]{c} F & \SetCell[r=2]{c} G
& \SetCell[r=2]{c} H \\
\cline{5-8}
& & & & M & N & O & P & & & \\
\end{tblr}%
\end{table}%
\end{document}