Weird corners with \cline

You get precise control with \hhline:

\documentclass{article}
\usepackage{hhline}

\begin{document}

\begin{tabular}{c|c|c|c}
\hhline{~|-|-|~}
a&b&c&d\\
\hhline{~|-|-|~}
\end{tabular}

\end{document}

enter image description here

  • ~ means no rule for the cell,
  • | means an intersection with a vertical rule,
  • - means a rule for the cell.

Don't know why it happens, but here's a fix...diminish the \\ by \arrayrulewidth (EDITED to reflect \arrayrulewidth rather than \fboxrule, hat tip: David Carlisle).

\documentclass[11pt,oneside]{article}
%\usepackage{array}

\begin{document}

\begin{table}
\centering
\begin{tabular}{c|c|c|c}
\cline{2-3}
a&b&c&d\\[-\arrayrulewidth]
\cline{2-3}
\end{tabular}  
\end{table}

\end{document}

enter image description here

If one is concerned that this approach shrinks the height of the cell by -\arrayrulewidth, then just compensate by adding an extra \arrayrulewidth to the depth of the line before the shrunken \\. Compare the original box on the left with the revised on the right.

\documentclass[11pt,oneside]{article}
%\usepackage{array}
\newcommand\mystrut{\rule[\dimexpr-\dp\strutbox-\arrayrulewidth]{0pt}{%
  \dimexpr\baselineskip+\arrayrulewidth}}
\begin{document}

\begin{table}
\centering
\begin{tabular}{c|c|c|c}
\cline{2-3}
a&b&c&d\\
\cline{2-3}
\end{tabular}%
%
\begin{tabular}{c|c|c|c}
\cline{2-3}
a&b&c&d\mystrut\\[-\arrayrulewidth]
\cline{2-3}
\end{tabular}  
\end{table}

\end{document}

enter image description here

Tags:

Tables