latex - LaTeX中多行表格上的行色

标签 latex colors pdflatex multirow

因此,我昨晚尝试学习LaTeX,并试图尽快获得用于学校作业的模板。其中一部分需要构建表。我想使用多行,但需要像标题一样工作的多行被涂成灰色。这是我迄今为止从全能的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}

不幸的是,这不适用于我在VM中拥有的Debian GNU/Linux 5.0.4(lenny)上的pdflatex版本1.4.0。最终,它看起来像this,而不是正确地执行了操作,其中multirow之后的第一个单元格是被涂黑的垃圾。

最佳答案

试试这个:

\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}

产生:

alt text

编辑:

是的,>{...}是用于将\columncolor放入其中的命令(必须在其中!)。另请参阅this PDF中的4.1。

关于latex - LaTeX中多行表格上的行色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2599879/

相关文章:

c - 如何处理.dll依赖关系?

r - 如何获取 knitr .Rnw 文档中使用的软件包列表?

heroku - 如何在heroku中安装pdflatex

c# - 找不到初始化文件 gs_init.ps

visual-studio - Visual Studio 格式化 - 更改方法颜色

CSS:拆分框边框颜色

python - 使用 Python 将颜色图/渐变图应用于图像

latex - 如何插入带有\raggedleft 文本的表格以及如何修复左侧的孔表

emacs - Beamer 组织模式 : pause between blocks, 覆盖,发现 block

r - Anova 表比较组,在 R 中,导出到 latex ?