This is a follow-up question for Aligning numbers by decimal points in table columns.

User lockstep provided this solution:

555 \\
7.77 \\

The accepted answer worked; but I subsequently found that it did not if the numbers are bolded in the table (i.e. within \textbf{}). In this case, everything is flushed left. I do need to use bold face in my case (to direct the user's eyes towards a particular column in a larger table).

To give an example, below is a test table and the output.

   \begin{tabular}{@{}l S[table-format=3.2] S[table-format=3.2]@{}}
          \textbf{Foo} & \textbf{Normal} & \textbf{Bold}  \\
          foo1 & 111 & \textbf{111}\\
          foo2 & 222.2 & \textbf{222.2}\\
          foo3  & 3.33 & \textbf{3.33}\\
          foo4  & 4 & \textbf{4}\\
          foo5  & 5.5 & \textbf{5.5}\\


alt text

I checked the manual but didn't find anything about this. I suppose the presence of the markup confuses the parser to believe there cell is not a number, but this is mere speculation and I could be wrong.

Thanks in advance for suggestions.


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.)




    \textbf{Foo} & \textbf{Normal} & \textbf{Bold} \\
    foo1 & 111 & 111 \\
    foo2 & 222.2 & 222.2 \\
    foo3 & 3.33 & 3.33 \\
    foo4 & 4 & 4 \\
    foo5 & 5.5 & 5.5 \\

  • @lockstep, thank you for [detect-all], spend 4 hrs and couldn't fix it before. – ceoec May 3 '15 at 13:09

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

\robustify\bfseries \sisetup{
detect-weight = true , locale = DE , }

\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 \\


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.

  • Well, I actually had the question lockstep thought the OP had which is to only typeset single cells in bold. This works wonderfully, thanks! – Christian Jan 28 '13 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.