[texhax] question about \if
Heiko Oberdiek
heiko.oberdiek at googlemail.com
Fri Nov 12 11:22:12 CET 2010
On Fri, Nov 12, 2010 at 05:31:13PM +1100, Vafa Khalighi wrote:
> \newcommand{\test}[1]{\if#1t True\fi}
> \test{t}
>
> gives "True" as expected.
>
> I want to change that so that \test{txys} gives "True" but I do not know
> how?
And what do you want to test?
* argument starts with `t',
* after expansion the first token is `t',
* the argument contains `t',
* ...
The context is important, are assigments allowed or is the
test restricted to expandable contexts?
...
Variant without expansion:
\makeatletter
\newcommand{\test}[1]{%
\expandafter\ifx\expandafter t\@car#1XX\@nil
True%
\fi
}
\makeatother
Yours sincerely
Heiko Oberdiek
More information about the texhax
mailing list