1

Question:

I have one MWE of tree in which i want to add one more node under G having lable I. How to do this?

\documentclass[10pt]{article}
\usepackage{pgf,tikz,pgfplots}
\pgfplotsset{compat=1.15}
\usepackage{mathrsfs}
\usetikzlibrary{arrows}
\pagestyle{empty}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{center}
    \begin{tikzpicture}
    \node [circle,draw]{F} [level distance=10mm,sibling distance=25mm]
    child { node [circle,draw]{D} [level distance=10mm ,sibling distance=15mm]
        child {node [circle,draw] {B}
            child {node [circle,draw] {A}}
            child {node [circle,draw]{C}}}
        child {node [circle,draw]{E}}
    }
    child {node [circle,draw] {J} [level distance=10mm ,sibling distance=15mm]
        child {node [circle,draw] {G}}
        child {node [circle,draw]{K}}
    };
\end{tikzpicture}
\end{center}    

\end{document}
2

Like this:

enter image description here

\documentclass[10pt]{article}
\usepackage{tikz}

\pagestyle{empty}
\begin{document}
\begin{center}
    \begin{tikzpicture}
    \node [circle,draw]{F} [level distance=10mm,sibling distance=25mm]
    child { node [circle,draw]{D} [level distance=10mm ,sibling distance=15mm]
        child {node [circle,draw] {B}
            child {node [circle,draw] {A}}
            child {node [circle,draw]{C}}}
        child {node [circle,draw]{E}}
    }
    child {node [circle,draw] {J} [level distance=10mm ,sibling distance=15mm]
        child {node [circle,draw] {G}
            child {node [circle, draw] {I}}  % <--- added node
                }
        child {node [circle,draw]{K}}
    };
\end{tikzpicture}
\end{center}    

\end{document}

Addendum: Solution based on your comment (if I understood you correctly):

\documentclass[10pt]{article}
\usepackage{tikz}

\begin{document}
    \begin{center}
\begin{tikzpicture}
    \node [circle,draw]{F} [level distance=10mm,sibling distance=25mm]
    child { node [circle,draw]{D} [level distance=10mm ,sibling distance=15mm]
        child {node [circle,draw] {B}
            child {node [circle,draw] {A}}
            child {node [circle,draw]{C}}}
        child {node [circle,draw]{E}}
    }
    child {node [circle,draw] {J} [level distance=10mm ,sibling distance=15mm]
        child {node [circle,draw] {G}
            child[missing]                  % <--- added node
            child {node [circle, draw] {I}} % <--- added node
                }
        child {node [circle,draw]{K}}
    };
\end{tikzpicture}
    \end{center}    
\end{document}

enter image description here

Alternative solution with use of the forest package:

\documentclass{article}
\usepackage{forest}

\begin{document}
\begin{center}
    \begin{forest}
for tree = {
    circle,
    draw,
    minimum size=1.5em,
    inner sep=2pt,
    s sep+=4mm
            }
[F
    [D
        [B
            [A]
            [C]
        ]
        [E]
    ]
    [J,fit=band
        [G
            [,phantom]
            [I]
        ]
        [K]
    ]
]
    \end{forest}
\end{center}
 \end{document}

which gives similar result:

enter image description here

  • yes but how to rotate node (I) to right – Maths4Sandy Sep 27 at 15:14
  • @Maths4Sandy, sorry, i do not understand you. What you like rotate? Text in node? – Zarko Sep 27 at 15:25
  • What you have added (node I) – Maths4Sandy Sep 27 at 15:28
  • @Maths4Sandy, yes, I added node I as you asked. Now you like to rotate node I. How you imagine this? Rotate text in node in the clockwise direction? To clarify what you mean, please provide a sketch (add it to your question). – Zarko Sep 27 at 15:37
  • In tree we can see that two nodes G and K are arranged below node J slightly diagonal position. in same manner can we arrange our node I (with circle) in diagonal position – Maths4Sandy Sep 27 at 15:45

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.