I have a table
(implemented through tabular
) that uses the xcolor
package to shade certain cells. The shading I'm interested is both entire cell shading (e.g. \cellcolor{red}
) and element shading (e.g. \color{red}
).
What I want to achieve is a function through xcolor
(or similar package) that would allow me to implement a color of varying intensity. For example it would be nice if I could go \color{red}{0.01}
in a cell, and the contents were only slightly red (but still almost black), or \color{red}{1.00}
and the contents would be completely red.
How can I achieve this with both \cellcolor{red}
and \color{red}
?
Here's an example table that I want to achieve this in:
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{rrrrl}
\hline\hline
\multicolumn{1}{c}{Sepal.Length}&\multicolumn{1}{c}{Sepal.Width}&\multicolumn{1}{c}{Petal.Length}&\multicolumn{1}{c}{Petal.Width}&\multicolumn{1}{c}{Species}\tabularnewline
\hline
$5.1$& $3.5$& $1.4$& $0.2$& setosa\tabularnewline
$4.9$&\cellcolor{red} $3.0$&\color{red} $1.4$& $0.2$& setosa\tabularnewline
$4.7$& $3.2$& $1.3$& $0.2$& setosa\tabularnewline
$4.6$& $3.1$& $1.5$& $0.2$& setosa\tabularnewline
$5.0$& $3.6$& $1.4$& $0.2$& setosa\tabularnewline
$5.4$& $3.9$& $1.7$& $0.4$& setosa\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}
I am mainly looking for a solution that keeps the "purity" of red (i.e. when I reduce the intensity it's still red it just has white mixed in).
\cellcolor[rgb]{1,x,x}
wherex
is a real number in the interval[0,1]
, however I'm not sophisticated enough to build it into a function.