[NTG-context] Need help defining command.

Keith J. Schultz schultzk at uni-trier.de
Tue Oct 22 14:50:47 CEST 2013


Hi Wolfgang,

Am 22.10.2013 um 11:31 schrieb Wolfgang Schuster <schuster.wolfgang at gmail.com>:

> 
> Am 22.10.2013 um 10:34 schrieb Keith J. Schultz <schultzk at uni-trier.de>:
> 
>> 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).
I thought about that, but I do not know I could use start/-commands in this context!

regards
	Keith


More information about the ntg-context mailing list