What's the best way to draw loop invariants in LaTeX?

Here's one way to do it with TikZ (am I wrong in assuming the arrows are supposed to point at the separators between the boxes?):

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}
\matrix[matrix of nodes,
  name=matrix,
  draw, % Outer border
  inner sep=0pt,
  minimum width=2cm, % Width of boxes
  text depth=.5ex, % To ensure that lower edges line up correctly
  minimum height=.75cm, % Height of boxes
]{
  $<$ pivot & $\ge$ pivot & ?\\ % The nodes
};

% Separators
\draw (matrix-1-2.south west) -- (matrix-1-2.north west); 
\draw (matrix-1-3.south west) -- (matrix-1-3.north west);

% Define a style for all arrows, then draw the arrows with nodes
% This can be used to change the thickness or the tips for all arrows at once
\tikzstyle{arrowstyle}=[latex-]
\draw [arrowstyle] (matrix-1-1.south west) -- +(-90:0.8) node [anchor=north] {left};
\draw [arrowstyle] (matrix-1-2.south west) -- +(-90:0.8) node [anchor=north] {pivotLocation};
\draw [arrowstyle] (matrix-1-3.south west) -- +(-90:0.8) node [anchor=north] {i};
\draw [arrowstyle] (matrix-1-3.south east) -- +(-90:0.8) node [anchor=north] {right};-
\end{tikzpicture}

\end{document}


One could come up with similar results with just some TeX:

\documentclass{article}
\begin{document}
\vbox{
  \offinterlineskip\sf
  \def\mapup{$\Big\uparrow$}
  \halign{&\vrule\vphantom{$\bigg($}\hbox to 1.5in{\hfil#\hfil}\vrule\cr
    \noalign{\hrule}
    $<$pivot&$>=$pivot&?\cr
    \noalign{\hrule}
    \omit\mapup&\omit\llap{\mapup}&\omit\mapup&\omit\llap{\mapup}\cr
    \omit\strut Left&\omit\hidewidth\llap{pivotLocation\qquad}\hidewidth&\omit $i$&\omit\llap{Right}\cr
  }
}
\end{document}


run it with xelatex or use latex->dvips->ps2pdf

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{pst-node,tabularx,ragged2e}
\SpecialCoor
\renewcommand\tabularxcolumn[1]{>{\Centering}m{#1}}
\begin{document}

\sffamily\def\arraystretch{2}
\begin{tabularx}{\textwidth}{|X|X|X|}\hline
\rnode[lb]{l1}{}\hfill <pivot \hfill\rnode[rb]{r1}{}   & >=pivot &
\rnode[lb]{l3}{}\hfill ? \hfill\rnode[rb]{r3}{}\\\hline
\end{tabularx}
\psset{arrowscale=2,arrows=<-,offsetA=-10pt,offsetB=-15mm}
\ncline{l1}{l1}\ncline{r1}{r1}\ncline{l3}{l3}\ncline{r3}{r3}
\uput{16mm}[-90](l1){Left}
\uput{16mm}[-90](r1){pivot Location}
\uput{16mm}[-90](l3){i}
\uput{16mm}[-90](r3){Right}

\end{document}