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

If you don't want to use the tabu package you can define a \rowstyle command together with supporting column types + and = as follows:

\documentclass{article}

\usepackage{array}
\usepackage{xcolor}

\makeatletter

\newcommand*{\@rowstyle}{}

\newcommand*{\rowstyle}[1]{% sets the style of the next row
  \gdef\@rowstyle{#1}%
  \@rowstyle\ignorespaces%
}

\newcolumntype{=}{% resets the row style
  >{\gdef\@rowstyle{}}%
}

\newcolumntype{+}{% adds the current row style to the next column
  >{\@rowstyle}%
}

\makeatother

\begin{document}

\begin{tabular}{ =l | +l +l +l +l }
  \rowstyle{\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{tabular}

\end{document}

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}

enter image description here

Tags:

Color

Tables