![TikZ - 自动机 - 调整一些重叠边缘的弯曲](https://linux22.com/image/446173/TikZ%20-%20%E8%87%AA%E5%8A%A8%E6%9C%BA%20-%20%E8%B0%83%E6%95%B4%E4%B8%80%E4%BA%9B%E9%87%8D%E5%8F%A0%E8%BE%B9%E7%BC%98%E7%9A%84%E5%BC%AF%E6%9B%B2.png)
我想调整以下输出中的一些弯曲边缘。最好的方法是什么?
这是我使用的代码。
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows}
\tikzset{
->,
>=stealth',
node distance=3cm,
every state/.style={thick},
initial text =,
}
\newenvironment{tikzautomata}{
\begin{center}
\begin{tikzpicture}[shorten >=1pt, on grid, auto]
}{
\end{tikzpicture}
\end{center}
}
\begin{document}
\section*{Exercice 3.3 -- Une solution (correcte ?)}
\begin{tikzautomata}
\node[state]
(0) {$0$};
\node[state, right of=0]
(1) {$1$};
\node[state, right of=1]
(2) {$2$};
\draw
(0) edge[bend left, above] node{\texttt{inc}} (1)
(1) edge[bend left, above] node{\texttt{inc}} (2)
(2) edge[bend left, below] node{\texttt{inc}} (0)
(0) edge[bend left, above] node{\texttt{dec}} (2)
(2) edge[bend left, below] node{\texttt{dec}} (1)
(1) edge[bend left, below] node{\texttt{dec}} (0);
\end{tikzautomata}
\end{document}
答案1
您忘记写出要如何调整它。以下是猜测:
\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{automata, positioning, arrows.meta}
\tikzset{
->,
>=Stealth,
node distance=3cm,
every state/.style={thick},
initial text =,
}
\newenvironment{tikzautomata}{
\begin{center}
\begin{tikzpicture}[shorten >=1pt, on grid, auto]
}{
\end{tikzpicture}
\end{center}
}
\begin{document}
\section*{Exercice 3.3 -- Une solution (correcte ?)}
\begin{tikzautomata}
\node[state]
(0) {$0$};
\node[state, right of=0]
(1) {$1$};
\node[state, right of=1]
(2) {$2$};
\draw
(0) edge[bend left, above] node{\texttt{inc}} (1)
(1) edge[bend left, above] node{\texttt{inc}} (2)
(2) edge[bend left=2cm, below] node{\texttt{inc}} (0)
(0) edge[bend left=2cm, above] node{\texttt{dec}} (2)
(2) edge[bend left, below] node{\texttt{dec}} (1)
(1) edge[bend left, below] node{\texttt{dec}} (0);
\end{tikzautomata}
\end{document}
答案2
\ncarc
使用命令来做很简单pst-node
:您只需选择 arcangle
参数的值,即圆弧和节点线之间的角度:
\documentclass[border=6pt, svgnames]{standalone}
\usepackage{pst-node}
\begin{document}
\begin{pspicture}(-1,-2.25)(9,2.25)
\psset{unit=4cm, arrowinset=0.15, radius=0.2}
\Cnodeput(0,0){A}{\Large 0}
\Cnodeput(1,0){B}{\Large 1}
\Cnodeput(2,0){C}{\Large 2 }
\psset{arcangle=30, arrows=->, labelsep=2pt}
\everypsbox{\ttfamily}
\ncarc{A}{B}\nbput{inc} \ncarc{B}{C}\nbput{inc}
\ncarc{B}{A}\nbput{dec} \ncarc{C}{B}\nbput{dec}
\psset{arcangle=45}
\ncarc{A}{C}\naput{dec} \ncarc{C}{A}\naput{inc}
\end{pspicture}
\end{document}