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.

How can I connect 2 horizontal nodes on a tree? That is I want to connect z1 to z2. but the line should continue to the right of z2 and left of z1 to show continuity. Like wise for theta 1 and theta 2. Tree image

My current latex commands:

\begin{tikzpicture}[level distance=1.2cm, 
                    level 1/.style={sibling distance=4cm},
                    level 2/.style={sibling distance=1cm}
                   ]
\centering
\tikzstyle{every node}=[circle,draw]

\node (Root) [black] {$z_{1}$}
    child {
    node {$\theta_{1}$} 
    child { node {$\varphi_{1}$} edge from parent node[left,draw=none]{} }
    child { node {$\varphi_{2}$} }
    child { node {$\varphi_{3}$} }
};
\hspace*{4cm}\node (Root) [black] {$z_{2}$}
child {
    node {$\theta_{2}$}
    child { node {$\varphi_{1}$} }
    child { node {$\varphi_{2}$} }
    child { node {$\varphi_{3}$} }
    child { node {$\varphi_{4}$} }
};

\end{tikzpicture}
share|improve this question
    
Welcome to the site. You have some spacing and centering commands that won't work inside the tikz environment. Instead you can use \node (Root) at (xcoord,ycoord) {... –  percusse Jan 26 at 14:12

1 Answer 1

I made some improvements to your code:

  1. Using the positioning library for the right=4cm of Root1 syntax.
  2. Using \tikzset instead of \tikzstyle.
  3. Renaming the (Root) nodes to (Root1) and (Root2) to connect them using \draw.

\documentclass[tikz]{standalone}
\usetikzlibrary{positioning}
\tikzset{every node/.style = {circle,draw}}
\begin{document}
\begin{tikzpicture}[level distance=1.2cm, 
        level 1/.style={sibling distance=4cm},
        level 2/.style={sibling distance=1cm}
    ]
    \node (Root1) [black] {$z_{1}$}
    child {
        node {$\theta_{1}$} 
        child { node {$\varphi_{1}$} edge from parent node[left,draw=none]{} }
        child { node {$\varphi_{2}$} }
        child { node {$\varphi_{3}$} }
    };
    \node[right=4cm of Root1] (Root2) [black] {$z_{2}$}
    child {
        node {$\theta_{2}$}
        child { node {$\varphi_{1}$} }
        child { node {$\varphi_{2}$} }
        child { node {$\varphi_{3}$} }
        child { node {$\varphi_{4}$} }
    };
    \draw (Root1) -- (Root2);
\end{tikzpicture}
\end{document}

enter image description here

share|improve this answer
    
Thank you! I tried to draw the line on other nodes but I get error can u please help –  user1965914 Feb 2 at 12:20
    
@user1965914 Of course, I can help. You could either post your specific problem as another question or we discuss it in the chat. –  Henri Menke Feb 2 at 12:22
    
I need to draw a line from the left hand size of Z1 to the right hand side of Z2 as a arrow line showing the time flow. And same with theta 1. The line must start from the left most. I tried for a day now but i just couldn't make it work –  user1965914 Feb 2 at 12:31
    
@user1965914 Hm, I'm also stuck a little here, because \draw (Root1) to[out=180,in=0,bend left] (Root2); doesn't work as expected. –  Henri Menke Feb 2 at 12:48

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.