Align numbers by decimal point using siunitx and bfseries
I assume that your answer is actually continuation of your question (I suggest to edit your question and move it there).
Problem in aligning of cells content and boldface fonts for some of them is in option parse-numbers=false
. Without it all with exception of cells of form (-0.01)
works as expected, those cells generate errors. This can be prevented by putting them into curly braces: {(-0.03)}
, however it is not aligned as desired anymore.
For the particular case of table in question, can be used dirty trick shown in the code below, which mitigate this problem. See, if result is satisfactory.
\documentclass[preview,border=1pt]{standalone}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{etoolbox}% <-- new
\newcommand{\ubold}{\fontseries{b}\selectfont} % renew def. for non-extended bold font
\robustify\ubold
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\begin{document}
\begin{table}
\caption{My Caption}
\centering
\begin{tabular}{ l *{6}{S[input-symbols = {()},
table-space-text-post=\ ,% <-- for spacing of )
detect-weight,
table-format=-1.2]}}
\toprule
\multicolumn{7}{c}{Panel A: Univariate Sorts Based on $\beta_{\sigma,t}$} \\ \midrule
& \mc{Low} & & \mc{Med} & & \mc{High} & \mc{High-Low} \\ \midrule
MV & 1.64 & 1.14 & 1.58 & 1.08 & 1.45 & \\
& (1.17) & (0.97) & (0.87) & (0.64) & (1.03) & \\
TA & \ubold 1.90 & 1.03 & 0.88 & 0.87 & 1.35 & \\
& (1.63) & (1.75) & (1.06) & (0.43) & {(-0.03)} % <--- here is problem
& {~~~} \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
Result:
Trick is in added space for right parenthesize in column formatting.
Addendum After three years I would write this table as follows:
\documentclass[preview,border=1pt]{standalone}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{etoolbox} % <-- new
\usepackage{xparse} % <-- new
\NewExpandableDocumentCommand\mc{O{1}m} % <--
{\multicolumn{#1}{c}{#2}}
\begin{document}
\begin{table}
\sisetup{input-open-uncertainty= , % <-- new
input-close-uncertainty= , % <-- new
table-space-text-pre=(, % <-- new
table-space-text-post=), % <-- new
table-align-text-pre=false,% <-- new
detect-weight,
mode=text, % <-- new
table-format=-1.2}
\renewcommand{\bfseries}{\fontseries{b}\selectfont} % <-- new
\newrobustcmd{\B}{\bfseries} % <-- changed
\caption{My Caption}
\centering
\begin{tabular}{ l *{6}{S} } % <--- changed
\toprule
\mc[7]{Panel A: Univariate Sorts Based on $\beta_{\sigma,t}$} \\
\midrule
&\mc{Low}& &\mc{Med}& &\mc{High}& \mc{High-Low} \\
\midrule
MV & 1.64 & 1.14 & 1.58 & 1.08 & 1.45 & \\
& (1.17) & (0.97) & (0.87) & (0.64) & ( 1.03) & \\
\addlinespace
TA &\B 1.90 & 1.03 & 0.88 & 0.87 & 1.35 & \\
& (1.63) & (1.75) & (1.06) & (0.43) & (-0.03) & \\ % <--- changed
\bottomrule
\end{tabular}
\end{table}
\end{document}
All changes in comparison to original code are marked by % <---
. Result now has more consistent appearance (correct align at decimal points, correct minus sign, width of boldface digits ares equal to normal ones):