我想用 Ti 绘制如下方案钾Z:
答案1
这只是展示一种无需明确坐标即可完成此操作的方法。我将两个方程式添加到同一个节点中,并将箭头放置在相对于此节点的角的位置。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[MyArrow/.style={-latex,shorten >= 0.1cm,shorten <=0.1cm,thick}]
\node (eq) [draw, inner sep=10pt,align=center] {$(a+b)^2=a^2+2ab+b^2$ \\[1ex]
$(a-b)^2=a^2-2ab+b^2$};
\draw [MyArrow] ($(eq.north west)!0.2!(eq.north east)$) -- ++(0,0.5) -| node[pos=0.25,fill=white,draw] {word} ($(eq.north west)!0.8!(eq.north east)$);
\draw [MyArrow] ($(eq.south east)!0.2!(eq.south west)$) -- ++(0,-0.5) -| node[pos=0.25,fill=white,draw] {word} ($(eq.south east)!0.8!(eq.south west)$);
\end{tikzpicture}
\end{document}
答案2
您可以在使用环境命令的地方使用\draw
此\path
代码tikzpicture
:
% Document
\begin{document}
\begin{tikzpicture}
% Formulas
\path (0,.25) node{$(a+b)^2=a^2+2ab+b^2$} --
(0,-.25) node{$(a-b)^2=a^2-2ab+b^2$} --
(-.5,1.3) node{word} --
(-.5,-1.3) node{word} ;
% Rectangle
\draw[thick] (-2.2,-.7) rectangle (2.2,.7);
\draw[thick] (-1,.9) rectangle (0,1.7) ;
\draw[thick] (-1,-.9) rectangle (0,-1.7);
% Lines
\draw[thick] (-1.5,.7) -- (-1.5,1.3) -- (-1,1.3) ;
\draw[thick,->] (0,1.3) -- (1,1.3) -- (1,.7) ;
\draw[thick] (-1.5,-.7) -- (-1.5,-1.3) -- (-1,-1.3);
\draw[thick,->] (0,-1.3) -- (1,-1.3) -- (1,-.7) ;
\end{tikzpicture}
\end{document}
要获得此图: