I am trying to colour certain table cells in some siunitx
S columns. The cell colour change with xcolor
/colortbl
works, but it seems to also change the cell contents to text-mode, which has unfortunate consequences when working with siunitx
and negative numbers. The coloured cells have a short text-mode minus sign while the rest stay in maths-mode with the longer minus sign. I'm not sure how to fix it. Here is an MWE and table image:
\documentclass{article}
\usepackage{siunitx}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\newcommand{\blue}{\cellcolor{blue!25}}
\begin{document}
\begin{table}[]
\begin{tabular}{
S[table-format = 0.2]
S[table-format = -0.2]}
\toprule
{A} & {B} \\ \midrule
0.26 & -0.38 \\
0.18 & \blue -0.34 \\
\blue 0.31 & -0.36 \\ \bottomrule
\end{tabular}
\end{table}
\end{document}