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
F
and thex
for instance. - A solution without magic constants would be prefered: the example here is just a MWE.