2

Until now I always used \invokepgfplotsforeach{1,...5} successfully. Since I have some nested dynamic code all using #1, #2, #3, etc., I wanted to name the foreach's variable #1 by using \foreach.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{tikzpicture}
    \begin{axis}
        \foreach \variable \in {1,3,5} {
            \addplot {\variable*x};
        }
    \end{axis}
\end{tikzpicture}
\end{document}

Unfortunately, even this MWE leads to the following error message:

! Paragraph ended before \pgffor@@vars was complete.

The same when I am using \pgfplotsforeachungrouped instead of \foreach. What is it missing?

  • 4
    It's just in, not \in. – campa Aug 16 '17 at 14:42
  • Really...? Really! Took me hours. Thanks a lot! - Post it as answer and I can mark the question as answered. – Chickenmarkus Aug 17 '17 at 16:04
  • Additionally, I have a follow up question when using group plots: tex.stackexchange.com/questions/386988 – Chickenmarkus Aug 18 '17 at 7:11
1

As campa said in his comment:

It's just in, not \in.

|improve this answer|||||

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.