2

I have a LaTeX document, where I have a tabularx environment, and I need to change all lines in the table to grey. I have tried this command \arrayrulecolor{grey}\hline, but it changed just the colour of the bottom line, how to change them all?

1
  • 1
    \arrayrulecolor does not act backwards, only the following rules will have the new colour then , i.e. you have to use it before tabularx for all following rules.
    – user31729
    Mar 25, 2016 at 15:39

1 Answer 1

3

The \arrayrulecolor commands sets the colour only for the following rules but not for those that were set before \arrayrulecolor was used. This change is 'global' in the sense that it acts on the following rules, but not outside of the tabular(x) etc. environment (see the example)

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .