# Color table element with siunitx S column

I have a table with numbers that I have aligned using the S column type provided by the siunitx package. I need to make one of the table elements red, but when I do that, the number that is red is no longer aligned.

What is the right way to do this? MWE below.

\documentclass{article}
\usepackage{siunitx}
\usepackage[]{xcolor}

\begin{document}
\begin{table} \centering
\caption{Table with \texttt{c} column type.}
\begin{tabular}{cc}
\hline
Symbol & \multicolumn{1}{c}{Value} \\
\hline
$\pi$ & 3.141592654 \\
$2\pi$ & 6.283185307 \\
$4\pi$ & 12.56637061 \\
$8\pi$ & {\color{red}25.13274123} \\
$e$   & 2.71828182845904524 \\
$\sqrt{2}$ & 1.41421356237309505 \\
\hline
\end{tabular}
\end{table}

\begin{table} \centering
\caption{Table with \texttt{S} column type.}
\begin{tabular}{cS}
\hline
Symbol & \multicolumn{1}{c}{Value} \\
\hline
$\pi$ & 3.141592654 \\
$2\pi$ & 6.283185307 \\
$4\pi$ & 12.56637061 \\
$8\pi$ & {\color{red}25.13274123} \\
$e$   & 2.71828182845904524 \\
$\sqrt{2}$ & 1.41421356237309505 \\
\hline
\end{tabular}
\end{table}
\end{document}

-

Simply remove the braces around the \color{red}25.13274123. They are not necessary, and content wrapped in braces are not considered numbers I think, hence not aligned as such.

Also, the \multicolumn is not necessary, it is enough to wrap Value in braces. The reason, as I understand it, is that the e in Value could be considered a part of an exponential number, e.g. 3e8, and siunitx will then try to align it. To protect it from alignment, wrap it in braces. This is mentioned in the manual, section 4.6 Tabular material (the last sentence starting on page 13).

\documentclass{article}
\usepackage{siunitx}
\usepackage{xcolor}
\begin{document}
\begin{table} \centering
\caption{Table with \texttt{S} column type.}
\begin{tabular}{cS}
\hline
Symbol & {Value} \\
\hline
$\pi$ & 3.141592654 \\
$2\pi$ & 6.283185307 \\
$4\pi$ & 12.56637061 \\
$8\pi$ & \color{red}25.13274123 \\
$e$   & 2.71828182845904524 \\
$\sqrt{2}$ & 1.41421356237309505 \\
\hline
\end{tabular}
\end{table}
\end{document}


-
I think siunitx, by default, will center-set items that are surrounded curly braces, regardless of the contents of the group. –  Mico Aug 14 '12 at 17:34
Well that was so easy, I'm almost embarrassed to have asked the question. Thanks! –  Jeremy Aug 14 '12 at 17:35