我尝试在所有状态下方添加花括号以将它们分组,但我找不到使它起作用的方法。此外,由于我需要通过对 n 进行归纳来证明定理,我该如何将三个点画成一个状态。以下是我目前所得到的。
\documentclass[10pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial] (q_0) {$a$};
\node[state] (q_1) [right=of q_0] {$a^2$};
\node[state] (q_2) [right=of q_1] {$a^3$};
\node[state,accepting] (q_3) [right=of q_2] {$a^n$};
\path[->]
(q_0) edge node {a} (q_1)
(q_1) edge node {a} (q_2)
(q_2) edge node {...} (q_3)
(q_3) edge [loop above] node {a} (q_3)
; %end path
\end{tikzpicture} \\
\end{document}
这张图片可以说明我的意思:
谢谢
答案1
\documentclass[10pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,automata,calc,positioning}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial] (q_0) {$a$};
\node[state] (q_1) [right=of q_0] {$a^2$};
\node[state] (q_2) [right=of q_1] {$a^3$};
\node[state,accepting] (q_3) [right=of q_2] {$a^n$};
\path[->]
(q_0) edge node {a} (q_1)
(q_1) edge node {a} (q_2)
(q_2) edge node {...} (q_3)
(q_3) edge [loop above] node {a} (q_3)
; %end path
\draw[decorate,decoration={brace,mirror,raise=6pt}, thick] ($(q_0.south west)+(-1.5,0)$)--(q_3.south east);
\end{tikzpicture}
\end{document}
答案2
对 Altermundus 的答案进行了一点改动,将 \dots 作为一个状态。
\documentclass[10pt,letterpaper]{article}
\usepackage[latin1]{inputenc}
\usepackage[left=1in,right=1in,top=1in,bottom=1in]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{tikz}
\usetikzlibrary{automata,positioning,decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial] (q_0) {$a$};
\node[state] (q_1) [right=of q_0] {$a^2$};
\node[state] (q_2) [right=of q_1] {$a^3$};
\node (q_dots) [right=of q_2] {$\cdots$};
\node[state,accepting] (q_3) [right=of q_dots] {$a^n$};
\path[->]
(q_0) edge node {a} (q_1)
(q_1) edge node {a} (q_2)
(q_2) edge node {a} (q_dots)
(q_dots) edge node{a} (q_3)
(q_3) edge [loop above] node {a} (q_3)
; %end path
\draw [decorate,decoration={brace,amplitude=10pt,mirror,raise=10pt},yshift=0pt]
(q_0.south west) -- (q_3.south east);
\end{tikzpicture} \\
\end{document}