我有一个LaTeX
文档,其中有一个tabularx
环境,我需要将表中的所有行更改为灰色。我试过这个命令\arrayrulecolor{grey}\hline
,但它只改变了底线的颜色,如何改变它们全部?
答案1
该\arrayrulecolor
命令仅针对以下规则设置颜色,而不针对之前设置的规则设置颜色\arrayrulecolor
。此更改是“全局”的,因为它作用于以下规则,但不作用于tabular(x)
等环境之外(参见示例)
\documentclass{book}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{lX}
\hline
foo & foobar \tabularnewline
\arrayrulecolor{red}
\hline
\end{tabularx}
\begin{center}
Another table with black rules
\end{center}
\begin{tabularx}{\linewidth}{lX}
\hline
foo & foobar \tabularnewline
\hline
\end{tabularx}
\begin{center}
Another table with red rules
\end{center}
\begin{tabularx}{\linewidth}{lX}
\arrayrulecolor{red}
\hline
foo & foobar \tabularnewline
\hline
\end{tabularx}
\end{document}