开发者

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{a开发者_如何学Pythonrticle}
\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.


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:

Rowcolor on a multirow tabular in LaTeX

EDIT:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