As pointed out here it is important to use
\multicolumn{3}{|l|}{}
in the following line of multicolumn
.
Nevertheless I am struggling around with the same issue (unconnected vertical lines) and can't find a solution for it:
Here is how far I got. Any ideas would be great.
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}
{\renewcommand{\arraystretch}{2}%
\begin{table}
\centering
\begin{tabular}{@{}ll|cc@{}} \toprule
\multicolumn{2}{c|}{\multirow{2}{*}{}} & \multicolumn{2}{c}{Text} \\
\cmidrule(r){3-4}
\multicolumn{2}{c|}{} & A & B\\ \midrule
\multicolumn{1}{c|}{\multirow{2}{*}{\thead{Text1 and \\ Text2}}} & C & \thead{1\\and 1}& 2 \\
\multicolumn{1}{c|}{} & D & 3 & \thead{4\\ and 4} \\
\bottomrule
\end{tabular}
\end{table}} \quad
booktabs
. Thebooktabs
documentation emphasizes "Never, ever use vertical rules". If you replace the\toprule
,\bottomrule
and\midrule
by\hline
the gaps will close. Better to remove the vertical rules, though.