Обсуждение: Latex formatting
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 differentreasons, 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
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 <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + It's impossible for everything to be true. +
Thanks for the reply Bruce. Ok, then I know. I will probably solve it by taking the produced Latex table and do some parsingto 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 <bruce@momjian.us> http://momjian.us > EnterpriseDB http://enterprisedb.com > > + It's impossible for everything to be true. + > > > -- > Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-novice
On 19 October 2012 01:38, Peter Wintoft <peter@lund.irf.se> wrote: > What language is used for patches? C > > / Peter Cheers, Andrej
Ok, thanks. Not fluent enough in C to be able to help. But I wrote a function that basically does the job, although someextra 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\\cdot10\^{\\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@lund.irf.se> wrote: >> What language is used for patches? > > C > >> >> / Peter > Cheers, > Andrej