1
\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{trees}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
    \node {One}[edge from parent fork right, grow'=right, align=right]
        child { node(yongnian) {1}
               child {node(xixiang){11}
                   child {node{111}
                        child {node{111}
                          child {node{111}}}}
                   }
               child {node(xihui)[below of=xixiang]{222}}
                child {node(xifu)[below of=xihui]{222}}
                 child {node(xilu)[below of=xifu]{222}}
               }
        child { node(qingnian)[below of=yongnian] {2}
            child {node{Me}}
            child {node{My}}
            }   
        child { node (shengnian)[below of=qingnian] {3}
             child {node{Josh}}
             child {node{arah}}
            }   
     child { node(fengnian)[below of=shengnian] {4}
             child {node{sh}}
             child {node{arah}}
            }           
    ;
\end{tikzpicture}

\end{document} 
2
  • Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it).
    – Jesse
    Commented Jan 22, 2015 at 12:05
  • Thank you. But I cannot understand. Commented Jan 22, 2015 at 12:24

1 Answer 1

2

Add appropriate distances for sibling distance like

level 1/.style={sibling distance=1in},
level 2/.style={sibling distance=1cm},

Further, you won't need all those below of= stuff here. As a side note with positioning library it should be below = of.

Code:

\documentclass{article}
\usepackage{tikz}

\usetikzlibrary{trees}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[
level 1/.style={sibling distance=1in},
level 2/.style={sibling distance=1cm},
grow'=right, align=right
  ]
    \node {One}[edge from parent fork right]
        child { node(yongnian) {1}
               child {node(xixiang){11}
                   child {node{111}
                        child {node{111}
                          child {node{111}}}}
                   }
               child {node(xihui){222}}
                child {node(xifu){222}}
                 child {node(xilu){222}}
               }
        child { node(qingnian) {2}
            child {node{Me}}
            child {node{My}}
            }
        child { node (shengnian) {3}
             child {node{Josh}}
             child {node{arah}}
            }
     child { node(fengnian) {4}
             child {node{sh}}
             child {node{arah}}
            }
    ;
\end{tikzpicture}

\end{document}

enter image description here

3
  • If I want the distance between 1 and 2 is three cm, 3 and 4 is five cm. Commented Jan 22, 2015 at 13:02
  • @YumingFeng Your wish may not be granted ;-)
    – user11232
    Commented Jan 22, 2015 at 13:10
  • @YumingFeng Changing distances as you request is not possible. BTW thanks are better conveyed here by up voting and accepting. Please refer to How do you accept an answer
    – user11232
    Commented Jan 22, 2015 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .