From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/84944 Path: news.gmane.org!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: Need help defining command. Date: Tue, 22 Oct 2013 11:31:26 +0200 Message-ID: <549F71B5-2659-4E3E-8DC1-301D94771017@gmail.com> References: <563CA660-912A-4857-9AA4-FB16AAD438EA@uni-trier.de> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1382434292 7593 80.91.229.3 (22 Oct 2013 09:31:32 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 22 Oct 2013 09:31:32 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Oct 22 11:31:38 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([5.39.185.229]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VYYJM-0004Qy-O8 for gctc-ntg-context-518@m.gmane.org; Tue, 22 Oct 2013 11:31:36 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id D735D10222; Tue, 22 Oct 2013 11:28:41 +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 aDTNlp9cWbOO; Tue, 22 Oct 2013 11:28:39 +0200 (CEST) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id D9ED810212; Tue, 22 Oct 2013 11:28:38 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 921E210212 for ; Tue, 22 Oct 2013 11:28:37 +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 kcNipn6lZiee for ; Tue, 22 Oct 2013 11:28:35 +0200 (CEST) Original-Received: from filter4-ams.mf.surf.net (filter4-ams.mf.surf.net [192.87.102.72]) by balder.ntg.nl (Postfix) with ESMTP id C384610210 for ; Tue, 22 Oct 2013 11:28:35 +0200 (CEST) Original-Received: from mail-ea0-x22f.google.com (mail-ea0-x22f.google.com [IPv6:2a00:1450:4013:c01::22f]) by filter4-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r9M9aRfx003565 for ; Tue, 22 Oct 2013 11:36:27 +0200 Original-Received: by mail-ea0-f175.google.com with SMTP id m14so4013816eaj.6 for ; Tue, 22 Oct 2013 02:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=c78BOzLm5unfDr6AwbOIWebnPNz3a/UhBxZ249Qj8DQ=; b=BpdAXAPcEBLgZ3kAcFAA83UXfCl7txhMnyo/0OBHF48VJvOyWbJD9hXSxykD48ywdr IoL/wJPAgzPTRpheLqW6koUpjHMKjXgEg/mdtxQPNfv5FUQaHhf5HhMNOx6p9gqEJ2Yr BD7mBNZHsTg7Ed6nU/WJNrPZGgRUzwqauWp9IR8ybIXhzNY6ED4V/nGAKX9jkV5fWbnY 9O34HKM/oPN+PvFU2U20a3jPHyH8S/G1MV/A8LRIGa9cs6mWCZ2zBBMs29QtZdXayiup FJd4EBgcec8SvaVpCUbk3NGINTHrelWddHjjUL0VSKW76+nLXnd1v0mCRWsqvvNL2Z/r +UdA== X-Received: by 10.15.68.198 with SMTP id w46mr746102eex.108.1382434288818; Tue, 22 Oct 2013 02:31:28 -0700 (PDT) Original-Received: from keima.localdomain (x2f253ad.dyn.telefonica.de. [2.242.83.173]) by mx.google.com with ESMTPSA id e13sm54584228eeu.4.2013.10.22.02.31.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 22 Oct 2013 02:31:28 -0700 (PDT) In-Reply-To: <563CA660-912A-4857-9AA4-FB16AAD438EA@uni-trier.de> X-Mailer: Apple Mail (2.1510) X-Bayes-Prob: 0.9589 (Score 4.7, tokens from: @@RPTN) X-CanIt-Geo: ip=2a00:1450:4013:c01::22f; country=IE X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 01KE9Arcc - da18641cb175 - 20131022 X-Scanned-By: CanIt (www . roaringpenguin . com) 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:84944 Archived-At: Am 22.10.2013 um 10:34 schrieb Keith J. Schultz : > HI All, > > I remember seeing some seeing what I want to do but I can not find it. > > I would like to define a command that takes an optional key-valued list and > 1 or 2 manditory ones. > > Something like > > \unexanded\def\MyCommand[#1]#2% > {% > \NassiGroupFrame[#1]{#2}% > }% \unexanded\def\MyCommand {\dosingleempty\doMyCommand} \def\doMyCommand[#1]#2% {\NassiGroupFrame[#1]{#2}} > or > > \unexanded\def\MyCommand[#1]#2% > {% > % extract keyvalue > \NassiGroupFrame[\width=\extractedvalueone]{hbox to \extractvaletwo{#2}}% > }% \unexanded\def\MyCommand {\dosingleempty\doMyCommand} \def\doMyCommand[#1]#2% {\begingroup \getdummyparameters[valueone=6cm,valuetwo=5cm,#1] \NassiGroupFrame[width=\dummyparameter{valueone}]{\hbox to \dummyparameter{valuetwo}{#2}}% \endgroup} \MyCommand[valuetwo=4cm]{...} > where \NassiGroupFrame is a Frame. > > To give you an idea why I need this see the MWE below. > This is a relatively simple example, there will be more complicated frames and > they will be nested. > > Maybe I am chasing windmills and there is a better way and I should use cld or lua for > outputing the Frames so that I can have spacing between the command and avoid having > to use "%" after the first opening "{". > Or does someone know how it can be done. Is there a way to use ConTeXt to write the command There are ways to ignore the spaces at the begin (\ignorespaces) and end (\removeunwantedspaces) of a group but you should rethink first your interface for your commands (why no start/stop commands). It can be also useful to draw the whole diagram with Metapost and use the TeX commands only to pass the content to Metapost. Wolfgang ___________________________________________________________________________________ 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 ___________________________________________________________________________________