From: Vnpenguin <vnpenguin@vnoss.org>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: LuaTeX & printf() function ?
Date: Fri, 23 Jul 2010 22:53:01 +0200 [thread overview]
Message-ID: <AANLkTi=wVv93-6OuphHjxDcEEwJ3H2ecjL1x5hnZ1VJ8@mail.gmail.com> (raw)
In-Reply-To: <AANLkTikYx9c-D-V93f2DKMqjZ7Ndxh13=uR3_7zhxBkv@mail.gmail.com>
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
___________________________________________________________________________________
next prev parent reply other threads:[~2010-07-23 20:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-23 20:25 Vnpenguin
2010-07-23 20:38 ` luigi scarso
2010-07-23 20:39 ` luigi scarso
2010-07-23 20:53 ` Vnpenguin [this message]
2010-07-23 21:23 ` Hans Hagen
2010-07-23 21:29 ` Vnpenguin
2010-07-23 21:36 ` Hans Hagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTi=wVv93-6OuphHjxDcEEwJ3H2ecjL1x5hnZ1VJ8@mail.gmail.com' \
--to=vnpenguin@vnoss.org \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).