you can colored rows with help of package xcolor
with option ˙[table]` (see mwe below) using macro
\rowcolors{2}{white}{gray!20}
before beginning of table. since \rowcolor
overwrite \columncolor
, the part of rowcolors in the first column had to be "over colored" by \cellcolor{white}
. special care needed \multirow
. that it is not covered by row colors had to be moved below a of spanned cells:
\multirow{-4}{*}{System (I)}
& texto1 & texto2 & texto3 & Texto 4
for more space in rows i use package cellspace
and add attribute S
to appropriate column types. for better looking of table the vertical space around rules is removed.
special care is given to accommodate row colors to table width. since you use @{}
on beginning and end of column definition with out it the color spill out of table. this is prevented by
>{\columncolor{white}[0pt][\tabcolsep]}l
in the first and inthe last column (see mwe below).
mwe:
\documentclass{report}
\usepackage[table]{xcolor}
\usepackage{booktabs, cellspace, multirow}
\renewcommand{\aboverulesep}{0pt}
\renewcommand{\belowrulesep}{0pt}
\setlength\cellspacetoplimit{5pt}
\setlength\cellspacebottomlimit{5pt}
\begin{document}
\begin{table}
\centering
\rowcolors{2}{white}{gray!20}
\begin{tabular}{@{}>{\columncolor{white}[0pt][\tabcolsep]}l Sl l l
>{\columncolor{white}[\tabcolsep][0pt]}l@{}} % column definition is changed!
\toprule[0.5pt]
& \multicolumn{2}{Sc}{\textbf{Method 1}} & \multicolumn{2}{Sc}{\textbf{Method 2}} \\
\cellcolor{white}
& Iteration & Approximation & Iteration & Approximation \\
\cmidrule(r){2-3}\cmidrule(l){4-5}
& texto1 & texto2 & texto3 & Texto 4 \\
\cellcolor{white}
& texto1 & texto2 & texto3 & Texto 4 \\
& texto1 & texto2 & texto3 & Texto 4 \\
\cellcolor{white}
\multirow{-4}{*}{System (I)}
& texto1 & texto2 & texto3 & Texto 4 \\
\midrule
%
& texto1 & texto2 & texto3 & Texto 4 \\
\cellcolor{white}
& texto1 & texto2 & texto3 & Texto 4 \\
& texto1 & texto2 & texto3 & Texto 4 \\
\cellcolor{white}
\multirow{-4}{*}{System (I)}
& texto1 & texto2 & texto3 & Texto 4 \\
\bottomrule[0.5pt]
\end{tabular}
\caption{Comparison of the methods}
\end{table}
\end{document}
note: from your question is not very clear, if you like multirow
cell white or also should be colored with gray strips. in latter case you need only to remove all \cellcolor{white}
in table code.
edit:
alternative scheme of a table coloring and use of horizontal rules which (to my opinion) better group rows and columns. table body in this case is:
\begin{table}
\centering
\rowcolors{2}{gray!20}{white}
\begin{tabular}{@{}>{\columncolor{white}[0pt][\tabcolsep]}l Sl l l
>{\columncolor{white}[\tabcolsep][0pt]}l@{}} % column definition is changed!
\toprule[0.5pt]
& \multicolumn{2}{Sc}{\textbf{Method 1}} & \multicolumn{2}{Sc}{\textbf{Method 2}} \\
\cmidrule(r){2-3}\cmidrule(l){4-5}
& Iteration & Approximation & Iteration & Approximation \\
\midrule
\cellcolor{white}
& texto1 & texto2 & texto3 & Texto 4 \\
& texto1 & texto2 & texto3 & Texto 4 \\
\cellcolor{white}
& texto1 & texto2 & texto3 & Texto 4 \\
\multirow{-4}{*}{System (I)}
& texto1 & texto2 & texto3 & Texto 4 \\
\midrule
%
\cellcolor{white}
& texto1 & texto2 & texto3 & Texto 4 \\
& texto1 & texto2 & texto3 & Texto 4 \\
\cellcolor{white}
& texto1 & texto2 & texto3 & Texto 4 \\
\multirow{-4}{*}{System (I)}
& texto1 & texto2 & texto3 & Texto 4 \\
\bottomrule[0.5pt]
\end{tabular}
\caption{Comparison of the methods}
\end{table}