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

Here is a table with the siunitx S column type. I would like the italic value (the command with swapshift) to be still centered on the decimal point. The superscript can be variable, but will almost always be just "a" or "b", maybe "c", never more than 1 letter in length.


\newcolumntype{g}{>{\rule{1.2em}{0em}}r@{ }l}
\newcommand{\range}[1]{\mcol{1}{c}{\bfseries #1}}
\begin{tabular}{gS[table-format=1.2]S[table-format=1.2]S[table-format=1.2]S[table-format=1.2]} \toprule%
\mcol{2}{c}{\mrow{2}{*}{Position}} & \mcol{2}{c}{Computed} & \mcol{2}{c}{Experimental} \\%
& & \mcol{1}{c}{\textbf{#1}} & \mcol{1}{c}{\textbf{#2}} & \mcol{1}{c}{\textbf{#1}} & \mcol{1}{c}{\textbf{#2}} \\%
\cmidrule[\lightrulewidth](r){1-2} \cmidrule[\lightrulewidth](lr){3-4} \cmidrule[\lightrulewidth](l){5-6}}%

    \caption{Calculated and Experimental \oneh{} Shifts (in ppm) for carvomenthones \CNref{carvomenthone}}\label{tab:SI:carvomenthone1H}
    2 & & 2.47 & 2.48 & 2.45 & 2.33 \\
    3 & \greek{\alpha} & 1.87 & 1.29 & \swapshift{1.87}{a} & 1.30 \\
    3 & \greek{\beta} & 1.70 & 2.12 & \range{1.60--1.75} & 2.10 \\
    10 & Me & 1.06 & 0.92 & 1.10 & \swapshift{1.01}{b} \\ \bottomrule
share|improve this question
With this data you could use \newcommand{\swapshift}[2]{\mcol{1}{c}{\kern0.1em\textit{#1}\rlap{\textsuperscr‌​ipt{#2}}}}, but that won't work with all range of numerical data. Not sure if there is a proper way to eliminate the \kern0.1em fudge factor, but that was required since this text is in italics. – Peter Grill Sep 5 '12 at 4:29
@PeterGrill Sorry, I keep getting an Undefined control sequence,<argument> \textsuperscript{a}... error now with that updated swapshift command. – J M Sep 5 '12 at 6:16
up vote 2 down vote accepted

Simplifying your example a bit, I think you want something like

  \sisetup{table-format = 1.2, detect-all}
      r@{ }
      S[table-space-text-post = \textsuperscript{a}]
      S[table-space-text-post = \textsuperscript{b}]
      \multicolumn{2}{c}{\multirow{2}{*}{Position}} &
        \multicolumn{2}{c}{Computed} &
        \multicolumn{2}{c}{Experimental} \\
       & &
         {\textbf{201a}} & {\textbf{201b}} & {\textbf{201a}} & {\textbf{201b}} \\
       2 &          & 2.47 & 2.48 &         2.45                       & 2.33 \\
       3 & $\alpha$ & 1.87 & 1.29 & \itshape 1.87{\textsuperscript{a}} & 1.30 \\
       3 & $\beta$  & 1.70 & 2.12 & {\bfseries 1.60--1.75}             & 2.10 \\
      10 & Me       & 1.06 & 0.92 &         1.10                      &
        \itshape 1.01{\textsuperscript{b}} \\

The key here is to use \itshape to alter the formatting while retaining siunitx S column alignment, plus setting up so space for the superscript using table-space-text-post.

I've also cut down on the use of \multicolumn, as {...} will escape thing from siunitx more clearly. siunitx treats anything inside a wrapping set of braces as 'text', so for example

& {\bfseries 1.60--1.75} &

typesets the material without parsing the number: the alignment of 'text' is governed by the table-text-alignment key. (You could alternatively use \multicolumn and \tablenum, but that seems overly complex here.)

The table-space-text-post setting reserves 'some space' for additional material after the number. It needs to be wide enough when typeset to hold the largest item you will have after the text in a column. Usually, this is simply a case of picking something representative, although if the letter width varies a lot in your font then that may be an issue. I've used superscript a and b as they are the only things in those columns: I guess if you have an m or w to fit in you'll need to use them as they are wider!

share|improve this answer
Ah wonderful! Can you explain your comment about the multicolumn and the {...} what is the {...}? Also, is there a way to use use the table-space-text-post for more than one possibility? I have one particularly nasty NMR spectra that requires superscripts up to the letter g in one column. – J M Sep 5 '12 at 7:09
Thank you so much for the added explanation, definitely help me understand better! I've implemented it into my thesis, and it works great. – J M Sep 5 '12 at 16:05

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.