Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have three trees in latex , I have this construction :

enter image description here

with his code :

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

but I want to represent 2 like this and the third before?

enter image description here

share|improve this question
    
It's not clear to me what your question is. Can you please elaborate a little more? Also, your example code won't work, you need to add the positioning and automata libraries. –  Gonzalo Medina Jun 20 '12 at 14:32
    
Your MWE does not compile for me with TeXLive2011. Please add the necessary packages to get this to compile. –  Peter Grill Jun 20 '12 at 17:07
    
Please write a clear question –  Wassim Sboui Jun 21 '12 at 13:44

2 Answers 2

up vote 1 down vote accepted

If your question is just about positioning the figures, you could use minipages to get them where you want. The output on the left imitates your example, with blank lines in between the tikzpictures. As is the case in normal text, blank lines are treated as a new paragraph. On the right is the output obtained by wrapping them in a minipage to get them where you want:

enter image description here enter image description here

Code:

\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}
share|improve this answer

The result of tikzpicture environment is a box. You can use something like \vbox,\hboxor something in the spirit of 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}    

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.