I use tikz-pgf for typesetting my commutative diagrams. I generally use the matrix of math nodes which has the pleasant effect of ensuring that all of the entries in a row are aligned according to their baselines. Compare the two versions in the following picture, the left are aligned by their center [sic] anchors, the right by their base ones.

This works well, until one adds arrows. Unless given explicit anchors, arrows are drawn between the centres of nodes and whilst the bases of the right-hand nodes are aligned, their centres are not. So adding arrows yields the following:

Now, clearly I'm exaggerating for effect but it is noticeable even with a slight discrepancy.
One can manually add the anchors, but that's a pain (and the seemingly best anchor, mid, is ever so slightly too low: it is at .5ex above baseline but by examining \(A \to B\) I think it should be at .6ex).
So my question: can I align both nodes and arrows so that the nodes are aligned by baseline but \draw[->] (a) -- (b); just works.
Here's some code to play with:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikz[baseline]{ \node[rectangle] (a) {\(A_{\rule{1pt}{2em}}\)};
\node[rectangle] (b) at (2,0) {\(B^{\rule{1pt}{2em}}\)}; \draw[->] (a)
-- (b);}
\tikz[baseline]{ \node[anchor=base,rectangle] (a)
{\(A_{\rule{1pt}{2em}}\)}; \node[anchor=base,rectangle] (b) at (2,0)
{\(B^{\rule{1pt}{2em}}\)}; \draw[->] (a) -- (b);}
\end{document}
Note: This is an ask-and-answer question. I spent a not-insignificant amount of time hacking this this afternoon. Then I did a bit of searching to see if the question had already been asked, and while it hadn't - hence still asking - I did find that, to coin a phrase, "there's a package for that", but I didn't find the solution from that package mentioned anywhere on this site - though this problem has been seen in other answers.
