# Coloring a multirow

i have currently this code in LaTeX

\begin{footnotesize}
\begin{center}
\begin{longtable}[c]{ll}
\caption[API da listagem de um docente]{API da listagem de um docente.}  \label{relStruct}\\
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{\textcolor{WhiteC}{\textbf{URL}} \cellcolor{GreenC}} &
\multicolumn{2}{|c|}{http://di76.di.fct.unl.pt:3007/people} \\ \hline
\multicolumn{1}{|c|}{\textcolor{WhiteC}{\textbf{Method}} \cellcolor{GreenC}} &
\multicolumn{2}{|c|}{GET} \\ \hline
\multirow{2}*{\textcolor{WhiteC}{\textbf{QueryString}} \cellcolor{GreenC}} &
start= & The number of the first person to return \\  &  end= & The number of the last person to return \\ \hline
\multirow{2}{*}{\textcolor{WhiteC}{\textbf{Returns}} \cellcolor{GreenC}} &
\multicolumn{2}{|c|}{200 OK \& XML (people/people+xml)} \\ &
\end{tabular}
%\end{center}
\end{longtable}
\end{center}
\end{footnotesize}


And the output of this code its a table where the 2 multirow parts are not painted fully, only the top of the row its painted. Anyone can tell me how to fix these problem in order to paint completely?

-

## migrated from stackoverflow.comJun 19 '11 at 16:48

This question came from our site for professional and enthusiast programmers.

The best solution is to use \colorcolumn, for the first column, in the table format. Notice also that I changed \mulrirow{2}{*}{...} to \mulrirow{-2}{*}{...} to avoid problems with the text being overwritten by the color.

\documentclass{book}
\usepackage{longtable,multirow,array}
\usepackage[table]{xcolor}
\usepackage{lipsum}% just to generate some text

\colorlet{WhiteC}{white}% to make the example compilable
\colorlet{GreenC}{blue!60}% to make the example compilable

\begin{document}

\begingroup
\footnotesize
\begin{longtable}[c]{|>{\columncolor{GreenC}}l|l|l|}
\caption[API da listagem de um docente]{API da listagem de um docente.}  \label{relStruct}\\
\hline
\multicolumn{1}{|c|}{\cellcolor{GreenC}\textcolor{WhiteC}{\textbf{URL}}}  & \multicolumn{2}{c|}{http://di76.di.fct.unl.pt:3007/people} \\ \hline
\multicolumn{1}{|c|}{\cellcolor{GreenC}\textcolor{WhiteC}{\textbf{Method}}}
& \multicolumn{2}{c|}{GET} \\ \hline
& start= & The number of the first person to return \\
\multirow{-2}{*}{\textcolor{WhiteC}{\textbf{QueryString}}} & end=
& The number of the last person to return \\ \hline
& \multicolumn{2}{c|}{200 OK \& XML (people/people+xml)} \\
\multirow{-2}{*}{\textcolor{WhiteC}{\textbf{Returns}}}
\end{longtable}
\endgroup

\end{document}


There's no footnotesize environment; \footnotesize is a switch. I don't understand why you are using a tabular environment inside a longtable; use longtable if your table will admit page breaks and tabular otherwise. I redefined the colors GreenC and WhiteC to make my code compilable for everyone.

-
In the first column of the first two rows, you only need to enter \textcolor{WhiteC}{\textbf{URL}} and \textcolor{WhiteC}{\textbf{Method}}, respectively, as you've already used the \columncolor command. I.e., no need for the \cellcolor instructions, right? –  Mico Nov 21 '11 at 3:44

With multirow there are known problems when it's required to color a cell. I would define, in the preamble,

\newcommand{\mycell}[2][c]{\begin{tabular}{@{}#1@{}}#2\end{tabular}}
\newcommand{\greencell}[1]{\textcolor{WhiteC}{\bfseries #1}\cellcolor{GreenC}}


and write the table as

\begin{table}
\centering
\caption[API da listagem de um docente]{API da listagem de um docente.}  \label{relStruct}
\medskip
\footnotesize

\begin{tabular}{|c|c|}
\hline
\greencell{URL} & http://di76.di.fct.unl.pt:3007/people \\
\hline
\greencell{Method}&  GET \\
\hline
\greencell{QueryString} &
\mycell[l|l]{%
start= & The number of the first person to return \\
end= & The number of the last person to return} \\
\hline
\greencell{Returns} &
\mycell{200 OK \& XML (people/people+xml) \\

The double row cells are input as argument to \mycell, which can receive an optional argument to express the kind of "subtabular" you need.
Whether you prefer this method or the \multirow method as in Gonzalo's solution is a matter of taste.