# Spooky behaviour of siunitx in a table

### ! Updated !

1-as asked by @marmot, the code has been updated
2-as pointed out by @egreg, the code has been updated
3-a new doubt has arisen meanwhile! See "Second Part" Below!

## Original question, now the first part of the question!

I'm trying to compile a table that centers it elements around the decimal point. For that purpose, I'm using the "S" option of siunitx in tabular, as specified below. This table is placed on a two-column page - hence the table* function.

\documentclass[a4paper,12pt,numbered,print,index]
\usepackage{siunitx} % use this package module for SI units
\usepackage{multirow}
\usepackage{multicol}

\begin{document}

\begin{table*}% table* allows a table to spawn the entire width of the page.
\label{C3-table:2}
\caption{Spectroscopic Parameters and Relative Energies Calculated at the MP2/6-311++G(d,p) Level of Theory for the Lowest-Energy Conformers of Synephrine}
\centering
\begin{tabular}{lSSSS}
\toprule
&Rotamer $I$   &Rotamer $II$ &Rotamer $III$&Rotamer $IV$ \\
\midrule
$A^{a}$      &3065.6858(11)$^{b}$   &3064.85192(78) &2479.83963(70) &2478.4259(21)\\
$B$          &540.46172(20)   &538.62660(18)  &614.51086(19)  &613.38156(16)\\
$C$         &498.99506(17)   &501.10248(14)  &582.56681(33)  &584.25597(24)\\
$\chi_{aa}$  &  2.3300(70)    &  2.3960(63)   &  1.3220(75)   &  1.257(35)\\
$\chi_{bb}$  & -2.9628(70)    & -2.7624(76)   & -3.7288(81)   & -3.514(23)\\
$\chi_{cc}$  &  0.6328(70)    &  0.3724(76)   &  2.4068(81)   &  2.257(23)\\
$\mu_{a}^{c}$&Y               &Y              &N              &N\\
$\mu_{b}^{c}$&Y               &Y              &Y              &Y\\
$\mu_{c}^{c}$&Y               &Y              &N              &Y\\
$N^{e}$      &24              &26             &19             &25\\
$\sigma^{e}$   &2.3             &2.3            &3.5            &3.3\\
\bottomrule
\end{tabular}
\caption*{ \small $^{a}A$, $B$, and $C$ are the rotational constants (in $MHz$); $\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N nuclear quadrupole coupling tensor (in $MHz$). $^{b}$Standard errors indicated in parentheses in units of the last digit. $^{c}$Y (yes) and N (no) indicate whether $a-$, $b-$, and $c-$type transitions were observed for each structure. $^{d}$Number of fitted transitions. $^{e}$Root mean square of the fit (in $kH$z).}
\end{table*}

\end{document}


I noticed that using the using \begin{tabular}{lSSSS} option forces a lot of empty spaces in the column (understandable), but the end result is quite awful! Observe that an "e" was "eaten away" using this tabulation!

Using the {lllll}, for instance, renders the table correctly, but unaligned

Any insight/solution to this problem would be much appreciated!

## Second part of the Question!

When applying a variation of egreg's code,

\begin{table*}[p] % table* allows a table to spawn the entire width of the page.

\caption{Spectroscopic Parameters and Relative Energies Calculated at the
MP2/6-311++G(d,p) Level of Theory for the Lowest-Energy Conformers of Synephrine}
\label{C3-table:4} % should go after \caption

\centering
\setlength{\tabcolsep}{0pt}
\sisetup{table-align-text-post=false}

\begin{tabular*}{\textwidth}{ @{\extracolsep{\fill}} l *{6}{S[table-format=4.5(2)]} @{} }
\toprule
& {Rotamer $I$} & {Rotamer $II$} & {Rotamer $III$} & {Rotamer $IV$} & {Rotamer $V$} & {Rotamer $VI$} \\
\midrule
$A$\tn{a} & 2619.31951(91)\TN{b} &  2621.43704(81) & 2431.79192(93) & 2429.8036(26) & 1751.6139(17) & 1749.29934(76)\\
$B$ & 417.815936(90) &  416.712685(80) & 401.522388(86) & 399.97472(24) & 491.43186(17) & 491.01374(10) \\
$C$ & 386.003079(87) & 387.043532(75) & 383.211109(81) & 385.16449(25) & 464.06642(12) & 465.271378(96)\\
$\chi_{aa}$ & 2.524(18) & 2.587(16) & 2.537(19) & 2.580(72) & 1.573(47) & 1.596(12) \\
$\chi_{bb}$ &-3.054(13) &-2.778(12) &-4.767(15) &-4.764(62) &-1.187(31) &-0.9142(93)\\
$\chi_{cc}$ & 0.530(13) & 0.250(12) & 2.231(14) & 2.184(62) &-0.387(31) &-0.6818(93)\\
$\mu_{a}$\tn{c} & {Y}   & {Y} & {Y} & {Y} & {N} & {N} \\
$\mu_{b}$\tn{c} & {Y}   & {Y} & {Y} & {Y} & {Y} & {Y} \\
$\mu_{c}$\tn{c} & {Y}   & {Y} & {Y} & {N} & {N} & {Y} \\
$N$\tn{d}       & \num{31} & \num{32} & \num{18} \num{20} & \num{14} & \num{20} \\
$\sigma$\tn{e}  & \num{2.1} & \num{1.8} & \num{2.3} & \num{3.1} & \num{1.7} & \num{2.1} \\
\bottomrule
\end{tabular*}

