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 want to draw the process like in the picture using the code below, however, there is some problem, would someone help me?

enter image description here

 \usepackage[latin1]{inputenc}
    \usetikzlibrary{trees}
    \usepackage{verbatim}

        \tikzstyle{level 1}=[level distance=1.5cm, sibling distance=3.5cm]
        \tikzstyle{level 2}=[level distance=1.5cm, sibling distance=2cm]


    \tikzstyle{bag} = [text width=20em, text centered]
    \tikzstyle{end} = [circle, minimum width=3pt,fill, inner sep=0pt]



    \begin{tikzpicture}[grow=down]
    \node[bag] { $(B)$}
        child {
            node[bag] {$(R_{good})$}
                child {
                    node[bag] {$(and)$}
                    edge from parent
                    node[right]  {$and$}
                }
                edge from parent
                node[right] {$t$}
        };
    \end{tikzpicture}
share|improve this question
2  
Instead of posting only code snippets, you should post complete minimal example documents. That makes it easier for others to help you. Also, you should avoid general statements like "there is some problem": It's better to explain in words how your output differs from what you expect. –  Jake Aug 13 '12 at 12:40

1 Answer 1

up vote 7 down vote accepted

Do you want something like:

enter image description here

The code is:

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{trees}

\tikzset{level 1/.style={level distance=1.5cm, sibling distance=3.5cm}}
\tikzset{level 2/.style={level distance=1.5cm, sibling distance=2cm}}

\tikzset{bag/.style={text width=20em, text centered,yshift=-0.2cm}}

\begin{document}
\begin{tikzpicture}[grow=down, -stealth]
\node[bag]{$(B)$} 
    child{ edge from parent node[right]{t}; \node[bag]{$(Rgood)$}
            child{ edge from parent node[right]{and}; \node[bag]{$(and)$}
                    child[missing]
                    child{ edge from parent node[right=0.1cm]{it}; \node[bag]{$(path1)$}}
                    child{ edge from parent node[right=0.1cm]{else}; \node[bag]{$(path2)$}}
            }
    };
\end{tikzpicture}

\end{document}

I actually removed the unused style end, changed the deprecate syntax tikzstyle with the equivalent tikzset. Moreover, for the leaves, i made use of the option missing to let path1 be exactly below the previous and. You can add an arrow by simply inserting it as option of the tikzpicture environment.

share|improve this answer
    
thanks, however, in the picture, the connector is an arrow. I don't know how to draw the arrow to connect two objects. –  sweetyBaby Aug 13 '12 at 12:45
    
@sweetyBaby: you are right. I've edited my answer to accomplish this, however for it I would recommend you to reference to the pgfmanual. –  Claudio Fiandrino Aug 13 '12 at 12:53
    
As we can see, in latex image in the above, two arrows are different. For example "and->path1" and "and->path2", the arrow connecting "and -> path2" is bolder than that of "and->path1", why? –  sweetyBaby Aug 13 '12 at 18:18
    
Actually, in the code there are no option that can made one arrow bolder than the other one. I don't have an answer for this, sorry. –  Claudio Fiandrino Aug 14 '12 at 6:19

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.