From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/56278 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: Formatting numbers in LuaTeX Date: Sun, 14 Feb 2010 22:01:56 +0100 Message-ID: <4B7864C4.6030009@wxs.nl> References: <6B43096F-E43D-4492-BDB7-ED22DAE97ECE@rz-online.de> <20100214121138.GA13222@gaston.couberia.bzh> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252"; Format="flowed" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1266181364 21881 80.91.229.12 (14 Feb 2010 21:02:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Feb 2010 21:02:44 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Sun Feb 14 22:02:40 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Nglbz-0006Wh-9v for gctc-ntg-context-518@m.gmane.org; Sun, 14 Feb 2010 22:02:39 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 67042C9D6D; Sun, 14 Feb 2010 22:02:31 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id vYei+NuC9UZd; Sun, 14 Feb 2010 22:02:28 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 4C83CC9CCD; Sun, 14 Feb 2010 22:02:27 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A1D6EC9C97 for ; Sun, 14 Feb 2010 22:02:23 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 2AINziXu1uTd for ; Sun, 14 Feb 2010 22:02:01 +0100 (CET) Original-Received: from mail.solcon.net (dsl-083-247-100-017.solcon.nl [83.247.100.17]) by balder.ntg.nl (Postfix) with ESMTP id 911F1C9CCD for ; Sun, 14 Feb 2010 22:01:58 +0100 (CET) X-Default-Received-SPF: pass (skip=loggedin (res=PASS)) x-ip-name=10.100.1.194; Original-Received: from [10.100.1.194] (unverified [10.100.1.194]) by controller-9 (SurgeMail 4.2d2) with ESMTP id 5950-1713362 for multiple; Sun, 14 Feb 2010 22:01:02 +0100 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1 In-Reply-To: X-Authenticated-User: hagen@controller-9 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:56278 Archived-At: On 14-2-2010 14:10, Andreas Harder wrote: > \startluacode > local floor =3D math.floor > local round =3D function(n) return floor(1000*n+0.5)/1000 end > > sqrt =3D math.sqrt > pi =3D math.pi > function my_equation(s, r) > r =3D round(r) > r =3D tostring(r) > tex.print(s:gsub("*", "$=B7$") .. "=3D" .. r:gsub("%.", ",")) > end > \stopluacode beware, this creates (and possibly overloads) sqrt, pi and my_equation = as gobals Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- ___________________________________________________________________________= ________ If your question is of interest to others as well, please add an entry to t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________