[NTG-context] Macro in a macro with optional argument

luigi scarso luigi.scarso at gmail.com
Tue Feb 12 10:05:04 CET 2019


On Tue, Feb 12, 2019 at 8:27 AM Pierre-Francois Bonnefoi <
bonnefoi.pf at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20190212/4389a049/attachment.html>


More information about the ntg-context mailing list