ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: luigi scarso <luigi.scarso@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: LuaTeX & printf() function ?
Date: Fri, 23 Jul 2010 22:38:40 +0200	[thread overview]
Message-ID: <AANLkTin4sDosDdp9nq6176AnxcV+z1Apb4ZRr14VWFkG@mail.gmail.com> (raw)
In-Reply-To: <AANLkTimsSVvoY=Oc6v6UC0fDwqs1J=Fmqg_DQeEvtgXN@mail.gmail.com>

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
___________________________________________________________________________________

  reply	other threads:[~2010-07-23 20:38 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 [this message]
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

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=AANLkTin4sDosDdp9nq6176AnxcV+z1Apb4ZRr14VWFkG@mail.gmail.com \
    --to=luigi.scarso@gmail.com \
    --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).