1

I want to put color into a multirow cells in table with a rotate text, but when I put it the text appears behind color as the example below (is part of a book - I'm using Springer format)

Code:

\usepackage{makeidx} 
\usepackage{graphicx}  
\usepackage{multicol}  
\usepackage[bottom]{footmisc}
\usepackage{array}
\usepackage{graphicx} 
\usepackage{multirow}
\usepackage{hhline}
\usepackage{makecell} 
\usepackage{mathptmx}   
\usepackage{helvet}   
\usepackage{courier}  
\usepackage{type1cm}  
\usepackage{makeidx}   
\usepackage{graphicx}    
\usepackage{multicol}    
\usepackage[bottom]{footmisc}
\usepackage[spanish]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{multirow}

. . .

\begin{document}
\definecolor{Gray}{gray}{0.85}
\begin{table}[H]
    \centering
    \begin{tabular}{|c|c|c|c|c|}
        \hline 
        \multirow{7}{*}{\rotatebox[origin=c]{90}{\textbf{Experiment}}}  & \cellcolor{Gray}\textbf{Date} & \cellcolor{Gray}\textbf{Target} & \cellcolor{Gray}\textbf{Count} & \cellcolor{Gray}\textbf{Observations} \\ \cline{2-5}
                                                                        & 1 & Lamp & 21 & \\ \cline{2-5}
                                                                        & 2 & Radio & 22 & \\ \cline{2-5}
                                                       \cellcolor{Gray} & 3 & Window & 24 & \multicolumn{1}{l|}{Medium Noise} \\ \cline{2-5}
                                                                        & 4 & Door & 21 & \\ \cline{2-5}
                                                                        & 5 & TV & 18 & \\ \cline{2-5}
                                                                        & 6 & Phone & 24 & \\ \cline{2-5}
        \hline
    \end{tabular}
    \caption{My Table.}
    \label{tabla:final}
\end{table}
\end{document}

Getting:

My Table

1
  • Welcome to TeX.SX! Please make your code compilable by completing it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.
    – Dai Bowen
    Commented Dec 17, 2016 at 19:11

2 Answers 2

2

First the background color should be drawn, then the text placed on top of it. The example also uses \cellcolor{Gray} for the complete first column:

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{multirow}
\usepackage{graphicx}
\begin{document}
\definecolor{Gray}{gray}{0.85}
\begin{table}
    \centering
    \begin{tabular}{|>{\cellcolor{Gray}}c|c|c|c|c|}
        \hline
        & \cellcolor{Gray}\textbf{Date} & \cellcolor{Gray}\textbf{Target}
        & \cellcolor{Gray}\textbf{Count} & \cellcolor{Gray}\textbf{Observations}
        \\ \cline{2-5}
        & 1 & Lamp & 21 & \\ \cline{2-5}
        & 2 & Radio & 22 & \\ \cline{2-5}
        & 3 & Window & 24 & \multicolumn{1}{l|}{Medium Noise} \\ \cline{2-5}
        & 4 & Door & 21 & \\ \cline{2-5}
        & 5 & TV & 18 & \\ \cline{2-5}
        \multirow{-7}{*}{\rotatebox[origin=c]{90}{\textbf{Experiment}}}
        & 6 & Phone & 24 & \\ \cline{2-5}
        \hline
    \end{tabular}
    \caption{My Table.}
    \label{tabla:final}
\end{table}
\end{document}

Result

0

Alternative solution is put multirow cell on the end, when the column is already colored:

\documentclass{article}
\usepackage{graphicx}
\usepackage[table]{xcolor}
\usepackage{multirow}

\begin{document}
\definecolor{Gray}{gray}{0.85}
\begin{table}[htb]
    \centering
    \begin{tabular}{|>{\columncolor{Gray}}c|c|c|c|c|}
        \rowcolor{Gray}\hline
    & \textbf{Date} & \textbf{Target}   & \textbf{Count}    & \textbf{Observations} \\ 
        \cline{2-5}
    & 1             & Lamp              & 21                &                       \\
        \cline{2-5}
    & 2             & Radio             & 22                &                       \\
        \cline{2-5}
    & 3             & Window            & 24 & \multicolumn{1}{l|}{Medium Noise}    \\ 
        \cline{2-5}
    & 4             & Door              & 21                &                       \\ 
        \cline{2-5}
    & 5             & TV                & 18                &                       \\ 
        \cline{2-5}
\multirow{-7}{*}{\rotatebox[origin=c]{90}{\textbf{Experiment}}}  
    & 6             & Phone             & 24                &                       \\ 
        \hline
    \end{tabular}
    \caption{My Table.}
    \label{tabla:final}
\end{table}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .