我想绘制两个并排的自动机图形;但是我无法将它们放在一个\begin{}
\end{}
标签中,因为节点距离可以改变,而且两张图片之间的距离也不同。如果能提供一个最小的例子就更好了。谢谢。
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\node[state,initial] (q_0) {$q_0$};
\node[state,accepting] (q_1) [right=of q_0] {$q_1$};
\node[state] (q_2) [right=of q_1] {$q_2$};
\path[->]
(q_0) edge node {a} (q_1)
(q_1) edge node {$\lambda$} (q_2)
(q_2) edge [bend right] node {$\lambda$} (q_0)
; %end path
\end{tikzpicture}
答案1
如果两幅图能保持在一条线上,那无非就是
\begin{tikzpicture}
<code for the first picture>
\end{tikzpicture}
\begin{tikzpicture}
<code for the second picture>
\end{tikzpicture}
它们将在底部对齐。
答案2
您可以使用小页面:
\noindent
\begin{minipage}{.5\textwidth}
\centering
\begin{tikzpicture}
<code for the first picture>
\end{tikzpicture}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\begin{tikzpicture}
<code for the second picture>
\end{tikzpicture}
\end{minipage}
或者子浮点数(使用subfig
包):
\begin{figure}
\subfloat[first caption here]
{
\begin{tikzpicture}
<code for the first picture>
\end{tikzpicture}
}
\subfloat[second caption here]
{
\begin{tikzpicture}
<code for the second picture>
\end{tikzpicture}
}
\end{figure}
答案3
这是我根据 TikZ 教程中的以下示例提出的解决方案http://www.texample.net/tikz/examples/nodetutorial/
\begin{tikzpicture}[shorten >=1pt,node distance=2cm,on grid,auto]
\begin{scope}
\node[state,initial] (q_1) {$q_1$};
\node[state,accepting] (q_2) [right=of q_1] {$q_2$};
\node[state] (q_3) [below right=of q_1] {$q_3$};
\path[->]
(q_1) edge [bend left] node {a} (q_2)
(q_1) edge [loop above] node {b} (q_1)
(q_2) edge [bend left] node {a,b} (q_3)
(q_3) edge [bend left] node {a} (q_2)
(q_3) edge [bend left] node {b} (q_1)
;
\end{scope}
\begin{scope}[xshift=10cm]
\node[state,initial] (q_1) {$q_1$};
\node[state,accepting] (q_2) [right=of q_1] {$q_2$};
\node[state] (q_3) [below right=of q_1] {$q_3$};
\path[->]
(q_1) edge [bend left] node {a} (q_2)
(q_1) edge [loop above] node {b} (q_1)
(q_2) edge [bend left] node {a,b} (q_3)
(q_3) edge [bend left] node {a} (q_2)
(q_3) edge [bend left] node {b} (q_1)
;
\end{scope}
\end{tikzpicture}