这是先前这个问题。我取得了一些进展,但还没有完成。我在此基础上继续努力这个答案
我目前拥有的:
我希望它是:
- 这两条线平行吗?
- 在中间添加两个箭头
- 在蓝色箭头下方添加问号
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc, chains,
positioning}
\usetikzlibrary{ext.paths.ortho}
\usetikzlibrary{ext.node-families}
\usetikzlibrary{arrows.meta,
decorations.markings,
positioning
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
[arr/.style={> = {Stealth}}]% replace standard arrow tip
% ~~~ coordinates for the triangles ~~~~~~~~~~
\coordinate (A) at (0,0);
\coordinate (B) at (5,0);
\coordinate (C) at (1.2,2.5);
\coordinate (D) at (3.2,2.5);
\coordinate (c) at (1,1.5);
\coordinate (a) at (-0.2,-1);
\coordinate (b) at (2.5, -1);
% ~~~ triangles ~~~~~~~~~
\draw (C) -- (A) -- (B) -- (D);
\draw (a) -- (c) -- (b);
% ~~~ rectangles ~~~~~~~~~~
\node [draw] (R) at (0.8,.4) {};
\node [draw, anchor=south west] (S) at(R.north east) {};
% ~~~ blue arrow ~~~~~~
% with a nicer arrow tip
% using nodes anchors
% bending the blue line
\draw [blue, ->, arr]
(R.south) to [out=-90, in=-90, looseness=2.75] (S.south);
% ~~~ red line ~~~~~~~~~~
% use rounded corners, radius 7mm
% draw a path, which runs through the rectangles
\draw [red, ->, arr, rounded corners=7mm]
(1,2) -- (R) -- (0.3,-1) -- (1.7,-1) -- (S) -- ((1.2, 2);
\end{tikzpicture}
\end{figure}
\end{document}
答案1
- 要使线平行,请使用极坐标
(θ:r)
。相对坐标也有帮助,例如\draw (A) -- ++(θ:r);
。 - 中间的箭头应该作为
marking
装饰使用postaction=decorate
- 问号可以是相对于线定位的节点。
\documentclass{article}
\usepackage{tikz}
%\usetikzlibrary{arrows.meta,
% calc, chains,
% positioning}
%\usetikzlibrary{ext.paths.ortho}
%\usetikzlibrary{ext.node-families}
\usetikzlibrary{arrows.meta,
decorations.markings,
%positioning
}
\begin{document}
\begin{figure}[htbp]
\centering
\begin{tikzpicture}
[arr/.style={> = {Stealth}}, arrmark/.style={decoration={markings, mark=at position #1 with {\arrow{>}}}, postaction=decorate}]% replace standard arrow tip
% ~~~ coordinates for the triangles ~~~~~~~~~~
\coordinate (A) at (0,0);
\coordinate (B) at (5,0);
\coordinate (C) at (60:3);
%\coordinate (D) at (3.2,2.5);
%\coordinate (c) at (1,1.5);
\coordinate (a) at (-0.2,-1);
%\coordinate (b) at (2.5, -1);
% ~~~ triangles ~~~~~~~~~
\draw (C) -- (A) -- (B) -- ++(120:3)coordinate(D);
\draw (a) -- ++(60:3)coordinate(b) -- ++(-60:3)coordinate(c);
% ~~~ rectangles ~~~~~~~~~~
\node [draw] (R) at (1,.4) {};
\node [draw, anchor=south west] (S) at(R.north east) {};
% ~~~ blue arrow ~~~~~~
% with a nicer arrow tip
% using nodes anchors
% bending the blue line
\draw [blue, ->, arr]
(R.south) to [out=-90, in=-90, looseness=2.75]node[below right=-3pt]{\scriptsize?} (S.south);
% ~~~ red line ~~~~~~~~~~
% use rounded corners, radius 7mm
% draw a path, which runs through the rectangles
\draw[red] (R) -- ++(80:1.2);
\draw [red, ->, arr, rounded corners=7mm, arrmark=.15, arrmark=.6]
(R) -- (0.3,-1) -- (1.7,-1) -- (S) -- ++(80:1.2);
\end{tikzpicture}
\end{figure}
\end{document}