Graphics
Image ↓
How to add images Image positioning How to add captions and a label to an image How to rotate and scale back an image
Charts ↓
Introduction & SmartDiagram TikZ: Simple Drawings TikZ: Advanced Commands PGFPlots
Tables ↓
Environment Cell spanning Positioning Coloring
Vector drawing ↓
Latexdraw Putting things together
Coloring

Coloring a table
This subsection explains how to color a row, a column and a single cell. It is possible to find many color combinations here. In order to use an imported color, it is necessary to add the definition of the color before \begin{document}. Two packages are needed: \usepackage{colortbl} and \usepackage[table]{xcolor}.


CODE
\definecolor{cambridgeblue}{rgb}{0.64, 0.76, 0.68}
\definecolor{chromeyellow}{rgb}{1.0, 0.65, 0.0}
\newcolumntype{a}{>{\columncolor{chromeyellow}}c}
\begin{document}

\begin{center}
\begin{tabular}{|c | c | c | c | l}
example &\cellcolor{red} 12312312 & example & \multicolumn{2} {r|} {\cellcolor{pink}tables rule the world}\\ \hline
\rowcolor{cambridgeblue} coloring& table long & very bad coloring & example table & 123456789 \\
\end{tabular}
\vspace{2cm}

\begin{tabular}{|a| c | c | }\hline
example & table & colours \\
example & colours & table \\
example & table & colours \\
example & colours & table \\
example & table & colours \\
example & colours & table \\
\end{tabular}
\end{center}


In the first table, the command \cellcolor{colour} is used to color a single cell. In order to color a multiple column, the command \cellcolor must be placed inside the brackets with content and before it. For coloring a row, it is necessary to use the command \rowcolor{color}, where the color is a color of the row and to put it before the row.
In order to change the color of a column, it is necessary to define a new type of column by \newcolumntype{name}{>{\columncolor{color}}alignment}, where the name is the casual name choosen by user, the color is a color of the background and alignment is the alignment of the the column. See table number two as an example.
Alternate coloring
This subsections explains how to create a table with alternating coloring. The command \rowcolors{starting row}{color odd rows}{color even rows} is applied. Where the starting row is a number of a row, from which starts the the alternating coloring, the color odd rows is a color which will be applied only for odd rows and color even rows is the same but for even rows.


CODE
\rowcolors{1}{gray!25}{green}
\begin{tabular}{|c|c|}
Table example & Table example\\
example color & example color\\
example color & example color\\
example color & example color\\
example color & example color\\
\end{tabular}


In this example, the alternating coloring starts from the first row and the two colors are light grey and green.