Recently I've made a question which I ask how could I make a common factor scheme, and someone makes it works. But now, it has unformatted my other expression. Could someone help me?
The code:
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\usetikzlibrary{calc}
\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{a}ax + \tikzmark{b}ay) = \tikzmark{c}a(x + y)
\tikz[remember picture, overlay, baseline=0pt] {
\draw[red, thick] ($(pic cs:a) + (0.1, 0.2)$) to[out=90, in=90] ($(pic cs:c) + (0.1, 0.2)$);
\draw[red, thick] ($(pic cs:b) + (0.1, 0.2)$) to[out=90, in=90] ($(pic cs:c) + (0.1, 0.2)$);
}
\]
\[\tikzmark{MarkA}a(b\tikzmark{MarkB}+c\tikzmark{MarkC})=ab+ac \DrawBox{OrangeRed}{Cerulean}\]
\begin{align*}
-(2x+5)&=(-\tikzmark{MarkA}1)(2x\tikzmark{MarkB}+5\tikzmark{MarkC})\DrawBox{OrangeRed}{Cerulean}\\
&=(-1)(2x)+(-1)(5)\\
&=-2x+(-5)\\
&=-2x-5
\end{align*}
\end{document}
(The purpose of the second part is to explicit the distributive property)
tikzmark
library, don't use\newcommand\tikzmark...
in addition. Because the library already defines a macro by that name, you get an error.