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

7
  • 1
    Yes, the third way is better. You'll improve with this code for the rule: \hhline{|>{\arrayrulecolor{lightgray}}->{\arrayrulecolor{black}}|-|}. The very thin line inside the cell is mainly due to the pdfviewer. – Bernard Nov 29 '19 at 11:45
  • Use the package cals instead. – Sveinung Nov 29 '19 at 12:00
  • @Sveinung For the next project I try out cals instead. Looks much more the way that I want to typeset tables. Thank you! – topskip Nov 29 '19 at 12:04
  • @Bernard Thank you! If you put this as an answer, I'll accept it. Otherwise I just upvote your comment :-) – topskip Nov 29 '19 at 12:04
  • 1
    You may have a look at the answer to this question. – Sveinung Nov 29 '19 at 12:11
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

2
  • 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

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.