我正在尝试创建类似的东西使用这个例子。我修改了源代码,这就是我所拥有的
\documentclass[tikz]{standalone}
\usetikzlibrary{automata,chains}
\begin{document}
\begin{tikzpicture}[start chain=going left,node distance=2cm]
\node[state, on chain] (N+1) {N+1};
\node[state, on chain] (N) {N};
\node[on chain] (g) {...};
\node[state, on chain] (2) {2};
\node[state, on chain] (1) {1};
\node[state, on chain] (0) {0};
\draw[
>=latex,
% every node/.style={above,midway},% either
auto=right, % or
loop above/.style={out=75,in=105,loop},
every loop,
]
(0) edge[loop above] node {$p_{0,0}$} (0)
edge node {$p_{0,1}$} (1)
(1) edge[loop above] node {$p_{1,1}$} (1)
(1) edge node {$p_{1,2}$} (2)
(2) edge[loop above] node {$p_{2,2}$} (2)
edge node {$p_{2,3}$} (g)
(g) edge[] node {$p_{N-1,N}$} (N);
(N) edge[loop above] node {$p_{N,N}$} (N)
edge node {$p_{N,N+1}$} (N+1)
(N) edge[bend left] node {$p_{N,N}$} (0)
(N+1) edge[loop above] node {$p_{N+1,N+1}$} (N)
(N+1) edge[bend left] node {$p_{N+1,N+1}$} (0)
% The \draw path is like the one above.
\end{tikzpicture}
\end{document}
但是我好像搞错了。我哪里搞错了?
答案1
您几乎已经到达目标。您只是放错了分号并混淆了标签。
\documentclass[tikz]{standalone}
\usetikzlibrary{automata,chains}
\begin{document}
\begin{tikzpicture}[start chain=going left,node distance=2cm]
\node[state, on chain] (N+1) {$N+1$};
\node[state, on chain] (N) {$N$};
\node[on chain] (g) {$\cdots$};
\node[state, on chain] (2) {$2$};
\node[state, on chain] (1) {$1$};
\node[state, on chain] (0) {$0$};
\draw[
>=latex,
% every node/.style={above,midway},% either
auto=right, % or
loop above/.style={out=75,in=105,loop},
every loop,
]
(0) edge[loop above] node {$p_{0,0}$} (0)
edge node {$p_{0,1}$} (1)
(1) edge[loop above] node {$p_{1,1}$} (1)
(1) edge node {$p_{1,2}$} (2)
(2) edge[loop above] node {$p_{2,2}$} (2)
edge node {$p_{2,3}$} (g)
(g) edge[] node {$p_{N-1,N}$} (N)
(N) edge[loop above] node {$p_{N,N}$} (N)
edge node {$p_{N,N+1}$} (N+1)
(N) edge[bend left] node[below] {$p_{N,N}$} (0)
(N+1) edge[loop above] node {$p_{N+1,N+1}$} (N)
(N+1) edge[bend left] node[below] {$p_{N+1,N+1}$} (1);
% % The \draw path is like the one above.
\end{tikzpicture}
\end{document}