\begin{document}
\begin{enumerate}
\item[1.4] description
\item[e] description
\begin{figure}[ht] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
\centering % centers the figure
\begin{tikzpicture}
\node[state, initial] (q1) {$q_1$};
\node[state, accepting, right of=q1] (q2) {$q_2$};
\node[state,right of=q2] (q3) {$q_3$};
\draw
(q1) edge[bend right, below] node{b} (q3)
(q1) edge[above] node{a} (q2)
(q2) edge[loop above] node{a,b} (q2)
(q3) edge[loop above] node{a, b} (q3);
\end{tikzpicture}
\caption{$\{w$: $w$ starts with an $a\}$}
\label{fig:my_label}
\begin{tikzpicture}
\node[state, initial, accepting] (s1) {$s_1$};
\node[state, accepting, right of=s1] (s2) {$s_2$};
\node[state,right of=s2] (s3) {$s_3$};
\draw
(s1) edge[loop below] node{a} (s1)
(s1) edge[above] node{b} (s2)
(s2) edge[loop below] node{a} (s2)
(s2) edge[above] node{b} (s3)
(s3) edge[loop above] node{a, b} (s3);
\end{tikzpicture}
\caption{$\{w$: $w$ has at most one $b\}$}
\label{fig:my_label2}
\end{figure}
\end{enumerate}
\end{document}
答案1
- 为了增加
tikz
带有标题的连续图像之间的垂直空间,请在第二幅图像之前插入\medskip
或bigskip
或。\vspace{<desired distance>}
tikz
- 图像中节点之间的距离非常小,为了确定它们,我将使用
positioning
能够定义节点边界之间距离(而不是它们中心之间的距离)的库
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{automata,positioning}
\usepackage[skip=1ex, font=small]{caption}
\begin{document}
\begin{enumerate}
\item[1.4] description
\item[e] description
\begin{figure}[ht] % ’ht’ tells LaTeX to place the figure ’here’ or at the top of the page
\centering % centers the figure
\begin{tikzpicture}[node distance=15mm] % distance between nodes
\node[state, initial] (q1) {$q_1$};
\node[state, accepting, right=of q1] (q2) {$q_2$}; % observe syntax for defining of node distances
\node[state,right=of q2] (q3) {$q_3$};
\draw
(q1) edge[bend right, below] node{b} (q3)
(q1) edge[above] node{a} (q2)
(q2) edge[loop above] node{a,b} (q2)
(q3) edge[loop above] node{a, b} (q3);
\end{tikzpicture}
\caption{$\{w$: $w$ starts with an $a\}$}
\label{fig:my_label}
\bigskip %for vertical distance between images
\begin{tikzpicture}[node distance=15mm]
\node[state, initial, accepting] (s1) {$s_1$};
\node[state, accepting, right=of s1] (s2) {$s_2$};
\node[state,right =of s2] (s3) {$s_3$};
\draw
(s1) edge[loop below] node{a} (s1)
(s1) edge[above] node{b} (s2)
(s2) edge[loop below] node{a} (s2)
(s2) edge[above] node{b} (s3)
(s3) edge[loop above] node{a, b} (s3);
\end{tikzpicture}
\caption{$\{w$: $w$ has at most one $b\}$}
\label{fig:my_label2}
\end{figure}
\end{enumerate}
\end{document}