两支箭不同的原因是什么?

两支箭不同的原因是什么?

考虑以下代码:

\documentclass{beamer}

\usepackage{tikz}

\usetikzlibrary{shapes,positioning,automata,arrows.meta}

\begin{document}

\begin{frame}[t]

  \begin{tikzpicture}[overlay,remember picture,
    every state/.style={ellipse,draw=blue}]

    \node[state,xshift=3cm,yshift=-4cm,align=center] (q1) {A};
    \node[state,align=center,right=3cm of q1] (q2) {B};

    \path[draw=blue!50,very thick,arrows={-
       Latex[blue!50]
      %Stealth[length=11pt,open,round]
      % Computer Modern Rightarrow
    }]
    (q1) edge [above] node {\small 1} (q2);

  \path[draw=blue!50,very thick,arrows={-
    Latex[blue!50]
    %Stealth[length=8pt,open]
  }]
  (q1) edge [above,loop] node {\small 0} (q1);

  \end{tikzpicture}
\end{frame}

\end{document}

示例输出

为什么这两个箭头尽管有相同的选项但却彼此不同?

答案1

请尝试以下操作:

\documentclass{beamer}
    \usepackage{tikz}
\usetikzlibrary{arrows.meta,automata,quotes,positioning,shapes}

    \begin{document}
\begin{frame}
\centering
  \begin{tikzpicture}[
     node distance=3cm,
                 >={Latex[blue!50]},
every state/.style={ellipse,draw=blue},
 every edge/.style={draw=blue!50,very thick,->},
 every loop/.style={min distance=12mm},
              auto
                        ]
\node (q1) [state]              {A};
\node (q2) [state,right=of q1]  {B};

\path   (q1) edge ["1"] (q2)
        (q1) edge [loop above,"0"] ();
  \end{tikzpicture}
\end{frame}
    \end{document}

我在图片前言中定义了箭头和边缘样式。我还优化了您的代码:引入 TikZ 库quotes以更简单地标记路径。结果是:

在此处输入图片描述

答案2

你可以通过以下代码来绘制它,就像TikZ 手册第159页:

\documentclass{beamer}

 \usepackage{tikz}
 \usetikzlibrary{shapes,positioning,automata,arrows.meta}

\begin{document}
  \begin{frame}[t]

        \begin{tikzpicture}[%
         overlay,remember picture,
         every state/.style={ellipse,draw=blue},
         every loop/.style={to path={..controls..+(-0.3,0.2) .. +(-0.4,0.3).. (\tikztotarget) \tikztonodes}},
         every edge/.style={draw=blue!50,very thick,arrows={- Latex[blue!50]}}
                            ]
           \node[state] (q1) at (3,-3) {A};
           \node[state,right=3cm of q1] (q2) {B};
           \path (q1) edge  node[above] {\small 1} (q2); %[draw=blue!50,very thick,arrows={- Latex[blue!50] }]
           \path (q1) edge [loop above] node[above] {\small 0} (q1); %[draw=blue!50,very thick,arrows={- Latex[blue!50]}]
           \end{tikzpicture}
 \end{frame}

 \end{document}

这使:

在此处输入图片描述

相关内容