Aligned equations node inside a tikz matrix. Impossible?
I have run into a problem using Tikz. I want to create a node containing a number of equations, which I want to be vertically aligned (so that the equals sign on each line is aligned). I can successfully achieve this using "aligned" in the amsmath package (minimal example is shown in (A) below).
My problem is that I then want to use this node within a tikz matrix. When you try and do this (minimal example shown in (B) below). the alignment no longer works. I think the problem is that the matrix is getting confused by the & signs used to achieve the aligment in the aligned environment. I have also tried using align and eqnarray (inside minipage) instead of aligned, but since they also use & to align equations, the same problem occurs.
Surely this is either a bug or a problem. Does anyone know of a solution?
=== (A) A working example of aligned equations within a node ===
\node [draw=black,rectangle] (test) {%
$
\begin{aligned}
x &= y \\
y &= z + 2
\end{aligned}
$
};
================================================
=== (B) Broken alignment when the node is used in a matrix ====
\matrix[row sep=2mm, column sep=2mm]
{
\node [draw=black,rectangle] (test) {%
$
\begin{aligned}
x &= y \\
y &= z + 2
\end{aligned}
$
}; \\
};
================================================