1

Source:

Better solution to display the Distributive Property

Question:

When i came across the answer given by Peter Grill,

i am very interesting to know that how we can extend(modify) this codes for this type of multiplication (a+b)(c+d)=ac+ad+bc+bd

I mean how can we draws arrows between the parts of these two brackets.

I tried lot at my best level but couldn't find the appropriate corrections.

CODE:

\documentclass{article}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}
\newcommand{\DrawBox}[2]{%
  \begin{tikzpicture}[overlay,remember picture]
    \draw[->,shorten >=5pt,shorten <=5pt,out=70,in=130,distance=0.5cm,#1] (MarkA.north) to (MarkC.north);
    \draw[->,shorten >=5pt,shorten <=5pt,out=50,in=140,distance=0.3cm,#2] (MarkA.north) to (MarkB.north);
  \end{tikzpicture}
}
\begin{document}
    \LARGE
\[\tikzmark{MarkA}(a+b)(c\tikzmark{MarkB}+d\tikzmark{MarkC})=ac+ad+bc+bd \DrawBox{OrangeRed,distance=1cm,in=110,shorten >=10pt}{Cerulean,out=115,in=70,distance=1.5cm}\]


\end{document}
SandyM
  • 2,757

1 Answers1

3
\documentclass{article}
\usepackage{amsmath}
\usepackage[dvipsnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\begin{document}
\[(\tikzmark{MarkA}a+\tikzmark{MarkB}b)(c\tikzmark{MarkC}+d\tikzmark{MarkD})=ac+ad+bc+bd   
\begin{tikzpicture}[overlay,remember picture]
    \draw[->,shorten >=5pt,shorten <=5pt,out=70,in=110,distance=0.75cm,OrangeRed,] (MarkA.north) to (MarkD.north);
    \draw[->,shorten >=5pt,shorten <=5pt,out=60,in=110,distance=0.5cm,Cerulean] (MarkA.north) to (MarkC.north);
    \draw[->,shorten >=1pt,shorten <=2pt,out=-70,in=-110,distance=0.5cm,OrangeRed,] (MarkB.south) to (MarkD.south);
    \draw[->,shorten >=1pt,shorten <=2pt,out=-60,in=-110,distance=0.25cm,Cerulean] (MarkB.south) to (MarkC.south);
  \end{tikzpicture}
\]

\end{document}

enter image description here

Ignasi
  • 136,588