这个例子不起作用,因为?
\LinkNodes
不起作用
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier}
\usepackage{amsmath,tkz-linknodes}
\usepackage{tikz}
\begin{document}
\begin{NodesList}
\begin{displaymath}
\begin{aligned}
3(2a&-5b)&-7a(2a&+3b)&+5(a^2&+3b)& \AddNode[1] \AddNode[2] \AddNode[3] \AddNode[4] \AddNode[5] \AddNode[6] \AddNode[7]\\
6a+&\AddNode[1]\\
& -15b& \AddNode[2]\\
&& -14a^2& \AddNode[3]\\
&& &-21ab& \AddNode[4]\\
&&& &+5a^2& \AddNode[5]\\
&&&& &+15b& \AddNode[6]\\
6a&-15b&-14a^2&-21ab&+5a^2&+15b&\AddNode[7]\\
\end{aligned}
\end{displaymath}
\LinkNodes{$3\cdot 2a$}%
\LinkNodes{$3\cdot(-5b)$}%
\LinkNodes{$-7a\cdot(2a)$}%
\LinkNodes{$-7a\cdot(3b)$}%
\LinkNodes{$5\cdot(a^2)$}%
\LinkNodes{$5\cdot(3b)$}%
\end{NodesList}
\end{document}
答案1
您需要编译两次更新:我\AddNode[i]
在最后一次之前添加了&
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[upright]{fourier}
\usepackage{amsmath,tkz-linknodes}
\usepackage{tikz}
\begin{document}
\begin{NodesList}
\begin{displaymath}
\begin{aligned}
3(2a&-5b)&-7a(2a&+3b)&+5(a^2&+3b)&\AddNode[1]\AddNode[2]\AddNode[3]\AddNode[4]\AddNode[5]\AddNode[6]\AddNode[7]\\
6a+&\AddNode[1]\\
& -15b\AddNode[2]&\\
&& -14a^2\AddNode[3]&\\
&& &-21ab\AddNode[4]&\\
&&& &+5a^2\AddNode[5]&\\
&&&& &+15b\AddNode[6]&\\
6a&-15b&-14a^2&-21ab&+5a^2&+15b&\AddNode[7]\\
\end{aligned}
\end{displaymath}
\tikzset{LabelStyle/.style = {left=0.1cm,pos=.5,text=red,fill=white}}
\LinkNodes[margin=3cm]{$3\cdot 2a$}%
\LinkNodes[margin=2cm]{$3\cdot(-5b)$}%
\LinkNodes[margin=1cm]{$-7a\cdot(2a)$}%
\LinkNodes[margin=0cm]{$-7a\cdot(3b)$}%
\LinkNodes[margin=-1cm]{$5\cdot(a^2)$}%
\LinkNodes[margin=-2cm]{$5\cdot(3b)$}%
\end{NodesList}
\end{document}
另一种可能性:
\begin{NodesList}
\begin{displaymath}
\begin{aligned}
3(2a&-5b)&-7a(2a&+3b)&+5(a^2&+3b)&\AddNode[1]\AddNode[2]\AddNode[3]\AddNode[4]\AddNode[5]\AddNode[6]\AddNode[7]\\
6a+&\AddNode[1]\\
& -15b\AddNode[2]&\\
&& -14a^2\AddNode[3]&\\
&& &-21ab\AddNode[4]&\\
&&& &+5a^2\AddNode[5]&\\
&&&& &+15b\AddNode[6]&\\
6a&-15b&-14a^2&-21ab&+5a^2&+15b&\AddNode[7]\\
\end{aligned}
\end{displaymath}
\tikzset{LabelStyle/.style = {pos=0,above,text=red}}
\LinkNodes[margin=1.5cm]{$3\cdot (2a)$}%
\LinkNodes[margin=0cm]{$3\cdot(-5b)$}%
\LinkNodes[margin=-1.5cm]{$-7a\cdot(2a)$}%
\LinkNodes[margin=-3cm]{$-7a\cdot(3b)$}%
\LinkNodes[margin=-4.5cm]{$5\cdot(a^2)$}%
\LinkNodes[margin=-6cm]{$5\cdot(3b)$}%
\end{NodesList}
这是一个用于完成简单任务的小包,也许我可以更轻松地让您直接使用 TikZ 来获得您想要的东西。