删除具有彩色背景的多列表格中的水平规则

删除具有彩色背景的多列表格中的水平规则

我尝试删除多行/单元格颜色设置中的水平规则:

\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}

这是我目前得到的。第三次尝试看起来好一些,但仍然不太好。有什么建议吗?

在此处输入图片描述

答案1

这里有一个解决方法,可以完全删除多行单元格中的细线。我还加载了xcolor选项[table],这样就不必加载了,并且我在表格序言中colortbl稍微简化了代码 。最后一句;当您使用时,请在单元格内容后立即写入>{\columncolor{lightgray}}cellcolor{some colour}没有任何空间,因为这个空间将被添加到内容中并扩大单元格。

比较:

\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}

在此处输入图片描述

相关内容