Equation connected by lines

I have written a code that defines a new environment in which aligned equation are connected by lines as in the image:

I think it is useful when, inside the align environment, there is the need of splitting on step in more than one line like in this second example:

It uses tikz and amsmath packages. Lines can connect also different math sign than = and the line width is customizable.

My questions are:

1. I initially wrote this code for learning but then I search for packages that already include this feature and I didn't find anything. Do you know if there exist such a package?
2. Do you think it is a useful feature? How can I improve it?
3. If the answer to second point is "yes", do you think it's better to write a package with this feature or to suggest its insertion into the amsmath package?

EDIT

The \vdotswithin feature provided by the mathtools is different because it adds the vdots in a separated line:

\usepackage{mathtools}
\begin{align*}
\prod_{z^n=-1}(w_1(z)^n+1) &= \prod_{z^n=-1}(w_1(z)^n+1) + \prod_{z^n=-1}(w_1(z)^n+1) \\
&\vdotswithin{=}\\
&= \prod_{z^n=-1}(w_1(z)^n+1)
\end{align*}


• Nice. Maybe it could be added to mathtools? The latter has \vdotswithin, which can be used to put vdots between = signs or elsewhere. – Alex Aug 27 '13 at 15:42
• How come I didn't see this before? While I write something like this on the blackboard, I would never use it in a printed document: it's easy to lose one's tracks on a wide board, not on a finely printed document. – egreg Oct 18 '13 at 9:06
• I agree with egreg's comment. As for including in amsmath or mathtools the fact that you use tikz would add a lot of overhead to those packages. My opinion is that you are best writing a separate style file for this. Isn't this question mostly opinion? – Andrew Swann Nov 22 '13 at 10:18
• I have trouble understanding what answers you are expecting here. It seems you are asking for comments. Would you accept an answer "As far as I know, no such package exists"? – Stephan Lehmke Nov 30 '13 at 5:42
• What exactly is the bounty attached to this question meant to be for? What sort of attention is required? That is, it looks as though comments have more-or-less answered the 3 queries: 1. Probably not but \shortvdotswithin may be similar. 2. Possibly not to others but if you find it useful, somebody else may. If this is often used in writing on paper, it might be useful to show students how to keep track in that context. Various suggestions were made but there's no code here to improve. 3. mathtools or separate. Probably separate given tikz. What further is expected exactly? – cfr Jan 26 '14 at 21:15

Run it with xelatex:

\documentclass{article}
\usepackage{amsmath}
\usepackage{pst-node}
\begin{document}
\begin{align*}
\prod_{z^n=-1}(w_1(z)^n+1) & \rnode{A}{\;=\;} \prod_{z^n=-1}(w_1(z)^n+1)+\prod_{z^n=-1}(w_1(z)^n+1) \\
& \rnode{B}{\;=\;} \prod_{z^n=-1}(w_1(z)^n+1)\\
& \rnode{C}{\;=\;} mx+b\\
& \rnode{D}{\;=\;} Ax + By + C
\end{align*}
\psset{nodesepB=2pt}\ncline{A}{B}\ncline{B}{C}\ncline{C}{D}
\end{document}


From the question, without code given, it is difficult to tell how easy/difficult the OP's current implementation is. So I put this forward, realizing that it may be step backward. If so, please advise, and I will remove the answer.

Here, I create three macros \topeq, \mideq, and \boteq, each with one optional argument. The first extends a short vertical bar downward from the equal sign, as if were the top equation in the list; the second extends a short bar upward and downward; the third extends a bar upward, as if it were the last equation on the list. For textstyle equations, this should be sufficient to solve the problem. However, if the equations extend vertically in display style, the bars will be too short as shown below:

For this reason, the optional argument to each of these macros is a length to make one of the bars (for \topeq, it is the bar length below the =, for \mideq and \boteq, it is the length to extend above the =).

THE ADVANTAGE TO THIS APPROACH over my original solution is that one does not need the exact length of the vertical bar, rather one only needs to make it long enough to overlay the adjacent bar. Thus, the optional argument length typically has to only be accurate to, let's say, 1ex. The other advantage, as already mentioned, is that for textstyle equations, no optional arguments should be needed.

\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\newcommand\topeq[1][1ex]{%
\mathrel{\stackunder[0pt]{=}{\smash{\rule[-#1]{.5pt}{#1}}}}%
}
\newcommand\boteq[1][1.5ex]{%
\mathrel{\stackon[1.6pt]{=}{\smash{\rule{.5pt}{#1}}}}%
}
\newcommand\mideq[1][1.5ex]{%
\mathrel{\stackon[1.6pt]{%
\stackunder[0pt]{=}{\smash{\rule[-1ex]{.5pt}{1ex}}}%
}{\smash{\rule{.5pt}{#1}}}}}
\begin{document}
\begin{align*}
\prod_{z^n=-1}(w_1(z)^n+1) &\topeq \prod_{z^n=-1}(w_1(z)^n+1) + \prod_{z^n=-1}(w_1(z)^n+1) \\
&\mideq[5ex] \prod_{z^n=-1}(w_1(z)^n+1)\\
&\mideq[4ex] mx+b\\
&\boteq Ax + By + C
\end{align*}
\end{document}


This same result, with the extensions is shown here:

In this MWE, I implement \coneq (connect equal sign) which draws a vertical bar upward from an equal sign. The downside is that the user must specify how long the vertical bar is. The upside is the implementation is trivial. (I have a slightly revised notion that I am working on, and will post, if successful).

\documentclass{article}
\usepackage{amsmath}
\usepackage{stackengine}
\def\coneq#1{\mathrel{\stackon[2pt]{=}{\smash{\rule{.5pt}{#1}}}}}
\begin{document}
\begin{align*}
\prod_{z^n=-1}(w_1(z)^n+1) &= \prod_{z^n=-1}(w_1(z)^n+1) + \prod_{z^n=-1}(w_1(z)^n+1) \\
&\coneq{5.1ex} \prod_{z^n=-1}(w_1(z)^n+1)\\
&\coneq{4.5ex} mx+b\\
&\coneq{2.0ex} Ax + By + C
\end{align*}
\end{document}