我正在尝试为文档中的行着色。我使用的代码如下
\documentclass[11pt,a4paper, twoside]{scrbook}
\usepackage{longtable,tabu}
\usepackage[table]{xcolor}
\definecolor{grey1}{gray}{0.6}
\definecolor{grey2}{gray}{0.9}
\begin{document}
\taburowcolors[2] 2 {grey2..grey2}
\begin{longtabu}[H]{XXl}
\caption{Chemicals and Reagents}\\[2mm]
\rowcolor{grey1}
\textbf{Product} & \textbf{Manufacturer} & \textbf{Reference}\\
Whatever & from whomever & 123456789\\
Whatever & from whomever & 123456789\\
Whatever & from whomever & 123456789\\
\end{longtabu}
\end{document}
在 overleaf 上运行一切正常,但使用最新更新的 TeXstudio 和 MikTex2.9 无法对行进行着色。这是我的日志文件。如果您能帮忙,我将不胜感激。
答案1
同样的疑问已发布在GitHub, 看最简单的 MWE 具有交替行颜色 #18。针对当前版本tabu
(v2.9 2019/01/11
)的建议解决方案注释了一些命令,请参阅数字。有关更多详细信息,请参阅提供的解决方案GitHub
。
我尝试了这个修复tabu.sty
,它满足了你的要求。也许它会在下一个release-2.10
版本中修复tabu
答案2
使用tabularx
而不是损坏的tabu
包:
\documentclass[11pt,a4paper, twoside]{scrbook}
\usepackage{longtable,tabu}
\usepackage[table]{xcolor}
\definecolor{grey1}{gray}{0.6}
\definecolor{grey2}{gray}{0.9}
\usepackage{tabularx}
\rowcolors{2}{red}{blue}
\begin{document}
\begin{table}[htbp]
\caption{Chemicals and Reagents}
\begin{tabularx}{\linewidth}{XXl}
\rowcolor{grey1}
\textbf{Product} & \textbf{Manufacturer} & \textbf{Reference}\\
Whatever & from whomever & 123456789\\
Whatever & from whomever & 123456789\\
Whatever & from whomever & 123456789\\
\end{tabularx}
\end{table}
\end{document}