我试图解释代数表达式的乘法顺序。使用 MWE 和\usepackage{tikz-dependency}
,我未能得到我想要的结果:
$\begin{aligned}[t]
(a+b)^{2}&=\begin{dependency} [theme = simple]
\begin{deptext}
(\&a+\&b)(\&a+\&b)
\end{deptext}
\depedge{1}{3}{1}
\depedge{1}{4}{2}
\depedge{2}{3}{3}
\depedge{2}{4}{4}
\end{dependency}
\\&=a^2+ab+ba+b^2
\\&=a^2+2ab+b^2
\end{aligned} $
答案1
我当然不知道你想要什么,但至少这是有效的:
\documentclass{article}
\usepackage{amsmath,tikz-dependency}
\begin{document}
\[
\begin{aligned}[t]
(a+b)^{2}&=
\begin{dependency}[theme = simple,baseline=-3pt]
\begin{deptext}[inner xsep=0pt,column sep=0pt,nodes={inner sep=0pt}]
$($\&$a$\&${}+{}$\&$b$\&$)($\&$a$\&${}+{}$\&$b$\&$)$ \\
\end{deptext}
\depedge{1}{6}{1}
\depedge{1}{8}{2}
\depedge{4}{6}{3}
\depedge{4}{8}{4}
\end{dependency}
\\&=a^2+ab+ba+b^2
\\&=a^2+2ab+b^2
\end{aligned}
\]
\end{document}