\raggedright\footnotesize

\begin{enumerate}[label=\tn{\alph*},leftmargin=*]
\item $A$, $B$, and $C$ are the rotational constants (in \si{MHz});
$\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N
nuclear quadrupole coupling tensor (in \si{MHz}).

\item Standard errors indicated in parentheses in units of the last digit.

\item Y (yes) and N (no) indicate whether $a$-, $b$-, and $c$-type transitions
were observed for each structure.

\item Number of fitted transitions.

\item Root mean square of the fit (in \si{kHz}).
\end{enumerate}

\end{table*}


I've found out that it's way too big!

There are a couple options here: 1- I tried pdflscape but somehow it didn't work properly (still working on it!) 2- Font resizing (ugh!) 3- Ask for a "a-ha!" solution from the community!

• Please make your snippet compilable: add the documentclass, \begin{document},\end{document}, and explain where one can find tabular.sty.
– user121799
Jan 15, 2018 at 16:31
• Try \sisetup{table-format=4.5(2)}. Jan 15, 2018 at 16:35
• @TeXnician, could you provide a simple example in order to see how that option is integrated? Jan 15, 2018 at 16:41
• @Strelok I will provide an example when yours is compilable, i.e. when I can test my assumption. Currently your example does not compile (look e.g. at the documentclass; and adding article results in errors with the headers of your table which should be surrounded by braces). Jan 15, 2018 at 16:43
• You shouldn’t pile up problems in the same question. Clearly, six columns with eleven digit numbers are likely not to fit in the text width, just as you can’t squeeze an elephant into a suitcase. Smaller type isn’t a feasible choice, so sideways seems the choice. In this case, use tabular and remove the extracolsep bit. Because of the table notes, you should consider threeparttable Jan 16, 2018 at 7:20

A possibly better way to typeset your table.

The S columns should be given the number of digits; the last five rows should have all centered entries (aligning the numbers in the last two rows at the period would mean nothing).

I also suggest separating carefully the note markers from exponents. There are also several other fixes (note \si{MHz}, for instance).

\documentclass[a4paper]{article}
\usepackage{siunitx} % use this package module for SI units
\usepackage{booktabs}
\usepackage{enumitem}

