I am using the positioning TikZ library to make a commutative diagram. I am having trouble getting the bottom arrow to be horizontal.
Here is the output with my problem: the positioning library is on the left, and the output I thought I should get (done with the matrix library) is on the right. The problem is the arrow above $\psi^{-1}$
: it is not exactly horizontal on the left version of the diagram.
What am I doing wrong? Is there a reason I shouldn't be getting the same picture on the left and on the right?
And here is my code:
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\begin{document}
\[
\begin{tikzpicture}[ baseline=(current bounding box.center)]
% Tell it where the nodes are
\node (F) {$M^P \cap \pi_W^{-1}( U) $};
\node (E) [right=of F] {$V$};
\draw[->] (F)-- node [above] {\footnotesize $\pi_V$} (E);
\node (C) [below=of F] {$U \subset W$};
\draw[->] (F)-- node [left] {\footnotesize $\pi_W$} (C);
\node (B) [below=of E] {$I \times V$};
\draw[->] (C)-- node [below] {\footnotesize $\psi^{-1}$} (B);
\draw[<-] (E)-- (B);
\end{tikzpicture}
=
\begin{tikzpicture}[every node/.style={midway}, baseline=(current bounding box.center)]
\matrix[column sep={6em,between origins},
row sep={3em}] at (0,0)
{
\node (F) {$M^P \cap \pi_W^{-1}( U) $}; &
\node (E) {$V$};\\
\node (C) {$U \subset W$};&
\node (B) {$I \times V$};\\};
\draw[->] (F)-- node [above] {\footnotesize $\pi_V$} (E);
\draw[->] (F)-- node [left] {\footnotesize $\pi_W$} (C);
\draw[->] (C)-- node [below] {\footnotesize $\psi^{-1}$} (B);
\draw[<-] (E)-- (B);
\end{tikzpicture}
\]
\end{document}
tikz-cd
.below=of x
on both nodes simply positions the new node some standard distance belowx
(node distance
actually, which is1cm and 1cm
by default).below
uses the south anchor, so if one of the nodes has a greater depth it will also have a slightly lower anchor (since the centers are aligned, due to the placement usingright=of...
). This causes the new nodes to not be aligned horizontally. You can remedy this by using the center anchor explicitly. when sayingbelow=of ...
.