0

As is common with tables with numeric results, I would like to mark some values by using \textbf (usually the best results obtained). When I try to combine the S type of column provided by siunitx with \textbf, I loose the decimal separator alignment. A solution has been given five years ago, I have tried it and it doesn't work:

\documentclass{article}
\usepackage{array,siunitx,booktabs,tabularx}
\robustify\bfseries
\sisetup{table-parse-only,detect-weight=true,detect-inline-weight=text}
\newcommand{\tbnum}[1]{\multicolumn{1}{c}{\bfseries \num{#1}}}
\begin{document}


\begin{tabularx}{\textwidth}{llXS}\toprule
A&B&C&\multicolumn{1}{c}{Numbers}\\\midrule
bla&bla&bla&0.535\\
bla&bla&bla&0.535\\
bla&bla&bla&0.535\\\midrule
bla&bla&bla&\tbnum{1322.0}\\\bottomrule
\end{tabularx}

\end{document}

What am I doing wrong?

1
  • maybe the answer below will suit
    – js bibra
    Dec 5, 2020 at 0:34

2 Answers 2

2

enter image description here

\documentclass{article}
\usepackage{array,siunitx,booktabs,tabularx}
\usepackage{etoolbox}
\robustify\bfseries
\sisetup{detect-weight=true,detect-inline-weight=text}
%\newcommand{\tbnum}[1]{\multicolumn{1}{c}{\bfseries \num{#1}}}
\begin{document}


\begin{tabularx}{\textwidth}{llXS}\toprule
A&B&C&\multicolumn{1}{c}{Numbers}\\\midrule
bla&bla&bla&0.535\\
bla&bla&bla&0.535\\
bla&bla&bla&0.535\\\midrule
bla&bla&bla&\bfseries 1322.0\\\bottomrule
\end{tabularx}

\end{document}
1
  • 1
    Thanks for the tip! And I would like to add, for those who use mathspec and xelatex like me that among the options of \sisetup one has to add also detect-all otherwise the font is not correct.
    – yannis
    Dec 5, 2020 at 9:58
0

I would define robust command for S cells' contents making bold:

\documentclass{article}
\usepackage{booktabs,tabularx}
\usepackage{siunitx}
\usepackage{etoolbox}
\newrobustcmd\B{\DeclareFontSeriesDefault[rm]{bf}{b}\bfseries}   % <-- 
                         
\begin{document}


\begin{tabularx}{\textwidth}{l l X S[detect-weight,             % <--
                                     mode=text,                 % <--
                                     table-format=4.1]
                            }
    \toprule
A   & B     & C     & {Numbers} \\
    \midrule
bla & bla   & bla   & 0.535\\
bla & bla   & bla   & 0.535\\
bla & bla   & bla   & 0.535\\
    \midrule
bla & bla   & bla   &\B 1322.0  \\
    \bottomrule
\end{tabularx}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .