TikZ PGF – How to Draw Arrows Between Parts of an Equation to Show Math Distributive Property

arrowsdiagramsmath-modetechnical-drawingtikz-pgf

There is a part of my paper where I use the distributive property and it might not be clear to the reader to see the operation result (I'm using in proposional logic for a proof). The logic equation (part of) is:

$$ (l_{1}) \vee \big( (p \vee q) \wedge (\neg p \vee q) \wedge (p \vee \neg q) \wedge (\neg p \vee \neg q)\big) $$
$$ (l_{1} \vee p \vee q) \wedge (l_{1} \vee \neg p \vee q) \wedge (l_{1} \vee p \vee \neg q) \wedge (l_{1} \vee \neg p \vee \neg q) $$

So I was wondering if there is a way to represent this operation like a 'shower' (see another example in pic 1). Maybe there is some hidden magic mathmode command or pkg for this. At last we can also rely on tikz.

Distributive Property

Best Answer

The following uses pst-node from the pstricks bundle. So, you need to compile it with either latex -> dvips -> ps2pdf, or xelatex:

enter image description here

\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{pst-node}% http://ctan.org/pkg/pst-node
\begin{document}
\[
  \begin{array}{c}
    \psDefBoxNodes{n1}{(l_{1})} \vee \big( 
      \psDefBoxNodes{n2}{(p \vee q)} \wedge 
      \psDefBoxNodes{n3}{(\neg p \vee q)} \wedge 
      \psDefBoxNodes{n4}{(p \vee \neg q)} \wedge 
      \psDefBoxNodes{n5}{(\neg p \vee \neg q)}\big) \\
    (l_{1} \vee p \vee q) \wedge (l_{1} \vee \neg p \vee q) \wedge (l_{1} \vee p \vee \neg q) \wedge (l_{1} \vee \neg p \vee \neg q)
  \end{array}
\]
\psset{nodesep=3pt,arcangle=15}
\ncarc{->}{n1:tC}{n2:tC}
\ncarc{->}{n1:tC}{n3:tC}
\ncarc{->}{n1:tC}{n4:tC}
\ncarc{->}{n1:tC}{n5:tC}
\end{document}

\psDefBoxNodes{<node>}{<stuff>} declares a special node <node> for <stuff>. Subsequently one can refer to the bounding box location of the node using character combinations. In the above example, <node>:tC refers to the top Center of <node>.