From: luigi scarso <luigi.scarso@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Macro in a macro with optional argument
Date: Tue, 12 Feb 2019 10:05:04 +0100 [thread overview]
Message-ID: <CAG5iGsBg+DJ-zxW9Gfv0CdCyxnzHE-kUxf8AsHQ_+MH1Aeffzg@mail.gmail.com> (raw)
In-Reply-To: <AC721F19-398B-4FED-BB07-55969B7D716A@unilim.fr>
[-- Attachment #1.1: Type: text/plain, Size: 1056 bytes --]
On Tue, Feb 12, 2019 at 8:27 AM Pierre-Francois Bonnefoi <
bonnefoi.pf@gmail.com> wrote:
> Hello,
>
> I try to define automatically some macros to include cliparts in my TikZ
> drawings and I've defined the following macro :
>
> \def\clipart#1#2{%
> \expandafter\def\csname tk#1\endcsname{\dosingleempty\expandafter\csname
> dotk#1\endcsname}%
> \expandafter\def\csname
> dotk#1\endcsname[##1]{\iffirstargument\image{cisco/#1}{##1}\else\image{cisco/#1}{#2}\fi}
> }
>
> \clipart{pc}{.8} % defines the macro \tkpc to include the picture
> "cisco/pc"
>
> The issue arises when I use the newly defined \tkpc : the argument is not
> optional and I have to put \kpc[.5] for example.
> To add insult to injury, the value passed in argument is ignored also :
> \iffirtargument return always false...
>
> Do you have any idea ?
>
> Best regards,
> Pierre-François.
>
could be that \dosingleempty sees \expandafter ?
try
\expandafter\def\csname tk#1\endcsname{\dosingleempty{\expandafter\csname
dotk#1\endcsname}}%
--
luigi
[-- Attachment #1.2: Type: text/html, Size: 1606 bytes --]
[-- Attachment #2: Type: text/plain, Size: 493 bytes --]
___________________________________________________________________________________
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2019-02-12 9:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-11 11:35 Pierre-Francois Bonnefoi
2019-02-12 9:05 ` luigi scarso [this message]
2019-02-12 16:38 ` Wolfgang Schuster
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=CAG5iGsBg+DJ-zxW9Gfv0CdCyxnzHE-kUxf8AsHQ_+MH1Aeffzg@mail.gmail.com \
--to=luigi.scarso@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).