This example is copied from this SO. but I wish to create a two dimension matrix with foreach loop\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage{etoolbox}
\begin{document}
\begin{tikzpicture}
\let\desc\empty
\foreach \x/\y in {a/b,b/c,c/d}{%
\xappto\desc{\expandonce{\x \\}}
%\xappto\desc{\expandonce{\x & \y \\}}
}
\matrix [matrix of nodes] {
\desc
};
\end{tikzpicture}
\end{document}
But if I open the commented line instead the one dimension version, compile will failure!
How should I modify this example to support 2-d matrix create with foreach loop?




tabstackengineis not liketikzin it graphical capabilities, so if your goal is to create a matrix and then overlay nodal "activity" upon it, it would be best to stick withtikz. – Steven B. Segletes Mar 01 '20 at 03:05