Consider this MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes] {
a \\
b \\
c \\
};
\end{tikzpicture}
\end{document}
It might be convenient to fill the matrix with a foreach loop:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix [matrix of nodes] {
\foreach \c in {a,b,c}{
\c \\
}
};
\end{tikzpicture}
\end{document}
This however fails with the message
! Extra }, or forgotten
\endgroup.
It seems like the ending brace of \foreach bothers the matrix node. Can a matrix be populated with \foreach and how?
&are placed in wrong or strange ways. – Martin Scharrer May 09 '17 at 13:03