Saturday, 1 June 2013

\bfseries and alignment in table

\bfseries and alignment in table

I'm trying to highlight some decimal-point aligned entries in two large tables which are arranged in two columns. I'm using \bfseries to do this and unfortunately this seems to be affecting the alignment. I have read the documentation and have made \bfseries robust by prepending \robustify, however the result is still somewhat misaligned. Here is an example which contains a small part of the table:
\documentclass{article}

\usepackage{comment}

\usepackage[left=1.5cm, right=1.5cm]{geometry}
\usepackage{subcaption}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{etoolbox,siunitx}

\newcommand{\mcone}[1]{\multicolumn{1}{l}{#1}}

\begin{document}

\begin{table}
  \begin{subtable}[b]{0.47\textwidth}
  \resizebox{1\textwidth}{!}
  {%
    \large
    \robustify\bfseries
    \sisetup{detect-weight=true,detect-inline-weight=math}
    \begin{tabular}{S[table-format=1.2(2)]S[table-format=1.2(2)]S[table-format=2.2(2)]S[table-format=2.2(2)]}
    \toprule
        1.68(2) & 2.66(16) & 8.39(12) & 13.11(25)\\
        0.95(1) & 1.38(4)  & 4.64(18) &  9.76(32)\\
        0.80(1) & 1.18(5) & 7.52(31) & 12.64(24)\\
        0.95(1) & 1.32(3) & 3.13(15) & \bfseries 8.68(29)\\
        0.21(0) & 0.30(1) & 5.59(63) & 12.07(23)\\
        0.36(0) & 0.50(1) & \bfseries 1.26(16) &  9.42(57)\\
        0.15(0) &  0.22 (1) & 3.49(98) & 12.19(34)\\
      \cmidrule(l{\dimexpr 0.5em}r{\dimexpr 0.5em}){1-4}
        0.83(1) & 1.22(5) & \bfseries 5.08(26) & \bfseries 10.95(32)\\
    \bottomrule
    \end{tabular}
  }
  \end{subtable}
  \hspace{0.05\textwidth}
  \begin{subtable}[b]{0.47\textwidth}
  \resizebox{1\textwidth}{!}
  {%
    \large
    \robustify\bfseries
    \sisetup{detect-weight=true,detect-inline-weight=math}
    \begin{tabular}{S[table-format=1.2(2)]S[table-format=1.2(2)]S[table-format=2.2(2)]S[table-format=2.2(2)]}
    \toprule
        \bfseries 1.68(2) & \bfseries 2.66(1) & 8.39(12) & 13.11(25)\\
        0.95(1) & 1.38(4)  & 4.64(18) &  9.76(32)\\
        0.80(1) & 1.18(5) & 7.52(31) & 12.64(24)\\
        0.95(1) & 1.32(3) & 3.13(15) & 8.68(29)\\
        0.21(0) & 0.30(1) & 5.59(63) & 12.07(23)\\
        0.36(0) & 0.50(1) & 1.26(16) &  9.42(57)\\
        0.15(0) &  0.22 (1) & 3.49(98) & 12.19(34)\\
      \cmidrule(l{\dimexpr 0.5em}r{\dimexpr 0.5em}){1-4}
        0.83(1) & 1.22(5) & \bfseries 5.08(26) & \bfseries 10.95(32)\\
      \bottomrule
    \end{tabular}
  }
  \end{subtable}
\end{table}


\end{document}
This is the result I get, the decimal points are not aligned. Any ideas how to fix this? I'm using TexLive 2012 installed via the Ubuntu package manager.

No comments:

Post a Comment