Take the 2-minute tour ×
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.

The minimal example below gives me a strange offset in numbers with exponential numbers. I think tabu and siunitx are getting in each others way. Is anyone aware of a workaround?

\documentclass[parskip=half]{scrartcl}

\usepackage{siunitx}
\usepackage{tabu,booktabs}

\begin{document}

\newcolumntype Z{X[c,m]{%
S[%
tight-spacing = true,
round-mode=places,
round-precision=2,
]
}}
\tabucolumn Z
\begin{tabu} to \linewidth {X[l,m,1.2]ZZZZZ}
\hline
Water vapour* & 18.01534 & -2.418379e+8 & 1.886964e+5 &
2.605& 572.4\\
\hline
\end{tabu}

\end{document}

enter image description here

share|improve this question
1  
The author of tabu is very active on comp.text.tex, but not here. You might want to (also) ask this question there. –  Martin Scharrer May 9 '11 at 10:44
    
@Martin Ok, thank you, will do –  Martin H May 9 '11 at 10:57
add comment

1 Answer 1

up vote 7 down vote accepted

The question was answered by the developer on comp.text.tex and I thought I share it here to answer the question:

Well. In next version, thank to Bruno Le Floch rewritting process, there is no \tabucolumn command:

\newcolumntype Z{ XS[m,
 tight-spacing=true,round-mode=places,
                          round-precision=2] }

X[options]{S[option]} is implemented as XS[ X option , S option] but both still work.

\tabucolumn indeed has no signifiance: I put it there due to some potential parsing problems of the tabu preamble. Problems that no more exist thank to B Le Floch.

XS ( or X[..]{S[...]} ) is always centered: there is no point to set the horizontal alignment for S and s columns: the alignment can't be chosen.

\begin{tabu} to \linewidth {X[l,m,1.2]ZZZZZ}

Avoid X[l,m,1.2] -> for XS columns the comma is "reserved" to separate the options of X with the options for S. Thus it's good practice not to use any delimiter for X options : X [1.2 lm] (and more readable imho)

\hline
 Water vapour*&  18.01534&  -2.418379e+8&  1.886964e+5&
 2.605&  572.4\\
 \hline
\end{tabu}

Now the problem of the vertical alignment: ;-)

The problem is not tabu but siunitx (sorry ;-( ): siunitx leaves too much fixed space before the numbers, because the S column mechanism proceeds with "fixed width". To be able to adjust the spacing, the S column should read the whole tabular and then choose the spacing depending on the "natural length" of each typeset number in each column.

This is what is done inside tabu X, but tabu cannot adjust the spacing made by siunitx: the spaces are inside a box, and tabu can't destroy the box (and thereafter re-align the numbers ! )

If you try with:

 \newcolumntype Z{X[-1
 m]{S[tight-spacing =
 true,round-mode=places,
round-precision=2]}}


 \begin{tabu} to \linewidth {X[lm] |
 *5{Z|}} \hline Water vapour* & 18.01534 & -2.418379e+8 & 1.886964e+5 &
 2.605& 572.4\\ \hline \end{tabu} 

There is no more problems of alignment. But the columns width are not the same. You can understand the problem with :

 \newcolumntype Z{S[tight-spacing =
 true,round-mode=places,
 round-precision=2]}

\begin{tabu} to \linewidth {X[-1 lm] |
*5{Z|}} \hline Water \par vapour* & 18.01534 & -2.418379e+8 & 1.886964e+5 &
2.605& 572.4\\ \hline \end{tabu}

This shows that siunitx needs more space than the X coefs allow. Hence the line break inside the X[m] ( ie m ) column.

So: change your margin, or artificially raise the tabu width:

 \newcolumntype Z{X[m]{S[tight-spacing
 = true,round-mode=places,
 round-precision=2]}}
 \hskip-10mm \begin{tabu} to 500pt
 {X[-1 lm] | *5{Z|}} \hline Water \par
 vapour* & 18.01534 & -2.418379e+8 &
 1.886964e+5 &
 2.605& 572.4\\ \hline \end{tabu}

Here there is no more problem. (for future version 2.9 at least)

share|improve this answer
add comment

Your Answer

 
discard

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.