0

My question is similar to siunitx: aligning numbers by decimal points in tables doesn't work for bolded or italicized numbers , except I would like to apply formatting to a row or a specific cell, not a whole column. I have not been able to applying the suggested answers to make siunitx interpret the bold or color macros.

The section 9.4 of the siunitx package documentation says that

using the e-TeX protected mechanism is the recommended course of action to prevent expansion of macros in table cells

but I still don't know how to properly do that. I tried to apply what is proposed here with no success:

\documentclass{article}
\usepackage{booktabs}
\usepackage{etoolbox}
\robustify\bfseries
\usepackage{siunitx,xcolor}
\sisetup{detect-weight=true, detect-inline-weight=text, locale = FR}

\begin{document}

\begin{tabular}{l S S} \toprule \textbf{Foo} & \textbf{Col1} & \textbf{Col2} \ \midrule foo1 & 11.1 & 11.1\ foo2 & 222.2 & 222.2\ \textbf{foo3} & \textbf{3.333} & \textbf{3.333}\ foo4 & 4 & 4\ foo5 & 555.55 & \textcolor{gray}{555.55}\ foo6 & 6.00 & 6.00\ \bottomrule \end{tabular}

\end{document}

table example

Thanks for your help.

Tobard
  • 1,189

1 Answers1

0

Thanks to @Joseph Wright comment I made it using \bfseries instead of \textbf, and \color instead of \textcolor (with no brackets at all):

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx,xcolor}
\sisetup{detect-weight=true, detect-inline-weight=text, locale = FR}

\begin{document}

\begin{tabular}{l S S} \toprule \textbf{Foo} & \textbf{Col1} & \textbf{Col2} \ \midrule foo1 & 11.1 & 11.1\ foo2 & 222.2 & 222.2\ \textbf{foo3} & \bfseries 3.333 & \bfseries 3.333\ foo4 & 4 & 4\ foo5 & 555.55 & \color{gray} 555.55\ foo6 & 6.00 & 6.00\ \bottomrule \end{tabular}

\end{document}

enter image description here

Tobard
  • 1,189