# Problem with setting up vertical lines in booktabs tables

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}

• The line between Text1andText2 and C / D maybe should stay as it is. – KLJ Dec 4 '18 at 17:57
• The issue is not the same as the linked question. The gaps you see is because you are using vertical rules with booktabs. The booktabs 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. – Phelype Oleinik Dec 4 '18 at 17:59
• please look at the documentation for booktabs, the package author makes it clear he thinks vertical rules are evil and by design the package makes them unusable – David Carlisle Dec 4 '18 at 18:23

Booktabs sets a vertical padding above and below its rules. You can set this padding to 0, and enjoy the other functionalities. Anyway, with \arraystretch set to 2, do you really need it? If necessary, you can replace it with the \setcellgapes command from makecell. I took the opportunity to slightly simplify the code of your table, with the \multirowthead command:

\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}

\begin{table}
\renewcommand{\arraystretch}{2}%
\centering
\aboverulesep = 0pt
\belowrulesep = 0pt
\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|}{\multirowthead{2}[-1ex]{Text1 and \\ Text2}} & C & \thead{1\\and 1}& 2 \\
\multicolumn{1}{c|}{} & D & 3 & \thead{4\\ and 4} \\
\bottomrule
\end{tabular}

\end{document}


• Thanks for the support and simplification as well! – KLJ Dec 5 '18 at 7:31
• Interesting to see that there is no "multicolumnthead" – KLJ Dec 5 '18 at 7:51
• @KLJ: Yes, that's a mystery to me. – Bernard Dec 5 '18 at 9:31

As mentioned in the booktabs documentation (and with that in the comments above) I tried it without the vertical lines and have to admit that it looks better now:

\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}

\begin{document}

{\renewcommand{\arraystretch}{2}%
\begin{table}
\centering
\begin{tabular}{@{}ccc@{}}
\toprule
& \multicolumn{2}{c}{Text} \\
\cmidrule(r){2-3}
\thead{Text1 and \\ Text2} & A & B\\
\midrule
C & \thead{1\\and 1}& 2 \\
D & 3 & \thead{4\\ and 4} \\
\bottomrule
\end{tabular}