\documentclass[12pt]{book}
\usepackage[paperwidth=16cm, paperheight=24cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{qtree}
\usepackage{adjustbox}
\usepackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true,factor=1100,stretch=10,shrink=10]{microtype}
\usepackage{multicol}
\usepackage{ragged2e}
\usepackage{makecell, tabularx}
\usepackage{xcolor}
\usepackage{pstricks} %%
\usepackage{tikz} %%
\usetikzlibrary{arrows,automata,matrix,positioning}
\newcolumntype{L}[1]{>{\RaggedRight}X} % new
\newcommand\code[1]{\texttt{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\setlength{\unitlength}{1cm}
\begin{document}
\begin{tikzpicture}[>=stealth', shorten >=1pt, auto, node distance=1cm]
\node[initial, state](1){1};
\node[state](2)[above right=of 1]{2};
\node[state](3)[right=of 2]{3};
\node[state](4)[below=of 2]{4};
\node[state](5)[right=of 4]{5};
\node[state, accepting](6)[right=of 5]{6};
\path[->] (1) edge node {$\epsilon$} (2);
\path[->] (2) edge node {a} (3);
\path[->] (1) edge node {$\epsilon$} (4);
\path[->] (4) edge node {b} (5);
\path[->] (3) edge node {$\epsilon$} (6);
\path[->] (5) edge node {$\epsilon$} (6);
\end{tikzpicture}
\end{document}
答案1
主要变化:
- 把节点
4
放在below right=of 1
- 把节点
6
放在above right=of 5
\documentclass[12pt]{book}
\usepackage[paperwidth=16cm, paperheight=24cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,matrix,positioning}
\begin{document}
\begin{tikzpicture}[>=stealth', shorten >=1pt, auto, node distance=1cm]
\node[initial, state](1){1};
\node[state] (2) [above right=of 1] {2};
\node[state] (3) [right=of 2] {3};
\node[state] (4) [below right=of 1] {4};
\node[state] (5) [right=of 4] {5};
\node[state, accepting] (6) [above right=of 5] {6};
\path[->] (1) edge node {$\epsilon$} (2);
\path[->] (2) edge node {a} (3);
\path[->] (1) edge node {$\epsilon$} (4);
\path[->] (4) edge node {b} (5);
\path[->] (3) edge node {$\epsilon$} (6);
\path[->] (5) edge node {$\epsilon$} (6);
\end{tikzpicture}
\end{document}