2

I've been struggling with table editing, so I started using a website to generate tables in LaTeX. However, whenever I'm using multirow and borders, things get a little tricky. I get a discontinuous line along my column.

As a test, I'm using this:

\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{@{}c|cc@{}}
Test               & a & b \\ \midrule
\multirow{2}{*}{x} & 1 & 2 \\ \cmidrule(l){2-3} 
               & 3 & 4
\end{tabular}
\end{table}

This is the result:

test table

I'm using TexPortable with MiKTeX 2.9.6210 and Texmaker 4.5.

4

This is related to the padding around horizontal lines in booktabs (the lengths \aboverulesep and \belowrulesep). Vertical rules should not be used with booktabs in general (this principle suffers exceptions). A workaround consists in setting them to 0 and replacing them with more or less equivalent lengths added at the top and bottom of cells with the tools from makecell.

\documentclass{article}
\usepackage{booktabs, multirow, array, makecell, caption}

\begin{document}

\begin{table}[!htb]
\centering
\setlength\aboverulesep{0pt}\setlength\belowrulesep{0pt}
\setcellgapes{3pt}\makegapedcells
\caption{My caption}
\label{my-label}
\begin{tabular}{@{}c|cc@{}}
Test & a & b \\ \midrule
\multirow{2}{*}{x} & 1 & 2 \\ \addlinespace[-0.03em]\cmidrule(l){2-3}
               & 3 & 4
\end{tabular}
\end{table}

\end{document} 

enter image description here

  • I've tried that and it worked on the vertical line, but the horizontal line is still discontinuous, here. Thank you! – Tiago Correia Apr 26 '17 at 9:18
  • 1
    Do you mean the short line between 2nd and 3rd row? I thought it was there purposely. The responsible is the (l) optional argument of \cmidrule. Just remove it. – Bernard Apr 26 '17 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.