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.

Possible Duplicate:
how to draw special line in a picture

I use the code below to draw a picture, however the line is straight from s2 to s4 refer to the image.enter image description here

However, I want the line like an angle like the red line in the picture.would someone help me how to do it?

\usepackage{tikz}
\usetikzlibrary{trees}
\resizebox{.5\textwidth}{!}{
\tikzset{level 1/.style={level distance=0.7cm, sibling distance=3cm}}
\tikzset{level 2/.style={level distance=0.7cm, sibling distance=6cm}}

\tikzset{bag/.style={text centered,yshift=-0.2cm}}
\begin{tikzpicture}[grow=down, -stealth]
\node[bag]{$S_0{:}(B,true,0)$}
    child{ edge from parent node[right]{$\lsInvoke \_ DS$}; \node[bag]{$S_1{:}(R_{good})$}
            child{ edge from parent node[right]{and}; \node[bag]{$S_2{:}(and)$}
                    child[missing]
                    child{ edge from parent node[right=0.1cm]{$[else]$}; \node[bag]{$S_3{:}(A_1)$}
                    }
                    child{ edge from parent node[right=0.9cm]{$[if]$}; \node[bag]{$S_4{:}(R_{good})$}
                    }
            }
    };
\end{tikzpicture}} 
share|improve this question

marked as duplicate by Torbjørn T., Marco Daniel, percusse, lockstep, Tom Bombadil Aug 24 '12 at 3:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1  
as a mwe goes, i thought you should know that your code doesn't compile stand alone. it would be nice to add things like the document class you're using and such. –  asia1281 Aug 17 '12 at 17:16
    
I get errors trying to compile your code. giving up on this path. Did you forget a semicolon? –  JLDiaz Aug 17 '12 at 17:21
    
You can refer to the manual for edge from parent path option. –  percusse Aug 17 '12 at 17:51
    
yes, I have referred it, however, i just see how to draw dashed line and so on, But nothing about this kind of line. So would you please help me? –  sweetyBaby Aug 18 '12 at 1:40
    
@asia1281, sorry for the error code, you I have updated the new codes, please refer to tex.stackexchange.com/questions/67650/… –  sweetyBaby Aug 18 '12 at 2:02
add comment

1 Answer

i can't compile your code, and don't have any experience with trees, which appears to draw the path for you. this should demonstrate the concept i think you're looking for though:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \coordinate (A) at (0,0);
    \coordinate (B) at (5,-1);
    \draw (A) -- (B);
    \draw[thick,dashed,red,->] (A) -| (B);
\end{tikzpicture}
\end{document}

which produces:

result

the most important part for you here is the use of -| instead of -- to create the path in a rectilinear coordinate system instead of the standard one. when used with draw, instead of drawing a straight line, this draws the components of that line.

perhaps you can just create named coordinates at S_2 and S_4 and overlay the rectilinear path over it?

share|improve this answer
    
unless, of course, you want the rectilinear line INSTEAD of the straight line...in which case i can't really help without a valid mwe. –  asia1281 Aug 17 '12 at 17:40
add comment

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