Similar to the situation described in Expand after all that stuff?, I have a macro looking like
\somecommand{Some Argument}{\secondarg}.
I also need to expand the argument \secondarg
before using it in \somecommand
. The solution with etextools
,
\usepackage{etextools}
\expandnext{\somecommand{Some Argument}}{\secondarg},
proposed by Martin Scharrer, is fine for me.
However, my problem is that instead of \secondarg
I have the construction defined as
\expandafter\newcommand\csname secondarg\the\value{mycounter}\endcsname{Second argument 1}.
If I simply replace \secondarg
by \csname secondarg\the\value{mycounter}\endcsname
, the result looks such as the argument is not expanded. Is there an easy way to expand it correctly, maybe by rewriting the example with etextools
?
Best Answer
replace
by
(you usually need 2^n-1
\expandafter
for some value of n )To get the three
\expandafter
in the right place you could do:which produces
showing that
hello
was passed as argument.Or for the modified version requested in comments:
which fully expands
#2
and expands#3
twice producing