3

I'm trying to align numbers (that are bolded, between parentheses, etc.) by decimal points in table columns while using the auto-round option of the siunitx package. The following code doesn't work:

\documentclass{article}
\usepackage[detect-all]{siunitx}
\begin{document}
\sisetup{table-auto-round,input-open-uncertainty=,input-close-uncertainty=,
tableformat=-1.1}
\begin{tabular}{SS}
1.14 & \textbf{-1.15} \\
\footnotesize{(1.34)} & \footnotesize{(1.35)}\\
\textbf{-1.54} & 1.55
\end{tabular}
\end{document}
2
  • 2
    I have an answer half-written, but notice a bug in siunitx. I'll have to look at that first!
    – Joseph Wright
    Commented Dec 23, 2011 at 22:29
  • Ok. I also noticed that using the array package to make the whole second line footnotesize doesn't seem to work either. Is there a solution? Thanks in advance.
    – petobens
    Commented Dec 23, 2011 at 22:50

1 Answer 1

7

You cannot put stuff inside a group and expect siunitx to be able to tell it is a number. For that reason, you should use \bfseries rather than \textbf to make cell contents bold. This needs \bfseries to be 'robust', most easily achieved using the etoolbox package and its \robustify macro:

\documentclass{article}
\usepackage{etoolbox}
\usepackage[detect-all]{siunitx}
\robustify\bfseries
\begin{document}
\sisetup
  {
    table-auto-round,
    input-open-uncertainty=,
    input-close-uncertainty=,
    table-format=-1.1
  }
\begin{tabular}{SS}
1.14            & \bfseries -1.15 \\
( 1.34)         & (1.35)\\
\bfseries -1.54 & 1.55
\end{tabular}
\end{document}

I'm really not sure what you are up to with \footnotesize. Maintaining alignment here looks pretty tough.

6
  • Note: in answering this question, I spotted a bug in v2.4e of siunitx which is fixed but will take a few days to propagate around the world, especially given the time of year.
    – Joseph Wright
    Commented Dec 23, 2011 at 23:01
  • Thank you again. I wanted to use footnotesize for standard errors of parameter estimates in a regression. Since they are not as important as the estimated coefficients I wanted to report them in smaller size (and in parentheses).
    – petobens
    Commented Dec 23, 2011 at 23:13
  • The parenthesis are no issue, but changing the size is. Setting up an alignment relies on knowing how big the digits are, and so changing the size of the digits (and the .) is a disaster. It is possible to set up to get the size to change but the alignment breaks. Moreover, I'd say that it's bad design to alter the size of text in a table. The parenthesis alone should be enough.
    – Joseph Wright
    Commented Dec 24, 2011 at 8:44
  • Without the option [detect-all] when calling the package siunitx, the command \bfseries doesn't work (no error, it just doesn't make it bold).
    – Vivi
    Commented Oct 10, 2013 at 1:23
  • @Vivi That’s why it’s in: \usepackage[detect-all]{siunitx}. \sisetup{detect-all} should work, too. Commented Oct 10, 2013 at 1:26

You must log in to answer this question.

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