我有一个关于定位的问题。假设我们有两个节点 (A) 和 (B)。(A) 位于 (B) 的左侧:
\node (A) {A};
\node [left of=A] (B) {B};
我们可以在(A)和(B)之间画一条箭头,像这样:
\draw[->] (A.east) -- (B.west);
但是我怎样才能在这个箭头上方稍微画一个水平箭头,例如类似的(A.east)+(0,0.5cm)--(B.west)+(0,0.5cm)
?(这不起作用;这只是为了让你明白我在要求什么。)
答案1
答案2
虽然yshift
这是对您的问题的完美回答,但请注意,您也可以使用该calc
库来实现与您要求的完全相同的目标:
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[>=latex]
\node (A) {A};
\node [left of=A] (B) {B};
\draw[->] (A.east) -- (B.west);
\draw[->] ($(A.east)+(0,0.5)$) -- ($(B.west)+(0,0.5)$);
\end{tikzpicture}
\end{document}
答案3
像这样(两个解决方案)
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\begin{document}
\begin{tikzpicture}[>=latex]
\node (A) {A};
\node [left of=A] (B) {B};
\draw[->] (A.east) -- (B.west);
\draw[->,blue] (A.20) coordinate(dd)-- (dd-|B.west);
\draw[->,red] ($(A.east)!0.5!(A.north east)$) coordinate(dd) -- (dd-|B.west);
\end{tikzpicture}
\end{document}
答案4
\documentclass {scrartcl}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\tikzstyle{vertex} = [ color=black, text=black, fill=black!10]
\tikzstyle{edge} = [thick]
\node[draw, vertex] (A) {A};
\node[draw, vertex, left=of A] (B) {B};
\draw[->, red, thick] (A.west) -- (B.east);
\draw[->, green, thick] (A.150) -- (B.30);
\draw[->, blue, thick] (A.210) -- (B.-30);
\end{tikzpicture}
\end{document}