tikz-cd, commutative-diagrams – Positioning Arrows in Commutative Diagrams Using TikZ-cd or Otherwise

commutative-diagramstikz-cd

I'm trying to make commutative diagrams to go with my math notes.
So far, I've experimented with AMScd and TikZ-cd. But here's the problem: I need to align the arrows so that I can control where their tails and heads go. For instance, I have the following diagram:

enter image description here

I need to align the ϕ arrow's tail to be directly below U and its head to be directly above ϕ(U). Similarly, for the ψ arrow.

Ideally, I'm looking for something simple (like the ampersand in the matrix, align, or eqnarray environments) because I'll need to make such diagrams throughout the document. Also, there will be more complicated diagrams with diagonal arrows!

enter image description here

I've experimented so far, unsuccessfully, with AMScd and TikZ-cd. I'm not really familiar with the TikZ package — so I haven't tried using its matrix, or graph, or whatever it is. Here is the AMScd and TikZ-cd code that generatse the first diagram (I'm not really worried about aligning the diagonal arrow):

Using AMScd:

\[
\begin{CD}
x \in U \subseteq M @>f>> f\left(x\right) \in V \subseteq N \\
@V\phi VV @VV\psi V \\
\phi\left(x\right) \in \phi\left(U\right) \subseteq \mathbb{R}^{m} @>>\psi f \phi^{-1}> \psi\left(f\left(x\right)\right) \in \psi\left(V\right) \subseteq \mathbb{R}^{n}
\end{CD}
\]

Using TikZ-cd:

\[
\begin{tikzcd}
x \in U \subseteq M \arrow{r}{f}
\arrow{d}{\phi} &
f\left(x\right) \in V \subseteq N
\arrow{d}{\psi} \\
\phi\left(x\right) \in \phi\left(U\right) \subseteq \mathbb{R}^{m}
\arrow{r}{\psi f \phi^{-1}} &
\psi\left(f\left(x\right)\right) \in \psi\left(V\right) \subseteq \mathbb{R}^{n}
\end{tikzcd}
\]

Any help would be welcome. Thanks in advance!

Best Answer

As far as tikz-cd is concerned, there is no way to point to a particular character in a cell, because all the commands refer to a cell. So there are two ways I can think of:

  • use the option shift left=<dimension> (or shift right) to manually adjust the arrows position. This will work for you because the characters in your example case are on top of each other but it's manual and it might not work for other cases. So I think in your case the best solution is the second one.

  • draw the diagram and the use tikzmark and TikZ do draw the arrows. I haven't tested this, but tikzmark has worked before inside a math environment, so it should work.

I don't know the other package so I can't speak on that. If I come up with a better solution, I'll edit the answer.