How can I create a tree node with an aligned math equations inside?


doesn't work


Gives a lot of margin and I don't want to manually tune 100.

\nodepart from shapes tikz library seems to be overkill and doesnt do the alignment.

Any ideas?

2 Answers 2


You could use an aligned environment with inline math inside nodes, their size is automatically calculated. Here's a small example with such a node in a tree:

\begin{tikzpicture}[every node/.style={rectangle,draw}]
\node {Example:}
  child {node {%
     a &= bx + c\\
     a+b &= d +1


alt text

  • Great! it works. But why align doesn't? Aug 8, 2010 at 14:26
  • 5
    align is displayed, set off normal text and centered. Here it requires a minipage environment or \parbox, so it needs specifying a width. At least for the centering.
    – Stefan Kottwitz
    Aug 8, 2010 at 14:40


As pointed out by Zarko in the comments, the text width option to the node already defines a minipage. Thus, the minipage environment is superfluous unless you want the minipage width different than the node width.

I know this is old, but, for future reference, if you want to number your equations or really want to use an align environment, you may place it inside a minipage and specify both the node text width and minipage width properties to whatever works for you.


    % These are needed to remove the vertical space around above and below
    % the align and flalign environments

    \node [rectangle, draw] (example) {Examples:};
    \node [rectangle, draw, right=1cm, text width=4cm] (eq1) at (example.east) {
                x + y &= 1 \\
                x - 2y &= 1
    \node [rectangle, draw, below=0.5cm, text width=4cm] (eq2) at (eq1.south) {
                x + y &= 2& \\
                x - 2y &= 2&
    \draw [->, line width=1pt] (example) -- (eq1);
    \draw [->, line width=1pt] (example) |- (eq2);

This example also includes flalign, since I believe it looks better than align when the node has borders.

enter image description here

  • 1
    when you define text width of node, the node behavior as minipage, consequently use of minipage in your example` is superfluous. the same result you will obtain without it.
    – Zarko
    Sep 14, 2018 at 13:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .