7

I found the following post to change the font color of a single row in a table:

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

My row is a long table with 70 rows and for about 25 the I want to change the font color. I was wondering if there is a better way of coloring these 25 rows rather than using \rowfont{\color{red}} 25 times?

Josh
  • 847

1 Answers1

5

enter image description here

\documentclass{article}

\usepackage{color,array}

\makeatletter


\def\zapcolorreset{\let\reset@color\relax\ignorespaces}
\def\colorrows#1{\noalign{\aftergroup\zapcolorreset#1}\ignorespaces}

\makeatother

\begin{document}

\begin{tabular}{ll}
1&2\\
1&2\\
1&2\\\colorrows{\color{red}}
1&2\\
1&2\\
1&2\\\colorrows{\color{black}}
1&2\\
1&2\\
1&2
\end{tabular}
\end{document}
David Carlisle
  • 757,742
  • 2
    Doesn't this need something like \edef\endtabular{\unexpanded\expandafter{\endtabular}\noexpand\reset@color} as well to ensure that the colour stops at the end of the table (if not manually reset)? – Joseph Wright Jan 26 '16 at 18:34