I am trying to define a style to help my pupils understand the resolution of equations. Nevertheless, I have two problems :
1 : I cannot make arrows of grey color between the steps of the resolution. 2 : How can I use this style intelligently to add steps to the resolution ?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes}
\begin{document}
\tikzset{
eq/.style={minimum width=3cm,rectangle},
bubble/.style={draw,help lines,ellipse},
}
%%%%%%%%%%%%%%%%%%%% What I would like to automate %%%%%%%%%%%%%%%%%%%%
\begin{tikzpicture}
\node[eq] (first) {$e=mc^2$};
\node[bubble] (left) [below left=of first] {$\times 2$};
\node[bubble] (right) [below right=of first] {$\times 2$};
\node[eq] (second) [below right=of left] {$2e=2mc^2$};
\draw[help lines] (first.west) to [out=180,in=90] (left.north);
\draw[help lines] (first.east) to [out=0,in=95] (right.north);
\draw[->,help lines] (left.south) to [out=-90,in=180] (second.west);
\draw[->,help lines] (right.south) to [out=-90,in=0] (second.east);
\node[bubble] (lleft) [below left=of second] {$-1$};
\node[bubble] (rright) [below right=of second] {$-1$};
\node[eq] (third) [below right=of lleft] {$2e-1=2mc^2-1$};
\draw[help lines] (second.west) to [out=180,in=90] (lleft.north);
\draw[help lines] (second.east) to [out=0,in=95] (rright.north);
\draw[->,help lines] (lleft.south) to [out=-90,in=180] (third.west);
\draw[->,help lines] (rright.south) to [out=-90,in=0] (third.east);
\end{tikzpicture}
\vspace{1cm}
%%%%%%%%%%%%%%%%%%%% Intent of automation %%%%%%%%%%%%%%%%%%%%
\tikzset{%
nexteq/.style n args={2}{%
append after command={
\pgfextra{\let\mainnode=\tikzlastnode}
node[bubble] (left) [below left=of \mainnode] {#1}
node[bubble] (right) [below right=of \mainnode] {#1}
node[eq] (second) [below right=of left] {#2}
(\mainnode.west) to [out=180,in=90] (left)
(\mainnode.east) to [out=0,in=95] (right.north)
(left.south) to [out=-90,in=180] (second.west)
(right.south) to [out=-90,in=0] (second.east)
},
}
}
\begin{tikzpicture}
\draw node(first) [eq,nexteq={$\times 2$}{$2e=2mc^2$}] {$e=mc2$};
\end{tikzpicture}
\end{document}
minimal
for examples - it is not intended for the purpose and causes seemingly mysterious problems.edge[help lines,out=180,in=90]
instead ofto
paths