[Tuglist] colortbl

Radhakrishnan CV tuglist@tug.org.in
Sat, 11 May 2002 12:48:53 +0530 (IST)


On Fri, 10 May 2002 at 04:14, somendra bhattacharjee wrote:

   I am trying to use the rowno counter (suggested in this list) to
   generate periodic sequence of row colours.

   The simplest case is one colour for odd rows and another for
   even.

   A modification of the rowno example (given below) when latex'ed
   with scrollmode seems to give an OK ps file.

   However, there is _one_ error message _per_ row of the table
   (coming from the ifthenelse loop). What is going wrong here?  Or
   is there a better way of doing this automatic row colour.

Please use the following code in the preamble of your document:

\makeatletter
\def\rowcolor{%
  \global\let\CT@do@color\CT@@do@color
  \@ifnextchar[\CT@rowa\CT@rowb}
\def\CT@rowa[#1]#2{%
  \gdef\CT@row@color{\CT@color[#1]{#2}}%
  \CT@rowc}
\def\CT@rowb#1{%
  \gdef\CT@row@color{\CT@color{#1}}%
  \CT@rowc}
\def\CT@rowc{%
  \@ifnextchar[\CT@rowd%
   }
\def\CT@rowd[#1]{\@testopt{\CT@rowe[#1]}{#1}}
\def\CT@rowe[#1][#2]{%
  \@tempdimb#1%
  \@tempdimc#2%
  \xdef\CT@row@color{%
    \expandafter\noexpand\CT@row@color
    \@tempdimb\the\@tempdimb
    \@tempdimc\the\@tempdimc
    \relax}%
}
\makeatother
   
This is slightly hacked version of \rowcolor macros to suit your 
requirements.   

-- 
Radhakrishnan