
Betrachten Sie den folgenden Code:
\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}
Warum unterscheiden sich diese beiden Pfeile trotz derselben Optionen voneinander?
Antwort1
Versuche Folgendes:
\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}
Ich definiere Pfeile und Kantenstile in der Bildpräambel. Außerdem optimiere ich Ihren Code: führe die TikZ-Bibliothek quotes
zur einfacheren Beschriftung von Pfaden ein. Das Ergebnis ist:
Antwort2
Sie können es mit dem folgenden Code zeichnen, wie imTikZ-HandbuchSeite 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}
Das Ergebnis ist: