Better solution to display the Distributive Property

This already has the structure built in for you to provide other options to control the lines that are drawn. You can adjust the

  • out= to control the angle at the start of the arrow,
  • in= to control the angle at the end of the arrow,
  • distance= to control the height of the arrow,
  • and the two shorten to adjust how close the start and end are to the particular node.

There are probably other options, that should be in the PGF manual related to the syntax of using to instead of -- for line drawing.

enter image description here

Notes:

  • I also moved the position of the in: 2\tikzmark{MarkB}x so that the arrow points to the center of the 2x term.

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}
\[\tikzmark{MarkA}a(b\tikzmark{MarkB}+c\tikzmark{MarkC})=ab+ac \DrawBox{OrangeRed,distance=0.75cm,in=110,shorten >=3pt}{Cerulean,out=60,in=110,distance=0.5cm}\]

\begin{align*}
-(2x+5)&=(-\tikzmark{MarkA}1)(2\tikzmark{MarkB}x+5\tikzmark{MarkC})\DrawBox{OrangeRed,distance=0.75cm}{Cerulean,out=60,in=110,distance=0.5cm}\\
       &=(-1)(2x)+(-1)(5)\\
       &=-2x+(-5)\\
       &=-2x-5
\end{align*}
\end{document}

Tags:

Tikz Pgf