TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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

I would like to have my numbers aligned left but centered in a table as in this solution, which I also tried to apply. Now my numbers are of the form ~24%. For a correct alignment I tried to protect the non-number parts by writing it as {$\sim$}24{ \%}. The % is well behind the number, however the ~ is centered in the column and overlapping the numbers. Same thing happens when using something like {xx}60{ \%} where now the xx and the numbers overlap. How to protect the ~ to stay left of the number?



      & {Before treatment} & {After treatment} \\
     component1 & {$\sim$}60{ \%} & {$\sim$}15{ \%} \\
     component2 & {$\sim$}14{ \%} & {$\sim$}4{ \%} \\
     component3 & {$\sim$}26{ \%} & {$\sim$}81{ \%} \\

share|improve this question
Take a look at the table-space-text-* options. Can you provide a sample table? For \sim for a ~, please see How does one insert a backslash or a tilde (~) into LaTeX? On that note, \sim is also allowed as input-comparator so it shouldn’t be a problem if you properly declare the comparator usage for that column. – Qrrbrbirlbel Nov 18 '13 at 16:32
up vote 4 down vote accepted

As said in the comment, the table-space-text-post option helps with saving the right space after the number. To stay with siunitx default setting, the thin space \, is used instead of a full space.

The \sim macro is already one of the allowed input macros of siunitx and is used as a comparator. This allows you to use \sim without any protection in the column. The space for it is allocated with the table-comparator switch, or, for the special table-format option with an < (or > or …?) in front of the integer part.


\begin{tabular}{l *2{S[table-format=<2.0, table-space-text-post=\,\%]}}
               & {Before treatment} & {After treatment} \\ \midrule
    component1 & \sim 60 \,\%       & \sim 15 \,\%      \\
    component2 & \sim 14 \,\%       & \sim 4  \,\%      \\
    component3 & \sim 26 \,\%       & \sim 81 \,\%      \\ \bottomrule


enter image description here

share|improve this answer
If I would use some text like xx before the number, then it would have to be done with table-space-text-pre? – Tanja Nov 18 '13 at 17:54
@user2758804 Correct. For more information, check out the manual, and for examples, see Can the siunitx table alignment feature, S, align ratios? – Qrrbrbirlbel Nov 18 '13 at 18:30

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.