# Suggested way to color a multirow table without package of colored tabulars

I have this code:

\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,booktabs}
\usepackage{amssymb}
\usepackage[table]{xcolor}

\usepackage{booktabs}

\begin{document}

{\centering
\begin{tabular}{>{\centering\arraybackslash}m{2cm} >{\centering\arraybackslash}m{3cm}>{\centering\arraybackslash}m{4cm}}
\arrayrulecolor{red}\toprule
\rowcolor{gray!60}Something & Number & \begin{tabular}{c}Something \\(splitted)\end{tabular}\\\midrule
\rowcolor{gray!20}\cellcolor{gray!60} & 1 & Here is a sentence automatically breakad\\
\rowcolor{gray!40}\cellcolor{gray!60}&2 & 2 secs  \\
\rowcolor{gray!20}\cellcolor{gray!60}&3 & 2 secs  \\
\rowcolor{gray!40}\cellcolor{gray!60}&4 & 2 secs  \\
\rowcolor{gray!20}\cellcolor{gray!60}&5 & 2 secs \\
\rowcolor{gray!40}
\multirow{-6}{*}{\cellcolor{gray!60}Multirow}&6 & 2 secs\\\bottomrule
\end{tabular}

\end{document}


That reproduces this table:

How can I solve the horizontal lines problem in a way that: 1) they don't appear at all inside the "multirowed" colored cell 2) they don't "break" my red colored lines?

I don't want to use a tabu or tikz or similar solutions... but just looking for ways with regular tabular environment.

I am thinking about coloring the clines and may by make them thicker but I don't know the way.

Any suggestions?

Edit: I want too keep the horizontal (almost invisible) lines beetween the columns and also if possible between the other rows except of the ones inside the "multirowed" cell and around the red lines. If I can not keep them, at least to recreate them via \cline{} or something (but the vertical too).

I firstly thought a solution to create some colored \clines but didn't manage to find information on how to do it. Other solution and suggestions are appreciated.

@Bernard's answer is much appreciated but I have the next problems:

(B1) The separating lines between columns and the other rows are needed to separate between separate cells (like rows with numbers 3, 4 and 5 and like the separation between columns in the following picture):

(B2) The color around the \toprule, \midrule and \botomrule (the red lines) is still white.

The above image has still the problems 1 and 2 [=(B2)] above but doesn't have the (B1)

• So what do you want to remove? The white space around the red lines or the small "white lines" between columns and rows? – TeXnician Sep 20 '18 at 7:59
• @TeXnician I am sorry I was not clear enough... I edited the post to make it clear. (I will be AFK for some hours) – koleygr Sep 20 '18 at 8:19

Here is a hack, playing with the optional argument of \\ and the overhang values of \rowcolor:

\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,booktabs}
\usepackage{amssymb}
\usepackage[table]{xcolor}

