Why does this not work in common?
\newcommand{\test}[2][]{ \node[draw, #1] {#2}; } Only if I say
\newcommand{\test}[2][]{ \begin{tikzpicture} \node[draw, #1] {#2}; \end{tikzpicture} } it works sometimes - but everytime a complete tikzpicture...?
Hint: I want so set a more complex command (contains foreach) several times into a TikZ-matrix, so the following MWE contains a TikZ-matrix.
\documentclass{article} \usepackage{tikz} \usetikzlibrary{matrix} \begin{document} \newcommand{\test}[2][]{ \node[draw, #1] {#2}; } \test{aaa} % Does not work! ================== \begin{tikzpicture} \matrix (m) [matrix of nodes, nodes in empty cells]{ a & b \\ \test{aaa} & \test[red]{bbb} \\ % Does not work! ================== }; \end{tikzpicture} \end{document} 
