我想调整以下内容(我已经根据本网站上的另一个答案进行了调整),以便线条在节点之前停止,并且箭头更大/更清晰。
有人可以帮忙吗?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
% Syntax:
% \DoublLine[half of the double line distance]{first node}{second node}{options line 1}{options line 2}
\newcommand\DoubleLine[5][3pt]{%
\path(#2)--(#3)coordinate[at start](h1)coordinate[at end](h2);
\draw[#4]($(h1)!#1!90:(h2)$)--($(h2)!#1!-90:(h1)$);
\draw[#5]($(h1)!#1!-90:(h2)$)--($(h2)!#1!90:(h1)$); }
\begin{document}
\begin{tikzpicture}[main_node/.style={circle,fill=green!20,draw,minimum
size=1em,inner sep=3pt]}]
\node[main_node] (b) at (0,0) {};
\node[main_node] (a) at (-1.5, -2) {};
\node[main_node] (c) at (1.5, -2) {};
\DoubleLine{a}{b}{->, dashed}{<-}
\DoubleLine{b}{c}{<-,dashed}{->}
\DoubleLine{a}{c}{->,dashed}{<-}
\end{tikzpicture}
\end{document}
答案1
要缩短路径,请使用shorten >= length
和shorten <= length
。关于箭头问题,您可以简单地使用不同的、更明显的箭头尖(使用库,arrows.meta
您可以使用类似>=To[scale=1.4]
放大箭头尖的东西)有关更多详细信息和箭头尖类型,请参阅 PGF 手册和arrows.meta
库;在下面的例子中,我使用了Latex
第二张图的提示箭头。
完整代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows.meta}
\newcommand\DoubleLine[5][3pt]{%
\path(#2)--(#3)coordinate[at start](h1)coordinate[at end](h2);
\draw[#4]($(h1)!#1!90:(h2)$)--($(h2)!#1!-90:(h1)$);
\draw[#5]($(h1)!#1!-90:(h2)$)--($(h2)!#1!90:(h1)$);
}
\begin{document}
\begin{tikzpicture}[
shorten >= 5pt,
shorten <= 5pt,
main_node/.style={
circle,
fill=green!20,
draw,
minimum size=1em,
inner sep=3pt
}
]
\node[main_node] (b) at (0,0) {};
\node[main_node] (a) at (-1.5, -2) {};
\node[main_node] (c) at (1.5, -2) {};
\DoubleLine{a}{b}{->, dashed}{<-}
\DoubleLine{b}{c}{<-,dashed}{->}
\DoubleLine{a}{c}{->,dashed}{<-}
\end{tikzpicture}
\begin{tikzpicture}[
shorten >= 5pt,
shorten <= 5pt,
>=Latex,
main_node/.style={
circle,
fill=green!20,
draw,
minimum size=1em,
inner sep=3pt
}
]
\node[main_node] (b) at (0,0) {};
\node[main_node] (a) at (-1.5, -2) {};
\node[main_node] (c) at (1.5, -2) {};
\DoubleLine{a}{b}{->, dashed}{<-}
\DoubleLine{b}{c}{<-,dashed}{->}
\DoubleLine{a}{c}{->,dashed}{<-}
\end{tikzpicture}
\end{document}