Hi, Here is my test: =================================================== \setuppapersize[A4][A4] \usetypescript[postscript] \setupbodyfont[palatino,12pt] \starttext \startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(355/14)} \stopformula \stoptext =================================================== It works well and give me result = 25,357142857143. In order to obtain 2 decimal number I tried: \startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.printf("%0.2f",355/14)} \stopformula But it does not work. Here is the error: tex.printf("\doplaceformulanumber \stopdisplaymath \global \let \gdef \ETC. ! File ended while scanning text of \zerocount. <inserted text> } <*> ./test-lua.tex ? Another try: \startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(string.format("%0.2f",355/14))} \stopformula gives me the same error. So is there really a function printf() in LuaTeX engine ? Thanks
On Fri, Jul 23, 2010 at 10:25 PM, Vnpenguin
Hi, Here is my test: =================================================== \setuppapersize[A4][A4] \usetypescript[postscript] \setupbodyfont[palatino,12pt]
\starttext \startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(355/14)} \stopformula \stoptext ===================================================
It works well and give me result = 25,357142857143. In order to obtain 2 decimal number I tried:
\startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.printf("%0.2f",355/14)} \stopformula
But it does not work. Here is the error:
tex.printf("\doplaceformulanumber \stopdisplaymath \global \let \gdef \ETC. ! File ended while scanning text of \zerocount. <inserted text> } <*> ./test-lua.tex ?
Another try:
\startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(string.format("%0.2f",355/14))} \stopformula
gives me the same error.
So is there really a function printf() in LuaTeX engine ?
Thanks ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
hm, what about tex.sprint(tex.ctxcatcodes,string.format("\%.2f",355/14) ? -- luigi
On Fri, Jul 23, 2010 at 10:38 PM, luigi scarso
On Fri, Jul 23, 2010 at 10:25 PM, Vnpenguin
wrote: Hi, Here is my test: =================================================== \setuppapersize[A4][A4] \usetypescript[postscript] \setupbodyfont[palatino,12pt]
\starttext \startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(355/14)} \stopformula \stoptext ===================================================
It works well and give me result = 25,357142857143. In order to obtain 2 decimal number I tried:
\startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.printf("%0.2f",355/14)} \stopformula
But it does not work. Here is the error:
tex.printf("\doplaceformulanumber \stopdisplaymath \global \let \gdef \ETC. ! File ended while scanning text of \zerocount. <inserted text> } <*> ./test-lua.tex ?
Another try:
\startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(string.format("%0.2f",355/14))} \stopformula
gives me the same error.
So is there really a function printf() in LuaTeX engine ?
Thanks ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________
hm, what about tex.sprint(tex.ctxcatcodes,string.format("\%.2f",355/14) sorry tex.sprint(tex.ctxcatcodes,string.format("\%.2f",355/14))
-- luigi
On Fri, Jul 23, 2010 at 22:39, luigi scarso
On Fri, Jul 23, 2010 at 10:38 PM, luigi scarso
wrote: On Fri, Jul 23, 2010 at 10:25 PM, Vnpenguin
wrote: Hi, Here is my test: =================================================== \setuppapersize[A4][A4] \usetypescript[postscript] \setupbodyfont[palatino,12pt]
\starttext \startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(355/14)} \stopformula \stoptext ===================================================
It works well and give me result = 25,357142857143. In order to obtain 2 decimal number I tried:
\startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.printf("%0.2f",355/14)} \stopformula
But it does not work. Here is the error:
tex.printf("\doplaceformulanumber \stopdisplaymath \global \let \gdef \ETC. ! File ended while scanning text of \zerocount. <inserted text> } <*> ./test-lua.tex ?
Another try:
\startformula K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(string.format("%0.2f",355/14))} \stopformula
gives me the same error.
So is there really a function printf() in LuaTeX engine ?
Thanks
hm, what about tex.sprint(tex.ctxcatcodes,string.format("\%.2f",355/14) sorry tex.sprint(tex.ctxcatcodes,string.format("\%.2f",355/14))
Ahhhhhhh, forgot to escape %, my bad !!! The code \ctxlua{tex.print(string.format("\%0.2f",355/14))} works ok for me. Thanks,
On 23-7-2010 10:53, Vnpenguin wrote:
\startformula
K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(string.format("%0.2f",355/14))} \stopformula
or \ctxlua{context("\letterpercent0.2f",355/14)} we can consider adding \let\pct\letterpercent but nice is: \ctxluacode{context("%0.2f",355/14)} i'll add this but keep in mind that this will only work in the text stream, not in macro definitions or as arguments Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Fri, Jul 23, 2010 at 23:23, Hans Hagen
On 23-7-2010 10:53, Vnpenguin wrote:
\startformula
K = \frac{\sigma_1}{\sigma_2} = \frac{355}{14}= \ctxlua{tex.print(string.format("%0.2f",355/14))} \stopformula
or
\ctxlua{context("\letterpercent0.2f",355/14)}
we can consider adding
\let\pct\letterpercent
but nice is:
\ctxluacode{context("%0.2f",355/14)}
i'll add this but keep in mind that this will only work in the text stream, not in macro definitions or as arguments
With the format "%..." it's better to call something like \clxluacode{contextf()} ? (like print() & printf())
On 23-7-2010 11:29, Vnpenguin wrote:
\clxluacode{contextf()} ? (like print()& printf())
No, as context() is already built in for quite a while and I don't want to polute the global namespace any more that it already is. Also, there is no printf in lua and I see no reason to mimick c calls (for me printf does not feel more natural). Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (3)
-
Hans Hagen
-
luigi scarso
-
Vnpenguin