2
\documentclass[12pt]{article}
\usepackage[ paperwidth=8.27in, paperheight=11.69in]{geometry}
\usepackage{booktabs, siunitx}
\usepackage[svgnames,table]{xcolor}
\usepackage{longtable}
\usepackage{multirow}

\begin{document}
\begin{center}
\begin{tabular}{cc}
\toprule
\rowcolors{1}{}{gray!10}
\begin{tabular}{cccc}
\multicolumn{4}{c}{Replication I}\\
\midrule
a & bc & 1 & d\\
24.0 & 15.8 & 17.5 & 20.8 \\
ad & c & bd & b \\
27.5 & 24.3 & 22.5 & 18.3 \\
abc & cd & ab & ac \\
21.5 & 15.5 & 26.2 & 27.5 \\
abcd & acd & bcd & abd  \\
28.5 & 30.5 & 28.9 & 24.5 \\ 
\midrule
\end{tabular} & \rowcolors{1}{}{gray!10} \begin{tabular}{cccc}
\multicolumn{4}{c}{Replication II}\\
\midrule
ab & abc & 1 & bd \\ 
12.1 & 14.5 & 10.5 & 13.5 \\ 
d & a & ac & bc \\ 
12.0 & 9.0 & 15.0 & 15.8 \\ 
c & abcd & cd & b \\ 
11.5 & 17.2 & 16.0 & 11.0 \\ 
bcd & ad & abd & acd \\ 
19.5 & 13.2 & 12.9 & 13.5 \\ 
\midrule
\end{tabular} \\
\rowcolors{1}{}{gray!10}
\begin{tabular}{cccc}
\multicolumn{4}{c}{Replication III} \\
\midrule
a & 1 & bcd & abcd \\
26.0 & 18.5 & 29.8 & 25.8 \\
acd & ac & c & abc \\
35.0 & 25.7 & 30.5 & 25.4 \\
cd & ab & d & ad \\
17.8 & 26.0 & 24.5 & 30.2 \\
bc & bd & abd & b \\
17.9 & 20.4 & 25.4 & 15.8 \\
\end{tabular} & \rowcolors{1}{}{gray!10}
\begin{tabular}{cccc}
\multicolumn{4}{c}{Replication IV} \\
\midrule
abcd & a & 1 & abc \\ 
34.5 & 35.4 & 32.5 & 30.9 \\ 
acd & bc & bcd & d \\ 
45.3 & 43.5 & 30.4 & 28.9 \\ 
c & cd & ac & b \\ 
38.0 & 37.5 & 29.8 & 32.5 \\ 
abd & ab & bd & ad \\ 
36.5 & 30.5 & 30.0 & 38.5 \\
\end{tabular} \\
\bottomrule 
\end{tabular} 
\end{center}
\end{document}

enter image description here

I need rows colored alternatively but in doubles. That is, I need rows 2-3 in gray, rows 4-5 in white, rows 6-7 in gray and so on.

What should I do?

  • 1
    Hi ! Have a look on : tex.meta.stackexchange.com/questions/228/… – flav Nov 24 '17 at 7:14
  • 1
    Welcome to TeX.SX! In general, when asking a question, you should show what work you've done so far. Are you familiar with the tabular environment? – A Gold Man Nov 24 '17 at 7:14
  • 2
    If you can handle it, please read this article. – A Gold Man Nov 24 '17 at 7:42
  • Thank u. I am new here. So didn't know. But I have edited my question. I hope this works. – Manu J M Nov 24 '17 at 10:23
5

A possible solution is to use \hiderowcolors/\showrowcolors:

\documentclass[12pt]{article}
\usepackage[ paperwidth=8.27in, paperheight=11.69in]{geometry}
\usepackage{booktabs, siunitx}
\usepackage[svgnames,table]{xcolor}
\usepackage{longtable}
\usepackage{multirow}
\newcommand{\mytablecolor}{\rowcolors{2}{gray!10}{gray!10}}

\begin{document}
    \begin{center}
        \begin{tabular}{cc}
            \toprule
            \mytablecolor
            \begin{tabular}{cccc}
                \multicolumn{4}{c}{Replication I}\\
                \midrule
                a & bc & 1 & d\\
                24.0 & 15.8 & 17.5 & 20.8 \\
                \hiderowcolors ad & c & bd & b \\
                27.5 & 24.3 & 22.5 & 18.3 \\
                \showrowcolors abc & cd & ab & ac \\
                21.5 & 15.5 & 26.2 & 27.5 \\
                \hiderowcolors abcd & acd & bcd & abd  \\
                28.5 & 30.5 & 28.9 & 24.5 \\ 
                \midrule
            \end{tabular} & 
            \mytablecolor
            \begin{tabular}{cccc}
                \multicolumn{4}{c}{Replication II}\\
                \midrule
                ab & abc & 1 & bd \\ 
                12.1 & 14.5 & 10.5 & 13.5 \\ 
                \hiderowcolors d & a & ac & bc \\ 
                12.0 & 9.0 & 15.0 & 15.8 \\ 
                \showrowcolors c & abcd & cd & b \\ 
                11.5 & 17.2 & 16.0 & 11.0 \\ 
                \hiderowcolors bcd & ad & abd & acd \\ 
                19.5 & 13.2 & 12.9 & 13.5 \\ 
                \midrule
            \end{tabular} \\
            \mytablecolor
            \begin{tabular}{cccc}
                \multicolumn{4}{c}{Replication III} \\
                \midrule
                a & 1 & bcd & abcd \\
                26.0 & 18.5 & 29.8 & 25.8 \\
                \hiderowcolors acd & ac & c & abc \\
                35.0 & 25.7 & 30.5 & 25.4 \\
                \showrowcolors cd & ab & d & ad \\
                17.8 & 26.0 & 24.5 & 30.2 \\
                \hiderowcolors bc & bd & abd & b \\
                17.9 & 20.4 & 25.4 & 15.8 \\
            \end{tabular} & 
            \mytablecolor
            \begin{tabular}{cccc}
                \multicolumn{4}{c}{Replication IV} \\
                \midrule
                abcd & a & 1 & abc \\ 
                34.5 & 35.4 & 32.5 & 30.9 \\ 
                \hiderowcolors acd & bc & bcd & d \\ 
                45.3 & 43.5 & 30.4 & 28.9 \\ 
                \showrowcolors c & cd & ac & b \\ 
                38.0 & 37.5 & 29.8 & 32.5 \\ 
                \hiderowcolors abd & ab & bd & ad \\ 
                36.5 & 30.5 & 30.0 & 38.5 \\
            \end{tabular} \\
            \bottomrule 
        \end{tabular} 
    \end{center}
\end{document}

enter image description here

  • This is exactly what I wanted. Grazie CarLaTex :-) – Manu J M Nov 25 '17 at 3:26

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.