# siunitx Auto-detect table-format in S column

I am typesetting a number of tables, here is an example of my desired output:

There are several features:

• A variety of number formats: integer with no uncertainty, floats and scientific notation with uncertainty.
• Uncertainties range from (2) to (19) and the number of significant digits is between 1 and (typically) 5.
• The decimal point (or implicit decimal point for integers) must be aligned for each column.
• Other features (eg. \times symbol) are also aligned, although this isn't critical.
• Sometimes the header cell is the longest within a column (eg. N [10^6] column) and sometimes not (eg. double column).

I am able to achieve the desired output using siunitx's S-column feature. However, it seems I have to specify the table-format on a per-column basis. To get the table as shown, I used:

\begin{table}[h!]
\caption{Desired formatting, manual \texttt{table-format} for each column}
\footnotesize
\sisetup{table-number-alignment = center}
\begin{tabular}{ S[table-format=5.0]
S[table-format=4.0]
S[table-format=1.4(2)e+2]
S[table-format=2.2(1)]
S[table-format=2.2(1)]
S[table-format=1.3(2)]
S[table-format=1.3(1)e+2] }
\toprule
{$T$ $\qty[\si{\kelvin}]$}       &  {$\mathcal{N}$ $\qty[\num{e6}]$} &  {$k_\mathrm{d}^{\mathit{(eff)}}$ $\qty[\si{\cm\cubed\per\sec}]$}           &  {\textit{simple}}                                                          &  {\textit{swap}}                                                            &  {\textit{double}}                                                          &  {$k_\mathrm{m}$ $\qty[\si{\cm\cubed\per\sec}]$}                            \\
\midrule
8000                        &       90                          &       3.163 \pm 0.007 e-12                                                  &       76.59 \pm 0.07                                                        &       23.32 \pm 0.07                                                        &       0.095 \pm 0.006                                                       &       4.26 \pm 0.04 e-14                                                    \\
10000                       &       180                         &       1.2147 \pm 0.0010 e-11                                                &       72.59 \pm 0.03                                                        &       27.00 \pm 0.03                                                        &       0.409 \pm 0.005                                                       &       2.109 \pm 0.006 e-13                                                  \\
13000                       &       18                          &       3.948 \pm 0.006 e-11                                                  &       67.63 \pm 0.06                                                        &       31.07 \pm 0.06                                                        &       1.301 \pm 0.016                                                       &       8.56 \pm 0.04 e-13                                                    \\
\bottomrule
\end{tabular}
\end{table}


Note that I've used a user-determined table format for each column, such as S[table-format=1.4(2)e+2]. That format was determined by looking at the data for that column, and picking the maximum significant figures, uncertainty digits, and exponent digits. I will be generating many tables and would like to avoid manually specifying the format, if possible.

I have tried to let siunitx auto-determine the format in two ways. Simply using S yields: which has way too much whitespace, because this default puts the decimal place in the center of each column.

Specify a single table-format=3.4(2)e+2 for the entire table doesn't work either, because the data are so varied:

Is there any way to auto-detect a column-specific table-format based on the contents of each column? This seems (naively) like something that could exist, but I've been unable to find a reference to it.

I'm open to other packages, but I've been pretty happy with siunitx overall so far.

• nice wish, however latex is mark-up macro language. this means that you need inform it for each document element, how should it looks. many things can be automated (like calculation of the X columns in tabularx), but not all or so complicated as you like to have. i'll be glad if I'm wrong :-) – Zarko Aug 31 '18 at 19:51
• Yeah, I agree. Worth checking, I think - and if it's possible but not implemented this can serve as a feature request. – Ross Aug 31 '18 at 20:02
• @Ross - Feature requests are off-topic on this site. Please direct it at the author/maintainer of the siunitx package. (His email address may be found on the title page of the package's user guide.) – Mico Aug 31 '18 at 22:02
• So, I guess the consensus here is 'no, this feature does not currently exist'? – Ross Sep 1 '18 at 15:58