The following code works perfectly:
\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{collcell}
%The min, mid and max values
\newcommand*{\MinNumber}{0.0}%
\newcommand*{\MidNumber}{0.5} %
\newcommand*{\MaxNumber}{1.0}%
%Apply the gradient macro
\newcommand{\ApplyGradient}[1]{%
\ifdim #1 pt > \MidNumber pt
\pgfmathsetmacro{\PercentColor}{max(min(100.0*(#1 - \MidNumber)/(\MaxNumber-\MidNumber),100.0),0.00)} %
\hspace{-0.33em}\colorbox{green!\PercentColor!yellow}{#1}
\else
\pgfmathsetmacro{\PercentColor}{max(min(100.0*(\MidNumber - #1)/(\MidNumber-\MinNumber),100.0),0.00)} %
\hspace{-0.33em}\colorbox{red!\PercentColor!yellow}{#1}
\fi
}
\newcolumntype{R}{>{\collectcell\ApplyGradient}c<{\endcollectcell}}
\renewcommand{\arraystretch}{0}
\setlength{\fboxsep}{3mm} % box size
\setlength{\tabcolsep}{0pt}
\begin{document}
\begin{table}[ht]
\begin{center}
\begin{tabular}{*{10}{R}}
0.03 & 0.34 & 0.41 & 0.25 & 0.89 & 0.49 & 0.79 & 0.83 & 0.82 & 0.94 \\
\end{tabular}
\end{center}
\end{table}
\end{document}
When I edit the code above to extract the data from a file rather than directly in the code, it doesn't!
. . .
\begin{table}[ht]
\begin{center}
\begin{tabular}{*{10}{R}}
\input{"data.tex"}
\end{tabular}
\end{center}
\end{table}
. . .
If I change the column type from R to c, it compiles with no errors but something in the macro is not working when the data is in a separate file. The contents of the data.tex file are as follows:
0.03 & 0.34 & 0.41 & 0.25 & 0.89 & 0.49 & 0.79 & 0.83 & 0.82 & 0.94 \\
How can I find a workaround to this?
