# siunitx format definition does not take effect

could someone please me a give me a hint on that? I use the package to align the numbers in the columns of a table. However, it seems that the table format definition does not take effect. For example in row D the minus and the less-than sign seem to break it. Any ideas on how to properly align this?

\begin{table}
\centering
\caption{a table.}
\label{table:x}
\begin{scriptsize}
\begin{tabular}
{
l
l
S[table-format = 2.2]
S[table-format = 2.2]
S[table-format = -1.2]
S[table-format = 2]
S[table-format = 0.2]
}
\toprule
Dim                 &       Cond        & {\emph{M} (secs)}     & {\emph{SD}}           & {\emph{t}}                & {\emph{df}}                   & {\emph{p}}            \\
\midrule
\multirow{2}{*}{A}  &       B           & 49.50                 & 16.37                 & \multirow{2}{*}{0.03}     & \multirow{2}{*}{15}           & \multirow{2}{*}{.97}  \\
&       E           & 49.37                 & 14.89                 &                           &                               &                       \\

\midrule
\multirow{2}{*}{B}  &       B           & 30.37                 & 10.85                 & \multirow{2}{*}{2.88}     & \multirow{2}{*}{15}           & \multirow{2}{*}{.01}  \\
&       E           & 24.18                 & 8.78                  &                           &                               &                       \\

\midrule
\multirow{2}{*}{C}  &       B           & 9.12                  & 5.30                  & \multirow{2}{*}{2.38}     & \multirow{2}{*}{15}           & \multirow{2}{*}{.03}  \\
&       E           & 5.56                  & 3.36                  &                           &                               &                       \\
\midrule
\multirow{2}{*}{D}  &       B           & 0.18                  & 0.54                  & \multirow{2}{*}{-8.90}    & \multirow{2}{*}{15}           & \multirow{2}{*}{{<}.01} \\
&       E           & 11.50                 & 5.13                  &                           &                               &                       \\

\bottomrule
\end{tabular}
\end{scriptsize}
\end{table}


• (1) welcome, (2) please change this into a full minimal example, that others can just copy and test as it is. That makes it a lot easier to help you. – daleif Nov 30 '17 at 12:56
• your table can't works as it is. you need to enclose multirows in curly braces and with this you lost S columns properties (contents in them are centered). you should consider to reformat your table (change column type or omit multirow cells. – Zarko Nov 30 '17 at 16:05

This is just a comment to the answer by @Zarko and how I'd use \tablenum here. I use three different macros here as not to add formatting directly into the columns. Notice how the alignment is different in each of the last three columns.

\documentclass{article}
\usepackage{booktabs, multirow}
\usepackage{siunitx}
\usepackage[font=small, labelfont=bf, skip=1ex]{caption}

