background shading a table row 

Newsgroups: comp.text.tex
> i can background shade a row of text with the following sequence:
>   \colorbox[gray]{0.90}{\makebox[\textwidth][l]{#1}}
> how can i do that for a row of a tabular-table?

Use the colortbl package. It has a \rowcolor command.

Piet van Oostrum

Sample \rowcolor command 

\begin{tabular}{|l|c|}
\rowcolor[gray]{.9} one&two\\
\rowcolor[gray]{.5} three&four
\end{tabular}

NB, this command is not recognized by either latex2html or latex2rtf.

Table features 

http://www.mip.sdu.dk/~mads/latex.php3

It is also possible to make some nice things on the tables. If you want to have some of the rows with color you can use the package colortbl.sty. If you for instance want to make a small table with a black row then use can small example could be:

Preamble:
\usepackage{colortbl}


Example:
\begin{table}[!ht]
\begin{center}
\begin{tabular}{ |c| }
\hline
\rowcolor{black} \\
\hline
Hello World\\
\hline
\end{tabular}
\caption{\label{SomeLabel} The Caption!}
\end{center}
\end{table}

The LaTeX colortbl package 

http://www.mackichan.com/index.html?techtalk/476.htm~mainFrame

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 dvi 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. 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.
  5. 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/supported/carlisle directory. It should work successfully with other packages that have syntax compatible to that of the array package, such as longtable and dcolumn.

MacKichan Software, Inc