Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Repeated decimals with siunitx

508 views
Skip to first unread message

maurizio...@gmail.com

unread,
Jul 25, 2012, 9:17:22 AM7/25/12
to
I am using package siunitx which I find convenient.

Is it possible to use command

\num

with repeated decimals, like

$1=0.\overline{9}$ ???

It would be nice to be able to write

\num{0.\overline{9}}

but it seems it doesn't work. I would find this useful in order to be able to switch with one stroke from comma to period and viceversa for separating the decimal part if I choose so (This is country dependent).

Any help?

Thanks,
M.

Heiko Oberdiek

unread,
Jul 25, 2012, 9:52:17 AM7/25/12
to
maurizio...@gmail.com wrote:

> I am using package siunitx which I find convenient.
>
> Is it possible to use command
>
> \num
>
> with repeated decimals, like
>
> $1=0.\overline{9}$ ???
>
> It would be nice to be able to write
>
> \num{0.\overline{9}}

AFAICS this is not supported by siunitx.
A workaround is to put braces around the expression with \overline:

\documentclass[12pt]{article}
\usepackage{siunitx}

\begin{document}
$\num{1} = \num{0.{\overline{9}}}$

$1/7 \approx \num{0.142857}$

$1/7 = \num{0.{\overline{142857}}}$

$1/7 = \num{0.{\overline{142\thinspace 857}}}$
\end{document}

But that's just a workaround. Because the digits are hidden from the
parser by the brace group, no space is automatically inserted between
group of digits. And this syntax is outside the specification of \num.
Thus the behaviour might change with other versions of siunitx.
(The example was tested with 2012/05/03 v2.5c.)

Best would be if you can make a feature request to ask the
author of the package to implement the missing feature,
if he has time and find the feature interesting.

--
Heiko Oberdiek

Joseph Wright

unread,
Jul 25, 2012, 11:39:30 AM7/25/12
to
The 'number parser' has a limit to what it will understand. Here, you
want to turn it off, either locally

\num[parse-numbers = false]{0.\overline{9}}

or globally

\sisetup{parse-numbers = false}
\num{0.\overline{9}}
--
Joseph Wright

Heiko Oberdiek

unread,
Jul 25, 2012, 4:38:55 PM7/25/12
to
Joseph Wright <joseph...@morningstar2.co.uk> wrote:

> On 25/07/2012 14:17, maurizio...@gmail.com wrote:
> > I am using package siunitx which I find convenient.
> >
> > Is it possible to use command
> >
> > \num
> >
> > with repeated decimals, like
> >
> > $1=0.\overline{9}$ ???
> >
> > It would be nice to be able to write
> >
> > \num{0.\overline{9}}
> >
> > but it seems it doesn't work. I would find this useful in order to be able to switch with one stroke from comma to period and viceversa for separating the decimal part if I choose so (This is country dependent).

> The 'number parser' has a limit to what it will understand. Here, you
> want to turn it off, either locally
>
> \num[parse-numbers = false]{0.\overline{9}}
>
> or globally
>
> \sisetup{parse-numbers = false}
> \num{0.\overline{9}}

However, this disables also other features (decimal point, spacing):

\documentclass[12pt]{article}
\usepackage{siunitx}

\begin{document}
$ \num{123456.123456} = \num{123456,123456} $

\sisetup{parse-numbers=false}
$ \num{123456.\overline{123456}} \neq \num{123456,\overline{123456}} $

\end{document}

--
Heiko Oberdiek
0 new messages