Document 476

The LaTeX colortbl package

Version: 3.x, 4.x, 5.x - Scientific WorkPlace & Scientific Word

The package produces colored background panels and rules for specified columns or rows of a table or array. Colortbl implements LaTeX support for color when the active typeset output driver can produce colored text.

You can add color to a row in a table by inserting a package command in the table. Adding color to a column is more complex: you must enter the colortbl package commands, along with commands for the entire tabular environment, in an encapsulated TeX field. You indicate the size of each color panel and the corresponding color you want with commands placed at the start of the tabular environment.

The basic command syntax is as follows:

\columncolor[w]{x}[y][z] or \rowcolor[w]{x}[y][z]

where

w is the color model: rgb (red, green, blue); cmyk (cyan, magenta, yellow, black); gray; or named (names known to the selected driver),

x is the selected color,

y is the amount of left overhang past the widest entry in the column, and

z is the amount of right overhang past the widest entry in the column.

See the package documentation for instructions and for additional examples of package effects.

How to add color to a table row

  1. Add the colortbl package to your document.
  2. Create a table.
  3. Place the insertion point in the table at the beginning of the row you want to appear in color.
  4. Enter an encapsulated TeX field.
  5. In the entry area, type \rowcolor[w]{x}[y][z], completing the command as described above.
  6. Choose OK.

How to add color to a table column

  1. Place the insertion point where you want the table to appear.
  2. Enter an encapsulated TeX field.
  3. In the entry area, enter the complete tabular environment.
  4. Place the insertion point at the beginning of the column you want to appear in color.
    For example, if your table is defined with the command \begin{tabular}{\l\l\l\} and you want to add color to the first column, place the insertion point after the first \.
  5. Type >{\columncolor[w]{x}[y][z]}, completing the command as defined above.
  6. Choose OK.

Many driver options are available through the Options and Packages command on the Typeset menu. The package is installed in the TCITeX/TeX/LaTeX/contrib/carlisle directory. It should work successfully with other packages that have syntax compatible to that of the array package, such as longtable and dcolumn.

Last revised 02/07/06

This document was created with Scientific WorkPlace.