From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/78873 Path: news.gmane.org!not-for-mail From: Philipp Gesang Newsgroups: gmane.comp.tex.context Subject: Re: using variable for subscript in math+lua Date: Thu, 25 Oct 2012 03:02:55 +0200 Message-ID: <20121025010255.GB21449@phlegethon.router_intern> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0341695622==" X-Trace: ger.gmane.org 1351126992 11049 80.91.229.3 (25 Oct 2012 01:03:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 25 Oct 2012 01:03:12 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Oct 25 03:03:19 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TRBqw-0007kj-Iz for gctc-ntg-context-518@m.gmane.org; Thu, 25 Oct 2012 03:03:18 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6B27E101FF; Thu, 25 Oct 2012 03:03:10 +0200 (CEST) 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 X6vavOvE7JIC; Thu, 25 Oct 2012 03:03:07 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 48CAE101F1; Thu, 25 Oct 2012 03:03:07 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6E3B9101F1 for ; Thu, 25 Oct 2012 03:03:05 +0200 (CEST) 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 D-Vm56+1yyQn for ; Thu, 25 Oct 2012 03:03:02 +0200 (CEST) Original-Received: from filter4-til.mf.surf.net (filter4-til.mf.surf.net [194.171.167.220]) by balder.ntg.nl (Postfix) with ESMTP id 57C42101EB for ; Thu, 25 Oct 2012 03:03:02 +0200 (CEST) Original-Received: from relay2.uni-heidelberg.de (relay2.uni-heidelberg.de [129.206.210.211]) by filter4-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id q9P130bC025671 for ; Thu, 25 Oct 2012 03:03:01 +0200 Original-Received: from ix.urz.uni-heidelberg.de (cyrus-portal.urz.uni-heidelberg.de [129.206.100.176]) by relay2.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id q9P12xFn024999 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 25 Oct 2012 03:02:59 +0200 Original-Received: from extmail.urz.uni-heidelberg.de (extmail.urz.uni-heidelberg.de [129.206.100.140]) by ix.urz.uni-heidelberg.de (8.13.8/8.13.8) with ESMTP id q9P12wOJ016184 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 25 Oct 2012 03:02:58 +0200 Original-Received: from localhost (p4FFFD72D.dip.t-dialin.net [79.255.215.45]) (authenticated bits=0) by extmail.urz.uni-heidelberg.de (8.13.4/8.13.1) with ESMTP id q9P12vYd020636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO) for ; Thu, 25 Oct 2012 03:02:58 +0200 Mail-Followup-To: mailing list for ConTeXt users In-Reply-To: X-Operating-System: Linux phlegethon 3.5.6-1-ARCH X-License: "CC-BY-SA 3.0" User-Agent: Mutt/1.5.21 (2010-09-15) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=129.206.210.211; country=DE; region=01; city=Heidelberg; latitude=49.4167; longitude=8.7000; http://maps.google.com/maps?q=49.4167,8.7000&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0VIfd31TT - 6e7a88216910 - 20121025 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.220 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:78873 Archived-At: --===============0341695622== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="mojUlQ0s9EVzWg2t" Content-Disposition: inline --mojUlQ0s9EVzWg2t Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable =B7=B7=B7=B7=B7=B7=B7=B7=B7 > Dear Hans, Lucas, Wolfgang, Aditya >=20 > Now, I write a matrix using \startluacode by the helps of you. > Also, I can do some operations in matrices which reduced my typing job. > In this code, I have to give all the entries of a matrix as a table. It i= s good to use in many cases. >=20 > I have one more question. If the given array is as the following and it w= orks well. >=20 > However, there might be a better way to do job using "for" iteration. > I tired to use "i, j" in several ways but it doesn't work. =20 Inside a string the variables are just bytes. To print to a string you can interpolate with string.format() [1]. [1] http://www.lua.org/manual/5.1/manual.html#pdf-string.format =B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7= =B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7= =B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7 \startluacode document =3D document or { } -- recommended: use namespace document.print_matrix =3D function (x, y) if not y then y =3D x end -- default to square context.startmatrix{left =3D "\\left(\\,", right =3D "\\,\\right)"} local schema =3D "a_{%d%d}" -- %d: prints integer part for i=3D1, x do for j=3D1, y do --- use the template defined above to print the --- row and column context.NC(string.format(schema, i, j)) end context.NR() end context.stopmatrix() end \stopluacode \starttext \startformula \ctxlua{document.print_matrix(3)} \stopformula \startformula \ctxlua{document.print_matrix(9,4)} \stopformula \startformula \ctxlua{document.print_matrix(9)} \stopformula \stoptext \endinput =B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7= =B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7= =B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7=B7 >=20 > Is there a way to do such a job using "for" iteration? >=20 > Thank you for reading. >=20 > Best regards, >=20 > Dalyoung > _________________________________________________________________________= __________ > If your question is of interest to others as well, please add an entry to= the Wiki! >=20 > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : http://www.pragma-ade.nl / http://tex.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > _________________________________________________________________________= __________ --=20 () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments --mojUlQ0s9EVzWg2t Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAlCIj78ACgkQ02lYlJYWs9KHIwCfSC5LEWCF6tSqU5hQEB1e4XsS IP0An120JywlQFwahlxpXQW7zJWftbc+ =7BIV -----END PGP SIGNATURE----- --mojUlQ0s9EVzWg2t-- --===============0341695622== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ___________________________________________________________________________________ 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 ___________________________________________________________________________________ --===============0341695622==--