[Tex/LaTex] Rectangular diagram with TikZ

diagramstikz-pgf

I have a problem with getting rectangular diagrams in LaTeX. For example, the diagram below gives a diagram which looks like a trapezium. What do I need to change to get what I want ?

\begin{center}
\begin{tikzpicture}
  % Tell it where the nodes are
  \node (A) {$short expression$};
  \node (B) [below=of A] {$long expression$};
  \node (C) [right=of A] {$short expression$};
  \node (D) [right=of B] {$long expression$};
  % Tell it what arrows to draw
  \draw[-stealth] (A)-- node[left] {} (B);
  \draw[stealth-] (B)-- node [below] {} (D);
  \draw[stealth-] (A)-- node [above] {} (C);
  \draw[-stealth] (C)-- node [right] {} (D);,
\end{tikzpicture}
\end{center}

Best Answer

You need to specify a minimum width for each of the nodes so that they are all the same size. If this is something you will be doing a lot, it's easiest to create a style for this, as I've done in the example below:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[fixed/.style={minimum width={1.25in}}]

  % Tell it where the nodes are
  \node[fixed] (A) {$short expression$};
  \node[fixed] (B) [below=of A] {$long expression$};
  \node[fixed] (C) [right=of A] {$short expression$};
  \node[fixed] (D) [right=of B] {$long expression$};
  % Tell it what arrows to draw
  \draw[-stealth] (A)-- node[left] {} (B);
  \draw[stealth-] (B)-- node [below] {} (D);
  \draw[stealth-] (A)-- node [above] {} (C);
  \draw[-stealth] (C)-- node [right] {} (D);,
\end{tikzpicture}

\end{document}

This solution has a certain advantage over using the every node/.style since if you have other nodes in the drawing you may not want them all to be of the same size.