3

I know that this is a duplicate to A macro that passes each word of its argument to another macro as an argument?, that's why I kept the title, but I didn't manage to get the right result when the argument that contained the words is given also as a macro.

See the code below:

\documentclass{minimal}%
\begin{document}

\def\somefigures{1 2 3 4 5 6 7 8 9}
\def\wbox#1{\boxw#1 \empty}
\def\boxw#1 #2{\fbox{#1}\ \ifx #2\empty\else\expandafter\boxw\fi #2}

\wbox{1 2 3 4 5 6 7 8 9}\bigskip

\wbox{\somefigures}

\end{document}
digital-Ink
  • 3,083

1 Answers1

6

You're short some expansion inside \wbox:

enter image description here

\documentclass{article}%
\begin{document}

\def\somefigures{1 2 3 4 5 6 7 8 9}
\def\wbox#1{\expandafter\boxw#1 \empty}% expanded #1 first
\def\boxw#1 #2{\fbox{#1}\ \ifx #2\empty\else\expandafter\boxw\fi #2}

\wbox{1 2 3 4 5 6 7 8 9}\bigskip

\wbox{\somefigures}

\end{document}
Werner
  • 603,163