Siunitx: Changing table-format mid-table

horizontal alignmentsiunitxtables

Let's say I have a number of values associated with a system that I want to display in a table. Each value falls in one of two groups: The first group consists of large values, the second one of small ones. I want to place all of them in one table and use siunitx' alignment feature, but only for between values in the same group. That is, all large values should be aligned with respect to the other large values and the same for the small values, but the two groups should just be centered with respect to each other. In other words, I want to change table format mid-table.

  • Is this possible?
  • If not, can I fake the effect somehow without losing alignment and minimal width for the first column?

Here is an MWE

\documentclass{article}

\usepackage{siunitx}

\begin{document}

\begin{tabular}{ c S }
  large 1 & 74295.2 \\
  large 2 & 4398.4 \\
  large 3 & 12358 \\
  small 1 & 98.255 \\
  small 2 & 2.7382 \\
  small 3 & 1.5 \\
\end{tabular}

\end{document}

which yields the following output

MWE output

but I want something like this

desired output

Best Answer

You could use \tablenum:

\documentclass{article}

\usepackage{siunitx}

\begin{document}

\begin{tabular}{ c S[table-format = 5.1] }
  large 1 & 74295.2 \\
  large 2 & 4398.4 \\
  large 3 & 12358 \\
  small 1 & {\tablenum[table-format = 2.3]{98.255}} \\
  small 2 & {\tablenum[table-format = 2.3]{2.7382}} \\
  small 3 & {\tablenum[table-format = 2.3]{1.5}} \\

\end{tabular}

\end{document}

though I wonder if this is a particularly helpful table for your readers.

Related Question