From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/52283 Path: news.gmane.org!not-for-mail From: Andreas Harder Newsgroups: gmane.comp.tex.context Subject: Re: =?windows-1252?q?loop_textext_and_=5CMPstring=7B=85?= =?windows-1252?q?=7D?= Date: Thu, 13 Aug 2009 18:41:53 +0200 Message-ID: References: <4409ACEE-4337-45DC-8DC2-9EEC858B8C5C@uni-koblenz.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 (Apple Message framework v936) Content-Type: multipart/mixed; boundary="===============2067649084==" X-Trace: ger.gmane.org 1250181734 3302 80.91.229.12 (13 Aug 2009 16:42:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 13 Aug 2009 16:42:14 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Aug 13 18:42:07 2009 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.50) id 1MbdNN-00061U-Su for gctc-ntg-context-518@m.gmane.org; Thu, 13 Aug 2009 18:42:05 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 02741C9A97; Thu, 13 Aug 2009 18:42: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 aniJPhiiN3dT; Thu, 13 Aug 2009 18:42:00 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id DE762C9A8A; Thu, 13 Aug 2009 18:42:00 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 27602C9A8A for ; Thu, 13 Aug 2009 18:41:59 +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 llkiq-QbyJv8 for ; Thu, 13 Aug 2009 18:41:57 +0200 (CEST) Original-Received: from deliver.uni-koblenz.de (deliver.uni-koblenz.de [141.26.64.15]) by balder.ntg.nl (Postfix) with ESMTP id 1332FC9A86 for ; Thu, 13 Aug 2009 18:41:57 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by deliver.uni-koblenz.de (Postfix) with ESMTP id E711578A12E3 for ; Thu, 13 Aug 2009 18:41:56 +0200 (CEST) Original-Received: from deliver.uni-koblenz.de ([127.0.0.1]) by localhost (deliver.uni-koblenz.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 16531-01 for ; Thu, 13 Aug 2009 18:41:54 +0200 (CEST) X-CHKRCPT: Envelopesender vrfy aharder@uni-koblenz.de Original-Received: from [192.168.1.102] (77-23-29-222-dynip.superkabel.de [77.23.29.222]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by deliver.uni-koblenz.de (Postfix) with ESMTP id 55C2278A13A1 for ; Thu, 13 Aug 2009 18:41:54 +0200 (CEST) In-Reply-To: X-Mailer: Apple Mail (2.936) X-Virus-Scanned: amavisd-new at uni-koblenz.de 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:52283 Archived-At: --===============2067649084== Content-Type: multipart/alternative; boundary=Apple-Mail-1--855909412 --Apple-Mail-1--855909412 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Am 13.08.2009 um 05:00 schrieb Aditya Mahajan: > You just need to work a little harder. > > \startbuffer[1] > This is a test > \stopbuffer > > \startbuffer[2] > Another test > \stopbuffer > > \startbuffer[3] > And again > \stopbuffer > > \startluacode > userdata = userdata or {} > function userdata.shift(i) > return "(" .. i .. "cm ," .. i .. "cm )" > end > > function userdata.buffers(i) > local idx = string.format("%s",i) > local b = buffers.data[idx] > if b then > if type(b) == "table" then > return table.concat(b) > else > return b > end > else > return "unknown" > end > end > > function userdata.draw_buffer(i) > return "draw btex " .. userdata.buffers(i) .. " etex shifted ".. > userdata.shift(i) .. ";" > end > \stopluacode > > \starttext > > > \startluacode > > context.startMPpage({offset = "1ex", width = [[\paperwidth]], > height = [[\paperheight]]}) > for i = 1,3 do > context(userdata.draw_buffer(i)) > end > context.stopMPpage() > \stopluacode > > \stoptext Thank you very much! I played today (a couple of hours) with your solution and adapted some things, so if someone is interested, I've attached the file. PS. I like the math.random() function I found in the Lua manual. Andreas --Apple-Mail-1--855909412 Content-Type: multipart/mixed; boundary=Apple-Mail-2--855909411 --Apple-Mail-2--855909411 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable
Am 13.08.2009 um = 05:00 schrieb Aditya Mahajan:

You = just need to work a little harder.

\startbuffer[1]
This is a = test
\stopbuffer

\startbuffer[2]
Another = test
\stopbuffer

\startbuffer[3]
And = again
\stopbuffer

\startluacode
 userdata =3D = userdata or {}
 function userdata.shift(i)
=    return "(" .. i .. "cm ," .. i .. "cm )"
=  end

 function userdata.buffers(i)
=    local idx =3D string.format("%s",i)
=    local b =3D buffers.data[idx]
   if = b then
     if type(b) =3D=3D "table" = then
       return = table.concat(b)
     else
=        return b
=      end
   else
=      return "unknown"
=    end
 end

 function = userdata.draw_buffer(i)
   return "draw btex " .. = userdata.buffers(i) .. " etex  shifted ".. userdata.shift(i) .. = ";"
=  end
\stopluacode

\starttext


\startluacode
 context.startMPpage({offset =3D "1ex", width =3D = [[\paperwidth]], height =3D [[\paperheight]]})
   for = i =3D 1,3 do
=      context(userdata.draw_buffer(i))
=    end
=  context.stopMPpage()
\stopluacode

\stoptext

Than= k you very much!

I played today (a couple of = hours) with your solution and adapted some things, so if someone is = interested, I've attached the = file.

= --Apple-Mail-2--855909411 Content-Disposition: attachment; filename=MP-Luatext2.tex Content-Type: application/x-tex; x-unix-mode=0644; name="MP-Luatext2.tex" Content-Transfer-Encoding: quoted-printable %=20<>=20=0A=0A%=20= \setuplanguage[de][lefthyphenmin=3D2,righthyphenmin=3D3]=0A=0A= \mainlanguage[de]=0A=0A\setuplayout[middle]=0A=0A= \definefontfeature[default][default][=0A=20=20mode=3Dnode,=0A=20=20= protrusion=3Dquality,=0A=20=20expansion=3Dquality,=0A=20=20= onum=3Dyes,pnum=3Dyes]=0A=0A%=20\usemodule[simplefonts][size=3D10pt]=0A=0A= %=20\setmainfont[Myriad=20Pro]=0A%=20\setmathfont[Cambria]=0A=0A= \setupbodyfont[ss,10pt]=0A=0A\setupinterlinespace[line=3D2.6ex]=0A=0A= \definefont[big][Serif=20at=20.25\vsize]=0A=0A=0A%%%%=20Buffer=20with=20= quotes=0A=0A\startbuffer[1]=0A=20=20Ohne=20Enthusiasmus=20keine=20= Mathematik!\hfill=20\mbox{(J.\,W.=20von=20Goethe)}\par=0A\stopbuffer=0A=0A= \startbuffer[2]=0A=20=20Es=20gibt=20Dinge,=20die=20den=20meisten=20= Menschen=20unglaublich=20erscheinen,=20die=0A=20=20nicht=20Mathematik=20= studiert=20haben.\hfill=0A=20=20(Archimedes,=20ca.=20285--212=20= v.\,Chr.)=20\par=20=0A\stopbuffer=0A=0A\startbuffer[3]=0A=20=20Reden=20= lernt=20man=20durch=20Reden.=20Beweisen=20lernt=20man=20durch=20= Beweisen!\hfill=0A=20=20\mbox{(mathem.=20Folklore)}\par=0A\stopbuffer=0A=0A= \startbuffer[4]=0A=20=20In=20der=20Mathematik=20gibt=20es=20keine=20= Autorit=C3=A4ten.=20Das=20einzige=20Argument=0A=20=20f=C3=BCr=20die=20= Wahrheit=20ist=20der=20Beweis.=20\hfill=20\mbox{(K.=20Urbanik)}\par=0A= \stopbuffer=0A=0A\startbuffer[5]=0A=20=20Die=20erste=20Regel,=20an=20die=20= man=20sich=20in=20der=20Mathematik=20halten=20muss,=20ist,=0A=20=20exakt=20= zu=20sein.=20Die=20zweite=20Regel=20ist,=20klar=20und=20deutlich=20zu=20= sein=20und=0A=20=20nach=20M=C3=B6glichkeit=20einfach.\hfill=20= \mbox{(L.\,N.\,M.=20Carnot)}\par=0A\stopbuffer=0A=0A\startbuffer[6]=0A=20= =20Vergesst=20nicht:=20Wenn=20ihr=20schwimmen=20lernen=20wollt,=20dann=20= geht=20mutig=20ins=0A=20=20Wasser,=20wenn=20ihr=20lernen=20wollt,=20= Aufgaben=20zu=20l=C3=B6sen,=20dann=20l=C3=B6st=0A=20=20sie.\hfill=20= \mbox{(G.=20Polya)}\par=0A\stopbuffer=0A=0A\startbuffer[7]=0A=20=20= Niemand=20soll=20uns=20aus=20dem=20Paradies=20(der=20Mengentheorie)=20= vertreiben,=0A=20=20das=20Cantor=20f=C3=BCr=20uns=20erschaffen=20= hat.\hfill=20\mbox{(D.=20Hilbert=0A=20=20=20=201862--1943)}\par=0A= \stopbuffer=0A=0A\startbuffer[8]=0A=20=20Wenn=20$A$=20gleich=20Erfolg=20= ist,=20dann=20gilt=20die=20Formel=20$A=20=3D=20x+y+z$;=20$x$=0A=20=20ist=20= Arbeit,=20$y$=20ist=20Vergn=C3=BCgen,=20$z$=20ist=20Mund=20halten.\hfill=20= \mbox{(A.=0A=20=20=20=20Einstein=201879--1955)}\par=0A\stopbuffer=0A=0A= \startbuffer[9]=0A=20=20Wenn=20ich=20ungl=C3=BCcklich=20bin,=20betreibe=20= ich=20Mathematik,=20um=20gl=C3=BCcklich=20zu=0A=20=20werden.=20Wenn=20= ich=20gl=C3=BCcklich=20bin,=20betreibe=20ich=20Mathematik,=20um=0A=20=20= gl=C3=BCcklich=20zu=20bleiben.\hfill=20\mbox{(Alfred=20Renyi=0A=20=20=20=20= 1921--1970)}\par=0A\stopbuffer=0A=0A\startbuffer[10]=0A=20=20Lernen=20= ohne=20zu=20denken=20ist=20eitel.=20Denken=20ohne=20zu=20lernen=20ist=0A=20= =20gef=C3=A4hrlich.\hfill=20(Konfuzius=20551--479=20v.\,Chr.)=20\par=0A= \stopbuffer=0A=0A\startbuffer[11]=0A=20=20Mathematik=20ist=20die=20= Wissenschaft=20der=20jungen=20Leute.=20Es=20kann=20gar=20nicht=0A=20=20= anders=20sein.=20Mathematik=20ist=20eine=20solche=20Gymnastik=20f=C3=BCr=20= den=20Verstand,=0A=20=20dass=20man=20daf=C3=BCr=20die=20ganze=20= Flexibilit=C3=A4t=20und=20Ausdauer=20der=20Jugend=0A=20=20= ben=C3=B6tigt.\hfill=20\mbox{(N.=20Wiener=201894--1964)}\par=0A= \stopbuffer=0A=0A\startbuffer[12]=0A=20=20Das=20Leben=20ist=20nur=20f=C3=BC= r=20zwei=20Dinge=20gut:=20Mathematik=20zu=20entdecken=20und=0A=20=20= Mathematik=20zu=20lernen.\hfill=20\mbox{(S.-D.=20Poisson=20= 1781--1840)}\par=0A\stopbuffer=0A=0A=0A%%%%=20text=20appearappearance=0A=0A= \setupframed[=0A=20=20width=3D\dimexpr(.62\hsize/3+2ex),=0A=20=20= align=3D{right,hz,hanging},=0A=20=20offset=3D1ex,=0A=20=20corner=3Dround]=0A= =0A=0A%%%%=20Lua=20code=20from=20Aditya=20Mahajan=0A=0A\startluacode=0A=20= =20userdata=20=3D=20userdata=20or=20{}=0A=20=20=0A=20=20function=20= userdata.buffers(i)=0A=20=20=20=20=20local=20idx=20=3D=20= string.format("%s",i)=0A=20=20=20=20=20local=20b=20=3D=20= buffers.data[idx]=0A=20=20=20=20=20if=20b=20then=0A=20=20=20=20=20=20=20=20= if=20type(b)=20=3D=3D=20"table"=20then=0A=20=20=20=20=20=20=20=20=20=20=20= return=20table.concat(b)=0A=20=20=20=20=20=20=20=20else=0A=20=20=20=20=20= =20=20=20=20=20=20return=20b=0A=20=20=20=20=20=20=20=20end=0A=20=20=20=20= =20else=0A=20=20=20=20=20=20=20=20return=20"unknown"=0A=20=20=20=20=20= end=0A=20=20end=0A=20=20=0A=20=20function=20userdata.draw_buffer(i)=0A=20= =20=20=20=20return=0A=20=20=20=20=20"draw=20= textext(\"\\framed{\\ignorespaces=20"=0A=20=20=20=20=20=20=20..=20= userdata.buffers(i)=20..=20"=20}\")=20"=0A=20=20end=0A\stopluacode=0A=0A=0A= \startluacode=0A=20=20context.startuseMPgraphic("boxen")=0A=20=20=20=20= context("w:=3D\the\hsize/3;=20h:=3D\the\vsize/4;=20pair=20punkt;=20= transform=20t;")=0A=20=20=20=20context("path=20box;=20=20box=20:=3D=20= unitsquare=20xscaled=20w=20yscaled=20h;")=0A=20=20=20=20=0A=20=20=20=20k=20= =3D=200=0A=20=20=20=20for=20i=20=3D=201,3=20do=0A=20=20=20=20=20=20for=20= j=20=3D=201,4=20do=0A=20=20=20=20=20=20=20=20k=20=3D=20k=20+=201=0A=20=20= =20=20=20=20=20=20r=20=3D=20math.random(-10,10)=0A=20=20=20=20=20=20=20=20= context("punkt=20:=3D=20("=20..=20i=20..=20"*w,"=20..=20j=20..=20"*h)=20= ;")=0A=20=20=20=20=20=20=20=20context("t=20:=3D=20identity=20= shifted(punkt=20+=20center=20box=20+=20("=20..=20r*2=20..=20","=20..=20= r*2=20.."))=20rotatedaround(punkt+center=20box,=20"=20..=20r=20..=20")=20= ;")=0A=20=20=20=20=20=20=20=20--context("draw=20box=20shifted=20punkt=20= withcolor=20.5red=20;")=0A=20=20=20=20=20=20=20=20context("draw=20= textext(\"\\big\\gray=20"=20..=20k=20..=20"\")=20transformed=20t=20;")=0A= =20=20=20=20=20=20=20=20context(userdata.draw_buffer(k)=20..=20"=20= transformed=20t=20;")=0A=20=20=20=20=20=20end=0A=20=20=20=20end=0A=20=20= context.stopuseMPgraphic()=0A\stopluacode=0A=0A=0A= \defineoverlay[Hintergrund]{\useMPgraphic{boxen}}=0A=0A= \setupbackgrounds[text][background=3DHintergrund]=0A=0A=0A\starttext=20= \showframe=0A=0A=0A\stoptext=0A=0A%%%=20Local=20Variables:=20=0A%%%=20= mode:=20context=0A%%%=20TeX-master:=20t=0A%%%=20End:=20=0A%<>=0A= --Apple-Mail-2--855909411 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: 7bit

PS. I like the math.random() function I found in the Lua manual.

Andreas
--Apple-Mail-2--855909411-- --Apple-Mail-1--855909412-- --===============2067649084== 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 : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________ --===============2067649084==--