我试图使用 tikz 包绘制一个自动机,我想减小每个边上的节点和标签的大小,我试图把选项[比例=0.5]但它不起作用!我有:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata,shadows,fit,shapes}
\begin{document}
\begin{tikzpicture}[shorten >=1pt, node distance=2.5cm, on grid, auto,thick,initial text=,scale=0.3]
\node[state, initial] (0) {0};
\node[state] (1) [above right =of 0] {1};
\node[state] (2) [right =of 0] {2};
\node[state,accepting] (3) [right =of 2] {3};
\path[->] (0) edge node {a:a / 1.61} (1)
(0) edge node {b:b/ 0.22} (2)
(2) edge [loop below] node {b:a/ 0.69} ()
(2) edge node {b:a/ 0.69} (3);
\end{tikzpicture}
\end{document}
这给了我一张不太漂亮的照片:
答案1
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata,shadows,fit,shapes}
\begin{document}
\begin{tikzpicture}[shorten >=1pt, node distance=2.5cm, on grid, auto,thick,initial text=,scale=0.3]
\node[state, initial] (0) {0};
\node[state] (1) [above right =of 0] {1};
\node[state] (2) [right =of 0] {2};
\node[state,accepting] (3) [right =of 2] {3};
\begin{scope}[every node/.style={scale=.5}]
\path[->] (0) edge node {a:a / 1.61} (1)
(0) edge node {b:b/ 0.22} (2)
(2) edge [loop below] node {b:a/ 0.69} ()
(2) edge node {b:a/ 0.69} (3);
\end{scope}
\end{tikzpicture}
\end{document}
答案2
[en] 就我而言,在绘制图表时,我更喜欢用 em 来记录所有距离,这样可以通过局部更改字体大小来更改图表大小
[fr] 对我来说,当我开始追踪一个图表时,我更喜欢注意在这个允许的距离,在更改字体大小的位置以修改图表大小
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,automata,shadows,fit,shapes}
\begin{document}
{\tiny
\begin{tikzpicture}[shorten >=1pt, node distance=5em ,auto,thick,initial text=,]
\node[state, initial] (0) {0};
\node[state] (1) [above right =of 0] {1};
\node[state] (2) [right =of 0] {2};
\node[state,accepting] (3) [right =of 2] {3};
\path[->] (0) edge node {a:a / 1.61} (1)
(0) edge node {b:b/ 0.22} (2)
(2) edge [loop below] node {b:a/ 0.69} ()
(2) edge node {b:a/ 0.69} (3);
\end{tikzpicture}
}
{\small
\begin{tikzpicture}[shorten >=1pt, node distance=5em ,auto,thick,initial text=,]
\node[state, initial] (0) {0};
\node[state] (1) [above right =of 0] {1};
\node[state] (2) [right =of 0] {2};
\node[state,accepting] (3) [right =of 2] {3};
\path[->] (0) edge node {a:a / 1.61} (1)
(0) edge node {b:b/ 0.22} (2)
(2) edge [loop below] node {b:a/ 0.69} ()
(2) edge node {b:a/ 0.69} (3);
\end{tikzpicture}
}
{\Large
\begin{tikzpicture}[shorten >=1pt, node distance=5em , auto,thick,initial text=,]
\node[state, initial] (0) {0};
\node[state] (1) [above right =of 0] {1};
\node[state] (2) [right =of 0] {2};
\node[state,accepting] (3) [right =of 2] {3};
\path[->] (0) edge node {a:a / 1.61} (1)
(0) edge node {b:b/ 0.22} (2)
(2) edge [loop below] node {b:a/ 0.69} ()
(2) edge node {b:a/ 0.69} (3);
\end{tikzpicture}
}
\end{document}