Edit: This question is related to this one: How to change only the color of numbers (and not units) with numprint?
I tried the solution given here, but it enlarges the line spacing of the table as shown in the second example in the screenshot below.
\documentclass{article}
\usepackage{amsmath,numprint,tabularx,xcolor}
\begin{document}
Tabularx table \textbf{without} any color: \textbf{the spacing is normal.}
\begin{tabularx}{5cm}{|*{11}{X|}}
\hline
\multicolumn{2}{|c|}{$\rm m^2$} &
\multicolumn{2}{c|}{$\rm dm^2$} &
\multicolumn{2}{c|}{$\rm cm^2$} &
\multicolumn{2}{c|}{$\rm mm^2$} \\
\hline
&&&4,&&&& \\
&&&4&0&0&0& 0,\\
&0,&0&4&&&& \\
\hline
\end{tabularx}
\bigskip
Tabularx table \textbf{with} colors: \textbf{the line spacing is enlarged.}
\begin{tabularx}{5cm}{|*{11}{>{\color{blue}}X|}}
\hline
\multicolumn{2}{|c|}{$\rm m^2$} &
\multicolumn{2}{c|}{$\rm dm^2$} &
\multicolumn{2}{c|}{$\rm cm^2$} &
\multicolumn{2}{c|}{$\rm mm^2$} \\
\hline
&&&4,&&&& \\
&&&4&0&0&0& 0,\\
&0,&0&4&&&& \\
\hline
\end{tabularx}
\bigskip
Table with individually placed colours. \textbf{No problem at all.}
\begin{tabularx}{5cm}{|*{11}{X|}}
\hline
\multicolumn{2}{|c|}{$\rm m^2$} &
\multicolumn{2}{c|}{$\rm dm^2$} &
\multicolumn{2}{c|}{$\rm cm^2$} &
\multicolumn{2}{c|}{$\rm mm^2$} \\
\hline
&&&\textcolor{blue}{4,}&&&& \\
&&&\textcolor{blue}{4}&\textcolor{blue}{0}&\textcolor{blue}{0}&\textcolor{blue}{0}& \textcolor{blue}{0},\\
&\textcolor{blue}{0,}&\textcolor{blue}{0}&\textcolor{blue}{4}&&&& \\
\hline
\end{tabularx}
\end{document}


\rmin mathmode? Very beautiful your hat :) – Sebastiano Dec 27 '18 at 12:17>{\leavevmode\color{blue}}X|}instead of>{\color{blue}}X|}– moewe Dec 27 '18 at 12:22siunitxpackage.siunitxeven has facilities similar to those of thenumprintpackage. – moewe Dec 27 '18 at 12:29siunitx, which would also solve the color problem, but now the question is closed ... – Dec 27 '18 at 12:30