Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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)} \\ &
\multicolumn{2}{|c|}{404 Not Found} \\ \hline
\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?

share|improve this question
add comment

migrated from stackoverflow.com Jun 19 '11 at 16:48

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

2 Answers

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}}} 
    & \multicolumn{2}{c|}{404 Not Found} \\ \hline
\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.

share|improve this answer
    
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
add comment

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) \\
  404 Not Found} \\
\hline
\end{tabular}
\end{table}

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.

share|improve this answer
    
Thanks so much for the answers. It worked for both of the answers you gave me. :) Really appreciate the fast answer. Cheers! –  Peddro Jun 19 '11 at 19:43
2  
@Peddro: It would be fair to mark your preferred solution as the right one. –  Christian Lindig Jun 19 '11 at 20:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.