* LuaTeX & printf() function ? @ 2010-07-23 20:25 Vnpenguin 2010-07-23 20:38 ` luigi scarso 0 siblings, 1 reply; 7+ messages in thread From: Vnpenguin @ 2010-07-23 20:25 UTC (permalink / raw) To: ConTeXt list 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LuaTeX & printf() function ? 2010-07-23 20:25 LuaTeX & printf() function ? Vnpenguin @ 2010-07-23 20:38 ` luigi scarso 2010-07-23 20:39 ` luigi scarso 0 siblings, 1 reply; 7+ messages in thread From: luigi scarso @ 2010-07-23 20:38 UTC (permalink / raw) To: mailing list for ConTeXt users On Fri, Jul 23, 2010 at 10:25 PM, Vnpenguin <vnpenguin@vnoss.org> 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) ? -- luigi ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LuaTeX & printf() function ? 2010-07-23 20:38 ` luigi scarso @ 2010-07-23 20:39 ` luigi scarso 2010-07-23 20:53 ` Vnpenguin 0 siblings, 1 reply; 7+ messages in thread From: luigi scarso @ 2010-07-23 20:39 UTC (permalink / raw) To: mailing list for ConTeXt users On Fri, Jul 23, 2010 at 10:38 PM, luigi scarso <luigi.scarso@gmail.com> wrote: > On Fri, Jul 23, 2010 at 10:25 PM, Vnpenguin <vnpenguin@vnoss.org> 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 ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LuaTeX & printf() function ? 2010-07-23 20:39 ` luigi scarso @ 2010-07-23 20:53 ` Vnpenguin 2010-07-23 21:23 ` Hans Hagen 0 siblings, 1 reply; 7+ messages in thread From: Vnpenguin @ 2010-07-23 20:53 UTC (permalink / raw) To: mailing list for ConTeXt users On Fri, Jul 23, 2010 at 22:39, luigi scarso <luigi.scarso@gmail.com> wrote: > On Fri, Jul 23, 2010 at 10:38 PM, luigi scarso <luigi.scarso@gmail.com> wrote: >> On Fri, Jul 23, 2010 at 10:25 PM, Vnpenguin <vnpenguin@vnoss.org> 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, ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LuaTeX & printf() function ? 2010-07-23 20:53 ` Vnpenguin @ 2010-07-23 21:23 ` Hans Hagen 2010-07-23 21:29 ` Vnpenguin 0 siblings, 1 reply; 7+ messages in thread From: Hans Hagen @ 2010-07-23 21:23 UTC (permalink / raw) To: mailing list for ConTeXt users 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 ----------------------------------------------------------------- ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LuaTeX & printf() function ? 2010-07-23 21:23 ` Hans Hagen @ 2010-07-23 21:29 ` Vnpenguin 2010-07-23 21:36 ` Hans Hagen 0 siblings, 1 reply; 7+ messages in thread From: Vnpenguin @ 2010-07-23 21:29 UTC (permalink / raw) To: ConTeXt list On Fri, Jul 23, 2010 at 23:23, Hans Hagen <pragma@wxs.nl> wrote: > 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()) ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: LuaTeX & printf() function ? 2010-07-23 21:29 ` Vnpenguin @ 2010-07-23 21:36 ` Hans Hagen 0 siblings, 0 replies; 7+ messages in thread From: Hans Hagen @ 2010-07-23 21:36 UTC (permalink / raw) To: mailing list for ConTeXt users 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 ----------------------------------------------------------------- ___________________________________________________________________________________ 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 ___________________________________________________________________________________ ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-07-23 21:36 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-07-23 20:25 LuaTeX & printf() function ? Vnpenguin 2010-07-23 20:38 ` luigi scarso 2010-07-23 20:39 ` luigi scarso 2010-07-23 20:53 ` Vnpenguin 2010-07-23 21:23 ` Hans Hagen 2010-07-23 21:29 ` Vnpenguin 2010-07-23 21:36 ` Hans Hagen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).