\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{tikzpicture}[scale=1.5,line width=1]
%
\tikzstyle{a}=[
decoration={markings,mark=at position 1 with {\arrow[scale=1.5]{>}}},
postaction={decorate},
shorten >=9pt, shorten <=9pt,
]
\coordinate (u1) at (1,1);
\coordinate (u2) at (2,2);
\coordinate (u3) at (1,0);
\node[outer sep=10pt,rectangle,draw] at (u1) {\qquad};
\node[outer sep=10pt,rectangle,draw] at (u2) {\qquad};
\node[outer sep=10pt,rectangle,draw] at (u3) {\qquad};
\draw[a] (u1)--(u2);
\draw[a] (u3)--(u1);
\end{tikzpicture}
\end{document}
答案1
您正在缩短箭头9pt
并在位置处进行装饰1
。因此箭头尖端位于位置1
,并且线段较短。您必须在适当的位置(例如 0.83)进行装饰,这无论如何都会很丑陋。这里有一个替代方案:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.markings}
\begin{document}
\begin{tikzpicture}[scale=1.5,line width=1]
%
\tikzstyle{a}=[
%shorten >=9pt, shorten <=9pt,
decoration={markings,mark=at position 1 with {\arrow[scale=1.5]{>}}},
postaction={decorate},
]
%\coordinate (u1) at (1,1);
%\coordinate (u2) at (2,2);
%\coordinate (u3) at (1,0);
\node[outer sep=5pt,rectangle,draw] at (1,1)(u1) {\qquad};
\node[outer sep=5pt,rectangle,draw] at (2,2) (u2) {\qquad};
\node[outer sep=5pt,rectangle,draw] at (1,0) (u3) {\qquad};
\draw[a] (u1)--(u2);
\draw[a] (u3)--(u1);
\end{tikzpicture}
\end{document}
这里,我调整了outer sep
(无论如何都要保持它们很高),而不是coordinate
s,我直接定义了node
s,以便node
s 可以连接(不是coordinate
s)。通过outer sep
适当调整,您可以更改箭头的长度。如果您必须将某些东西连接到这些节点的中心,请使用(u1.center)
等。