I'm working on a complicated set of figures using the pgfplots package. As part of the figures, I'd like to be able to create a matrix of nodes in which rows are added using a call to \pgfplotsinvokeforeach
or a similar looping command. A minimal working example achieving something very close to what I want is given below.
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17, filter discard warning=false}
\usetikzlibrary{matrix}
\newcommand{\MakeMatrix}[1]{%
\matrix (myMatrix) [ matrix of nodes ]
{
A \\
\pgfplotsinvokeforeach{#1}{
##1
} \\
};
}
\begin{document}
\begin{tikzpicture}
\MakeMatrix{B,C,D,E,F}
\end{tikzpicture}
\end{document}
The document fails to compile, however, if I move the row separator \\
inside of the \pgfplotsinvokeforeach
loop (thus achieving my ultimate goal of one row per loop iteration). I'd like to know if this is achievable with \pgfplotsinvokeforeach
(ideal) or a similar approach to looping.