\newcommand{\tn}[1]{\textsuperscript{#1}}
\newcommand{\TN}[1]{\makebox[0pt][l]{\tn{#1}}}

\begin{document}

\begin{table*}% table* allows a table to spawn the entire width of the page.

\caption{Spectroscopic Parameters and Relative Energies Calculated at the
MP2/6-311++G(d,p) Level of Theory for the Lowest-Energy Conformers of Synephrine}
\label{C3-table:2} % should go after \caption

\centering
\setlength{\tabcolsep}{0pt}
\sisetup{table-align-text-post=false}

\begin{tabular*}{\textwidth}{ @{\extracolsep{\fill}} l *{4}{S[table-format=4.5(2)]} @{} }
\toprule
& {Rotamer $I$} & {Rotamer $II$} & {Rotamer $III$} & {Rotamer $IV$} \\
\midrule
$A$\tn{a}       & 3065.6858(11)\TN{b} & 3064.85192(78) & 2479.83963(70) & 2478.4259(21)\\
$B$             &  540.46172(20)      &  538.62660(18) &  614.51086(19) &  613.38156(16)\\
$C$             &  498.99506(17)      &  501.10248(14) &  582.56681(33) &  584.25597(24)\\
$\chi_{aa}$     &    2.3300(70)       &    2.3960(63)  &    1.3220(75)  &    1.257(35)\\
$\chi_{bb}$     &   -2.9628(70)       &   -2.7624(76)  &   -3.7288(81)  &   -3.514(23)\\
$\chi_{cc}$     &    0.6328(70)       &    0.3724(76)  &    2.4068(81)  &    2.257(23)\\
$\mu_{a}$\tn{c} & {Y}                 & {Y}           & {N}             & {N} \\
$\mu_{b}$\tn{c} & {Y}                 & {Y}           & {Y}             & {Y} \\
$\mu_{c}$\tn{c} & {Y}                 & {Y}           & {N}             & {Y} \\
$N$\tn{e}       & \num{24}            & \num{26}      & \num{19}        & \num{25} \\
$\sigma$\tn{e}  & \num{2.3}           & \num{2.3}     & \num{3.5}       & \num{3.3} \\
\bottomrule
\end{tabular*}

\raggedright\footnotesize

\begin{enumerate}[label=\tn{\alph*},leftmargin=*]
\item $A$, $B$, and $C$ are the rotational constants (in \si{MHz});
$\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N
nuclear quadrupole coupling tensor (in \si{MHz}).

\item Standard errors indicated in parentheses in units of the last digit.

\item Y (yes) and N (no) indicate whether $a$-, $b$-, and $c$-type transitions
were observed for each structure.

\item Number of fitted transitions.

\item Root mean square of the fit (in \si{kHz}).
\end{enumerate}

\end{table*}

\end{document}


• You're quite right, egreg! Thanks a lot for the heads up! The table looks gorgeous! Jan 15, 2018 at 17:08

Just to make the story shorter, I put the code with TeXnician's comment, and I'll be happy to remove this post. Apart from this trick, you need to put the items in the first row in braces, see siunitx manual table 7.

\documentclass[a4paper,12pt,numbered,print,index]{article}
\usepackage{siunitx} % use this package module for SI units
\usepackage{multirow}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{booktabs}
\sisetup{table-format=4.5(2)}
\begin{document}
\begin{table*}% table* allows a table to spawn the entire width of the page.
\label{C3-table:2}
\caption{Spectroscopic Parameters and Relative Energies Calculated at the MP2/6-311++G(d,p) Level of Theory for the Lowest-Energy Conformers of Synephrine}
\centering
\begin{tabular}{lSSSS}
\toprule
& {Rotamer $I$}   & {Rotamer $II$} & {Rotamer $III$} & {Rotamer $IV$} \\
\midrule
$A^{a}$      &3065.6858(11)$^{b}$   &3064.85192(78) &2479.83963(70) &2478.4259(21)\\
$B$          &540.46172(20)   &538.62660(18)  &614.51086(19)  &613.38156(16)\\
$C$         &498.99506(17)   &501.10248(14)  &582.56681(33)  &584.25597(24)\\
$\chi_{aa}$  &  2.3300(70)    &  2.3960(63)   &  1.3220(75)   &  1.257(35)\\
$\chi_{bb}$  & -2.9628(70)    & -2.7624(76)   & -3.7288(81)   & -3.514(23)\\
$\chi_{cc}$  &  0.6328(70)    &  0.3724(76)   &  2.4068(81)   &  2.257(23)\\
$\mu_{a}^{c}$& {Y}               & {Y}              & {N}              & {N}\\
$\mu_{b}^{c}$& {Y}               & {Y}              & {Y}              & {Y}\\
$\mu_{c}^{c}$& {Y}               & {Y}              & {N}              & {Y}\\
$N^{e}$      &24              &26             &19             &25\\
$\sigma^{e}$   &2.3             &2.3            &3.5            &3.3\\
\bottomrule
\end{tabular}
\caption*{ \small $^{a}A$, $B$, and $C$ are the rotational constants (in $MHz$); $\chi_{aa}$, $\chi_{bb}$, and $\chi_{cc}$ are elements of the $^{14}$N nuclear quadrupole coupling tensor (in $MHz$). $^{b}$Standard errors indicated in parentheses in units of the last digit. $^{c}$Y (yes) and N (no) indicate whether $a-$, $b-$, and $c-$type transitions were observed for each structure. $^{d}$Number of fitted transitions. $^{e}$Root mean square of the fit (in $kH$z).}
\end{table*}

\end{document}


• @TeXnician If you want, I can remove this post and you can upload your answer.
– user121799
Jan 15, 2018 at 16:57
• It worked like a charm! Thank you both very much, TeXnician and marmot! Jan 15, 2018 at 17:00
• I will not, egreg was faster and better. But please don't do a global \sisetup. Doing it locally is much better does avoid side effects. Jan 15, 2018 at 17:15
• Usually, table captions should be above the table, for obvious reasons. Jan 15, 2018 at 19:32
• @Bernard Absolutely! I did not pay any attention to this, all I did was too make the code compilable. Certainly egreg's take on this is much better than this. As I wrote, I'll be happy to remove it if I'm asked to.
– user121799
Jan 15, 2018 at 19:55