2

I have a problem with number alignment using the S table type from siunitx package. The numbers are not centered and especially on the right side the number falls out of the table. The table-number-alignment option doesn't work the way a expect it to do...

\documentclass{article}
\usepackage{rotating}
\usepackage{booktabs}
\usepackage{array,graphics}
\usepackage{siunitx}


\newcolumntype{R}[1]{%
>{\begin{turn}{90}\begin{minipage}{#1}%
\raggedright\hspace{0pt}}l%
<{\end{minipage}\end{turn}}%
}
\renewcommand{\arraystretch}{1.2} 
\begin{document}
\begin{table}
  \caption{bla..}
  \vspace{0.4em}
  \centering
  \label{tab:measurement}
  \sisetup{table-number-alignment = left, round-mode=places, round-precision=3
  } \footnotesize
    \begin{tabular}{@{}>{\raggedright\arraybackslash}m{2.54cm}*{9}{S}@{}}
      \toprule
      \multicolumn{1}{c}{Operation} &
      \multicolumn{1}{R{9em}}{Times executed} & 
      \multicolumn{1}{R{9em}}{Min Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Max Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Mean Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Standard Deviation Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Min Computing Time (s)} &
      \multicolumn{1}{R{9em}}{Max Computing Time (s)} &
      \multicolumn{1}{R{9em}}{Mean Computing Time (s)} &
      \multicolumn{1}{R{9em}}{Standard Deviation Computing Time (s)}\\
      \midrule
      Remove member from group & 14 &4480   &4480&  4480&   0&  15.15698&   94.44586&   26.47497429&    22.51140211\\
      Add member to group & 16397   &344&   344&    344&    0&  0.00484&    0.00484 &0.00484    &0\\
      \bottomrule
    \end{tabular}
\end{table}
\end{document}
3

I've applied the following two modifications to your code

  • Change the R column type so that its contents are centered in the respective column

  • Assign explicit table-format options to the 9 columns of type S.

enter image description here

\documentclass{article}
\usepackage{rotating} % rotating package loads graphicx package
\usepackage{booktabs}
\usepackage{array}
\usepackage{siunitx}

\newcolumntype{R}[1]{% add "\hfill" at start and end
>{\hfill\begin{turn}{90}\begin{minipage}{#1}%
\raggedright\hspace{0pt}}l%
<{\end{minipage}\end{turn}\hfill}%
}
\renewcommand{\arraystretch}{1.2} 
\begin{document}
\begin{table}
  \caption{bla..}
  \vspace{0.4em}
  \centering
  \label{tab:measurement}
  \sisetup{table-number-alignment = left, 
           round-mode = places, 
           round-precision = 3
  } 
  \footnotesize
    \begin{tabular}{@{} 
        >{\raggedright\arraybackslash}m{2.54cm}
        S[table-format=5.0,group-digits=false]
       *{3}{S[table-format=4.0]}
        S[table-format=1.0]
       *{4}{S[table-format=2.3]} @{}}
      \toprule
      Operation &
      \multicolumn{1}{R{9em}}{Times executed} & 
      \multicolumn{1}{R{9em}}{Min Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Max Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Mean Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Standard Deviation Traffic (Bytes)} &
      \multicolumn{1}{R{9em}}{Min Computing Time (s)} &
      \multicolumn{1}{R{9em}}{Max Computing Time (s)} &
      \multicolumn{1}{R{9em}}{Mean Computing Time (s)} &
      \multicolumn{1}{R{9.25em}}{Standard Deviation Computing Time (s)}\\
      \midrule
      Remove member from group & 14 &4480   &4480&  4480&   0&  15.15698&   94.44586&   26.47497429&    22.51140211\\
      Add member to group & 16397   &344&   344&    344&    0&  0.00484&    0.00484 &0.00484    &0\\
      \bottomrule
    \end{tabular}
\end{table}
\end{document}
  • Even though it would be a great extension to siunitx to calculate these values automatically... – S1lentSt0rm Oct 21 '14 at 19:52

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.