6

i trying to draw an automata using tikz package, and i want to decrease the size of node and labels on each edge , im have trying to put the option [scale=0.5] but it doesn't work ! I have :

\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}

this give me a not pretty picture : enter image description here

Wassim Sboui
  • 1,831

2 Answers2

10
\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} 

enter image description here

Alain Matthes
  • 95,075
3

[en] For my part, when it comes to plot a graph, I prefer to note all distances in ems which allows, by changing locally the size of the font to change the graph size

[fr] pour ma part, lorsqu'il s'agit de tracer un graphe, je préfère noter toutes les distances en em ce qui permet, en changeant localement la taille de la font de modifier la taille du graphe

\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}

enter image description here

rpapa
  • 12,350