\begin{document}
\begin{table}
% placing these macros here as they are likely to jsut be used for this particular table
\newcommand\mrtnumA[1]{\multirow{2}{*}{\tablenum[table-format=-1.2]{#1}}}
\newcommand\mrtnumB[1]{\multirow{2}{*}{\tablenum[table-format=2.0]{#1}}}
\newcommand\mrtnumC[1]{\multirow{2}{*}{\tablenum[table-format=<1.2]{#1}}}
\centering
\caption{a table.}
\label{table:x}
%\scriptsize
\begin{tabular}
{
*{2}{c}
*{2}{S[table-format = 2.2]}
*{3}{c}
}
\toprule
Dim                & Cond & {\emph{M} (secs)} & {\emph{SD}} & $t$             & $df$         & $p$             \\
\midrule
\multirow{2}{*}{A} & B    & 49.50             & 16.37       & \mrtnumA{0.03}  & \mrtnumB{15} & \mrtnumC{.97}   \\
& E    & 49.37             & 14.89       &                 &              &                 \\
\midrule
\multirow{2}{*}{B} & B    & 30.37             & 10.85       & \mrtnumA{2.88}  & \mrtnumB{15} & \mrtnumC{.01}   \\
& E    & 24.18             & 8.78        &                 &              &                 \\
\midrule
\multirow{2}{*}{C} & B    & 9.12              & 5.30        & \mrtnumA{2.38}  & \mrtnumB{15} & \mrtnumC{.03}   \\
& E    & 5.56              & 3.36        &                 &              &                 \\
\midrule
\multirow{2}{*}{D} & B    & 0.18              & 0.54        & \mrtnumA{-8.90} & \mrtnumB{15} & \mrtnumC{< .01} \\
& E    & 11.50             & 5.13        &                 &              &                 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


• @Zarko not sure if pinging in the body works, so I'll ping here as well. – daleif Dec 1 '17 at 10:21
• meanwhile i ask new question about this (tex.stackexchange.com/questions/404017/options-in-tablenum). it seems that you solve my problem of using options. i need more time to see all differences. thank you! – Zarko Dec 1 '17 at 10:39
• Thank you guys, you really helped me a lot! It now works as expected with the solution by @Zarko and the refinement by daleif And sorry for not providing the full minimal example. – jemu Dec 1 '17 at 15:18
• you not provide complete small document, therefore preamble and document class of your document is unknown. consequently final looks of table's caption is left to you.
• table is you show in question is not possible to compile (see my comment above)
• from possible solutions below is case with redesign column types

\documentclass{article}
\usepackage{booktabs, multirow}
\newcommand\mcm[1]{\multicolumn{1}{>{$}c<{$}}{#1}}
\usepackage{siunitx}

\begin{document}
\begin{table}
\centering
\caption{a table.}
\label{table:x}
%\scriptsize
\begin{tabular}
{
*{2}{c}
*{2}{S[table-format = 2.2]}
*{3}{r}
}
\toprule
Dim & Cond  & {\emph{M} (secs)}
& {\emph{SD}}
& \mcm{t}   & \mcm{df}  & \mcm{p}           \\
\midrule
\multirow{2}{*}{A}
& B     & 49.50 & 16.37 & \multirow{2}{*}{0.03}
& \multirow{2}{*}{15}
&  \multirow{2}{*}{.97}
\\
& E     & 49.37 & 14.89 &       &       &                           \\
\midrule
\multirow{2}{*}{B}
& B     & 30.37 & 10.85 & \multirow{2}{*}{2.88}
& \multirow{2}{*}{15}
& \multirow{2}{*}{.01}      \\
& E     & 24.18 & 8.78  &       &       &                           \\
\midrule
\multirow{2}{*}{C}
& B     & 9.12  & 5.30  & \multirow{2}{*}{2.38}
& \multirow{2}{*}{15}
& \multirow{2}{*}{.03}      \\
& E     & 5.56  & 3.36  &       &       &                           \\
\midrule
\multirow{2}{*}{D}
& B     & 0.18  & 0.54  & \multirow{2}{*}{$-8.90$}
& \multirow{2}{*}{15}
& \multirow{2}{*}{$< .01$}  \\
& E     & 11.50 & 5.13  &       &       &                           \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


edit:

consider daleif comment below, your table can be formatted as follows:

\documentclass{article}
\usepackage{booktabs, multirow}
\newcommand\mrtnum[1]{\multirow{2}{*}{\tablenum{#1}}}
\usepackage{siunitx}
\usepackage[font=small, labelfont=bf, skip=1ex]{caption}

\begin{document}
\begin{table}
\centering
\caption{a table.}
\label{table:x}
%\scriptsize
\begin{tabular}
{
*{2}{c}
*{2}{S[table-format = 2.2]}
*{3}{c}
}
\toprule
Dim & Cond  & {\emph{M} (secs)}
& {\emph{SD}}
& $t$   & $df$  & $p$           \\
\midrule
\multirow{2}{*}{A}
& B     & 49.50 & 16.37 & \mrtnum{0.03}
& \mrtnum{15}
&  \mrtnum{.97} \\
& E     & 49.37 & 14.89 &       &       &               \\
\midrule
\multirow{2}{*}{B}
& B     & 30.37 & 10.85 & \mrtnum{2.88}
& \mrtnum{15}
& \mrtnum{.01}  \\
& E     & 24.18 & 8.78  &       &       &               \\
\midrule
\multirow{2}{*}{C}
& B     & 9.12  & 5.30  & \mrtnum{2.38}
& \mrtnum{15}
& \mrtnum{.03}  \\
& E     & 5.56  & 3.36  &       &       &               \\
\midrule
\multirow{2}{*}{D}
& B     & 0.18  & 0.54  & \mrtnum{-8.90}
& \mrtnum{15}
& \mrtnum{< .01} \\
& E     & 11.50 & 5.13  &       &       &               \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


• I think we can still apply siunitx stuff to col 5, you can use the \numcell or what ever it is called. That would be usable for the last two cols as well – daleif Nov 30 '17 at 18:11
• @daleif, i don't know if it is possible and how to do this (with siunitx facility) . i'm very interested to learn this. – Zarko Nov 30 '17 at 18:50
• I'll see if I can make an example tomorrow (writing on a tablet at present). The macro basically does what S does for a column, but just for a cell. Very useful if you have a column with an overall alignment and a few others that can be aligned separately. – daleif Nov 30 '17 at 18:55
• Looked it up in the manual, p 15, it is called \tablenum – daleif Nov 30 '17 at 18:57
• @daleif, i will look in manula (i just upgrade my miktex installation which has now recent siunitx :-), so i'm currius, what is new and for \tablenum.) – Zarko Nov 30 '17 at 19:07

I don't think you should be using \multirow that adds nothing to the understanding of the table: differences are computed after the data has been read.

\documentclass{article}
\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}
\begin{table}
\centering
\caption{a table.}
\label{table:x}
\begin{tabular}{
l
l
S[table-format =  2.2]
S[table-format =  2.2]
S[table-format = -1.2]
S[table-format =  2.0]
S[table-format =  1.2,table-comparator=true]
}
\toprule
Dim & Cond  & {$M$ (\si{\sec})} & {$\mathit{SD}$} & {$t$} & {$df$} & {$p$} \\
\midrule
A & B & 49.50 & 16.37 \\
& E & 49.37 & 14.89 &  0.03 & 15 &  0.97 \\
B & B & 30.37 & 10.85 \\
& E & 24.18 &  8.78 &  2.88 & 15 &  0.01 \\