1

I try to remove a horizontal rule in multirow / cellcolor setting:

\documentclass{article}
\usepackage{hhline,array,multirow,xcolor,colortbl}
\begin{document}
\parindent0pt

\begin{tabular}{@{}|p{1cm}|l@{}}
\cellcolor{lightgray}     &    \cellcolor{lightgray} b \\
\cline{2-2}
\multirow{-2}{\linewidth}{\cellcolor{lightgray} a }&  \cellcolor{lightgray} d
\end{tabular}


\begin{tabular}{@{}|p{1cm}|l}
  \cellcolor{lightgray}     &    \cellcolor{lightgray} b \\
  \hhline{~-}
  \multirow{-2}{\linewidth}{\cellcolor{lightgray} a }&  \cellcolor{lightgray} d
\end{tabular}

\begin{tabular}{|p{1cm}|l}
  \cellcolor{lightgray}     &    \cellcolor{lightgray} b \\
  \hhline{>{\arrayrulecolor{lightgray}}->{\arrayrulecolor{black}}-}
  \multirow{-2}{\linewidth}{\cellcolor{lightgray} a }&  \cellcolor{lightgray} d
\end{tabular}
\end{document}

This is what I have got so far. The third attempt looks better, but still not good. Any advice?

enter image description here

topskip
  • 37,020

1 Answers1

2

Here is a workaround to remove completely the very thin lines in the multirow cell. I also loaded xcolor with option [table], which saves having to load colortbl, and I slightly simplified the code with >{\columncolor{lightgray}} in the tabular preamble. Last remark; when you use cellcolor{some colour}, write immediately after the cell contents without any space, as this space would be added to the contents and enlarge the cell.

Compare:

\documentclass{article}
\usepackage{hhline, array, multirow}
\usepackage[table]{xcolor}

\begin{document}

\parindent0pt

\begin{tabular}{|>{\columncolor{lightgray}}p{1cm}|>{\columncolor{lightgray}}l}
  \cellcolor{lightgray} &\cellcolor{lightgray}b \\
  \hhline{|>{\arrayrulecolor{lightgray}}->{\arrayrulecolor{black}}|-}
  \multirow{-2}{\linewidth}{\cellcolor{lightgray} a }&\cellcolor{lightgray} d
\end{tabular}
\bigskip

\begin{tabular}{|>{\columncolor{lightgray}}p{1cm}|>{\columncolor{lightgray}}l}
    & b \\
\noalign{\vskip-0.1pt}
  \hhline{|>{\arrayrulecolor{lightgray}}->{\arrayrulecolor{black}}|-}
\noalign{\vskip-0.1pt}
  \multirow{-2}{\linewidth}{ a }&\cellcolor{lightgray}d
\end{tabular}

\end{document}

enter image description here

Sveinung
  • 20,355
Bernard
  • 271,350
  • Clever solution, however, the code for a complicated table is complex. – Sveinung Nov 29 '19 at 13:13
  • You're right, however one may define a custom \myhhline which incorporates the parameters that won't change between tables with the same problem. – Bernard Nov 29 '19 at 13:18