I have two equations (one on top of the other) and I'd like to relate elements of the first one to elements of the second one by drawing an arrow between them.
I though of two ways to solve that:
- Place each element in a separate node, and then draw arrows between corresponding nodes.
- Have a single node for each equation (the full equation is put in the label), and find a way to get the coordinate of each element in the label.
I tried the first approach, but the horizontal spacing is odd: the node distance is obviously not the text spacing (see image below).
The second approach seems better to me (main reason: we keep the equation as a single node, which makes more sens imo), but I have no idea if it is possible to get the coordinate of a subpart of a label (and something tells me nodes should be considered as a single unsplittable element, so the solution would not be easy).
So far, using the 1st approach, I have:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\node (A) {\(A_1\)};
\node[anchor=west] at(A.east) (B) {\(= B_1 + \)};
\node[anchor=west] at(B.east) (C) {\(C_1\)};
\node[below of=A] (A') {\(A_2\)};
\node[anchor=west] at(A'.east) (B') {\(=B_2 + \)};
\node[anchor=west] at(B'.east) (C') {\(C_2\)};
\path (A) edge[<->] (A');
\path (B) edge[<->] (B');
\path (C) edge[<->] (C');
\end{tikzpicture}
\end{document}
which gives the following result (notice, for instance, the spacing on each side of the "+"):
More details:
- Vertical alignment of the equation is not a problem (i.e. it's fine if the arrows are not "vertical").
- Vertical alignment of the baseline of each element within an equation is not a problem (I know there is a relevant section in Tikz manual for this problem, so it's fine here).
- The equations should remain in the tikz picture. They are part of a kind of commutative diagram such as in here. An other way to look at the problem, based on this example is to be able to draw an arrow from below both the
Fand thexfor instance. - A solution without magic constants would be prefered: the example here is just a MWE.



\subnode, see my updated answer. – Nov 26 '19 at 16:18remember picturewhich is required than with the package itself ;-) – Bromind Nov 26 '19 at 23:54tikzmarkis quite useful! a search on pgfmanual gives no result, meanwhile the above code compile well. Why is that? – Black Mild Nov 27 '19 at 14:45\subnodeis mentioned on page 7. – Nov 27 '19 at 14:49tikzmark. It's not in the newest pgfmanual, but we still can use it ^^ I just wonder why – Black Mild Nov 27 '19 at 14:54tikzmarkis not mentioned in the pgf manual. It is a library written and maintained by LoopSpace, which is independent. There are quite a few such libraries. Apart from other master pieces by LoopSpace likeknots, thecdlibrary, which underliestikz-cd, is also not mentioned in the manual. – Nov 27 '19 at 14:56