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 add labels 3, 4, 5 on tree edges like you can see on picture, but I don't know how :(

enter image description here

My minimal example:

    \documentclass{article}
    \usepackage[T1]{fontenc}
    \usepackage{tikz}
    \usepackage{tikz-qtree}

    \usetikzlibrary{positioning}
    \usetikzlibrary{trees}

    \begin{document}

    \begin{center}
    \begin{tikzpicture}[sibling distance=40pt]
    \tikzset{edge from parent/.style=
    {draw,
    edge from parent path={(\tikzparentnode.south)
    -- +(0,-8pt)
    -| (\tikzchildnode)}}}
    \Tree [.\textrm{} [.$x_2=1$  ]
              [.$x_2\neq1$ [.$x_2=2$ ]
                           [.$x_2\neq2$ [.$x_2=3$ ]
                                        [.$x_2=4$ ] ] ] ]
   \end{tikzpicture}
   \end{center}

   \end{document}
share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

I wouldn't know how to do it using tikz-qtree, but using TikZ, it's easy:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usetikzlibrary{trees}

\begin{document}

\begin{center}
\begin{tikzpicture}[sibling distance=150pt]
\tikzset{edge from parent/.style=
  {draw,
  edge from parent path={(\tikzparentnode.south)
  -- +(0,-17pt)
  -| (\tikzchildnode)}}}
\coordinate
child {node {$x_2=1$} edge from parent node[auto,swap,pos=0.08] {3}}
child {node {$x_2\neq1$}
  child {node {$x_2=2$} edge from parent node[auto,swap,pos=0.08] {4}}
  child {node {$x_2\neq2$}
    child {node {$x_2=3$} edge from parent node[auto,swap,pos=0.08] {5}}
    child {node {$x_2=4$}}
  }
};
\end{tikzpicture}
\end{center}

\end{document}

enter image description here

share|improve this answer
    
THANK YOU BRO!!! –  user27318 Mar 16 '13 at 16:12
add comment

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.