0

I have a problem with foreach loop. When I pass parameters as list with '/' used as separator it works really well. However when any element in that list is defined with \def the separator seems to not work and the strings are concatenated.

\newcommand{\testme}[1]{
\foreach \aa/\bb in {#1} { 
    |\aa| |\bb| \newline
    }
}

\def\testmedef{{xyz}/{XYZ}}

\testme{
    {abc}/{CDE},
    \testmedef%
}

Result:

|abc|CDE|
|xyz/XYZ|xyz/XYZ|

Thank you for your kind help!

4

1 Answer 1

1

you can call:

\newcommand{\testme}[1]{
\foreach \aa/\bb in {#1} { 
    |\aa| |\bb| \newline
    }
}

\def\testmedef{{xyz}/{XYZ}}

\ExplSyntaxOn
  \cs_set_eq:NN \expandx \exp_args:Nx
\ExplSyntaxOff
\def\testmedef{{xyz}/{XYZ}}
\expandx\testme{abc/CDE,\testmedef}

3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .