3

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

2
  • 2
    Hmm... they seem basically two different tables to me. I would typeset the "large x" using kilo-units, too...
    – Rmano
    Nov 2, 2021 at 13:56
  • I understand the skepticism toward this table (I would have had the same objection) but the circumstances make it reasonable: The real values are physical measurements of different type (accordingly with different size and units) that are displayed in a certain format. The table is part of a log and the values should be input and displayed just like they are in the measurement to avoid confusion, so converting units isn't really an option. Making it separate tables (more than two in the real case) also isn't very pleasing. So this is what I deemed to be the best approach.
    – schtandard
    Nov 2, 2021 at 15:56

1 Answer 1

8

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.

1
  • Kind of obvious in retrospect.. I'll write a wrapper environment to make the input a bit easier and this should be perfect.
    – schtandard
    Nov 2, 2021 at 15:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .