\documentclass[12pt,a4paper]{article}
\usepackage{fixltx2e}%% the official fixes for LaTeX2e
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{lmodern}
\usepackage{geometry}
\usepackage{array}
\usepackage{colortbl}
\usepackage{listings}
\lstset{%% RN
  language=[AlLaTeX]{TeX},
  numbers=left,
  numberstyle=\scriptsize,
  numbersep=.8em,
  breaklines=true,
  xleftmargin=1.6em,
  abovecaptionskip=\abovecaptionskip,
  belowcaptionskip=\belowcaptionskip,
  framexleftmargin=1.6em,
  flexiblecolumns=true,
  basicstyle=\small\ttfamily,
  commentstyle=\small\ttfamily\itshape,
  keywordstyle=\underbar,
  rulesepcolor=\normalcolor,
}
\usepackage{graphicx}
\definecolor{myCol}{rgb}{1,0.95,0.95}
%
\makeatletter
\def\markCell{\@ifnextchar[{\@markCelli}{\@markCellii}}
\def\@markCelli[#1]#2#3{
	\hspace{0pt}\makebox[0pt][l]{%
		\raisebox{-0.25\height}{\huge\textcolor[#1]{#2}{#3}}}%
}
\def\@markCellii#1#2{
	\hspace{0pt}\makebox[0pt][l]{%
		\raisebox{-0.25\height}{\huge\textcolor{#1}{#2}}}%
}
\makeatother
%
\pagestyle{empty}
\parindent=0pt

\begin{document}
\title{Package \texttt{colortbl} and other Features}
\author{Herbert Voß}
\maketitle

\section{Overview}

\begin{table}[!htb]
\caption{\label{DemoTable}An overview, what's possible with \texttt{colortbl}}
\centering
\begin{minipage}{0.2\linewidth}
\begin{tabular}{|c|c|>{\columncolor{red}}c}\hline
    \multicolumn{1}{|>{\columncolor[gray]{.8}[0pt]}c}{1,1} &
	\multicolumn{1}{|>{\columncolor[gray]{.8}}c|}{2,1} &
	3,1\\\hline\hline
    1,2 & \multicolumn{1}{|>{\columncolor{blue}}c|}{2,2} &
	3,2\\\cline{2-2}\hline
    \rowcolor{yellow}1,3 & 2,3 & 3,3\\\hline
\end{tabular}
\end{minipage}\hfill
\begin{minipage}{0.78\linewidth}
\begin{lstlisting}
\begin{tabular}{|c|c|>{\columncolor{red}}c}\hline 
    \multicolumn{1}{|>{\columncolor[gray]{.8}[0pt]}c}{1,1} &
        \multicolumn{1}{|>{\columncolor[gray]{.8}}c|}{2,1} & 
        3,1\\\hline\hline 
    1,2 & \multicolumn{1}{|>{\columncolor{blue}}c|}{2,2} &
        3,2\\\cline{2-2}\hline 
    \rowcolor{yellow}1,3 & 2,3 & 3,3\\\hline
\end{tabular}
\end{lstlisting}
\end{minipage}
\end{table}

Package \verb|colortbl| is used to manipulate the background color
of table rows and colums. The commands are:

\begin{verbatim}
\columncolor[<colormodel>]{<color>}[<left overhang>][<right overhang>]
\rowcolor ... same arguments ...
\end{verbatim}


\section{The Arguments}

\subsection{Columns}

\begin{enumerate}
\item \verb|\columncolor[gray]{0.5}|\hfill%
    \begin{tabular}{>{\columncolor[gray]{0.8}}c}\hline 
	1,1\\\hline
    \end{tabular}\\
    with \verb|>{\columncolor[gray]{0.8}}c| For ,,c'' you can write ,,l'' for left or ,,r'' for right.
\begin{lstlisting}
\begin{tabular}{>{\columncolor[gray]{0.8}}c}\hline 
    1,1\\\hline
\end{tabular}
\end{lstlisting}
\item \verb|\columncolor{yellow}| \hfill%
    \begin{tabular}{>{\columncolor{yellow}}c}\hline 
	1,1\\\hline
    \end{tabular}\\
    with \verb|>{\columncolor{yellow}}c| 
\begin{lstlisting}
\begin{tabular}{>{\columncolor{yellow}}c}\hline 
    1,1\\\hline
\end{tabular}
\end{lstlisting}
\item \verb|\columncolor{yellow}[5mm][10mm]|\hfill%
    \begin{tabular}{>{\columncolor{yellow}[5mm][10mm]}c}\hline 
	1,1\\\hline
    \end{tabular}\\
    with \verb|>{\columncolor{yellow}[5mm][10mm]}c| This makes only sense if you like some white space 
    between two cells like the following one:\hfill{}%
\begin{lstlisting}
\begin{tabular}{>{\columncolor{yellow}[5mm][10mm]}c}\hline
    1,1\\\hline
\end{tabular}
\end{lstlisting}

    \begin{tabular}{>{\columncolor{yellow}[\tabcolsep][0.5\tabcolsep]}c>{\columncolor{yellow}[0.5\tabcolsep][\tabcolsep]}c}
	1,1 & 2,1\\
	1,2 & 2,2\\
    \end{tabular}\\
    The command for the first column is:\\
    \verb|>{\columncolor{yellow}[\tabcolsep][0.5\tabcolsep]}c|\\
    and for the second one:\\
    \verb|>{\columncolor{yellow}[0.5\tabcolsep][\tabcolsep]}c|
\begin{lstlisting}
\begin{tabular}{>{\columncolor{yellow}[\tabcolsep][0.5\tabcolsep]}c
                >{\columncolor{yellow}[0.5\tabcolsep][\tabcolsep]}c}
    1,1 & 2,1\\
    1,2 & 2,2\\
\end{tabular}
\end{lstlisting}

\end{enumerate}

\subsection{Rows}
For colored rows the \verb|\rowcolor|-command must appear as first command in any row. 
The last example with a command \verb|\rowcolor{red}| in
the first column of the first line gives a table like the following
one:\par
\begin{tabular}{>{\columncolor{yellow}[\tabcolsep][0.5\tabcolsep]}c
                >{\columncolor{yellow}[0.5\tabcolsep][\tabcolsep]}c}
    \rowcolor{red}1,1 & 2,1\\
    1,2 & 2,2\\
\end{tabular}

\begin{lstlisting}
\begin{tabular}{>{\columncolor{yellow}[\tabcolsep][0.5\tabcolsep]}c
                >{\columncolor{yellow}[0.5\tabcolsep][\tabcolsep]}c}
    \rowcolor{red}1,1 & 2,1\\
    1,2 & 2,2\\
\end{tabular}
\end{lstlisting}

The vertical borders are defined by the \verb|\columncolor|-command
and the horizontal ones by the \verb|\rowcolor|-command.
A \verb|\rowcolor|-command overwrites a \verb|\columncolor|-command!


\subsection{Single cells}

Coloring a single cell is not possible with the above described methods.
You must define the \textbf{single} cell as a \textbf{multicol} cell.
\begin{verbatim}
\multicolumn{n}{c}{\columncolor{<color>} blah}
\end{verbatim}

The first Table \ref{DemoTable} has for the cell (2,2) the entry

\begin{lstlisting}
\begin{tabular}{|c|c|>{\columncolor{red}}c}\hline 
    \multicolumn{1}{|>{\columncolor[gray]{.8}[0pt]}c}{1,1} &
        \multicolumn{1}{|>{\columncolor[gray]{.8}}c|}{2,1} & 
        3,1\\\hline\hline
    1,2 & \multicolumn{1}{|>{\columncolor{blue}}c|}{2,2} &
        3,2\\\cline{2-2}\hline 
    \rowcolor{yellow}1,3 & 2,3 & 3,3\\\hline
\end{tabular}
\end{lstlisting}


\section{Remarks}

\begin{itemize}
\item A \verb|\columncolor|-command is valid vor
all cells in one column! Therefore you can write it in any f the available
columns of all rows.
\item For more information look at the documentation of colortbl-package
\end{itemize}

\section{Example}

Figure \ref{tab:Demo} is another demonstartion of what is possible with package
\verb|colortbl| and it shows some other nice features.

\begin{table}
\centering
\scalebox{2.5}{% nur demo
\begin{tabular}{c>{\columncolor{myCol}}cc}
\markCell{blue}{A1}blah
  & B1
  & \markCell[gray]{0.9}{C1}Carole\\
A2
  & \markCell[gray]{0.75}{B2}blub
  & \multicolumn{1}{>{\columncolor{red}}c}{C2}\\
\rowcolor[gray]{0.95}A3
  & B3
  & \markCell[gray]{0.9}{C3}blubber\\
A & B & C
\end{tabular}%
}
\caption{Demo of \texttt{colortbl} and other features}\label{tab:Demo}
\end{table}

\begin{lstlisting}
[ ... ]
\usepackage{array}
\usepackage{colortbl}
\definecolor{myCol}{rgb}{1,0.95,0.95}
%
\makeatletter
\def\markCell{\@ifnextchar[{\@markCelli}{\@markCellii}}
\def\@markCelli[#1]#2#3{
	\hspace{0pt}\makebox[0pt][l]{%
		\raisebox{-0.25\height}{\huge\textcolor[#1]{#2}{#3}}}%
}
\def\@markCellii#1#2{
	\hspace{0pt}\makebox[0pt][l]{%
		\raisebox{-0.25\height}{\huge\textcolor{#1}{#2}}}%
}
\makeatother

[...]

\begin{tabular}{c>{\columncolor{myCol}}cc}
\markCell{blue}{A1}blah
  & B1
  & \markCell[gray]{0.9}{C1}Carole\\
A2
  & \markCell[gray]{0.75}{B2}blub
  & \multicolumn{1}{>{\columncolor{red}}c}{C2}\\
\rowcolor[gray]{0.95}A3
  & B3
  & \markCell[gray]{0.9}{C3}blubber\\
A & B & C
\end{tabular}%
\end{lstlisting}


\end{document}
