Re: Latex formatting

From: Peter Wintoft <peter(at)lund(dot)irf(dot)se>
To: Andrej <andrej(dot)groups(at)gmail(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-novice(at)postgresql(dot)org
Subject: Re: Latex formatting
Date: 2012-10-18 20:03:33
Message-ID: B9093982-ECE8-485C-82BF-FE128C01E7B9@lund.irf.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Ok, thanks. Not fluent enough in C to be able to help. But I wrote a function that basically does the job, although some extra parameter could be added to control the formatting:

create function sci (x float) returns text as $$ select regexp_replace(to_char(x,'9.99EEEE'),'(.+)e(-*)(\+*)(0*)(.+)',E'$\\1\\cdot 10\^{\\2\\5}$') $$

Example:

select sci(0.003337),sci(5678);
sci | sci
----------------------+---------------------
$ 3.34\cdot 10^{-3}$ | $ 5.68\cdot 10^{3}$
(1 row)

/ Peter

On 2012-10-18, at 20:55 , Andrej wrote:

> On 19 October 2012 01:38, Peter Wintoft <peter(at)lund(dot)irf(dot)se> wrote:
>> What language is used for patches?
>
> C
>
>>
>> / Peter
> Cheers,
> Andrej

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Gary Warner 2012-10-20 13:10:24 "Voting" question?
Previous Message Andrej 2012-10-18 18:55:15 Re: Latex formatting