Coloring text for whole table rows

Eddy asked on TeX.SX:

 
How to color the font of a single row in a table?
 

I have a table and I want to make the font color red for just one row (not the background). How do I do that? Here’s my table:

  \begin{tabular}{ l | l l l l }
        & 1 & 2 & 3 & 4 \\ 
    \hline 
    1   & A & B & C & D \\ 
    2   & A & B & C & D \\ 
    3   & A & B & C & D \\ 
    4   & A & B & C & D \\ 
  \end{tabular}

Answer:

You could use the tabu environment of the tabu package with the command \rowfont, for example:

\documentclass{article}
\usepackage{tabu}
\usepackage{xcolor}
\begin{document}
  \begin{tabu}{ l | l l l l }
  \rowfont{\color{red}}
        & 1 & 2 & 3 & 4 \\ 
    \hline 
    1   & A & B & C & D \\ 
    2   & A & B & C & D \\ 
    3   & A & B & C & D \\ 
    4   & A & B & C & D \\ 
  \end{tabu}
\end{document}
table with colored row text
Stefan Kottwitz

23. August 2011 by stefan
Categories: Figures and Tables, Questions & Answers, Tables, TeX.SX | 2 comments

Comments (2)

Leave a Reply