我在乳胶中有三棵树,我有这样的结构:
使用他的代码:
\documentclass[openright,a4paper,11pt,french]{report}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[shorten >=1pt, node distance=2cm, on grid, auto,thick,initial text=]
\node[state, initial,minimum size=3ex] (0) {0};
\node[state,minimum size=3ex] (1) [above right =of 0] {1};
\node[state,minimum size=3ex] (2) [right =of 0] {2};
\node[state,accepting,minimum size=3ex] (3) [right =of 2] {3/0};
\path[->] (0) edge node {a:a / 1.61} (1)
(0) edge node {b:b/ 0.22} (2)
(1) edge node {a:b/ 0} (2)
(2) edge [loop below] node {b:a/ 0.69} ()
(2) edge node {b:a/ 0.69} (3);
\end{tikzpicture}
\begin{tikzpicture}[shorten >=1pt, node distance=2cm, on grid, auto,thick,initial text=,minimum size=0pt]
\node[state, initial ,minimum size=3ex] (0) {0};
\node[state,minimum size=3ex] (1) [right =of 0] {1};
\node[state,accepting,minimum size=3ex] (2) [right =of 1] {2/0};
\path[->] (0) edge [loop above] node {a:a / 1.2} ()
(0) edge [bend left] node {a:b/ 2.3} (1)
(0) edge [bend right] node {b:a/ 0.51} (1)
(1) edge [loop below] node {b:b/ 0.92} ()
(1) edge node {a:a/ 0.51} (2);
\end{tikzpicture}
\begin{tikzpicture}[shorten >=1pt, node distance=2cm, on grid, auto,thick,initial text=,minimum size=0pt]
\node[state, initial,minimum size=3ex] (0) {0};
\node[state,minimum size=3ex] (1) [above right =of 0] {1};
\node[state,minimum size=3ex] (2) [right =of 0] {4};
\node[state,minimum size=3ex] (3) [right =of 2] {2};
\node[state,minimum size=3ex,accepting] (4) [right =of 3] {3/0};
\begin{scope}[every node/.style={scale=.7}]
\path[->] (0) edge node {a:a / 2.81} (1)
(0) edge node {a:b / 3.91} (2)
(0) edge [bend right] node {b:a / 0.73} (3)
(1) edge node {a:a / 0.51} (3)
(2) edge node {a:b / 0.92} (3)
(3) edge node {b:a / 1.2} (4);
\end{scope}
\end{tikzpicture}
\end{document}
但我想像这样表示 2 ,然后表示之前的第三个?
答案1
如果您的问题只是关于如何定位图形,您可以使用minipages
将它们放在您想要的位置。左侧的输出模仿您的示例,在 之间有空行。与普通文本一样,空行被视为新段落。右侧是通过将它们包装在 中以将它们放在您想要的位置而tikzpictures
获得的输出:minipage
代码:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [fill=yellow] (0,0) rectangle (2,2);
\end{tikzpicture}
\begin{tikzpicture}
\draw [fill=brown] (0,0) circle (1cm);
\end{tikzpicture}
\begin{tikzpicture}
\draw [fill=cyan] (0,0) -- (2,0) -- (1,2) -- cycle;
\end{tikzpicture}
\bigskip\hrule\bigskip
\begin{minipage}{0.45\linewidth}
\begin{tikzpicture}
\draw [fill=yellow] (0,0) rectangle (2,2);
\end{tikzpicture}
\begin{tikzpicture}% Need blank line above
\draw [fill=brown] (0,0) circle (1cm);
\end{tikzpicture}
\end{minipage}
% No blank line here
\begin{minipage}{0.45\linewidth}
\begin{tikzpicture}
\draw [fill=cyan] (0,0) -- (2,0) -- (1,2) -- cycle;
\end{tikzpicture}
\end{minipage}
\end{document}
答案2
tikzpicture 环境的结果是一个盒子。你可以使用类似的\vbox,\hbox
或符合 LaTeX 精神的东西:minipage
\documentclass[openright,a4paper,11pt,french]{report}
\usepackage{tikz}
\usetikzlibrary{positioning,automata}
\begin{document}
\begin{minipage}{7cm}
\begin{tikzpicture}[shorten >=1pt, node distance=2cm, on grid, auto,thick,initial text=]
\node[state, initial,minimum size=3ex] (0) {0};
\node[state,minimum size=3ex] (1) [above right =of 0] {1};
\node[state,minimum size=3ex] (2) [right =of 0] {2};
\node[state,accepting,minimum size=3ex] (3) [right =of 2] {3/0};
\path[->] (0) edge node {a:a / 1.61} (1)
(0) edge node {b:b/ 0.22} (2)
(1) edge node {a:b/ 0} (2)
(2) edge [loop below] node {b:a/ 0.69} ()
(2) edge node {b:a/ 0.69} (3);
\end{tikzpicture}
\begin{tikzpicture}[shorten >=1pt, node distance=2cm, on grid, auto,thick,initial text=,minimum size=0pt]
\node[state, initial ,minimum size=3ex] (0) {0};
\node[state,minimum size=3ex] (1) [right =of 0] {1};
\node[state,accepting,minimum size=3ex] (2) [right =of 1] {2/0};
\path[->] (0) edge [loop above] node {a:a / 1.2} ()
(0) edge [bend left] node {a:b/ 2.3} (1)
(0) edge [bend right] node {b:a/ 0.51} (1)
(1) edge [loop below] node {b:b/ 0.92} ()
(1) edge node {a:a/ 0.51} (2);
\end{tikzpicture}
\end{minipage}
\begin{minipage}{7cm}
\begin{tikzpicture}[shorten >=1pt, node distance=2cm, on grid, auto,thick,initial text=,minimum size=0pt]
\node[state, initial,minimum size=3ex] (0) {0};
\node[state,minimum size=3ex] (1) [above right =of 0] {1};
\node[state,minimum size=3ex] (2) [right =of 0] {4};
\node[state,minimum size=3ex] (3) [right =of 2] {2};
\node[state,minimum size=3ex,accepting] (4) [right =of 3] {3/0};
\begin{scope}[every node/.style={scale=.7}]
\path[->] (0) edge node {a:a / 2.81} (1)
(0) edge node {a:b / 3.91} (2)
(0) edge [bend right] node {b:a / 0.73} (3)
(1) edge node {a:a / 0.51} (3)
(2) edge node {a:b / 0.92} (3)
(3) edge node {b:a / 1.2} (4);
\end{scope}
\end{tikzpicture}
\end{minipage}
\end{document}