在像这样的简单绘图中(我使用automata
库):
\begin{tikzpicture}[shorten >=1pt,node
distance=2cm,auto,initial text=]
\tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20]
\node[state] (a) {};
\node[coordinate] (b) [right of=a] {};
\node[state] (c) [right of=b] {};
\draw[-] (a) edge node {a} (b);
\draw[->] (b) edge (c);
\end{tikzpicture}
b
尽管我没有在节点中指定它,但我还是在节点中获得了提示。我创建了一个附加节点(此处b
:)以创建一条分段线,但我不想在那里出现任何提示。我该如何摆脱那个提示?有趣的是,如果我在 的末尾放置一个星号-
作为 的选项\draw
,我会在 处得到一个实心圆和一个箭头提示b
,但如果我保留-
选项,并在 前添加一个星号->
,我会在 处得到两个实心圆b
。
我不知道如何将评论标记为好答案,但正确(也是最简单的)答案就在评论中。我用\draw[-] (a) edge
和\path (a) edge[-]
替换draw[->] (b) edge
了\path (b) edge[->]
。我还必须删除全局选项shorten >=1pt
,这仍然导致线条之间出现小间隙。我想要实现的是几条水平延伸的线条,然后以各种角度(末端带有箭头)汇聚在一个状态。感谢所有评论和答案。
答案1
要删除 处的提示node b
,首先删除coordinate
该命令中的选项。这将留下一小段空间。然后使用calc
计算新坐标以按线填充空间。
代码:方法 1
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{automata,arrows,calc}
\begin{document}
\begin{tikzpicture}[shorten >=0pt, node distance=2cm,auto]
\tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20]
\node[state] (a) {};
% method 1: remove the coordinate definition
\node [] (b) [right of=a] {};
\node[state] (c) [right of=b] {};
\draw (a) edge node{a} ($(b)+(0.2,0)$); % an extra line is drawn to fill the blank
\draw[->] (b) edge (c);
\end{tikzpicture}
\end{document}
编辑(2014/01/23):方法2
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{automata,arrows}
\begin{document}
\begin{tikzpicture}[shorten >=1pt, node distance=2cm,auto]
\tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20]
\node[state] (a) {};
% method 2: remove the coordinate definition and set outer sep=-4pt.
\node[outer sep=-4pt] (b) [right of=a] {};
\node[state] (c) [right of=b] {};
\draw (a) edge node{a} (b); % method 2: no extended draw.
\draw[->] (b) edge (c);
\end{tikzpicture}
\end{document}
答案2
据我了解,您期望的是两部分箭头:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node
distance=2cm,auto,initial text=]
\tikzstyle{every state}=[draw=blue!50,very thick,fill=blue!20]
\node[state] (a) {};
\node[coordinate] (b) [right of=a] {};
\node[state] (c) [right of=b] {};
\draw (a) [->] edge node {a}(b);
\draw [->] (b) -- (c);
\end{tikzpicture}
\end{document}