所以我昨晚尝试学习 LaTeX,我试图尽快完成学校作业的这个模板。其中一部分需要构建一个表。我想使用多行,但需要将充当标题的多行设置为灰色。这就是我迄今为止从万能的谷歌创建的。
\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}
不幸的是,这不适用于我在虚拟机中的 Debian GNU/Linux 5.0.4 (lenny) 上的 pdflatex 版本 1.4.0。它没有正确执行,最终看起来像这个,其中第一个单元格多行之后的行是黑色垃圾。
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.
发布评论
评论(1)
试试这个:
它会产生:
编辑:
是的,
>{...}
是放置\columncolor
的命令(必须位于其中!)。另请参阅 此 PDF。Try this:
Which produces:
EDIT:
Yes,
>{...}
is the command to place your\columncolor
in (must be in it!). Also see 4.1 from this PDF.