From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/65367 Path: news.gmane.org!not-for-mail From: "Verhaag, G.C.H.M." Newsgroups: gmane.comp.tex.context Subject: Re: How to run Typesetting in MetaPost example (MetaFun)? Date: Thu, 20 Jan 2011 10:59:59 +0100 Message-ID: <4D38079F.2010401@ziggo.nl> 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 1295518176 20669 80.91.229.12 (20 Jan 2011 10:09:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 20 Jan 2011 10:09:36 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Jan 20 11:09:32 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 1PfrSO-000327-7F for gctc-ntg-context-518@m.gmane.org; Thu, 20 Jan 2011 11:09:32 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 931BECAA05; Thu, 20 Jan 2011 11:09: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 grRZQhaIK8gu; Thu, 20 Jan 2011 11:09:28 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 67338CA9C1; Thu, 20 Jan 2011 11:09:28 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 6B9D9CA9C1 for ; Thu, 20 Jan 2011 11:09:26 +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 HaqIlRQahIds for ; Thu, 20 Jan 2011 11:09:14 +0100 (CET) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id D8BB9CA9C0 for ; Thu, 20 Jan 2011 11:09:14 +0100 (CET) Original-Received: from smtpq3.gn.mail.iss.as9143.net (smtpq3.gn.mail.iss.as9143.net [212.54.34.166]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id p0KA9EdC030280 for ; Thu, 20 Jan 2011 11:09:14 +0100 Original-Received: from [212.54.34.143] (helo=smtp12.gn.mail.iss.as9143.net) by smtpq3.gn.mail.iss.as9143.net with esmtp (Exim 4.71) (envelope-from ) id 1PfrS6-0002iu-9f for ntg-context@ntg.nl; Thu, 20 Jan 2011 11:09:14 +0100 Original-Received: from 541c2cdc.cm-5-5a.dynamic.ziggo.nl ([84.28.44.220]) by smtp12.gn.mail.iss.as9143.net with esmtp (Exim 4.71) (envelope-from ) id 1PfrFM-0004s2-Fl for ntg-context@ntg.nl; Thu, 20 Jan 2011 10:56:04 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1 X-Accept-Language: en In-Reply-To: X-ZiggoSMTP-MailScanner-Information: Please contact the ISP for more information X-ZiggoSMTP-MailScanner-ID: 1PfrFM-0004s2-Fl X-ZiggoSMTP-MailScanner: Found to be clean X-ZiggoSMTP-MailScanner-SpamCheck: geen spam, SpamAssassin (niet cached, score=0.177, vereist 5, ALL_TRUSTED -1.00, BAYES_20 -0.00, HELO_DYNAMIC_DHCP 0.21, RDNS_DYNAMIC 0.98, T_RP_MATCHES_RCVD -0.01) X-ZiggoSMTP-MailScanner-From: verhaaggchm@ziggo.nl X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=212.54.34.166; country=NL; region=05; city=Maastricht; latitude=50.8500; longitude=5.6833; http://maps.google.com/maps?q=50.8500,5.6833&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0rDVK9eM2 - 75fa8125fdc7 - 20110120 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 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:65367 Archived-At: Aditya Mahajan wrote: > 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 Hi, Okay, that makes things more clear, but couldn't find this in the manual! Maybe it is very obvious to someone more familiar with METAPOST. Well, I also tried the nice macro example on page 232 of the MetaFun manual by Hans, and got of course the same problems. But after I added the \newtoks\MPtoks \newbox\MPbox definitions to the file, it worked! Also the Inkscape alternative is very useful, thanks for helping me out! Regards, Gerard ___________________________________________________________________________________ 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 ___________________________________________________________________________________