0
\begin{figure}[H]
\centering
\begin{tikzpicture}[every tree node/.style={draw,circle},edge from parent path={(\tikzparentnode) -- (\tikzchildnode)},baseline]
\Tree [.\node(first) [draw, align=center] {\textbf{A} \\ \textit{\footnotesize{100 }}};
        \node(second) [draw, align=center] {\textbf{B} \\ \textit{\footnotesize{20 }}};
        \node(third) [draw, align=center, fill=orange] {\textbf{C} \\ \textit{\footnotesize{40 }}};
        \node(fourth) [draw, align=center] {\textbf{D} \\ \textit{\footnotesize{35 }}};
      ]
\begin{scope}[xshift=3in,every tree node/.style={},edge from parent path={}]
\end{scope}
\node[below]at(current bounding box.south){\textbf{Figura 2. Exemplo de Árvore Resultante}};
\end{tikzpicture}
\end{figure}

How do i increase the edge length from A to C?

enter image description here

5
  • 2
    Please post complete minimal code rather than a fragment.
    – cfr
    May 24, 2016 at 16:55
  • Actually thats all i have. Before and after the tikzpicture i have only text
    – GGirotto
    May 24, 2016 at 17:04
  • 2
    @Guilherme cfr was referring to packages, any relevant options in the preamble for Tikz trees and of course, the document class.
    – Alenanno
    May 24, 2016 at 17:20
  • O sorry. Im using this two packages: tikz and tikz-qtree
    – GGirotto
    May 24, 2016 at 17:32
  • 1
    @Guilherme Include them in the question. The code in there should be compilable so that we just need to copy/paste it.
    – Alenanno
    May 24, 2016 at 17:33

1 Answer 1

1

You can control the edges length by changing the sibling distance. Also, left=, right=, above=, below= can be used.

\begin{figure}
\centering
\begin{tikzpicture}[every tree node/.style={draw,circle}, level 1/.style={sibling distance=20mm},level 2/.style={sibling distance=20mm},edge from parent path={(\tikzparentnode) -- (\tikzchildnode)},baseline
]
\Tree [.\node(first) [draw, align=center] {\textbf{A} \\ \textit{\footnotesize{100 }}};
        \node(second) [draw, align=center] {\textbf{B} \\ \textit{\footnotesize{20 }}};
        \node(third) [draw, align=center, fill=orange,below=7mm] {\textbf{C} \\ \textit{\footnotesize{40 }}};
        \node(fourth) [draw, align=center] {\textbf{D} \\ \textit{\footnotesize{35 }}};
      ]
\begin{scope}[xshift=3in,every tree node/.style={},edge from parent path={}]
\end{scope}
\node[below]at(current bounding box.south){\textbf{Figura 2. Exemplo de Árvore Resultante}};
\end{tikzpicture}
\end{figure}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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