ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Need help defining command.
Date: Tue, 22 Oct 2013 11:31:26 +0200	[thread overview]
Message-ID: <549F71B5-2659-4E3E-8DC1-301D94771017@gmail.com> (raw)
In-Reply-To: <563CA660-912A-4857-9AA4-FB16AAD438EA@uni-trier.de>


Am 22.10.2013 um 10:34 schrieb Keith J. Schultz <schultzk@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).

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
___________________________________________________________________________________


  reply	other threads:[~2013-10-22  9:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-22  8:34 Keith J. Schultz
2013-10-22  9:31 ` Wolfgang Schuster [this message]
2013-10-22 12:45   ` Keith J. Schultz
2013-10-22 12:50   ` Keith J. Schultz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=549F71B5-2659-4E3E-8DC1-301D94771017@gmail.com \
    --to=schuster.wolfgang@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).