I tried to use the answer to the question asked here: How To Color A Single Multicolumn Cell
But if I use more rows with different multicolumn spacing, some of the colored multicolum-cells still have white padding on the right hand side. What am I doing wrong?
\documentclass{report}
\usepackage[margin=1in,headheight=.5in,headsep=0.25in]{geometry}
\usepackage[table]{xcolor}
\usepackage{ltablex}
\keepXColumns
\renewcommand\tabularxcolumn[1]{m{#1}}% for vertical centering text in X column
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand{\cell}[2]{\multicolumn{#1}{|>{\hsize=%
\dimexpr#1\linewidth+#1\tabcolsep+#1\tabcolsep-#1\arrayrulewidth}C|}{#2}}
\newcommand{\colorcell}[2]{\multicolumn{#1}{|>{\columncolor{red}\hsize=%
\dimexpr#1\linewidth+#1\tabcolsep+#1\tabcolsep-#1\arrayrulewidth}C|}{#2}}
\begin{document}
Standard Column Color
\begin{tabularx}{\textwidth}{|*{8}{C|}}
\hline
7 & 6 & 5 & 4 & 3 & 2 & 1 & 0 \\
\hline
\colorcell{1}{ a a a a a a a a a a a a}
& CLEAR
& \colorcell{2}{Colored Cell}
& CLEAR
& \colorcell{3}{Colored Cell} \\
\hline
\colorcell{2}{ a a a a a a a a a a a a}
& CLEAR
& \colorcell{2}{Colored Cell}
& CLEAR
& \colorcell{2}{Colored Cell} \\
\hline
a a a a a a a a a a a a
& CLEAR
& CLEAR
& CLEAR
& \colorcell{4}{Colored Cell} \\
\hline
\end{tabularx}
\end{document}




|from the left of cells in the first column you need a|at the left of the\multicolumnif in the first column (or better don't use vertical rules in coloured tables) – David Carlisle Feb 29 '20 at 15:28\dimexpr#1\linewidth+#1\tabcolsep+#1\tabcolsep-#1\arrayrulewidth}looks wrong, the#1need to be\numexpr#1-1\relax: if you span two columns then you only need to account for the middle column boundary, so that's 2\tabcolsep and 1\arrayrulewidth you need to add to the width of the text in the cell. – David Carlisle Feb 29 '20 at 15:39|mentioned at the beginning of the newcommand-definition{|>{\columncolor{red}\hsize=%? – NewBee Feb 29 '20 at 16:05|is always part of the cell to its left except the first column which has rules to left and right. A s for the second comment yes the arithmetic looks wrong in the answer you copied. – David Carlisle Feb 29 '20 at 16:11