Latex formatting

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Latex formatting

Peter Wintoft
Hi all,

I am quite new to Postgresql, but I have used MySQL quite a lot. But now I'm thinking of switching for several different reasons, and one of them is that I found that you can get output formatted as a Latex table. Excellent.

Now to my question: Is it possible to get decimal numbers in scientific notation, so that e.g. 0.052 becomes $5.2 \cdot 10^{-2}$ ?

Thanks!

Peter

--
Sent via pgsql-novice mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Reply | Threaded
Open this post in threaded view
|

Re: Latex formatting

Bruce Momjian
On Tue, Oct 16, 2012 at 07:47:37PM +0200, Peter Wintoft wrote:
> Hi all,
>
> I am quite new to Postgresql, but I have used MySQL quite a lot. But
> now I'm thinking of switching for several different reasons, and one
> of them is that I found that you can get output formatted as a Latex
> table. Excellent.
>
> Now to my question: Is it possible to get decimal numbers in
> scientific notation, so that e.g. 0.052 becomes $5.2 \cdot 10^{-2}$ ?

Uh, well, our Latex output hasn't been improved in quite some time, but
we are willing to accept patches to improve it.  Someone previously was
working on making the table output more flexible, but never submitted a
patch.

--
  Bruce Momjian  <[hidden email]>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + It's impossible for everything to be true. +


--
Sent via pgsql-novice mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Reply | Threaded
Open this post in threaded view
|

Re: Latex formatting

Peter Wintoft
Thanks for the reply Bruce. Ok, then I know. I will probably solve it by taking the produced Latex table and do some parsing to convert numbers into scientific notion.

What language is used for patches?

/ Peter

On 2012-10-16, at 20:29 , Bruce Momjian wrote:

> On Tue, Oct 16, 2012 at 07:47:37PM +0200, Peter Wintoft wrote:
>> Hi all,
>>
>> I am quite new to Postgresql, but I have used MySQL quite a lot. But
>> now I'm thinking of switching for several different reasons, and one
>> of them is that I found that you can get output formatted as a Latex
>> table. Excellent.
>>
>> Now to my question: Is it possible to get decimal numbers in
>> scientific notation, so that e.g. 0.052 becomes $5.2 \cdot 10^{-2}$ ?
>
> Uh, well, our Latex output hasn't been improved in quite some time, but
> we are willing to accept patches to improve it.  Someone previously was
> working on making the table output more flexible, but never submitted a
> patch.
>
> --
>  Bruce Momjian  <[hidden email]>        http://momjian.us
>  EnterpriseDB                             http://enterprisedb.com
>
>  + It's impossible for everything to be true. +
>
>
> --
> Sent via pgsql-novice mailing list ([hidden email])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice



--
Sent via pgsql-novice mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Reply | Threaded
Open this post in threaded view
|

Re: Latex formatting

Andrej Ricnik-Bay
On 19 October 2012 01:38, Peter Wintoft <[hidden email]> wrote:
> What language is used for patches?

C

>
> / Peter
Cheers,
Andrej


--
Sent via pgsql-novice mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice
Reply | Threaded
Open this post in threaded view
|

Re: Latex formatting

Peter Wintoft
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 <[hidden email]> wrote:
>> What language is used for patches?
>
> C
>
>>
>> / Peter
> Cheers,
> Andrej



--
Sent via pgsql-novice mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice