我怎样才能重新绘制这个没有节点并且只有箭头之间的点的东西?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{petri}
\tikzset{state/.style={circle,draw=gray,inner sep=0pt,minimum size=7mm,label=center:$#1$,name=#1},
redarrow/.style={->, red, fill=none,>=stealth},bluearrow/.style={->, blue, fill=none,>=stealth},
redline/.style={-,red,fill=none},blueline/.style={-,blue,fill=none}}
\begin{document}
\begin{tikzpicture}
\node[state=a^{-1}]{};
\node[state=1,right=of a^{-1}]{};
\node[state=b,above=of 1]{};
\node[state=a,right=of 1]{};
\node[state=ab^{-1},above=of a]{};
\node[state=aa,right=of a]{};
\node[state=ac,below=of a]{};
\node[state=acc,right=of ac]{};
\node[state=aca,below =of ac]{};
\draw[redarrow](a^{-1})--(1);
\draw[redarrow](1)--(b);
\draw[redarrow](1)--(a);
\draw[redarrow](ab^{-1})--(a);
\draw[redarrow](a)--(aa);
\draw[redarrow](a)--(ac);
\draw[redarrow](ac)--(acc);
\draw[redarrow](ac)--(aca);
\end{tikzpicture}
\end{document}
答案1
我不完全确定您在寻找什么,但也许这是一个开始:您可以简单地命名节点而不是指定state
,然后对每个节点使用一种样式来确保每个节点都是一个填充的圆圈。
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\usetikzlibrary{petri}
\tikzset{state/.style={circle,draw=gray,inner sep=0pt,minimum size=7mm,label=center:$#1$,name=#1},
redarrow/.style={->, red, fill=none,>=stealth},bluearrow/.style={->, blue, fill=none,>=stealth},
redline/.style={-,red,fill=none},blueline/.style={-,blue,fill=none},
every node/.append style={circle, fill}}
\begin{document}
\begin{tikzpicture}
\node (a^{-1}) {};
\node (1) [right=of a^{-1}]{};
\node (b) [above=of 1]{};
\node (a) [right=of 1]{};
\node (ab^{-1}) [above=of a]{};
\node (aa) [right=of a]{};
\node (ac) [below=of a]{};
\node (acc) [right=of ac]{};
\node (aca) [below =of ac]{};
\draw[redarrow](a^{-1})--(1);
\draw[redarrow](1)--(b);
\draw[redarrow](1)--(a);
\draw[redarrow](ab^{-1})--(a);
\draw[redarrow](a)--(aa);
\draw[redarrow](a)--(ac);
\draw[redarrow](ac)--(acc);
\draw[redarrow](ac)--(aca);
\end{tikzpicture}
\end{document}
答案2
您可以使用 简化代码matrix
。它有助于定位节点,并且使用matrix of nodes
选项会自动将名称添加到节点:matrix_name-row-column
。
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\usetikzlibrary{matrix}
\tikzset{state/.style={circle,draw=black, fill=black, inner sep=0pt,minimum size=7mm},
redarrow/.style={->, red, fill=none,>=stealth},
bluearrow/.style={->, blue, fill=none,>=stealth},
redline/.style={-, red, fill=none},
blueline/.style={-,blue,fill=none},
}
\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes, nodes={state}, column sep=1cm, row sep=1cm]
{&.&.&\\.&.&.&.\\&&.&.\\&&.&\\};
\foreach \i/\j in {1/2,2/3,3/4}
{
\draw[redarrow] (A-2-\i)--(A-2-\j);
\draw[redarrow] (A-\i-3)--(A-\j-3);
}
\draw[redarrow] (A-1-2)--(A-2-2);
\draw[redarrow] (A-3-3)--(A-3-4);
\end{tikzpicture}
\end{document}
我不确定你的意思,redraw without nodes
但如果你想使用硬编码坐标来放置点并在它们之间画箭头,看看会发生什么:
\begin{tikzpicture}
\draw plot[mark=*, only marks] coordinates {(0,2) (1,2) (1,3) (2,0) (2,1) (2,2) (2,3) (3,1) (3,2)};
\foreach \i/\j in {0/1,1/2,2/3}
{
\draw[redarrow] (\i,2)--(\j,2);
\draw[redarrow,<-] (2,\i)--(2,\j);
}
\draw[redarrow] (1,3)--(1,2);
\draw[redarrow] (2,1)--(3,1);
\end{tikzpicture}
使用nodes
命令draw[->] (A)--(B)
意味着在节点 A 的中心和节点 B 的中心之间画一个箭头,但仅限于节点边界之间,而draw[->] (0,0)--(0,1);
意味着在坐标之间画一个箭头(0,0)
,而(0,1)
不必担心在这些坐标上画什么。