Aligned equations node inside a tikz matrix. Impossible?

View: New views
2 Messages — Rating Filter:   Alert me  

Aligned equations node inside a tikz matrix. Impossible?

by ollywoodman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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}
$
}; \\
};
================================================

Re: Aligned equations node inside a tikz matrix. Impossible?

by Mark Wibrow-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

try putting `ampersand replacement=\&' into the matrix options, and
use \& to separate columns in the matrix. Then & can be used as normal
in the aligned environment:

\matrix[row sep=2mm, column sep=2mm, ampersand replacement=\&]
{
\node [draw=black,rectangle] (test) {%
$
 \begin{aligned}
    x &= y \\
    y &= z + 2
 \end{aligned}
$
};
\\};

Regards

Mark



2009/5/31 ollywoodman <ojw28@...>:

>
> 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}
> $
> }; \\
> };
> ================================================
> --
> View this message in context: http://www.nabble.com/Aligned-equations-node-inside-a-tikz-matrix.-Impossible--tp23803823p23803823.html
> Sent from the pgf-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
> is a gathering of tech-side developers & brand creativity professionals. Meet
> the minds behind Google Creative Lab, Visual Complexity, Processing, &
> iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
> Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
> _______________________________________________
> pgf-users mailing list
> pgf-users@...
> https://lists.sourceforge.net/lists/listinfo/pgf-users
>

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
pgf-users mailing list
pgf-users@...
https://lists.sourceforge.net/lists/listinfo/pgf-users