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,