0

I'm having trouble understanding why \pgfplotsforeachungrouped is breaking in certain spots.

Why does this work:

\documentclass{article}
\usepackage{pgfplotstable}
\def\macroOne#1{
    #1
    }

\def\macroTwo#1{
    \pgfplotsforeachungrouped \x/\y in {#1}{
    \macroOne{\x}
}
}

\begin{document}
    \macroTwo{%
        1/2%
        }%
\end{document}

But this doesn't?

\documentclass{article}
\usepackage{pgfplotstable}
\def\macroOne#1{
    #1
    }

\def\macroTwo#1{
    \pgfplotsforeachungrouped \x/\y/\z in {#1}{
    \macroOne{\x}
}
}

\begin{document}
    \macroTwo{%
        1/2/3%
        }%
\end{document}

The only difference between the two is that I added in one more sub-argument into \MacroTwo and the \pgfplotsforeachungrouped. Is there a way to make \pgfplotsforeachungrouped work for more than two sub-arguments?

  • 1
    It looks as if it can handle only two variables. But you should really consider to switch to the code @egreg suggested to your other question. With expl3 such list processing is much easier -- less \expandafter and lots of useful functions available out of the box. – Ulrike Fischer May 23 '18 at 16:44
  • Ulrike is right. \pgfplotsforeachungrouped can handle only two variables. I am pretty sure that there was a question on TeX.SX already about that topic, but couldn't find it ... But in the PGFPlotsToDo.pdf one can find a bug which states: "\pgfplotsforeachungrouped cannot be combined with three or more arguments like \foreach." – Stefan Pinnow May 23 '18 at 20:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.