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:

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}

Using TikZ-cd:

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}

Any help would be welcome. Thanks in advance!

  • Could you please complete the code fragments so we have compilable code?
    – cfr
    Commented Jan 15, 2016 at 1:04

2 Answers 2


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.

  • Maybe mention \subnode? (I assume tikz-cd uses nodes inside a tikzpicture so it isn't just a maths environment but also inside a node. Or am I wrong about that?)
    – cfr
    Commented Jan 15, 2016 at 1:11
  • @cfr I have no way to test that at the moment. But even then, how would you draw the arrow?
    – Alenanno
    Commented Jan 15, 2016 at 1:12
  • Just as usual. The point is you can't use a regular \tikzmark inside a node, I don't think.
    – cfr
    Commented Jan 15, 2016 at 1:27
  • @cfr I understand what you mean.
    – Alenanno
    Commented Jan 15, 2016 at 1:41
  • I added an example. They're easier to use in a way, I guess, as they are more like regular nodes... but different. At least, you don't have to remember whether it is pic cs or cs pic which I always get wrong.
    – cfr
    Commented Jan 15, 2016 at 1:49

If you use tikzmark, you will want to use \subnode[]{}{}, I think, because you are using it inside, I believe, a node and PGF doesn't know anything about the contents of nodes but just treats them as boxes. \subnode boxes the content and keeps track of where it is. You can use this in the same picture environment as you would a normal node. Here, however, you probably want to overlay the arrows you need to add. For example:

  x \in \subnode{u1}{$U$} \subseteq M \arrow{r}{f} & f(x) \in V \subseteq \tikzmark{n}{N} \arrow{d}{\psi} \\
  \phi(x) \in \subnode{u2}{$\phi(U)$} \subseteq \mathbb{R}^{m} \arrow{r}{\psi f \phi^{-1}} & \psi(f(x)) \in \psi(V) \subseteq \mathbb{R}^{n}
\begin{tikzpicture}[overlay, remember picture]
  \draw [->] (u1) edge ["$\phi$", right] (u2.north -| u1);


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .