ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Taco Hoekwater <taco@elvenkind.com>
Subject: Re: special macro problem again...
Date: Thu, 17 Mar 2005 20:13:03 +0100	[thread overview]
Message-ID: <4239D6BF.8060706@elvenkind.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0503171729320.4801@gaston.free.fr>

Peter Münster wrote:
> It's a repost.
> Does anybody have an idea to solve this problem?
> If not, I'm going to buy the TeXbook...

This particular problem can be solved thus:

  \unexpanded\def\MyNumber#1#2#3{%
    \doifmode{aaa}{#1}\doifmode{bbb}{#2}\doifmode{ccc}{#3}}

There are some other syntactical possibilities, but the general
algorithm is always the same: making sure that the \expanded
within \MyMacro doesn't expand \doifmode, since \doifmode breaks
under pressure like that. You were not expected to know about that
(because this is undocumented), so you do not have to feel badly
about not owning a copy of the TeXbook. :-)

However, the TeXbook does explain the basic underlying problem,
and since the LaTeX Companion is not very helpful to ConTeXt
users <cough>, it is absolutely *the* book to buy.

Greetings, Taco


> I try to expose the problem a bit clearer:
> 
> \newcount\MyVersion
> \def\MyMacro#1{%     This macro is somewhere in an environment file.
>   \getgparameters[XXX][#1]
>   \global\advance\MyVersion by 1
>   \bTR \expanded{\bTD \the\MyVersion \eTD} \expanded{\bTD \XXXNumber \eTD}\eTR
> }
> 
> \def\MyNumber#1#2#3{% This macro is a special one for the document.
>   \doifmode{aaa}{#1}\doifmode{bbb}{#2}\doifmode{ccc}{#3}}
> 
> \enablemode[bbb]
> 
> \starttext
> \bTABLE
> \bTR \bTD Version \eTD \bTD Number \eTD \eTR
> \MyMacro{Number=123}
> \MyMacro{Number=\MyNumber{111}{222}{333}} % error: Incomplete \iffalse
> \MyMacro{Number=456}
> \eTABLE
> \stoptext
> 
> Greetings, Peter
> 

  reply	other threads:[~2005-03-17 19:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-07 20:00 Peter Münster
2005-03-17 16:45 ` Peter Münster
2005-03-17 19:13   ` Taco Hoekwater [this message]
2005-03-17 20:07     ` Peter Münster

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=4239D6BF.8060706@elvenkind.com \
    --to=taco@elvenkind.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).