How do I color table columns?
Here a small example, which might be of help to you.
- Define your own color using
\definecolor{Gray}{gray}{0.85}
- Define your own columns using
\newcolumntype{a}{>{\columncolor{Gray}}c}
- You are ready to go.
Code
\documentclass{article}
\usepackage{xcolor,colortbl}
\newcommand{\mc}[2]{\multicolumn{#1}{c}{#2}}
\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\newcolumntype{a}{>{\columncolor{Gray}}c}
\newcolumntype{b}{>{\columncolor{white}}c}
\begin{document}
\begin{table}
\begin{tabular}{l | a | b | a | b}
\hline
\rowcolor{LightCyan}
\mc{1}{} & \mc{1}{x} & \mc{1}{y} & \mc{1}{w} & \mc{1}{z} \\
\hline
variable 1 & a & b & c & d \\
variable 2 & a & b & c & d \\ \hline
\end{tabular}
\end{table}
\end{document}
Result
You can use \columncolor
as
\begin{tabular}{|>{\columncolor[gray]{0.8}}c|c|c|c|c|c|c|c|}
code:
\documentclass{article}
\usepackage{colortbl}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{|>{\columncolor[gray]{0.8}}c|c|c|c|c|c|c|c|}
\hline
128&64&32&16&8&4&2&1\\\hline
1&0&1&1&0&1&0&1\\\hline
1&0&1&1&0&1&0&1\\\hline
\end{tabular}
\end{table}
\end{document}