siunitx: aligning numbers by decimal points in tables doesn't work for bolded or italicized numbers
You have to use the detect-all
package option and to add \bfseries
to the column declaration instead of using \textbf
for every cell. (Sorry for not answering before - I wrongly assumed you wanted a single cell in bold.)
\documentclass{article}
\usepackage{booktabs}
\usepackage[detect-all]{siunitx}
\begin{document}
\begin{table}
\begin{tabular}{@{}lS[table-format=3.2]>{\bfseries}S[table-format=3.2]@{}}
\toprule
\textbf{Foo} & \textbf{Normal} & \textbf{Bold} \\
\midrule
foo1 & 111 & 111 \\
foo2 & 222.2 & 222.2 \\
foo3 & 3.33 & 3.33 \\
foo4 & 4 & 4 \\
foo5 & 5.5 & 5.5 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
this came up recently in another forum and Joseph came up with a solution. I include his aswer. the key is to use the etoolbox
package and \robustify\bfseries
Okay, the way that
siunitx
works with formatting is a little complex as it has to pick up which macros to expand and which not to. As e-TeX is required, I've taken the attitude that things 'not to expand' can be e-TeX\protected
. For the case in hand, you therefore need to make `bfseries` robust. Something like\documentclass{article} \usepackage{colortbl,etoolbox,siunitx,xcolor} \robustify\bfseries \sisetup{ detect-weight = true , locale = DE , } \begin{document} \begin{table} \sisetup{ group-separator = ., table-format = 5.0, table-number-alignment = right , } \begin{tabular}{S[table-format = 8.0, table-number-alignment = right]SlSS} \rowcolor[gray]{0.9} \bfseries 1234567 & \bfseries 12345 & \bfseries Test & \bfseries 12345 & \bfseries 12345 \\ 1234567 & 12345 & Test & 12345 & 12345 \\ \end{tabular} \end{table} \end{document}should do the job. I've got a bug fix of siunitx to do, so I'll add a note on this to the documentation. Let me know if the above works for you.