latexcolorspdflatexmultirow

Rowcolor on a multirow tabular in LaTeX


So I tried learning LaTeX last night, and I trying to get this template for school assignments done ASAP. Part of that requires building a table. I want to use multirow, but need the multirows, that are acting like headings, to be colored gray. This is what I created so far from the almighty Google.

\documentclass{article}
\usepackage{xcolor,colortbl}
\begin{document}

\begin{tabular}{|l|l|p{5cm}|p{2.5cm}|l|l|}
\hline
\rowcolor{lightgray} 
Stage & Aim & Procedure & Materials & Focus & Time \\ 
\hline
\rowcolor{lightgray} 
\multicolumn{6}{|l|}{Engage} \\
\hline
Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
%\hline
\rowcolor{lightgray} \multicolumn{6}{|l|}{Study} \\
\hline
Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
\hline
\rowcolor{lightgray} 
\multicolumn{6}{|l|}{Activate} \\
\hline
Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
\hline
\rowcolor{lightgray} 
\multicolumn{6}{|l|}{Conclusion} \\
\hline
Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
\hline
\end{tabular}

\end{document}

Unfortunately, this does not work with pdflatex version 1.4.0 on Debian GNU/Linux 5.0.4 (lenny) I have in a VM. Instead of doing it correctly, it ends up looking like this, where the first cell of the row after the multirow is blacked-out garbage.


Solution

  • Try this:

    \documentclass{article}
    
    \usepackage{xcolor,colortbl}
    
    \begin{document}
    
    \begin{tabular}{|l|l|p{5cm}|p{2.5cm}|l|l|}
    
    \hline
    Stage & Aim & Procedure & Materials & Focus & Time \\ 
    \hline
    \multicolumn{6}{|>{\columncolor[gray]{.8}}l|}{Engage} \\ 
    \hline
    Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
    \hline
    \multicolumn{6}{|>{\columncolor[gray]{.8}}l|}{Study} \\ 
    \hline
    Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
    \hline
    \multicolumn{6}{|>{\columncolor[gray]{.8}}l|}{Activate} \\ 
    \hline
    Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
    \hline
    \multicolumn{6}{|>{\columncolor[gray]{.8}}l|}{Conclusion} \\ 
    \hline
    Row 0 & Row 1 & Row 2 & Row 3 & Row 4 & Row 5 \\
    \hline
    
    \end{tabular}
    
    \end{document}
    

    Which produces:

    alt text

    EDIT:

    Yes, >{...} is the command to place your \columncolor in (must be in it!). Also see 4.1 from this PDF.