Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
add comment

2 Answers

up vote 9 down vote accepted

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:

Result

share|improve this answer
    
Thank you Martin. –  Mia Apr 4 '11 at 9:01
add comment

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:

Vertically connected boxes

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.