To make the table more readable, following are the ways to color it:
Coloring Rows
Use \rowcolor
(provided by colortbl
; also loaded by xcolor
under the [table]
package option). Example:
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{tabular}{ | l | l | l | }
\rowcolor{green}
A & B & C \\
\rowcolor{red}
D & E & F \\
G & H & I \\
\rowcolor{blue}
J & K & L
\end{tabular}
\end{document}
Coloring Columns
Columns can be colored using following ways:
Defining column color property outside the table tag using \newcolumntype
:
\newcolumntype{a}{ >{\columncolor{yellow}} c }
Defining column color property inside the table parameters
\begin{tabular}{ | >{\columncolor{red}} c | l | l }
Example:
\documentclass{article}
\usepackage[table]{xcolor}
\newcolumntype{a}{>{\columncolor{yellow}}c}
\newcolumntype{b}{>{\columncolor{green}}c}
\begin{document}
\begin{tabular}{ a | >{\columncolor{red}}c | l | b }
\hline
A & B & C & D \\
E & F & G & H \\
\hline
\end{tabular}
\end{document}
Coloring Lines
Use \arrayrulecolor
. Example:
\documentclass{article}
\usepackage[table]{xcolor}
\arrayrulecolor{blue}
\begin{document}
\begin{tabular}{ | l | l | l | }
\hline
A & B & C \\
\hline
D & E & F\\
\hline
G & H & I \\
\hline
\end{tabular}
\end{document}
Coloring Cells
Use \cellcolor
. Example:
\documentclass{article}
\usepackage[table]{xcolor}
\begin{document}
\begin{tabular}{ | l | l | l | }
\hline
A & B & C \\
\hline
D & E & \cellcolor{green}F \\
\hline
G & H & I \\
\hline
\end{tabular}
\end{document}
We can define our own colors too using package colortbl
. Following are the tags examples:
\definecolor{Gray}{gray}{0.85}
\columncolor[RGB]{230, 242, 255}}
\columncolor[HTML]{AAACED}