# Vertically connected boxes with text and math inside them

I want to have lots of boxes (see http://www.texample.net/tikz/examples/boxes-with-text-and-math/) with text and math inside them. These boxes are arranged vertically and connected by a line.

How may I do it with LaTeX?

-
Do you want to do this using TikZ or the xy-pic package? You added the tag for both but your question links a TikZ example. IMHO there is no reason to use xy-pic. – Martin Scharrer Apr 4 '11 at 8:25
@Martin. Thanks Scharrer. TikZ – Mia Apr 4 '11 at 8:31
A sketch of the desired result would be very helpful. – ipavlic Apr 4 '11 at 8:49

Here a solution based on the TeXample you linked. It uses the positioning library to position the boxes below each other.

You need to give every box its own name (like box1, box2, ..., or any other label) so that you can reference them in the picture. Then use the drawing commands to connect them like \draw [your style] (box1) -- (box2);

### Code:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,snakes,positioning}
\usepackage{amsmath,amssymb}

\begin{document}

% Define box and box title style
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitle} =[fill=red, text=white]

\begin{tikzpicture}

% First box
\node [mybox] (box1){%
\begin{minipage}{0.50\textwidth}
To calculate the horizontal position the kinematic differential
equations are needed:
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{minipage}
};
% Fancy title of first box (remove if not required)
\node[fancytitle, right=10pt] at (box1.north west) {A fancy title};
\node[fancytitle, rounded corners] at (box1.east) {$\clubsuit$};
%
% Second Box, placed with 1cm distance below box1
\node [mybox,below=1cm of box1.south] (box2) {%
\begin{minipage}[t!]{0.5\textwidth}
Fermat's Last Theorem states that
$x^n + y^n = z^n$
has no non-zero integer solutions for $x$, $y$ and $z$ when $n > 2$.
\end{minipage}
};
% Draw a connection line between box1 and box2 with the same style like the box:
\draw [mybox] (box1) -- (box2);
% Now draw the fancy title (so that it is on top of the connection box)
\node[fancytitle] at (box2.north) {Fermat's Last Theorem};

% Third Box, placed with 1cm distance below box2
\node [mybox,below=1cm of box2.south] (box3) {%
\begin{minipage}[t!]{0.5\textwidth}
Fermat's Last Theorem states that
$x^n + y^n = z^n$
has no non-zero integer solutions for $x$, $y$ and $z$ when $n > 2$.
\end{minipage}
};
% Draw a connection line between box2 and box3 with the same style like the box:
\draw [mybox] (box2) -- (box3);
% Now draw the fancy title (so that it is on top of the connection box)
\node[fancytitle] at (box3.north) {Fermat's Last Theorem};

\end{tikzpicture}
%

\end{document}


### Result:

-
Thank you Martin. – Mia Apr 4 '11 at 9:01

What you are asking for seems very simple to achieve using TikZ. A MWE would be:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzstyle{box} = [rectangle, draw, black]
\begin{tikzpicture}
\node (first) [box] {some text, and some maths: $a = 1$};
\node (second) [box,below of=first] {other text, and some more maths: $b = 2$};
\node (third) [box,below of=second] {$c = 3$};
\draw (first) -- (second) -- (third);
\end{tikzpicture}
\end{document}
`

And here is the resulting picture:

-
Thank you. Right now, I do not have 15 reputation points to vote-up this useful answer. – Mia Apr 4 '11 at 9:03