TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As I understand it, using various options for the S column in siunitx, I may produce columns containing both numerical and nonnumerical entries. I may have the numerical entries aligned at their decimal points. I may have the text entries either left-, right-, or center- justified with respect to the column's width.

Is it possible to have the numerical entries aligned by their decimal, while controlling the text entries' alignment as it relates to the decimal marker?

To complicate things further, is it possible to apply alignments differently row by row? In particular, could I leave column-centered alignment for the head entry of a column, while making my special decimal marker-based alignment apply to later entries?

The following MWE sort of produces what I want with exaggerated numbers, but I have manually forced some space in the last two entries to make it happen. I want to not have to do this.







*enter image description here*

Note that I do want a centered title, and that ideally I actually want the remaining text entries centered with respect to a point that is roughly 0.5\ex to the left of the decimal marker. Also, note that since I have such asymmetry between integer an fractional parts, I do not think that table-number-alignment=center-decimal-marker is helpful.

share|improve this question
Can you elaborate on what you meant with “apply alignments differently row by row”. Isn't that what you get with your \heading macro? – Qrrbrbirlbel Oct 27 '12 at 0:01
@Qrrbrbirlbel Thanks for your answer - I will try to apply it Monday when I again have access to my desktop. I believe that in my experiments, the text alignment from S was overriding the alignment c in my \heading macro. As I recall parameters like table-text-alignment=left made the c in my \heading command pointless. I may be misremembering though - I went through a lot of experimentation this morning. – alex.jordan Oct 27 '12 at 2:21
I just updated my answer so that is easier useable. If I understand it correctly, \multicolumn overrides SIunitx's stuff. And “Title” was actually typeset centered to the whole column … – Qrrbrbirlbel Oct 27 '12 at 2:28
I'd also note that the business about wanting an alignment with offset is really outside of what siunitx was designed to handle. The intention of the S column is to align numerical columns, which it does a reasonable job of, but if you have very specific needs then there comes a point at which a custom solution is the best way forward. – Joseph Wright Oct 27 '12 at 6:59
Logged for v2.6: bitbucket.org/josephwright/siunitx/issue/205/… (probably over the Christmas holidays). – Joseph Wright Oct 27 '12 at 17:23

Let me say two things before:

  1. This is not an only-siunitx solution. Sadly, table-text-alignment doesn't take decimal-marker :(
  2. I provide two macros:
    1. \widestparts{<digits before …>}{<… and after decimal marker>}
    2. \tcenter{<text to center at the decimal marker>}

This works now, thanks to Peter Grill's question, Martin Scharrer's answer and Peter's hint in the chat.

Manual aligning

You can add another \textcenter macro that takes three arguments:

  1. stuff before your actual text,
  2. stuff after your actual text (in the example below I also removed the decimal marker .), and
  3. stuff that gets actually typeset.

For example:

    \hphantom{\num[add-decimal-zero = false,add-integer-zero = false,scientific-notation = fixed]{#2}}%


\usepackage{xcolor} % only for this example (redefinition of hphantom}
% getting the width of the decimal marker: . or ,
\newlength{\decimalmarkerwidth}\settowidth{\decimalmarkerwidth}{.} % or ,

% remove the % in the next line to get gray phantoms

\newcommand*\heading[1]{\multicolumn{1}{c}{#1}} % not used anymore ... (but can used (without the multicolumn) for other formatting (bf, color, ...)

\newcounter{alex@auxctr} % (Internal)

% \widestparts takes two arguments: #1 = number of digits before the decimal marker
                                  % #2 = number of digits after the decimal marker

% (Internal) \alex@widestpartauxloop loops over #2 and adds #2 times #3 to #1.

% \tcenter takes one argument: #1 = actual text that should be typeset
    \hphantom{\num[add-decimal-zero = false,add-integer-zero = false,scientific-notation = fixed]{.\alex@widestpartright}}%

\usepackage{booktabs} % for \top-, \mid- and \bottomrule

             \tcenter{Title}            \\ \midrule
                    1                   \\
                  2.000                 \\
                    6                   \\
                   24.0                 \\
                123456789               \\
    \tcenter{$\smash{\vdotswithin{.}}$} \\ % \smash is used to hide the oversized vertical height of \vdots
             \tcenter{$f(n)$}           \\ \bottomrule


Output with phantomed hidden stuff  Output with gray hidden stuff

share|improve this answer
Thanks for the answer. I can't play around with this until Monday, but at a glance I have a concern. I am working on a very long document with hundreds of tables like this. And I very much want a solution at the level of S. That is, I won't want to have to put anything more than a pair of braces around my non-numeric table entries, let siunitx and S detect what is numeric and what is not, and typeset accordingly. Can I modify S to wrap your tcenter around non-numeric entries? – alex.jordan Oct 27 '12 at 2:47
@alex.jordan: That might be a separate question, but you could possibly use the collcell package for that, although I don't think I have tried it with the S column. – Peter Grill Oct 27 '12 at 3:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.