\usepackage{booktabs, makecell}
\newcommand{\myrowcolor}[1]{\rowcolor{#1}[\tabcolsep][\dimexpr\tabcolsep+0.2pt]}

\begin{document}

{\centering\setlength{\extrarowheight}{2pt}
\begin{tabular}{>{\centering\arraybackslash}m{2cm} >{\centering\arraybackslash}m{3cm}>{\centering\arraybackslash}m{4cm}}
\arrayrulecolor{red}\toprule
\myrowcolor{gray!60} Something & Number & \makecell{Something \\(splitted)}\\\midrule
\myrowcolor{gray!20}\cellcolor{gray!60} & 1 & Here is a sentence automatically breakad\\[-0.2pt]
\myrowcolor{gray!40} \cellcolor{gray!60}&2 & 2 secs \\[-0.2pt]
\myrowcolor{gray!20} \cellcolor{gray!60}&3 & 2 secs \\[-0.2pt]
\myrowcolor{gray!40} \cellcolor{gray!60}&4 & 2 secs \\[-0.2pt]
\myrowcolor{gray!20} \cellcolor{gray!60}&5 & 2 secs \\[-0.2pt]
\myrowcolor{gray!40}
\multirow{-6.5}{=}{\cellcolor{gray!60}Multirow}&6 & 2 secs\\\bottomrule
\end{tabular}

\end{document}


However, in my opinion, the white strips around the booktabs rules, due to the padding of these rules (\aboverulesep and \belowrulesep), doesn't look so nice. It would look better deleting this padding, and, say, slightly increasing \arraystretch to compensate.

Edit:

Here is a solution to remove the white strips around booktabs rules: I set the padding of these rules to 0pt, and replace it with a minimal padding defined by cellspace at the top and bottom of all cells in columns with specifier prefixed with the letter S (or C if you load siunitx). I also introduced separating gray rules between rows:

\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{multirow,booktabs}
\usepackage{amssymb}
\usepackage[table]{xcolor}

\usepackage{booktabs, makecell, cellspace}
\setlength{\cellspacetoplimit}{4pt}
\setlength{\cellspacebottomlimit}{3pt}
\newcommand{\myrowcolor}[1]{\rowcolor{#1}[\tabcolsep][\dimexpr\tabcolsep+0.2pt]}
\newcommand{\myhhline}{\hhline{>{\arrayrulecolor{gray!60}}---}}

\begin{document}

{\centering
\setlength{\aboverulesep}{-0.1pt}
\setlength{\belowrulesep}{-0.1pt}
\begin{tabular}{>{\centering\arraybackslash}m{2cm} >{\centering\arraybackslash}m{3cm}>{\centering\arraybackslash}S{m{4cm}}}
\arrayrulecolor{red}\toprule
\rowcolor{gray!60} Something & Number & \makecell{Something \\(splitted)}\\\midrule
\rowcolor{gray!20}\cellcolor{gray!60} & 1 & Here is a sentence automatically breakad\\[-0.4pt]
\arrayrulecolor{gray!60}\midrule
\rowcolor{gray!40} \cellcolor{gray!60}&2 & 2 secs \\[-0.4pt]
\midrule
\rowcolor{gray!20} \cellcolor{gray!60}&3 & 2 secs \\[-0.4pt]
\midrule
\rowcolor{gray!40} \cellcolor{gray!60}&4 & 2 secs \\[-0.4pt]
\midrule
\rowcolor{gray!20} \cellcolor{gray!60}&5 & 2 secs \\[-0.4pt]
\midrule

\rowcolor{gray!40}
\multirow{-8}{=}{\cellcolor{gray!60}Multirow}&6 & 2 secs\\
\arrayrulecolor{red}\bottomrule
\end{tabular}

\end{document}


• Thank's for your answer, but still gives some problems (I edited the question). If you think it can not be done with tabular environment and not tikz overlays and other similar hacks like this I can accept it as an answer after a few days. – koleygr Sep 20 '18 at 11:28
• @koleygr, how about one with tabu? – J Leon V. Sep 20 '18 at 15:14
• @JLeonV. I think the tabu can do it. But I would prefer a tabular solution if possible. (If I will not find an answer I will ping you... But I would like to see some really thin separating lines as in (B1)... I think that it is possible with tabu and easy) – koleygr Sep 20 '18 at 15:44
• @koleygr: I've posted a new code. Please see if it fits your requirements. – Bernard Sep 20 '18 at 17:30
• Perfect @Bernard... Thank you really much. I appreciate your effort but can not upvote again. 1000 Thanks. – koleygr Sep 20 '18 at 19:54

Just to show some results with tabu, because vertical thin lines are not solved, and please do not take this as imposing the package, but I think tabu is designed just to solve these problems as an extension from tabularx because it focuses on working with colors, of course it is not easy and it is not enough, it also has its problems, but it produces the following results.

RESULT:

MWE:

% arara: pdflatex: {synctex: yes, action: nonstopmode}
\documentclass[a4paper,twocolumn]{article}
\usepackage[margin=1in]{geometry}
\usepackage{booktabs}
\usepackage{amssymb}

%Packages for beautifull tables.
\usepackage{tabu}
\usepackage{array}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage[table,xcdraw]{xcolor}
\usepackage{makecell}
\usepackage{lipsum} % Dummy text

\begin{document}
Some initial text.\\
\begin{table}[!h]
\def\TableLineSize{1.5pt}
\small
\tabulinesep =1.5pt
\tabulinestyle{\TableLineSize red}
\taburulecolor|red|{white}
\arrayrulewidth=1mm \doublerulesep=1mm
\taburowcolors[2] 2{gray!25 .. gray!50}
\begin{tabu} to \linewidth {X[1.2mc]X[1,mc]X[2.2,mc]} \firsthline\hline
\rowcolor{gray!60}
Something & Number & \makecell{Something \\(splitted)}\\ \firsthline\hline
\cellcolor{gray}& 1 & Here is a sentence automatically breaked \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\multirow{-10}{*}{\cellcolor{gray}Multirow}
& 1 & 2 secs  \\ \firsthline\hline
\end{tabu}
\caption{Usign tabu rowcolors to draw white and red huge lines}
\label{tab:tab1}
\end{table}

\vspace{-\baselineskip}

\begin{table}[!h]
\def\TableLineSize{0.75pt}
\small
\tabulinesep = 1.5pt
\tabulinestyle{\TableLineSize white}
\taburulecolor|red|{white}
\arrayrulewidth=2pt \doublerulesep=2pt
\taburowcolors[2] 2{gray!25 .. gray!50}
\begin{tabu} to \linewidth {X[1.2,mc]|X[1,mc]|X[2.2,mc]} \firsthline\hline
\rowcolor{gray!60}
Something & Number & \makecell{Something \\(splitted)} \\ \firsthline\hline
\cellcolor{gray}& 1 & Here is a sentence automatically breaked  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\multirow{-10}{*}{\cellcolor{gray}Multirow}
& 1 & 2 secs  \\ \firsthline\hline
\end{tabu}
\caption{Idem as table 1 but with thin separating lines}
\label{tab:tab1}
\end{table}

\lipsum[4]
\lipsum[4]
some text
\vspace{1.5\baselineskip}
\begin{table}[!h]
\def\TableLineSize{1.5pt}
\small
\tabulinesep =1.5pt
\tabulinestyle{\TableLineSize red}
\taburowcolors[2] 2{gray!25 .. gray!50}
\begin{tabu} to \linewidth {X[1.2mc]X[1,mc]X[2.2,mc]} \tabucline -
\rowcolor{gray!60}
Something & Number & \makecell{Something \\(splitted)}\\ \tabucline -
\cellcolor{gray}& 1 & Here is a sentence automatically breaked  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\cellcolor{gray}& 1 & 2 secs  \\
\multirow{-10}{*}{\cellcolor{gray}Multirow}
& 1 & 2 secs  \\ \tabucline -
\end{tabu}
\caption{Normal 1.5pt red lines}
\label{tab:tab1}
\end{table}

\vspace{1.5\baselineskip}
\begin{table}[!h]
\def\TableLineSize{0.75pt}
\small
\tabulinesep = 1.5pt
\tabulinestyle{\TableLineSize white}
\arrayrulewidth=1.5pt
\taburowcolors[2] 2{gray!25 .. gray!50}
\begin{tabu} to \linewidth {X[1.2,mc]|X[1,mc]|X[2.2,mc]} \tabucline[red] -
\rowcolor{gray!60}
Something & Number & \makecell{Something \\(splitted)} \\ \tabucline[red] -
\cellcolor{gray}& 1 & Here is a sentence automatically breaked  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\cellcolor{gray}& 1 & 2 secs  \\[-\TableLineSize] \tabucline {2-3}
\multirow{-10}{*}{\cellcolor{gray}Multirow}
& 1 & 2 secs  \\ \tabucline[red] -
\end{tabu}
\caption{Idem as table 3 but with thin separating lines}
\label{tab:tab1}
\end{table}

\lipsum[1-2]

\end{document}

• (+1) tabu has strong abilities... Thanks for adding... I will find time to study from your code. – koleygr Sep 20 '18 at 22:48