Re: [NTGcontext] using variable for subscript in math+lua (and math+MetaFun)
Dear Gesang and Hans, Your solution is working nicely. I may use lua to simplify my other work. I'd like to ask you one more thing. I tried to write a matrix using MetaFun to add some graphics as following: label(btex $a_{11}$ etex, ( , )); label(btex $a_{12}$ etex, ( , )); label(btex $a_{13}$ etex, ( , )); … label(btex $a_{3,3}$ etex, ( , )); Since the same command is repeated, I tested to use "for" iteration. But I couldn't succeed. It is OK to use the variable as a text but I couldn't find a way to use a variable as a subscript. For example, for i=1 unto 3: label(btex decimal(i) etex, (x,y)); endfor; is OK. But, for i=1 upto 3: label(btex $a_{i}$ etex, (x,y)); endfor; or for i=1 upto 3: label(btex $a_{deciaml(i)}$ etex, (x,y)); endfor; are not working as I wanted. Is there a way to use variable as a subscript in "label"? Thank you again. Best regards, Dalyoung
On 25102012 13:59, Jeong Dal wrote:
Dear Gesang and Hans,
Your solution is working nicely. I may use lua to simplify my other work.
I'd like to ask you one more thing.
I tried to write a matrix using MetaFun to add some graphics as following:
label(btex $a_{11}$ etex, ( , )); label(btex $a_{12}$ etex, ( , )); label(btex $a_{13}$ etex, ( , )); … label(btex $a_{3,3}$ etex, ( , ));
Since the same command is repeated, I tested to use "for" iteration. But I couldn't succeed. It is OK to use the variable as a text but I couldn't find a way to use a variable as a subscript.
For example,
for i=1 unto 3: label(btex decimal(i) etex, (x,y)); endfor;
is OK. But,
for i=1 upto 3: label(btex $a_{i}$ etex, (x,y)); endfor; or for i=1 upto 3: label(btex $a_{deciaml(i)}$ etex, (x,y)); endfor;
are not working as I wanted.
Is there a way to use variable as a subscript in "label"?
play with code like this \starttext \startluacode context.startMPcode() for i=1,10 do for j=1,10 do context('draw (%scm,%scm) withpen pencircle scaled 2mm ;',i,j) context('draw thetextext.top("\\tt%s,%s",(%scm,%scm+2mm)) ;',i,j,i,j) end end context.stopMPcode() \stopluacode \stoptext  Hans Hagen  PRAGMA ADE Ridderstraat 27  8061 GH Hasselt  The Netherlands tel: 038 477 53 69  voip: 087 875 68 74  www.pragmaade.com  www.pragmapod.nl 
Dear Hans, The structure of your code is very interesting. ((((MP code) inside ConTeXt) inside Lua) inside ConTeXt) again! It is really useful. Thank you. Best regards, Dalyoung
play with code like this
\starttext
\startluacode context.startMPcode() for i=1,10 do for j=1,10 do context('draw (%scm,%scm) withpen pencircle scaled 2mm ;',i,j) context('draw thetextext.top("\\tt%s,%s",(%scm,%scm+2mm)) ;',i,j,i,j) end end context.stopMPcode() \stopluacode
\stoptext
participants (2)

Hans Hagen

Jeong Dal