Document ClassesSI-unitx package

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
niles
Posts: 92
Joined: Mon Dec 01, 2008 9:35 pm

SI-unitx package

Post by niles »

Hi all.

Please take a look at the following code:

Code: Select all

\documentclass[10pt, a4paper]{article}

\usepackage[T1]{fontenc}   

\usepackage{amsfonts, amssymb, amsfonts}

\usepackage{ntheorem}
\usepackage[english]{babel}
\usepackage[ansinew]{inputenc}
\usepackage{booktabs}
\usepackage{SIunitx}


\begin{document}

\begin{table}[t]
\centering
\begin{tabular}{%
S[digitsep=none,decimalsymbol={\,\pm\,},
numdigits={0123456789.},numdecimal=+]}
\toprule
{Some Values} \\
\midrule
2.3456 + 0.02 \\
34.2345 + 0.001 \\
56.7835 + 0.067 \\
90.473 + 0.021 \\
\bottomrule
\end{tabular}
\end{table}

\end{document} 
What I want is to add an uncertainty, i.e. to write something like:

Code: Select all

(2.39 \pm 0.23) \cdot 10^9
But is there any way to rewrite my example to obtain this? I have looked at the SI-unitx manual (http://www.ctan.org/tex-archive/macros/ ... iunitx.pdf), but no example covers this problem.

Thanks in advance.

Regards,
Niles.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

SI-unitx package

Post by phi »

Hi,

unfortunately, siunitx has no support for uncertainties in tabular material. However, it is flexible enough to allow some hacks:

Code: Select all

\begin{tabular}{S[tabformat=3.4,tabnumalign=right,numaddn=(]@{$\,\pm\,$}S[tabformat=1.4e1,tabnumalign=left,numaddn=)]}
	\toprule
	\multicolumn{2}{c}{Some Values} \\
	\midrule
	(2.3456 & 0.02)e5 \\
	(34.2345 & 0.001)e4 \\
	(56.7835 & 0.067)e3 \\
	(90.473 & 0.021)e2 \\
	\bottomrule
\end{tabular}
This is an example of bad coding, but the results are ok.
User avatar
T3.
Posts: 208
Joined: Fri Mar 14, 2008 12:58 pm

SI-unitx package

Post by T3. »

Alignment on errors in tables is not supported in siunitx and your example is quite a hack to go around that limitation. I'm surprised that option decimalsymbol={\,\pm\,} is accepted at all. It's not a valid option according to the documentation.

Some time ago I had a discussion with Joseph Wright about alignment on errors in tables. One of the problems is what formating options would make sense in that case and how the user interface should look like. I don't think that abusing the current set of options is the way to go. If you have any good ideas, give Joseph a shout (you can reactivate that old thread of mine if you like). He's usually very responsive.

BTW, I treat it as a mistake if my students report errors as in your example (numbers are given with greater precision than the associated error for the first three numbers). Also, usually only one significant digit is retained in the error part (with possible exception for 0.10 <= err < 0.15).

Cheers,

Tomek
josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

Re: SI-unitx package

Post by josephwright »

Hi all,

As Tomek has pointed out, I am aware of the problem. In the thread on comp.text.tex, I said:

I'll think about your suggestions again, but there is a fundamental
issue with the way I wrote table support in siunitx. Originally, this
was very much a "side issue", but it seems to be more and more
important. My thinking is that I'll look at writing a "v2" of siunitx
using the expl3 code of LaTeX3, once it is stable enough to be generally
used. I *hope* that there will be something like pgfkeys available in
expl3 at some point. At that stage, I'll probably shift all of the
tabular support into its own key path, as the current situation is
rather "cramped".

This still applies, really. I need to look again at various internal parts of siunitx, not only for this issue but also for others (some specialist units, complex numbers, ...). I also really need to make the options more logical.

I've been doing some initial experiments on this, but I've had other things on the go. As the issues are clearly building up, I will perhaps devote some more time to this in the near future.

Joseph Wright
Joseph Wright
Post Reply