From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/65361 Path: news.gmane.org!not-for-mail From: Aditya Mahajan Newsgroups: gmane.comp.tex.context Subject: Re: How to run Typesetting in MetaPost example (MetaFun)? Date: Wed, 19 Jan 2011 12:42:42 -0500 (EST) Message-ID: References: <4D359A42.4030209@ziggo.nl> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1295458994 9380 80.91.229.12 (19 Jan 2011 17:43:14 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 19 Jan 2011 17:43:14 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Jan 19 18:43:10 2011 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 1Pfc3m-0003rG-Ns for gctc-ntg-context-518@m.gmane.org; Wed, 19 Jan 2011 18:43:06 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id EF551CAA1E; Wed, 19 Jan 2011 18:43:05 +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 y9nyULXARVuh; Wed, 19 Jan 2011 18:43:03 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 9443BCA9BC; Wed, 19 Jan 2011 18:43:03 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id DF9D7CA9BC for ; Wed, 19 Jan 2011 18:43:01 +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 EN-zZwQLZz3n for ; Wed, 19 Jan 2011 18:42:48 +0100 (CET) Original-Received: from filter7-ams.mf.surf.net (filter7-ams.mf.surf.net [192.87.102.75]) by balder.ntg.nl (Postfix) with ESMTP id D3FE9CA9B6 for ; Wed, 19 Jan 2011 18:42:48 +0100 (CET) Original-Received: from tombraider.mr.itd.umich.edu (smtp.mail.umich.edu [141.211.12.86]) by filter7-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p0JHgg5N006408 for ; Wed, 19 Jan 2011 18:42:47 +0100 Original-Received: FROM adi-netbook (Mismatch [65.94.14.230]) By tombraider.mr.itd.umich.edu ID 4D372291.18AB0.10156 ; Authuser adityam; 19 Jan 2011 12:42:41 EST In-Reply-To: <4D359A42.4030209@ziggo.nl> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=141.211.12.86; country=US; region=MI; city=Ann Arbor; postalcode=48109; latitude=42.2923; longitude=-83.7145; metrocode=505; areacode=734; http://maps.google.com/maps?q=42.2923,-83.7145&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0DDVtGGXV - 680ce8df7dcf - 20110119 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.75 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:65361 Archived-At: On Tue, 18 Jan 2011, Verhaag, G.C.H.M. wrote: > Hi, > > I wanted to try (using ConTeXt minimals MkIV) the example on page 228 of the > MetaFun manual, dealing with typesetting in MetaPost. I haven't look at the metapost manual ... but > The code is given as: > > \resetMPdrawing > \startMPdrawing > picture pic[] ; > numeric wid[], len[], pos[], n ; > wid[0] := len[0] := pos[0] := n := 0 ; > \stopMPdrawing > > \def\whatever#1% > {\appendtoks#1\to\MPtoks > \setbox\MPbox=\hbox{\bfd\the\MPtoks}% > \startMPdrawing > n := n + 1 ; len[n] := \the\wd\MPbox ; > \stopMPdrawing > \startMPdrawing[-] > pic[n] := textext("\bfd\setstrut\strut#1") ; > pic[n] := pic[n] shifted - llcorner pic[n] ; > \stopMPdrawing} > > \handletokens MetaPost is Fun!\with\whatever > > But is won't run. The following message is generated: The actual error message said ! Undefined control sequence. \@@toks ->\MPtoks So add \newtoks\MPtoks After which you get ! Undefined control sequence. \whatever ...endtoks #1\to \MPtoks \setbox \MPbox so add \newbox\MPbox After that the file compiles but you get an empty image. There are two things missing in the code. First you don't tell actually draw the metapost drawing. for that, add \MPdrawingdonetrue \getMPdrawing \resetMPdrawing Still an empty page. Again the pic[n] is calculated but never drawn. So add draw p[n] shifted (n*1cm,0) ; (or perhaps along a more sophisticated path), and now you have a working example: \newtoks\MPtoks \newbox\MPbox \resetMPdrawing \startMPdrawing picture p[] ; numeric wid[], len[], pos[], n ; wid[0] := len[0] := pos[0] := n := 0 ; \stopMPdrawing \def\whatever#1% {\appendtoks#1\to\MPtoks \setbox\MPbox=\hbox{\bfd\the\MPtoks}% \startMPdrawing n := n + 1 ; len[n] := \the\wd\MPbox ; p[n] := textext("\bfd\setstrut\strut#1") ; p[n] := p[n] shifted - llcorner p[n] ; draw p[n] shifted (n*1cm,0) ; \stopMPdrawing} \starttext \handletokens MetaPost is Fun!\with\whatever \MPdrawingdonetrue \getMPdrawing \resetMPdrawing \stoptext You could also have just used the macros from meta-txt: \useMPlibrary[txt] \startMPdefinitions newpath RotPath ; RotPath = fullcircle scaled 3cm ; \stopMPdefinitions \starttext \followtokens{Metapost is fun \quad} \stoptext @Hans: Perhaps we can have a more ConTeXtist interface to this macro: \definetextonepath [whatever] [color=..., style=..., mp=..., % path specification ] \whatever{Metapost is fun} Aditya ___________________________________________________________________________________ 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 ___________________________________________________________________________________